import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
+import java.util.Collections;
import org.tizen.installmanager.core.Config;
import org.tizen.installmanager.core.IMFatalException;
//installed path.
public static final String REGISTRY_FILE_NAME = "tizensdkpath";
public static final String MULTI_SDK_FILE_NAME = "multisdkpath";
+ public static final String REPO_HISTORY_FILE_NAME = "repo.history";
public static final String REGISTRY_FILE_PATH = PathUtil.get(
Config.INSTALL_MANAGER_CONFIG, REGISTRY_FILE_NAME);
private static final String OLD_REGISTRY_FILE_PATH = PathUtil.get(
Config.getConfigHome(), REGISTRY_FILE_NAME);
public static final String MULTI_SDK_FILE_PATH = PathUtil.get(
Config.INSTALL_MANAGER_CONFIG, MULTI_SDK_FILE_NAME);
+ public static final String REPO_HISTORY_FILE_PATH = PathUtil.get(
+ Config.INSTALL_MANAGER_CONFIG, REPO_HISTORY_FILE_NAME);
private static final String INSTALLED_PATH_KEY = "TIZEN_SDK_INSTALLED_PATH";
private static final String SDK_DATA_PATH_KEY = "TIZEN_SDK_DATA_PATH";
public static String sdkDataPath = "";
// public static String sdkDataPath = getSDKinfoBySDKPath(Config.getInstance().getTargetDir());
private static ArrayList<String> sdkPathList = getSDKPath();
+ private static ArrayList<String> repoHistory = getRepoHistory();
+ private final static int REPO_HISTORY_COUNT = 5;
/**
* Exports target path to the registry file.
return sdkPath;
}
+ public static ArrayList<String> getRepoHistory() {
+ File repoHistoryFile = new File(REPO_HISTORY_FILE_PATH);
+ ArrayList<String> repoHistory = new ArrayList<String>();
+ if (repoHistoryFile.exists()) {
+ repoHistory = getPathFromRegistryFile(REPO_HISTORY_FILE_PATH);
+ }
+ return repoHistory;
+ }
+
private static ArrayList<String> getPathFromRegistryFile(String filePath) {
ArrayList<String> sdkPaths = new ArrayList<String>();
InputStream is = null;
if (bw != null) {
try {
bw.close();
-
} catch (IOException e) {
Log.ExceptionLog(e);
}
}
}
+ public static void saveRepoInfo(String repository) {
+ if (repository == null || repository.isEmpty()) {
+ Log.err("Repository is invalid for registering : " + repository);
+ throw new IMFatalException(ErrorCode.INVALID_REPOSITORY_FOR_HISTORY);
+ }
+
+ File repoHistoryFile = new File(REPO_HISTORY_FILE_PATH);
+ if (!repoHistoryFile.exists() || Options.doInstallNoUI || Options.doRemoveNoUI) {
+ try {
+ repoHistoryFile = PathUtil.makeNewFile(REPO_HISTORY_FILE_PATH);
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ return;
+ }
+ } else {
+ if (repoHistory.contains(repository)) {
+ return;
+ }
+ }
+
+ if (repoHistoryFile == null) {
+ return;
+ }
+
+ removeOldHistory();
+
+ BufferedWriter bw = null;
+ try {
+ FileWriter fw = new FileWriter(repoHistoryFile);
+ bw = new BufferedWriter(fw);
+ if (!repoHistory.isEmpty()) {
+ for (String repo : repoHistory) {
+ if (!repo.equalsIgnoreCase("")) {
+ bw.write(repo);
+ bw.newLine();
+ }
+ }
+ }
+ bw.write(repository);
+ bw.newLine();
+ bw.flush();
+ } catch (IOException e) {
+ Log.err("Cannot register to file. " + repoHistoryFile.getAbsolutePath());
+ throw new IMFatalException(ErrorCode.CANNOT_REGISTER_TARGET_DIR);
+ } finally {
+ if (bw != null) {
+ try {
+ bw.close();
+ repoHistory.add(repository);
+ Log.log("Package server address history. => " + repoHistory);
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
+ }
+ }
+ }
+
+ private static void removeOldHistory() {
+ while (repoHistory.size() >= REPO_HISTORY_COUNT) {
+ repoHistory.remove(0);
+ }
+ }
+
/**
* Get installed version.
* @return
+/*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghee Yang <donghee.yang@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Yongsung kim <yongsung1.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
package org.tizen.installmanager.ui.dialog;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
import org.tizen.installmanager.core.Config;
import org.tizen.installmanager.lib.Downloader;
import org.tizen.installmanager.lib.ErrorController;
public class ChangeServerDialog extends Dialog {
private static final String STRING_TITLE = "Change Server";
private Label titleLabel = null;
- private Text serverText = null;
+ private Combo serverCombo = null;
private Label errLabel = null;
private String serverUrl = "";
+ private ArrayList<String> serverUrls = new ArrayList<String>();
public ChangeServerDialog(Shell parentShell) {
super(parentShell);
setTitle();
setTitleLabel(container);
- setServerUrlText(container);
+ setServerUrlComboBox(container);
setErrLabel(container);
return container;
@Override
protected void okPressed() {
- String changeServerUrl = serverText.getText();
+ String changeServerUrl = serverCombo.getText();
- if (serverUrl.equals(changeServerUrl)) {
+ if (serverUrls.contains(changeServerUrl)) {
+ serverUrl = changeServerUrl;
this.close();
} else {
if (isExactFormat(changeServerUrl)) {
titleLabel.setBounds(10, 10, 200, 23);
}
- private void setServerUrlText(Composite composite) {
- serverText = new Text(composite, SWT.BORDER);
- serverText.setBounds(10, 33, 360, 23);
- serverText.setEnabled(true);
+ private void setServerUrlComboBox(Composite composite) {
+ serverCombo = new Combo(composite, SWT.NONE);
+ serverCombo.setBounds(10, 33, 360, 23);
+ serverCombo.setEnabled(true);
- if (serverUrl.isEmpty()) {
- serverText.setText("http://");
+ if (serverUrls.isEmpty()) {
+ serverCombo.setText("http://");
} else {
- serverText.setText(serverUrl);
- serverText.selectAll();
+ serverCombo.setText(serverUrl);
+ for (String url : serverUrls) {
+ if (url != null) {
+ serverCombo.add(url);
+ }
+ }
}
}
serverUrl = url;
}
+ public void setCurrentServer(ArrayList<String> urls) {
+ serverUrls = urls;
+ }
+
public String getServerUrl() {
return serverUrl;
}
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
import org.tizen.installmanager.core.Config;
import org.tizen.installmanager.core.DistributionController;
import org.tizen.installmanager.core.InstallManager;
+import org.tizen.installmanager.core.InstallManagerConstants;
import org.tizen.installmanager.core.Config.ServerType;
import org.tizen.installmanager.core.IMFatalException;
import org.tizen.installmanager.core.SnapshotLog;
import org.tizen.installmanager.lib.Log;
import org.tizen.installmanager.lib.ErrorController.ErrorCode;
import org.tizen.installmanager.lib.Platform;
+import org.tizen.installmanager.lib.Registry;
import org.tizen.installmanager.pkg.lib.PackageManager;
import org.tizen.installmanager.pkg.model.Snapshot;
import org.tizen.installmanager.pkg.model.SnapshotList;
private String snapshotPath = "";
private String currentDistribution = "";
private String repository = "";
+ ArrayList<String> repos = new ArrayList<String>();
private ServerType serverType = ServerType.SNAPSHOT;
private SnapshotLogDialog snapshotDialog = null;
private Table snapshotTable;
- private Label localErrLabel;
private Label textPackageServerUrl;
private Label textLocalServerUrl;
private File imageFile;
private DistributionController controller = null;
private boolean noErr = true; // flag check to verify pkg list file path.
+ //patch support
+ private Button buttonPatch = null;
+ private Label labelPatch = null;
+ private Button buttonPatchSelection = null;
+
+ private static final int IMAGE_FILE = 0;
+ private static final int PATCH_FILE = 1;
+
//snapshot table column
public static final int TABLE_STATUS = 0;
public static final int TABLE_NAME = 1;
setLocalButton(container);
setFileDialog(container);
setLocalLabel(container);
- setLocalErrorlabel(container);
+
+// setSeparator_02(container);
+// setPatchButton(container);
+// setPatchDialog(container);
+// setPatchLabel(container);
return container;
}
this.repository = serverUrl;
}
+ public void setRepositories(ArrayList<String> serverUrls) {
+ if (serverUrls == null || serverUrls.isEmpty()) {
+ return;
+ }
+
+ this.repos = serverUrls;
+ }
+
/**
* Change package server type by install type(normal, snapshot, local).
* @param isConfDialog User push 'OK' button in configuration dialog is true, otherwise is false.
buttonSelectImage.setEnabled(false);
textLocalServerUrl.setEnabled(false);
textLocalServerUrl.setText("");
- localErrLabel.setText("");
setOkEnable(false);
}
});
public void widgetSelected(SelectionEvent e) {
ChangeServerDialog changeServerDialog = new ChangeServerDialog(composite.getShell());
changeServerDialog.setCurrentServer(repository);
+ changeServerDialog.setCurrentServer(Registry.getRepoHistory());
int ret = changeServerDialog.open();
if (ret == 0) {
String changeServerUrl = changeServerDialog.getServerUrl();
if (!repository.equals(changeServerUrl)) {
setPackageServerEnv(changeServerUrl);
}
+ if (!Registry.getRepoHistory().contains(changeServerUrl)) {
+ Registry.saveRepoInfo(changeServerUrl);
+ }
} else {
Log.log("Change server dialog is canceled.");
}
buttonLocal.setSelection(false);
textLocalServerUrl.setEnabled(false);
textLocalServerUrl.setText("");
- localErrLabel.setText("");
buttonSelectImage.setEnabled(false);
setOkEnable(true);
public void widgetSelected(SelectionEvent e) {
textLocalServerUrl.setEnabled(true);
buttonSelectImage.setEnabled(true);
- localErrLabel.setEnabled(true);
distributionCombo.setEnabled(false);
buttonChangeServer.setEnabled(false);
Log.log("SDK image File selection => " + strDir);
if (strDir.endsWith(SDK_IMAGE_ZIP_EXTENSION)) {
imageFile = new File(strDir);
- if (validation(strDir)) {
+ if (validation(strDir, IMAGE_FILE)) {
Log.log("Package list file found in SDK image => " + strDir);
textLocalServerUrl.setText(strDir);
- localErrLabel.setText("");
UNZIP_RESULT unzipResult = unzipSDKImageFile(imageFile);
if (checkUnzip(unzipResult)) {
setOkEnable(true);
}
@SuppressWarnings("unused")
- private boolean validation(String strDir) {
+ private boolean validation(String strDir, int fileStyle) {
ZipFile zipFile = null;
ZipEntry entry = null;
}
if (zipFile != null) {
- String packageList = PackageManager.getInstance().getPackageListFileName();
- Log.log("This platform must have package list file as '" + packageList + "'");
-
- entry = zipFile.getEntry(packageList);
+ if (fileStyle == IMAGE_FILE) {
+ String packageList = PackageManager.getInstance().getPackageListFileName();
+ Log.log("This platform must have package list file as '" + packageList + "'");
+
+ entry = zipFile.getEntry(packageList);
+ } else if (fileStyle == PATCH_FILE) {
+ String scriptFile = InstallManagerConstants.SDK_PATCH_SCRIPT;
+ Log.log("Patch must have execute script file as '" + scriptFile + "'");
+
+ entry = zipFile.getEntry(scriptFile);
+ } else {
+ try {
+ zipFile.close();
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
+ return false;
+ }
try {
zipFile.close();
return false;
}
}
-
- private void setLocalErrorlabel(Composite composite) {
- localErrLabel = new Label(composite, SWT.WRAP);
- localErrLabel.setBounds(20, 343, 475, 45);
- localErrLabel.setForeground(new Color(null, 255, 0, 0));
- }
/**
* Show file path dialog when file dialog button is pushed.
return strDir;
}
+
+ private void setSeparator_02(Composite composite) {
+ Label sep = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+ sep.setBounds(10, 348, 560, 1);
+ }
+
+ private void setPatchButton(Composite composite) {
+ buttonPatch = new Button(composite, SWT.RADIO);
+ buttonPatch.setSelection(false);
+ buttonPatch.setBounds(10, 358, 350, 18);
+ buttonPatch.setText("SDK patch");
+
+ buttonPatch.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ textLocalServerUrl.setEnabled(true);
+ buttonPatchSelection.setEnabled(true);
+
+ distributionCombo.setEnabled(false);
+ buttonChangeServer.setEnabled(false);
+ buttonSnapshotFilter.setEnabled(false);
+ buttonSelectImage.setEnabled(false);
+ setOkEnable(false);
+
+ snapshotPath = "";
+ }
+ });
+ }
+
+ private void setPatchDialog(Composite composite) {
+ buttonPatchSelection = new Button(composite, SWT.NONE);
+ buttonPatchSelection.setEnabled(false);
+ buttonPatchSelection.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ String strDir = showSettingPatchpathDlg();
+ if (strDir != null) {
+ Log.log("Success to open SDK patch selection file dialog.");
+ Log.log("SDK patch file selection => " + strDir);
+ if (strDir.endsWith(SDK_IMAGE_ZIP_EXTENSION)) {
+
+ }
+ }
+ }
+ });
+
+ buttonPatchSelection.setImage(PathUtil.getImageFromResource("/res/icons/icon_directory_open.png"));
+ if (!Platform.isMacOS()) {
+ buttonPatchSelection.setBounds(520, 381, 35, 29);
+ } else {
+ buttonPatchSelection.setBounds(525, 380, 40, 31);
+ }
+ }
+
+ private void setPatchLabel(Composite composite) {
+ labelPatch = new Label(composite, SWT.BORDER);
+ labelPatch.setBounds(10, 386, 500, 20);
+ labelPatch.setEnabled(false);
+ }
+
+ private String showSettingPatchpathDlg() {
+ FileDialog dlg = new FileDialog(Display.getCurrent().getShells()[0]);
+ dlg.setText("Select the SDK patch file.");
+ String strDir = null;
+ try {
+ strDir = dlg.open();
+ } catch (SWTException e) {
+ Log.ExceptionLog(e);
+ }
+
+ return strDir;
+ }
/**
* Unzip SDK ImageFile.