*/
package org.tizen.nativeplatform.pkgmgr;
+import java.io.File;
import java.io.IOException;
import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Hashtable;
import java.util.ResourceBundle;
+import java.util.concurrent.CopyOnWriteArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import java.util.Enumeration;
+import org.tizen.common.util.FileUtil;
import org.tizen.common.util.HostUtil;
-import org.tizen.nativecommon.build.exception.SBIException;
import org.tizen.nativeplatform.password.SudoPasswdManager;
import org.tizen.nativeplatform.pkgmgr.PackageManagerOuputReceiver;
+import org.tizen.nativeplatform.pkgmgr.model.Package;
import org.tizen.sdblib.IDevice;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
private final static int MAX_TIMEOUT = 10000;
private static String http_proxy = "";
private static final String REMOVE_PKGS = "rpm-x86-arm";
- private static final String NODEPS_OPTION = "--nodeps";
private static final String BUNDLE_NAME = RPMPackageCommander.class.getPackage().getName() + ".RPMPackageCommands";
private static ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
String command = getCommand(path, cmd);
try {
- HostUtil.executeWithConsole(command, "test");
+ HostUtil.executeWithConsole(command, "Platform Internal");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
- public static void InstallPkgToRootstrap(String fileList, String path) {
+
+ public static void InstallLocalPkgToRootstrap(ArrayList<String> fileList, String path) {
+ actionBeforeUseZypper(path);
- String cmd = String.format("%s;%s", getResetDbCmd(), getInstallLocalPkgCmd(fileList));
- String command = getCommand(path, cmd);
-
try {
- HostUtil.executeWithConsole(command, "test");
+ // copy
+ ArrayList<String> fileListOnRootstrap = new ArrayList<String>();
+ for (String filePath : fileList) {
+ String filename = new File(filePath).getName();
+ String pathOnRootstrap = "/tmp/" + filename;
+ try {
+ FileUtil.copyTo(filePath, path + pathOnRootstrap);
+ } catch (IOException e) {
+ //do nothing
+ }
+ fileListOnRootstrap.add(pathOnRootstrap);
+ }
+
+ // install
+ String cmd = String.format("%s;%s", getResetDbCmd(), getInstallLocalPkgCmd(fileListOnRootstrap));
+ String command = getCommand(path, cmd);
+ HostUtil.executeWithConsole(command, "Platform Internal");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
public static Document InstallPkgWithZypperXmlOut(String path, String pkgs, boolean refresh, boolean force) {
return doc;
}
- public static void UninstallPkgFromRootstrap(String fileList, String option, String path) {
+ public static void uninstallPkgFromRootstrap(CopyOnWriteArrayList<Package> pkgList, String path) {
+
+ String cmd = String.format("%s;%s", getResetDbCmd(), getUninstallPkgCmd(pkgList));
+ String command = getCommand(path, cmd);
+
+ try {
+ HostUtil.executeWithConsole(command, "Platform Internal");
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+
+ public static void UninstallPkgFromRootstrapNoDeps(String fileList, String path) {
- String cmd = String.format("%s;%s", getResetDbCmd(), getUninstallPkgCmd(fileList, option));
+ String cmd = String.format("%s;%s", getResetDbCmd(), getUninstallPkgCmdNoDeps(fileList));
String command = getCommand(path, cmd);
try {
- HostUtil.executeWithConsole(command, "test");
+ HostUtil.executeWithConsole(command, "Platform Internal");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
+
public static void InstallPkgToDevice(String fileList, IDevice device, PackageManagerOuputReceiver rec) {
if (device != null) {
try {
- String command = String.format("%s;%s", getResetDbCmd(), getInstallLocalPkgCmd(fileList));
+ String command = String.format("%s;%s", getResetDbCmd(), getInstallLocalPkgCmdWithRPM(fileList));
device.executeShellCommand(command, rec, MAX_TIMEOUT);
} catch (Exception e1) {
e1.printStackTrace();
return ret;
}
+
+ public static ArrayList<Package> getPackageListForRootstrap(String path) {
+ ArrayList<Package> packageList = new ArrayList<Package>();
+ Hashtable<String, Package> packageHash = new Hashtable<String, Package>();
+
+ try {
+ // get list using zypper
+ String cmd = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(), getRemotePkgListCmd());
+ String command = getCommand(path, cmd);
+ String result = HostUtil.returnExecute(command);
+ String[] splitStr = result.split("\n");
+ for (String s : splitStr ) {
+ s = s.replaceAll(" ", "");
+ String[] part = s.split("\\|");
+ if ( part.length == 5 && !part[1].equals("Repository")) {
+ String name = part[2];
+ String version = part[3];
+ String arch = part[4];
+ if ( part[0].equals("i") ) {
+ packageHash.put(name, new Package(name,version,version,arch) );
+ }
+ else if ( part[0].equals("v") ) {
+ Package p = packageHash.get(name);
+ if ( version.compareTo( p.getNewVersion() ) > 0 ) {
+ p.setNewVersion(version);
+ }
+ }
+ else {
+ packageHash.put(name, new Package(name,"",version,arch) );
+ }
+ }
+ }
+
+ // get installed packages using rpm
+ cmd = String.format("%s;%s", getResetDbCmd(), getInstalledPkgListCmd());
+ command = getCommand(path, cmd);
+ result = HostUtil.returnExecute(command);
+ splitStr = result.split("\n");
+ for (String s : splitStr) {
+ s = s.replaceAll(" ", "").trim();
+ String[] part = s.split(",");
+ if ( part.length == 3 ) {
+ String name = part[0];
+ String version = part[1];
+ String arch = part[2];
+ Package pkg = packageHash.get(name);
+ if ( pkg == null ) {
+ packageHash.put(name, new Package(name,version,"",arch));
+ }
+ else {
+ // do nothing
+ }
+ }
+ }
+ } catch (Exception e) {
+ // do nothing
+ }
+
+ Enumeration<Package> e = packageHash.elements();
+ while(e.hasMoreElements()) {
+ packageList.add(e.nextElement());
+ }
+
+ return packageList;
+ }
+
+
public static String getRemotePackageListForRootstrap(String path) {
String result = "";
return result;
}
- public static String getRepositoryListForRootstrap(String path) {
-
- String result = "";
+
+ // return (name -> url) hash table
+ public static Hashtable<String, String> getRepositoryListForRootstrap(String path) {
+ Hashtable<String, String> reposHash = new Hashtable<String, String>();
String cmd = String.format("%s;%s", getResetDbCmd(), getRepoListCmd());
String command = getCommand(path, cmd);
try {
- result = HostUtil.returnExecute(command);
+ String result = HostUtil.returnExecute(command);
+ String[] splitStr = result.split("\n");
+
+ // url list starts at 3 line
+ for (String reposStr: splitStr) {
+ reposStr = reposStr.replaceAll(" ", "");
+ String[] part = reposStr.split("\\|");
+ if ( part.length == 6 && !part[0].equals("#") ) {
+ reposHash.put(part[1], part[5]);
+ }
+ }
+
} catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ // do nothing
+ }
+
+ return reposHash;
+ }
+
+
+ public static void resetRepositoryForRootstrap(String path) {
+ String cmd = String.format("%s", getRepoResetCmd());
+ String command = getCommand(path, cmd);
+
+ try {
+ HostUtil.returnExecute(command);
+
+ } catch (Exception e) {
+ // do nothing
}
- return result;
}
+
public static String getRepositoryListForDevice(IDevice device, PackageManagerOuputReceiver rec) {
String command = getCommand(path, cmd);
try {
- HostUtil.executeWithConsole(command, "test");
+ HostUtil.executeWithConsole(command, "Platform Internal");
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
- public static String installRemotePkgForRootstrap(String pkgList, String path) {
+ public static String installRemotePkgForRootstrap(CopyOnWriteArrayList<Package> selectedList, String path) {
actionBeforeUseZypper(path);
String result = "";
- String cmd = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(), getInstallPkgCmd(pkgList));
+ String cmd = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(), getInstallPkgCmd(selectedList));
String command = getCommand(path, cmd);
try {
- HostUtil.executeWithConsole(command, "test");
+ HostUtil.executeWithConsole(command, "Platform Internal");
} catch (Exception e) {
e.printStackTrace();
}
String result = "";
try {
- String command = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(), getInstallPkgCmd(pkgList));
+ String command = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(), getInstallPkgCmdOld(pkgList));
rec.cleanLog();
device.executeShellCommand(command, rec, MAX_TIMEOUT);
} catch (Exception e) {
private static void actionBeforeUseZypper(String path) {
if (pkgInstalledSuccessfullyForRootstrap(REMOVE_PKGS, path)) {
- UninstallPkgFromRootstrap(REMOVE_PKGS, NODEPS_OPTION, path);
+ UninstallPkgFromRootstrapNoDeps(REMOVE_PKGS, path);
}
}
return String.format(resources.getString("Command.DistUpgrade"));
}
- private static String getInstallPkgCmd(String pkgList) {
+ private static String getInstallPkgCmd(CopyOnWriteArrayList<Package> pkgList) {
+ String pkgListStr = "";
+ for( Package pkg: pkgList) {
+ pkgListStr = pkgListStr.isEmpty() ? pkg.getName() : pkgListStr + " " + pkg.getName();
+ }
+ return String.format(resources.getString("Command.Install.Remote.Pkg"), pkgListStr);
+ }
+
+ private static String getInstallPkgCmdOld(String pkgList) {
return String.format(resources.getString("Command.Install.Remote.Pkg"), pkgList);
}
- private static String getInstallLocalPkgCmd(String pkgList) {
- return String.format(resources.getString("Command.Install.Local.Pkg"), pkgList);
+ private static String getInstallLocalPkgCmd(ArrayList<String> fileList) {
+ String pkgListStr = "";
+ for( String filePath: fileList) {
+ pkgListStr = pkgListStr.isEmpty() ? filePath : pkgListStr + " " + filePath;
+ }
+ return String.format(resources.getString("Command.Install.Local.Pkg"), pkgListStr);
}
-
- private static String getUninstallPkgCmd(String pkgList, String option) {
- return String.format(resources.getString("Command.Uninstall.Pkg"), pkgList, option);
+
+ private static String getInstallLocalPkgCmdWithRPM(String pkgList) {
+ return String.format(resources.getString("Command.Install.Local.Pkg.RPM"), pkgList);
}
+ private static String getUninstallPkgCmd(CopyOnWriteArrayList<Package> pkgList) {
+ String pkgListStr = "";
+ for( Package pkg: pkgList) {
+ pkgListStr = pkgListStr.isEmpty() ? pkg.getName() : pkgListStr + " " + pkg.getName();
+ }
+ return String.format(resources.getString("Command.Uninstall.Pkg"), pkgListStr);
+ }
+
+ private static String getUninstallPkgCmdNoDeps(String pkgList) {
+ return String.format(resources.getString("Command.Uninstall.Pkg.NoDeps"), pkgList);
+ }
private static String getRemoteRepoCmd(String name) {
return String.format(resources.getString("Command.Remove.Repo"), name);
private static String getRepoListCmd() {
return resources.getString("Command.List.Repo");
}
-
+
+ private static String getRepoResetCmd() {
+ return resources.getString("Command.Reset.Repo");
+ }
+
private static String getRemotePkgListCmd() {
return resources.getString("Command.List.Remote.Pkg");
}
private static String getCommand(String path, String cmd) {
String passwd = SudoPasswdManager.getSudoPassword();
return String.format("sh -c \'echo %s | sudo -S chroot %s sh -c \"%s\"\'", passwd, path, cmd);
- }
+ }
+
+
+ public static int compareVersion(String ver1, String ver2) {
+ ArrayList<String> tokList1 = tokenizeVersionString(ver1);
+ ArrayList<String> tokList2 = tokenizeVersionString(ver2);
+ int maxTokens = tokList1.size() > tokList2.size() ? tokList1.size() : tokList2.size();
+
+ for( int i = 0; i < maxTokens; i++ ) {
+ // check length
+ if ( i == tokList1.size() ) {return -1;}
+ if ( i == tokList2.size() ) {return 1;}
+
+ String tok1 = tokList1.get(i);
+ String tok2 = tokList2.get(i);
+
+ int value1 = -1, value2 = -1;
+ try {
+ value1 = Integer.parseInt(tok1);
+ }
+ catch ( NumberFormatException e) {
+ // do nothing
+ }
+
+ try {
+ value2 = Integer.parseInt(tok2);
+ }
+ catch ( NumberFormatException e) {
+ // do nothing
+ }
+
+ if ( value1 > value2 ) {
+ return 1;
+ }
+ else if ( value1 < value2 ) {
+ return -1;
+ }
+ else {
+ int result = tok1.compareTo(tok2);
+ if ( result != 0 ) {
+ return result;
+ }
+ }
+ }
+
+ return 0;
+ }
+
+ private static ArrayList<String> tokenizeVersionString(String ver) {
+ ArrayList<String> result = new ArrayList<String>();
+ final int NUM = 0;
+ final int ALPHA = 1;
+ final int NONALPHANUM = 2;
+ int oldStatus=NONALPHANUM;
+ String buf = "";
+ for( int i = 0; i < ver.length(); i++ ) {
+ char c = ver.charAt(i);
+ int newStatus;
+ if ( c >= '0' && c <= '9' ) {
+ newStatus = NUM;
+ }
+ else if ( (c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z') ) {
+ newStatus = ALPHA;
+ }
+ else {
+ newStatus = NONALPHANUM;
+ }
+
+ if ( oldStatus != newStatus ) {
+ if ( !buf.isEmpty() ) {
+ result.add(buf);
+ }
+ if ( newStatus != NONALPHANUM ) {
+ buf = String.valueOf(c);
+ }
+ else {
+ buf = "";
+ }
+ oldStatus = newStatus;
+ }
+ else {
+ if ( newStatus != NONALPHANUM ) {
+ buf += String.valueOf(c);
+ }
+ }
+ }
+ if ( !buf.isEmpty() ) {
+ result.add(buf);
+ }
+
+ return result;
+ }
}
package org.tizen.nativeplatform.pkgmgr.ui;
import java.io.File;
-import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
-import java.util.Iterator;
+import java.util.ArrayList;
import java.util.ResourceBundle;
import java.util.concurrent.CopyOnWriteArrayList;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ICheckStateProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.TabItem;
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.common.util.DialogUtil;
-import org.tizen.common.util.FileUtil;
-import org.tizen.nativecommon.build.CurrentEnabledProject;
import org.tizen.nativecommon.build.SmartBuildInterface;
-import org.tizen.nativeplatform.build.PlatformConfigurationManager;
-import org.tizen.nativeplatform.build.PlatformCheckCancelJob;
import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander;
-import org.tizen.nativeplatform.pkgmgr.model.InstalledPackage;
-import org.tizen.nativeplatform.pkgmgr.model.InstalledPkgProvider;
-import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
import org.tizen.nativeplatform.pkgmgr.model.Package;
import org.tizen.nativeplatform.pkgmgr.model.PackageProvider;
-import org.tizen.nativeplatform.pkgmgr.model.RemotePackage;
-import org.tizen.nativeplatform.pkgmgr.model.RemotePkgProvider;
import org.tizen.nativeplatform.pkgmgr.model.Repository;
import org.tizen.nativeplatform.pkgmgr.model.RepositoryProvider;
import org.tizen.nativeplatform.views.model.PlatformRootstrap;
public class BuildSystemTab {
- private IProject project;
private TabFolder folder = null;
private TableViewer repoViewer = null;
- private TableViewer pkgViewer = null;
+ private CheckboxTableViewer pkgViewer = null;
private final Shell shell;
- private FileDialog fd;
- private String previousFilterPath = null;
- private String selectedFileList;
private PlatformRootstrap rootstrap;
- private CopyOnWriteArrayList<Package> pkgs;
private String rootstrapPath = "";
- private String arch = "";
-
+ private Combo categoryCombo;
+ private Text filterText;
private final String BUNDLE_NAME = BuildSystemTab.class.getPackage().getName() + ".PkgMgrUIMessages";//$NON-NLS-1$
private final ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
+
public BuildSystemTab(Shell shell, TabFolder folder, PlatformRootstrap rootstrap) {
this.shell = shell;
this.folder = folder;
this.rootstrap = rootstrap;
this.rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(rootstrap.getPath().toOSString());
- this.arch = rootstrap.getArch();
- this.project = CurrentEnabledProject.getCurrentProject();
}
+
public void createTab() {
- initialize();
-
createBuildsystemTab(folder);
}
- private void initialize() {
- RepositoryProvider.INSTANCE.getBuildsystemRepos().clear();
- PackageProvider.INSTANCE.getBuildsystemPkgs().clear();
-
- String result = RPMPackageCommander.getRepositoryListForRootstrap(rootstrapPath);
- String[] splitStr = result.split("\n");
- // url list starts at 3 line
- for (int i = 2 ; i < splitStr.length ; i++) {
- String s = splitStr[i];
- s = s.replaceAll(" ", "");
- String[] part = s.split("\\|");
- String name = part[1];
- String uri = part[5];
-
- Repository repo = new Repository();
- repo.setName(name);
- repo.setUri(uri);
-
- RepositoryProvider.INSTANCE.getBuildsystemRepos().add(repo);
- }
-
- boolean dirty = false;
-
- for (String r : rootstrap.getRepositoryURLs()) {
- if (!existRepoUrl(r.trim())) {
- dirty = true;
- RPMPackageCommander.addRepositoryForRootstrap(getAvailableRepoName(), r, rootstrapPath);
- }
- }
-
- if (dirty) {
- initialize();
- }
-
- }
-
- private boolean existRepoUrl(String r) {
- for (Repository repo : RepositoryProvider.INSTANCE.getBuildsystemRepos()) {
- if (r.equals(repo.getUri().trim())) {
- return true;
- }
- }
-
- return false;
- }
-
- private boolean existRepoName(String n) {
- for (Repository repo : RepositoryProvider.INSTANCE.getBuildsystemRepos()) {
- if (n.equals(repo.getName().trim())) {
- return true;
- }
- }
-
- return false;
- }
-
- private String getAvailableRepoName() {
- String namePrefix = "url";
- for (int i=0 ; ; i++) {
- String name = namePrefix + String.valueOf(i);
- if (!existRepoName(name)) {
- return name;
- }
- }
- }
private void createBuildsystemTab( TabFolder parent )
{
Composite composite = new Composite(folder, SWT.NONE);
buildsystemTab.setControl(composite);
- composite.setLayout(new GridLayout(1, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ composite.setLayout(new GridLayout(1, false));
- //createInfoComposite( composite );
createRepositoryGroup( composite );
createPackageGroup( composite );
}
- private void createInfoComposite( Composite parent )
- {
- Composite info_comp = new Composite( parent, SWT.NONE );
- info_comp.setLayoutData(new GridData(GridData.BEGINNING));
- info_comp.setLayout(new GridLayout(1, false));
-
- Label configurationLabel = new Label(info_comp, SWT.LEFT);
- //configurationLabel.setText(String.format("%s %s", resources.getString("PkgMgr.Label.Configuration"), conf));
- }
private void createRepositoryGroup( Composite parent )
{
Group grpRepo = new Group(parent, SWT.NONE);
grpRepo.setText(resources.getString("PkgMgr.Frame.Respository"));
- grpRepo.setLayout(new GridLayout(1, false));
- GridData repo_gd = new GridData(GridData.FILL_BOTH);
+ GridData repo_gd = new GridData(GridData.FILL_HORIZONTAL);
+ repo_gd.heightHint = 110;
grpRepo.setLayoutData(repo_gd);
+ grpRepo.setLayout(new GridLayout(2, false));
- Composite repo_comp = new Composite( grpRepo, SWT.NONE );
- repo_comp.setLayoutData(new GridData(GridData.FILL_BOTH));
- repo_comp.setLayout(new GridLayout(2, false));
-
- Composite repo_comp_table = new Composite( repo_comp, SWT.NONE );
- repo_comp_table.setLayoutData(new GridData(GridData.FILL_BOTH));
- repo_comp_table.setLayout(new FillLayout());
-
- Composite repo_comp_buttons = new Composite( repo_comp, SWT.NONE );
- repo_comp_buttons.setLayoutData(new GridData(GridData.FILL_BOTH));
- repo_comp_buttons.setLayout(new GridLayout(1, false));
-
- createRepositoryTable( repo_comp_table );
- createRepositoryButtons( repo_comp_buttons );
+ createRepositoryTable( grpRepo );
+ createRepositoryButtons( grpRepo );
}
- private void createPackageGroup( Composite parent )
+
+ private void createRepositoryTable( Composite parent)
{
- Group grpPkg = new Group(parent, SWT.NONE);
- grpPkg.setText(resources.getString("PkgMgr.Frame.Package"));
- grpPkg.setLayout(new GridLayout(1, false));
- GridData pkgs_gd = new GridData(GridData.FILL_BOTH);
- pkgs_gd.heightHint = shell.getBounds().height / 3;
- grpPkg.setLayoutData(pkgs_gd);
-
- Composite pkg_comp = new Composite( grpPkg, SWT.NONE );
- pkg_comp.setLayoutData(new GridData(GridData.FILL_BOTH));
- pkg_comp.setLayout(new GridLayout(2, false));
-
- Composite pkg_comp_table = new Composite( pkg_comp, SWT.NONE );
- pkg_comp_table.setLayoutData(new GridData(GridData.FILL_BOTH));
- pkg_comp_table.setLayout(new FillLayout());
-
- Composite pkg_comp_buttons = new Composite( pkg_comp, SWT.NONE );
- pkg_comp_buttons.setLayoutData(new GridData(GridData.FILL_BOTH));
- pkg_comp_buttons.setLayout(new GridLayout(1, false));
-
- createPackageTable( pkg_comp_table );
- createPackageButtons( pkg_comp_buttons );
+ Composite composite = new Composite( parent, SWT.NONE );
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ composite.setLayoutData(gridData);
+ composite.setLayout(new FillLayout());
+
+ repoViewer = new TableViewer( composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL );
+ createColumnsForRepoTable( composite );
+ Table reposTable = repoViewer.getTable();
+ reposTable.setHeaderVisible(true);
+ reposTable.setLinesVisible(true);
+ repoViewer.setContentProvider(new ArrayContentProvider());
+ repoViewer.setInput(RepositoryProvider.INSTANCE.getBuildsystemRepos());
}
- private void createRepositoryTable( Composite parent)
+
+ private void createColumnsForRepoTable( Composite parent )
{
- repoViewer = new TableViewer( parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK );
- createColumnsForRepoTable( parent );
- Table tableForRepository = repoViewer.getTable();
- tableForRepository.addListener( SWT.Selection, new Listener(){
+ String[] titles = {resources.getString("PkgMgr.Repo.Table.Column.1"),
+ resources.getString("PkgMgr.Repo.Table.Column.2")};
+ int[] bounds = { 100, 600 };
+ TableViewerColumn colName = createTableViewerColumn( repoViewer, titles[0], bounds[0], SWT.NONE);
+ colName.setLabelProvider(new ColumnLabelProvider() {
@Override
- public void handleEvent(Event event) {
- if( event.detail == SWT.CHECK )
- {
- Repository repo = (Repository)event.item.getData();
- repo.setCheckColumn( !repo.getCheckColumn() );
- }
+ public String getText(Object element) {
+ Repository repo = (Repository)element;
+ return repo.getName();
+ }
+ });
+
+ TableViewerColumn colUrl = createTableViewerColumn( repoViewer, titles[1], bounds[1], SWT.NONE);
+ colUrl.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ Repository repo = (Repository)element;
+ return repo.getUri();
}
});
- tableForRepository.setHeaderVisible(true);
- tableForRepository.setLinesVisible(true);
- repoViewer.setContentProvider(new ArrayContentProvider());
- repoViewer.setInput(RepositoryProvider.INSTANCE.getBuildsystemRepos());
}
+
private void createRepositoryButtons( Composite parent )
{
- Button add_bt = new Button( parent, SWT.PUSH );
+ Composite composite = new Composite( parent, SWT.NONE );
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ RowLayout layout = new RowLayout(SWT.VERTICAL);
+ layout.pack = false;
+ composite.setLayout(layout);
+
+
+ Button add_bt = new Button( composite, SWT.PUSH );
add_bt.setText(resources.getString("PkgMgr.Button.AddRepo"));
add_bt.setToolTipText(resources.getString("PkgMgr.Button.AddRepo.Tooltip"));
add_bt.addMouseListener(new MouseListener(){
public void mouseDown(MouseEvent e) {
AddRepoDialog dialog = new AddRepoDialog(shell, resources.getString("PkgMgr.Tab.Buildsystem"));
- dialog.open();
+ if ( dialog.open() != AddRepoDialog.OK ) {
+ return;
+ }
+ String name = String.format("url%d", repoViewer.getTable().getItemCount());
+ String url = dialog.getRepositoryURL();
+ RPMPackageCommander.addRepositoryForRootstrap(name, url, rootstrapPath);
+
+ rootstrap.addRepositoryURL(url);
+ updateRepositoryInfo();
repoViewer.refresh();
-
- int recentTableIndex = 0;
- recentTableIndex = repoViewer.getTable().getItemCount();
-
- for (int i = 0; i < recentTableIndex; i++) {
- TableItem item = null;
- item = repoViewer.getTable().getItem(i);
- Repository repo = (Repository)item.getData();
- item.setChecked(repo.getCheckColumn());
-
- if (repo.getCheckDirty()) {
- RPMPackageCommander.addRepositoryForRootstrap(repo.getName(), repo.getUri(), rootstrapPath);
- repo.setCheckDirty(false);
- }
- }
}
@Override
});
- Button modify_bt = new Button( parent, SWT.PUSH );
+ Button modify_bt = new Button( composite, SWT.PUSH );
modify_bt.setText(resources.getString("PkgMgr.Button.ModifyRepo"));
modify_bt.setToolTipText(resources.getString("PkgMgr.Button.ModifyRepo.Tooltip"));
modify_bt.addMouseListener(new MouseListener(){
@Override
public void mouseDown(MouseEvent e) {
-
- CopyOnWriteArrayList<Repository> list = RepositoryProvider.INSTANCE.getBuildsystemRepos();
-
- Repository selectedRepo = null;
- int count = 0;
-
- for( Repository repo : list) {
- if (repo.getCheckColumn()) {
- count++;
- selectedRepo = repo;
- }
- }
-
- if (count != 1 ) {
+ int selectedIdx = repoViewer.getTable().getSelectionIndex();
+ if ( selectedIdx == -1 ) {
DialogUtil.openMessageDialog(resources.getString("PkgMgr.Message.Select.OnePackage"));
return;
}
+ Repository repos = (Repository)repoViewer.getTable().getItem(selectedIdx).getData();
ModifyRepoDialog dialog = new ModifyRepoDialog(shell, resources.getString("PkgMgr.Tab.Buildsystem"),
- selectedRepo.getName(), selectedRepo.getUri());
- dialog.open();
-
- repoViewer.refresh();
-
- int recentTableIndex = 0;
- recentTableIndex = repoViewer.getTable().getItemCount();
-
- for (int i = 0; i < recentTableIndex; i++) {
- TableItem item = null;
- item = repoViewer.getTable().getItem(i);
- Repository repo = (Repository)item.getData();
- item.setChecked(repo.getCheckColumn());
-
- if (repo.getCheckDirty()) {
- list.remove(selectedRepo);
- RPMPackageCommander.removeRepositoryForRootstrap(selectedRepo.getName(), rootstrapPath);
- RPMPackageCommander.addRepositoryForRootstrap(repo.getName(), repo.getUri(), rootstrapPath);
- repo.setCheckDirty(false);
- }
+ repos.getUri());
+ if ( dialog.open() != ModifyRepoDialog.OK ) {
+ return;
}
-
+ rootstrap.changeRepositoryURL(repos.getUri(), dialog.getRepositoryURL());
+ updateRepositoryInfo();
repoViewer.refresh();
- recentTableIndex = repoViewer.getTable().getItemCount();
-
- for (int i = 0; i < recentTableIndex; i++) {
- TableItem item = repoViewer.getTable().getItem(i);
- Repository repo = (Repository)item.getData();
- item.setChecked(repo.getCheckColumn());
- }
}
@Override
}
});
- Button remove_bt = new Button( parent, SWT.PUSH );
+ Button remove_bt = new Button( composite, SWT.PUSH );
remove_bt.setText(resources.getString("PkgMgr.Button.RemoveRepo"));
remove_bt.setToolTipText(resources.getString("PkgMgr.Button.RemoveRepo.Tooltip"));
remove_bt.addMouseListener(new MouseListener() {
@Override
public void mouseDown(MouseEvent e) {
- CopyOnWriteArrayList<Repository> list = RepositoryProvider.INSTANCE.getBuildsystemRepos();
-
- for( Repository repo : list)
- {
- boolean selected = false;
- selected = repo.getCheckColumn();
-
- if (selected) {
- list.remove(repo);
- RPMPackageCommander.removeRepositoryForRootstrap(repo.getName(), rootstrapPath);
- }
- }
-
+ int selectedIdx = repoViewer.getTable().getSelectionIndex();
+ if ( selectedIdx == -1 ) {
+ DialogUtil.openMessageDialog(resources.getString("PkgMgr.Message.Select.OnePackage"));
+ return;
+ }
+ Repository repos = (Repository)repoViewer.getTable().getItem(selectedIdx).getData();
+ rootstrap.removeRepositoryURL(repos.getUri());
+ updateRepositoryInfo();
repoViewer.refresh();
- int recentTableIndex = repoViewer.getTable().getItemCount();
-
- for (int i = 0; i < recentTableIndex; i++) {
- TableItem item = repoViewer.getTable().getItem(i);
- Repository repo = (Repository)item.getData();
- item.setChecked(repo.getCheckColumn());
- }
-
}
@Override
public void mouseUp(MouseEvent e) {
}
});
+ }
+
+
+ public void updateRepositoryInfo() {
+ initializeRepositoryInfo(rootstrap);
+ }
+
+
+ public static void initializeRepositoryInfo(PlatformRootstrap rootstrap) {
+ String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(rootstrap.getPath().toOSString());
+ RepositoryProvider.INSTANCE.getBuildsystemRepos().clear();
+ RPMPackageCommander.resetRepositoryForRootstrap(rootstrapPath);
+ int idx = 0;
+ for (String url : rootstrap.getRepositoryURLs()) {
+ String name = String.format("url%d", idx++);
+ RepositoryProvider.INSTANCE.getBuildsystemRepos()
+ .add(new Repository(name, url ));
+ RPMPackageCommander.addRepositoryForRootstrap(name, url, rootstrapPath);
+ }
+ }
+
+
+ public static void initializePackageInfo(PlatformRootstrap rootstrap) {
+ String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(rootstrap.getPath().toOSString());
+ PackageProvider.INSTANCE.getBuildsystemPkgs().clear();
+ PackageProvider.INSTANCE.getBuildsystemPkgs()
+ .addAll(RPMPackageCommander.getPackageListForRootstrap(rootstrapPath));
+ }
- Button refresh_bt = new Button( parent, SWT.PUSH );
+
+ private void createPackageGroup( Composite parent )
+ {
+ Group grpPkg = new Group(parent, SWT.NONE);
+ grpPkg.setText(resources.getString("PkgMgr.Frame.Package"));
+ GridData pkgs_gd = new GridData(GridData.FILL_BOTH|GridData.GRAB_VERTICAL);
+ grpPkg.setLayoutData(pkgs_gd);
+ grpPkg.setLayout(new GridLayout(1, false));
+
+ createPackageButtonsAndFilter( grpPkg );
+ createPackageTable( grpPkg );
+ }
+
+
+ private void createPackageButtonsAndFilter( Composite parent ) {
+ Composite composite = new Composite( parent, SWT.NONE );
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ composite.setLayout(new GridLayout(2, false));
+
+ createPackageButtons( composite );
+ createPackageFilter( composite );
+ }
+
+
+ private void createPackageButtons( Composite parent )
+ {
+ Composite composite = new Composite( parent, SWT.NONE );
+ RowLayout layout = new RowLayout(SWT.HORIZONTAL);
+ layout.pack = false;
+ composite.setLayout(layout);
+
+ Button refresh_bt = new Button( composite, SWT.PUSH );
refresh_bt.setText(resources.getString("PkgMgr.Button.RefreshRepo"));
refresh_bt.setToolTipText(resources.getString("PkgMgr.Button.RefreshRepo.Tooltip"));
refresh_bt.addMouseListener(new MouseListener(){
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
try {
- dialog.run(true, true, new IRunnableWithProgress() {
+ dialog.run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
monitor.beginTask(resources.getString("PkgMgr.Message.Refreshing"), -1);
-
- //PlatformCheckCancelJob cancelJob = new PlatformCheckCancelJob(monitor, project, sbi);
- //Thread checkCancelThread = new Thread(cancelJob);
- //checkCancelThread.start();
-
RPMPackageCommander.refreshRepositoryForRootstrap(rootstrapPath);
- //cancelJob.setFinishFlag(true);
+ monitor.done();
}
});
} catch (Exception e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
+ DialogUtil.openErrorDialog(
+ resources.getString("PkgMgr.Msg.Error.RefreshFailed")+
+ "("+e1.toString()+")");
}
}
@Override
public void mouseUp(MouseEvent e) {
}
- });
- }
-
- private void createPackageTable( Composite parent )
- {
- pkgViewer = new TableViewer( parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK );
- createColumns( parent );
- Table packageTable = pkgViewer.getTable();
- packageTable.addListener( SWT.Selection, new Listener(){
-
- @Override
- public void handleEvent(Event event) {
- if( event.detail == SWT.CHECK )
- {
- Package pkg = (Package)event.item.getData();
- pkg.setCheckColumn( !pkg.getCheckColumn() );
- }
- }
- });
-
- packageTable.setHeaderVisible(true);
- packageTable.setLinesVisible(true);
-
- pkgViewer.setContentProvider(new ArrayContentProvider());
- pkgViewer.setInput(PackageProvider.INSTANCE.getBuildsystemPkgs());
- }
-
- private void createPackageButtons( Composite parent )
- {
- Button add_rtpkg_bt = new Button( parent, SWT.PUSH );
- add_rtpkg_bt.setText(resources.getString("PkgMgr.Button.AddRPackage"));
- add_rtpkg_bt.setToolTipText(resources.getString("PkgMgr.Button.AddRPackage.Tooltip"));
- add_rtpkg_bt.addMouseListener(new MouseListener(){
+ });
+
+
+ Button upgrade_bt = new Button( composite, SWT.PUSH );
+ upgrade_bt.setText(resources.getString("PkgMgr.Button.Upgrade"));
+ upgrade_bt.setToolTipText(resources.getString("PkgMgr.Button.Upgrade.Tooltip"));
+ upgrade_bt.addMouseListener(new MouseListener(){
@Override
public void mouseDoubleClick(MouseEvent e) {
@Override
public void mouseDown(MouseEvent e) {
-
- RemotePkgProvider.INSTANCE.getPkgs().clear();
- RemotePkgProvider.INSTANCE.getSelectedPkgs().clear();
-
+
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
-
- try {
- dialog.run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
- monitor.beginTask(resources.getString("PkgMgr.Message.Getting.RemotePackage"), -1);
- genRemotePkgList();
- }
- });
- } catch (Exception e1) {
- e1.printStackTrace();
- }
-
- AddRemotePackageDialog dlg = new AddRemotePackageDialog(shell);
- dlg.open();
-
- dialog = new ProgressMonitorDialog(shell);
+
try {
- dialog.run(true, true, new IRunnableWithProgress() {
+ dialog.run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
- monitor.beginTask(resources.getString("PkgMgr.Message.Adding.Package"), -1);
- for (RemotePackage p : RemotePkgProvider.INSTANCE.getSelectedPkgs()) {
- addRemotePackage(p);
- }
+ InterruptedException {
+
+ monitor.beginTask(resources.getString("PkgMgr.Message.Upgrade"), -1);
+ RPMPackageCommander.DistUpgradeRootstrap(rootstrapPath);
+ monitor.done();
}
});
} catch (Exception e1) {
- e1.printStackTrace();
- }
-
- pkgViewer.refresh();
- int recentTableIndex = pkgViewer.getTable().getItemCount();
-
- for (int i = 0; i < recentTableIndex; i++) {
- TableItem item = pkgViewer.getTable().getItem(i);
- Package pkg = (Package)item.getData();
- item.setChecked(pkg.getCheckColumn());
- }
-
+ DialogUtil.openErrorDialog(
+ resources.getString("PkgMgr.Msg.Error.UpgradeFailed")+
+ "("+e1.toString()+")");
+ }
}
@Override
public void mouseUp(MouseEvent e) {
}
-
});
-
- Button add_lcpkg_bt = new Button( parent, SWT.PUSH );
- add_lcpkg_bt.setText(resources.getString("PkgMgr.Button.AddLPackage"));
- add_lcpkg_bt.setToolTipText(resources.getString("PkgMgr.Button.AddLPackage.Tooltip"));
- add_lcpkg_bt.addMouseListener(new MouseListener()
- {
+
+ Button install_bt = new Button( composite, SWT.PUSH );
+ install_bt.setText(resources.getString("PkgMgr.Button.Install"));
+ install_bt.setToolTipText(resources.getString("PkgMgr.Button.Install.Tooltip"));
+ install_bt.addMouseListener(new MouseListener(){
@Override
public void mouseDoubleClick(MouseEvent e) {
@Override
public void mouseDown(MouseEvent e) {
-
- int oldTableIndex = pkgViewer.getTable().getItemCount();
-
- fd = new FileDialog( shell, SWT.OPEN|SWT.MULTI);
- fd.setText(resources.getString("FileDlg.Title"));
- if (previousFilterPath == null)
- fd.setFilterPath(null);
- else
- fd.setFilterPath(previousFilterPath);
- String[] filterExt = { resources.getString("FileDlg.Filter.Ext") };
- fd.setFilterExtensions(filterExt);
-
- String _arch = "";
- if (PlatformConfigurationManager.isDeviceArch(arch)) {
- _arch = "armv7l";
- } else if (PlatformConfigurationManager.isEmulatorArch(arch)) {
- _arch = "i586";
- } else {
- _arch = arch;
- }
- String defaultPath = rootstrapPath + resources.getString("FileDlg.Default.Path") + _arch;
- fd.setFilterPath(defaultPath);
-
- selectedFileList = fd.open();
-
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
-
+ final CopyOnWriteArrayList<Package> selectedList =
+ PackageProvider.INSTANCE.getSelectedBuildsystemPkgs(false);
+
+ if(selectedList.isEmpty()) {
+ DialogUtil.openErrorDialog( resources.getString("PkgMgr.Error.Noselected.Package"));
+ return;
+ }
+
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
try {
dialog.run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
- monitor.beginTask(resources.getString("PkgMgr.Message.Adding.Package"), -1);
- if( selectedFileList != null )
- {
- String[] files = fd.getFileNames();
- previousFilterPath = fd.getFilterPath();
- for (int i=0, n = files.length; i<n; i++) {
- monitor.subTask(String.format("Adding %s", files[i]));
- StringBuffer buf = new StringBuffer();
- buf.append(fd.getFilterPath());
- if (buf.charAt(buf.length() -1) != File.separatorChar) {
- buf.append(File.separatorChar);
- }
- buf.append(files[i]);
- addLocalPackage( buf.toString());
- }
- }
+
+ monitor.beginTask(resources.getString("PkgMgr.Message.Installing.Package"), -1);
+ RPMPackageCommander.installRemotePkgForRootstrap(selectedList, rootstrapPath);
+ monitor.done();
}
});
- } catch (Exception e1) {
- e1.printStackTrace();
}
-
- pkgViewer.refresh();
-
- int recentTableIndex = pkgViewer.getTable().getItemCount();
-
- for (int i = oldTableIndex; i < recentTableIndex; i++) {
- TableItem item = pkgViewer.getTable().getItem(i);
- Package pkg = (Package)item.getData();
- item.setChecked(pkg.getCheckColumn());
+ catch (Exception e1) {
+ DialogUtil.openErrorDialog(
+ resources.getString("PkgMgr.Msg.Error.InstallFailed")+
+ "("+e1.toString()+")");
}
+
+ // update package list
+ updatePackageInfo(null);
+ pkgViewer.refresh();
}
@Override
}
});
-
- Button remove_bt = new Button( parent, SWT.PUSH );
- remove_bt.setText(resources.getString("PkgMgr.Button.RemoveList"));
- remove_bt.setToolTipText(resources.getString("PkgMgr.Button.RemoveList.Tooltip"));
- remove_bt.addMouseListener(new MouseListener() {
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- CopyOnWriteArrayList<Package> pkgList = PackageProvider.INSTANCE.getBuildsystemPkgs();
- for( Package pkg: pkgList)
- {
- boolean selected = false;
- selected = pkg.getCheckColumn();
- if (selected) {
- pkgList.remove(pkg);
- }
- }
- pkgViewer.refresh();
-
- int recentTableIndex = pkgViewer.getTable().getItemCount();
- for (int i = 0; i < recentTableIndex; i++) {
- TableItem item = null;
- item = pkgViewer.getTable().getItem(i);
- Package pkg = (Package)item.getData();
- item.setChecked(pkg.getCheckColumn());
- }
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- }
- });
-
- Label space = new Label(parent, SWT.NONE);
-
- Button install_bt = new Button( parent, SWT.PUSH );
- install_bt.setText(resources.getString("PkgMgr.Button.Install"));
- install_bt.setToolTipText(resources.getString("PkgMgr.Button.Install.Tooltip"));
- install_bt.addMouseListener(new MouseListener(){
+
+ Button installLocal_bt = new Button( composite, SWT.PUSH );
+ installLocal_bt.setText(resources.getString("PkgMgr.Button.InstallLocal"));
+ installLocal_bt.setToolTipText(resources.getString("PkgMgr.Button.InstallLocal.Tooltip"));
+ installLocal_bt.addMouseListener(new MouseListener() {
@Override
public void mouseDoubleClick(MouseEvent e) {
@Override
public void mouseDown(MouseEvent e) {
-
- pkgs = getSelectedPkg(PackageProvider.INSTANCE.getBuildsystemPkgs());
-
- if(pkgs.isEmpty()) {
- MessageDialog.openError(shell, "Error", resources.getString("PkgMgr.Error.Noselected.Package"));
- return;
- }
-
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
-
+ FileDialog fd = new FileDialog( shell, SWT.OPEN|SWT.MULTI);
+ fd.setText(resources.getString("FileDlg.Title"));
+ String[] filterExt = { resources.getString("FileDlg.Filter.Ext") };
+ fd.setFilterExtensions(filterExt);
+ String firstFilePath = fd.open();
+ if ( firstFilePath == null ) { return; }
+
+ String[] fileNames = fd.getFileNames();
+ final ArrayList<String> selectedFiles = new ArrayList<String>();
+ for( String fileName : fileNames ) {
+ selectedFiles.add(new File(firstFilePath).getParent()+"/"+fileName);
+ }
+
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
try {
- dialog.run(true, true, new IRunnableWithProgress() {
+ dialog.run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
- monitor.beginTask(resources.getString("PkgMgr.Message.Installing.Package"), -1);
- //PlatformCheckCancelJob cancelJob = new PlatformCheckCancelJob(monitor, project, sbi);
-
- try {
- String rpmPathList = "";
- String localPkgList = "";
- String remotePkgList = "";
-
- for (Package pkg : pkgs) {
- if (pkg instanceof LocalPackage) {
- LocalPackage p = (LocalPackage)pkg;
- String filePath = p.getPath();
- String filename = new File(filePath).getName();
- String pathOnRootstrap = "/tmp/" + filename;
- String copyToPath = rootstrapPath + pathOnRootstrap;
- FileUtil.copyTo(filePath, copyToPath);
- rpmPathList = rpmPathList.concat(pathOnRootstrap + " ");
- localPkgList = localPkgList.concat(pkg.getName() + " ");
- } else if (pkg instanceof RemotePackage) {
- remotePkgList = remotePkgList.concat(pkg.getName() + " ");
- }
- }
-
- //Thread checkCancelThread = new Thread(cancelJob);
- //checkCancelThread.start();
-
- if(!"".equals(remotePkgList)) {
- monitor.subTask(String.format("%s %s", resources.getString("PkgMgr.Message.Installing.Package"), remotePkgList));
- RPMPackageCommander.installRemotePkgForRootstrap(remotePkgList, rootstrapPath);
- }
-
- if(!"".equals(localPkgList)) {
- monitor.subTask(String.format("%s %s", resources.getString("PkgMgr.Message.Installing.Package"), localPkgList));
- RPMPackageCommander.InstallPkgToRootstrap(rpmPathList, rootstrapPath);
- for (String p : rpmPathList.split(" ")) {
- File f = new File(rootstrapPath + p);
- if (f.exists()) {
- f.delete();
- }
- }
- }
-
- for (Package pkg : pkgs) {
- String installedVer = RPMPackageCommander.getPkgInstalledVerForRootstrap(pkg.getName(), rootstrapPath);
- pkg.setInstalledVersion(installedVer);
- if ("".equals(installedVer)) {
- pkg.setInstallInfo(Package.INSTALLINFO.NOT_INSTALLED);
- } else if (installedVer.equals(pkg.getNewVersion())) {
- if (RPMPackageCommander.pkgInstalledSuccessfullyForRootstrap(pkg.getName(), rootstrapPath)) {
- pkg.setInstallInfo(Package.INSTALLINFO.INSTALLED);
- } else {
- pkg.setInstallInfo(Package.INSTALLINFO.NOT_INSTALLED);
- }
- } else {
- pkg.setInstallInfo(Package.INSTALLINFO.DIFFERENT_VERSION);
- }
- }
-
- } catch (IOException e) {
- //cancelJob.setFinishFlag(true);
- e.printStackTrace();
- }
-
- //cancelJob.setFinishFlag(true);
+ monitor.beginTask(resources.getString("PkgMgr.Message.Installing.LocalPackage"), -1);
+ RPMPackageCommander.InstallLocalPkgToRootstrap(selectedFiles, rootstrapPath);
monitor.done();
}
});
} catch (Exception e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
+ DialogUtil.openErrorDialog(
+ resources.getString("PkgMgr.Msg.Error.InstallFailed")+
+ "("+e1.toString()+")");
}
+ // update package list
+ updatePackageInfo(selectedFiles);
pkgViewer.refresh();
}
@Override
public void mouseUp(MouseEvent e) {
}
-
- });
+ });
- Button remove_ipkg_bt = new Button( parent, SWT.PUSH );
- remove_ipkg_bt.setText(resources.getString("PkgMgr.Button.Uninstall"));
- remove_ipkg_bt.setToolTipText(resources.getString("PkgMgr.Button.Uninstall.Tooltip"));
- remove_ipkg_bt.addMouseListener(new MouseListener(){
+ Button removeBt = new Button( composite, SWT.PUSH );
+ removeBt.setText(resources.getString("PkgMgr.Button.Uninstall"));
+ removeBt.setToolTipText(resources.getString("PkgMgr.Button.Uninstall.Tooltip"));
+ removeBt.addMouseListener(new MouseListener(){
@Override
public void mouseDoubleClick(MouseEvent e) {
@Override
public void mouseDown(MouseEvent e) {
-
- InstalledPkgProvider.INSTANCE.getPkgs().clear();
- InstalledPkgProvider.INSTANCE.getSelectedPkgs().clear();
+ final CopyOnWriteArrayList<Package> selectedList =
+ PackageProvider.INSTANCE.getSelectedBuildsystemPkgs(true);
+ if(selectedList.isEmpty()) {
+ DialogUtil.openErrorDialog( resources.getString("PkgMgr.Error.Noselected.Package"));
+ return;
+ }
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
-
try {
- dialog.run(true, true, new IRunnableWithProgress() {
+ dialog.run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
- monitor.beginTask(resources.getString("PkgMgr.Message.Getting.InstalledPackage"), -1);
- genInstalledPkgList();
+
+ monitor.beginTask(resources.getString("PkgMgr.Message.Uninstalling.Package"), -1);
+ RPMPackageCommander.uninstallPkgFromRootstrap(selectedList, rootstrapPath);
+ monitor.done();
}
});
} catch (Exception e1) {
- e1.printStackTrace();
+ DialogUtil.openErrorDialog(
+ resources.getString("PkgMgr.Msg.Error.UninstallFailed")+
+ "("+e1.toString()+")");
}
- RemoveInstalledPackageDialog dlg = new RemoveInstalledPackageDialog(shell, rootstrapPath);
- dlg.open();
+ // update package list
+ updatePackageInfo(null);
+ pkgViewer.refresh();
}
@Override
public void mouseUp(MouseEvent e) {
}
-
});
+ }
+
+
+ private void updatePackageInfo(ArrayList<String> localPackageFileList ) {
+ ArrayList<Package> fullList = RPMPackageCommander.getPackageListForRootstrap(rootstrapPath);
+ for( Package pkg: PackageProvider.INSTANCE.getBuildsystemPkgs()) {
+ for( Package currPkg: fullList ) {
+ if ( currPkg.getName().equals(pkg.getName())) {
+ // check newly install
+ if( !pkg.getInstalledVersion().equals(currPkg.getInstalledVersion())) {
+ pkg.setNewlyChanged(true);
+ }
+
+ pkg.setInstalledVersion(currPkg.getInstalledVersion());
+ break;
+ }
+ }
+ pkg.setChecked(false);
+ }
- Button upgrade_bt = new Button( parent, SWT.PUSH );
- upgrade_bt.setText(resources.getString("PkgMgr.Button.Upgrade"));
- upgrade_bt.setToolTipText(resources.getString("PkgMgr.Button.Upgrade.Tooltip"));
- upgrade_bt.addMouseListener(new MouseListener(){
+ // add if there is new package
+ for( Package currPkg: fullList ) {
+ boolean found = false;
+ for( Package pkg: PackageProvider.INSTANCE.getBuildsystemPkgs()) {
+ if ( currPkg.getName().equals(pkg.getName())) {
+ found = true;
+ break;
+ }
+ }
+
+ if ( !found ) {
+ PackageProvider.INSTANCE.getBuildsystemPkgs().add(currPkg);
+ currPkg.setNewlyChanged(true);
+ }
+ }
+
+ // check local package update
+ if ( localPackageFileList != null ) {
+ ArrayList<String> localPackageNameList = new ArrayList<String>();
+ for( String filePath: localPackageFileList) {
+ localPackageNameList.add(RPMPackageCommander.getPkgNameForFile(filePath));
+ }
+ for( Package pkg: PackageProvider.INSTANCE.getBuildsystemPkgs()) {
+ if( localPackageNameList.contains( pkg.getName() ) ) {
+ pkg.setNewlyChanged(true);
+ }
+ }
+ }
+ }
+
+
+ private void createPackageFilter( Composite parent ) {
+ Composite composite = new Composite( parent, SWT.NONE );
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL|GridData.GRAB_HORIZONTAL));
+ composite.setLayout(new GridLayout(3,false));
+
+ Label filterTextLabel = new Label(composite, SWT.NONE);
+ filterTextLabel.setText(resources.getString("PkgMgr.Label.Filter"));
+
+ categoryCombo = new Combo(composite, SWT.READ_ONLY);
+ String[] items = {"All","Installed","Upgradable"};
+ categoryCombo.setItems(items);
+ categoryCombo.addSelectionListener( new SelectionListener() {
@Override
- public void mouseDoubleClick(MouseEvent e) {
+ public void widgetSelected(SelectionEvent e) {
+ pkgViewer.refresh();
}
@Override
- public void mouseDown(MouseEvent e) {
-
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
-
- try {
- dialog.run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
-
- monitor.beginTask(resources.getString("PkgMgr.Message.Dist.Upgrade"), -1);
-
- //PlatformCheckCancelJob cancelJob = new PlatformCheckCancelJob(monitor, project, sbi);
- //Thread checkCancelThread = new Thread(cancelJob);
- //checkCancelThread.start();
-
- RPMPackageCommander.DistUpgradeRootstrap(rootstrapPath);
-
- //cancelJob.setFinishFlag(true);
- monitor.done();
- }
- });
- } catch (Exception e1) {
- e1.printStackTrace();
- }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
}
+ });
+ categoryCombo.select(0);
+
+
+ filterText = new Text( composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+ filterText.setLayoutData(gridData);
+ filterText.addModifyListener(new ModifyListener() {
@Override
- public void mouseUp(MouseEvent e) {
+ public void modifyText(ModifyEvent e) {
+ pkgViewer.refresh();
}
-
});
}
+
+
- private void createColumnsForRepoTable( Composite parent )
+ private void createPackageTable( Composite parent )
{
- String[] titles = {resources.getString("PkgMgr.Repo.Table.Column.1"),
- resources.getString("PkgMgr.Repo.Table.Column.2")};
- int[] bounds = { 200, 600 };
+ Composite composite = new Composite( parent, SWT.NONE );
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ composite.setLayout(new FillLayout());
- TableViewerColumn colName = createTableViewerColumn( repoViewer, titles[0], bounds[0], SWT.NONE);
- TableColumn column = colName.getColumn();
- column.addSelectionListener(new RepoTableSelectionAdapter(repoViewer));
+ pkgViewer = CheckboxTableViewer.newCheckList( composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK );
+ createColumns( composite );
+ Table packageTable = pkgViewer.getTable();
+ packageTable.addListener( SWT.Selection, new Listener(){
- colName.setLabelProvider(new ColumnLabelProvider() {
@Override
- public String getText(Object element) {
- Repository repo = (Repository)element;
- return repo.getName();
+ public void handleEvent(Event event) {
+ if( event.detail == SWT.CHECK )
+ {
+ Package pkg = (Package)event.item.getData();
+ pkg.setCheckColumn( !pkg.getCheckColumn() );
+ }
}
});
- TableViewerColumn colUrl = createTableViewerColumn( repoViewer, titles[1], bounds[1], SWT.NONE);
- column = colUrl.getColumn();
- column.addSelectionListener(new RepoTableSelectionAdapter(repoViewer));
+ packageTable.setHeaderVisible(true);
+ packageTable.setLinesVisible(true);
+
+ pkgViewer.setContentProvider(new ArrayContentProvider());
+ pkgViewer.setCheckStateProvider(new ICheckStateProvider() {
- colUrl.setLabelProvider(new ColumnLabelProvider() {
@Override
- public String getText(Object element) {
- Repository repo = (Repository)element;
- return repo.getUri();
+ public boolean isChecked(Object element) {
+ Package pkg = (Package) element;
+ return pkg.isChecked();
}
- });
+
+ @Override
+ public boolean isGrayed(Object element) {
+ return false;
+ }
+ });
+ pkgViewer.addFilter( new ViewerFilter() {
+
+ @Override
+ public boolean select(Viewer viewer, Object parentElement,
+ Object element) {
+ Package pkg = (Package) element;
+ if ( categoryCombo != null ) {
+ if ( categoryCombo.getText().equals("Installed") &&
+ pkg.getInstalledVersion().isEmpty() ) {
+ return false;
+ }
+ if ( categoryCombo.getText().equals("Upgradable") &&
+ ( pkg.getInstalledVersion().isEmpty() ||
+ pkg.getNewVersion().isEmpty() ||
+ RPMPackageCommander.compareVersion(pkg.getInstalledVersion(),pkg.getNewVersion()) >= 0 )) {
+ return false;
+ }
+ }
+ if ( filterText != null && !pkg.getName().contains(filterText.getText()) ) {
+ return false;
+ }
+ return true;
+ }
+
+ });
+ pkgViewer.addCheckStateListener( new ICheckStateListener() {
+
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ Package pkg = (Package)event.getElement();
+ pkg.setChecked(true);
+ }
+ });
+ pkgViewer.setInput(PackageProvider.INSTANCE.getBuildsystemPkgs());
}
+
+
private TableViewerColumn createTableViewerColumn(TableViewer viewer, String title, int bound, int Style) {
final TableViewerColumn viewerColumn = new TableViewerColumn( viewer, Style);
private void createColumns( Composite parent )
{
- String[] titles = {"Install Type", "Package Name", "Arch", "New Version", "Installed Version", "Status"};
- int[] bounds = { 120, 250, 60, 150, 150, 150};
+ String[] titles = {"S", "Package Name", "Installed Version", "New Version", "Arch", "Description"};
+ int[] bounds = { 24, 200, 150, 150, 60, 150};
- TableViewerColumn colInstallType = createTableViewerColumn( pkgViewer, titles[0], bounds[0], SWT.NONE);
-
- colInstallType.setLabelProvider(new ColumnLabelProvider() {
+ TableViewerColumn colSelection = createTableViewerColumn( pkgViewer, titles[0], bounds[0], SWT.NONE);
+ colSelection.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
- Package pkg = (Package)element;
- return pkg.getPkgType().toString();
+ return "";
}
});
-
+
TableViewerColumn colPackage = createTableViewerColumn( pkgViewer, titles[1], bounds[1], SWT.NONE);
-
colPackage.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
Package pkg = (Package)element;
- return pkg.getName();
+ if ( pkg.isNewlyChanged() ) {
+ return "*"+pkg.getName();
+ }
+ else {
+ return pkg.getName();
+ }
}
});
- TableViewerColumn colArch = createTableViewerColumn( pkgViewer, titles[2], bounds[2], SWT.NONE);
-
- colArch.setLabelProvider(new ColumnLabelProvider() {
+ TableViewerColumn colInsVer = createTableViewerColumn( pkgViewer, titles[2], bounds[2], SWT.NONE);
+ colInsVer.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
Package pkg = (Package)element;
- String arch = pkg.getArch();
- return arch;
+ String installedVer = pkg.getInstalledVersion();
+ return installedVer;
}
});
+
TableViewerColumn colNewVer = createTableViewerColumn( pkgViewer, titles[3], bounds[3], SWT.NONE);
colNewVer.setLabelProvider(new ColumnLabelProvider() {
}
});
- TableViewerColumn colInsVer = createTableViewerColumn( pkgViewer, titles[4], bounds[4], SWT.NONE);
- colInsVer.setLabelProvider(new ColumnLabelProvider() {
+ TableViewerColumn colArch = createTableViewerColumn( pkgViewer, titles[4], bounds[4], SWT.NONE);
+
+ colArch.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
Package pkg = (Package)element;
- String installedVer = pkg.getInstalledVersion();
- return installedVer;
+ String arch = pkg.getArch();
+ return arch;
}
});
- TableViewerColumn colStatus = createTableViewerColumn( pkgViewer, titles[5], bounds[5], SWT.NONE);
-
- colStatus.setLabelProvider(new ColumnLabelProvider() {
+ TableViewerColumn colDescription = createTableViewerColumn( pkgViewer, titles[5], bounds[5], SWT.NONE);
+ colDescription.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
- Package pkg = (Package)element;
- String status = pkg.getInstallInfo().toString();
- return status;
+ return "";
}
});
}
-
-
- private void genInstalledPkgList() {
- String list = RPMPackageCommander.getInstalledPackageListForRootstrap(rootstrapPath);
- String[] splitStr = list.split("\n");
-
- // Package list starts at 1 line
- for (int i = 1 ; i < splitStr.length ; i++) {
- String s = splitStr[i];
- s = s.replaceAll(" ", "").trim();
- InstalledPackage pkg = new InstalledPackage();
- pkg.setName(s);
- pkg.setCheckColumn(false);
-
- InstalledPkgProvider.INSTANCE.getPkgs().add(pkg);
- }
- }
-
-
- private void genRemotePkgList() {
-
- String list = RPMPackageCommander.getRemotePackageListForRootstrap(rootstrapPath);
- String[] splitStr = list.split("\n");
-
- // Package list starts at 5 line
- for (int i = 5 ; i < splitStr.length ; i++) {
- String s = splitStr[i];
- s = s.replaceAll(" ", "");
- String[] part = s.split("\\|");
- String status = part[0];
- String repo = part[1];
- String name = part[2];
- String version = part[3];
- String arch = part[4];
-
- RemotePackage pkg = new RemotePackage();
- pkg.setName(name);
- pkg.setArch(arch);
- pkg.setNewVersion(version);
- pkg.setRepo(repo);
- pkg.setCheckColumn(false);
- if ("i".equals(status)) {
- pkg.setInstallInfo(Package.INSTALLINFO.INSTALLED);
- } else if ("v".equals(status)) {
- pkg.setInstallInfo(Package.INSTALLINFO.DIFFERENT_VERSION);
- }
-
- RemotePkgProvider.INSTANCE.getPkgs().add(pkg);
- }
- }
-
- private void addRemotePackage( RemotePackage p ) {
- CopyOnWriteArrayList<Package> pkgs = PackageProvider.INSTANCE.getBuildsystemPkgs();
- Iterator<Package> debIter = pkgs.iterator();
-
- while( debIter.hasNext() ) {
- Package pkg = debIter.next();
- if( pkg.getName().equals(p.getName()) &&
- pkg.getNewVersion().equals(p.getNewVersion()) ) {
- return;
- }
- }
-
- String installedVer = RPMPackageCommander.getPkgInstalledVerForRootstrap(p.getName(), rootstrapPath);
- p.setInstalledVersion(installedVer);
- p.setCheckColumn(true);
- p.setPkgType(Package.PKGTYPE.REMOTE);
- PackageProvider.INSTANCE.getBuildsystemPkgs().add(p);
- }
-
- private void addLocalPackage( String rpmPath )
- {
- CopyOnWriteArrayList<Package> pkgs = PackageProvider.INSTANCE.getBuildsystemPkgs();
- Iterator<Package> debIter = pkgs.iterator();
-
- String pkgName = RPMPackageCommander.getPkgNameForFile(rpmPath);
- String newVer = RPMPackageCommander.getPkgVerForFile(rpmPath);
-
- while( debIter.hasNext() ) {
- Package pkg = debIter.next();
- if( pkg.getName().equals(pkgName) && pkg.getNewVersion().equals(newVer)) {
- return;
- }
- }
-
- LocalPackage pkg = new LocalPackage();
- pkg.setName(pkgName);
- pkg.setPath(rpmPath);
- pkg.setPkgType(Package.PKGTYPE.LOCAL);
- pkg.setArch(RPMPackageCommander.getArchForFile(rpmPath));
- pkg.setNewVersion(newVer);
-
- String installedVerForRootstrap = RPMPackageCommander.getPkgInstalledVerForRootstrap(pkg.getName(), rootstrapPath);
- pkg.setInstalledVersion(installedVerForRootstrap);
-
- if ("".equals(newVer)) {
- pkg.setCheckColumn(false);
- } else if (!"".equals(installedVerForRootstrap)) {
- if (!installedVerForRootstrap.equals(newVer)) {
- pkg.setInstallInfo(Package.INSTALLINFO.DIFFERENT_VERSION);
- } else {
- if (RPMPackageCommander.pkgInstalledSuccessfullyForRootstrap(pkgName, rootstrapPath)) {
- pkg.setInstallInfo(Package.INSTALLINFO.INSTALLED);
- }
- }
- }
-
- PackageProvider.INSTANCE.getBuildsystemPkgs().add(pkg);
- }
-
- private CopyOnWriteArrayList<Package> getSelectedPkg(CopyOnWriteArrayList<Package> pkgs) {
- CopyOnWriteArrayList<Package> _pkgs = new CopyOnWriteArrayList<Package>();
- for (Package pkg : pkgs) {
- if(pkg.getCheckColumn()) {
- _pkgs.add(pkg);
- }
- }
-
- return _pkgs;
- }
}