From 554200fd357a88e13a55cfa91f515b21b47d4819 Mon Sep 17 00:00:00 2001 From: "donghyuk.yang" Date: Wed, 4 Apr 2012 11:31:37 +0900 Subject: [PATCH] [Title] Prohibit from launching package manager on app project and show warning if http proxy is not set [Type] Enhancement Change-Id: I71cead143d6d21b86c6de9d937bc1cd3e05493f5 --- .../pkgmgr/PackageManagerRootstrapHandler.java | 47 +++++++++++++--------- .../nativeplatform/pkgmgr/RPMPackageCommander.java | 2 +- .../pkgmgr/RPMPackageCommands.properties | 3 ++ .../pkgmgr/ui/AddRemotePackageDialog.java | 4 +- .../nativeplatform/pkgmgr/ui/BuildSystemTab.java | 33 +++++++++------ .../tizen/nativeplatform/pkgmgr/ui/DeviceTab.java | 17 +++++--- .../pkgmgr/ui/PkgMgrUIMessages.properties | 8 ++++ .../nativeplatform/pkgmgr/ui/RPMPackageDialog.java | 14 ++++++- 8 files changed, 87 insertions(+), 41 deletions(-) diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/PackageManagerRootstrapHandler.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/PackageManagerRootstrapHandler.java index 53131c3..5b39c43 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/PackageManagerRootstrapHandler.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/PackageManagerRootstrapHandler.java @@ -28,6 +28,8 @@ */ package org.tizen.nativeplatform.pkgmgr; +import java.util.ResourceBundle; + import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IManagedProject; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; @@ -35,6 +37,8 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IProject; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.handlers.HandlerUtil; @@ -52,6 +56,10 @@ import org.tizen.sdblib.IDevice; * @see org.eclipse.core.commands.AbstractHandler */ public class PackageManagerRootstrapHandler extends AbstractHandler { + + private final String BUNDLE_NAME = PackageManagerRootstrapHandler.class.getPackage().getName() + ".RPMPackageCommands"; + private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + /** * The constructor. */ @@ -70,6 +78,26 @@ public class PackageManagerRootstrapHandler extends AbstractHandler { boolean enableRootstrap = true; boolean enableTarget = true; boolean enableRpmMgr = false; + + IProject project = CurrentEnabledProject.getCurrentProject(); + Shell shell = window.getShell(); + if (project == null) { + MessageDialog.openError(shell, "Error", resources.getString("PkgMgr.Error.Noselected.Project")); + return null; + } + + IConfiguration cfg =ManagedBuildManager.getBuildInfo( project ).getDefaultConfiguration(); + String targetName = PlatformConfigurationManager.getBuildTargetName(cfg); + if (targetName.contains("obs")) { + enableRpmMgr = true; + } + + IManagedProject managedProject = cfg.getManagedProject(); + String projectArtifactType = managedProject.getProjectType().getBuildArtefactType().getId(); + if (!projectArtifactType.equals(PlatformConfigurationManager.TIZEN_CUSTOM_DEBIAN_ARTIFACT_TYPE)) { + MessageDialog.openError(shell, "Error", resources.getString("PkgMgr.Error.Not.Platformproject")); + return null; + } if (device == null) { enableTarget = false; @@ -80,26 +108,9 @@ public class PackageManagerRootstrapHandler extends AbstractHandler { } } - IProject project = CurrentEnabledProject.getCurrentProject(); - if (project == null) { - enableRootstrap = false; - } else { - IConfiguration cfg =ManagedBuildManager.getBuildInfo( project ).getDefaultConfiguration(); - String targetName = PlatformConfigurationManager.getBuildTargetName(cfg); - if (targetName.contains("obs")) { - enableRpmMgr = true; - } - IManagedProject managedProject = cfg.getManagedProject(); - String projectArtifactType = managedProject.getProjectType().getBuildArtefactType().getId(); - if (!projectArtifactType.equals(PlatformConfigurationManager.TIZEN_CUSTOM_DEBIAN_ARTIFACT_TYPE) && - !projectArtifactType.equals(PlatformConfigurationManager.OLD_SLP_CUSTOM_DEBIAN_ARTIFACT_TYPE)) { - enableRootstrap = false; - } - } - if (enableRpmMgr) { RPMPackageDialog pkgdlg = new RPMPackageDialog(window.getShell(), target, enableRootstrap, enableTarget); - pkgdlg.open(); + pkgdlg.open(); } else { DEBPackageManager pkgdlg = new DEBPackageManager(window.getShell(), target, enableRootstrap, enableTarget); pkgdlg.open(); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommander.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommander.java index 6b12cc1..5c4d6e6 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommander.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommander.java @@ -58,7 +58,7 @@ public class RPMPackageCommander { String options = String.format("-path=. -cmd=\"%s;%s\"", getResetDbCmd(), getInstallLocalPkgCmd(fileList)); - try { + try { sbi.actionStream("command", options, targetID, null, stdoutStream, stderrStream); } catch (SBIException e) { e.printStackTrace(); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommands.properties b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommands.properties index edd0597..22b0319 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommands.properties +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommands.properties @@ -12,3 +12,6 @@ Command.Show.Info.Pkg = rpm -qi %s Command.Info.Pkg.File = rpm -qip %s Command.Change.Updatemode = /bin/change-booting-mode.sh --update +PkgMgr.Error.Noselected.Project = Any project is not selected.\n Please select "TIZEN Platform" project to use package manager. +PkgMgr.Error.Not.Platformproject = The project is not "TIZEN Platform" project.\n Please select "TIZEN Platform" project to use package manager. + diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/AddRemotePackageDialog.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/AddRemotePackageDialog.java index e019b7f..8ef4dc5 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/AddRemotePackageDialog.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/AddRemotePackageDialog.java @@ -260,14 +260,14 @@ public class AddRemotePackageDialog extends Dialog { private void updateCheck() { int recentTableIndex = packageViewer.getTable().getItemCount(); - Color gray = disp.getSystemColor(SWT.COLOR_LIST_SELECTION); + Color installedColor = disp.getSystemColor(SWT.COLOR_LIST_SELECTION); for (int i = 0; i < recentTableIndex; i++) { TableItem item = packageViewer.getTable().getItem(i); RemotePackage pkg = (RemotePackage)item.getData(); item.setChecked(pkg.getCheckColumn()); if (Package.INSTALLINFO.INSTALLED.equals(pkg.getInstallInfo())) { - item.setBackground(gray); + item.setBackground(installedColor); } } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/BuildSystemTab.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/BuildSystemTab.java index a65127b..a3fc4bd 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/BuildSystemTab.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/BuildSystemTab.java @@ -199,6 +199,7 @@ public class BuildSystemTab { { Button add_bt = new Button( parent, SWT.PUSH ); add_bt.setText(resources.getString("PkgMgr.Button.AddRepo")); + add_bt.setToolTipText(resources.getString("PkgMgr.Button.AddRepo.Tooltip")); add_bt.addMouseListener(new MouseListener(){ @Override @@ -224,8 +225,8 @@ public class BuildSystemTab { if (repo.getCheckDirty()) { ConsoleManager cm = new ConsoleManager(resources.getString("PkgMgr.Console.Name"), true); cm.clear(); - MessageConsoleStream mcsError = cm.getMessageConsoleStream(true); - MessageConsoleStream mcs = cm.getMessageConsoleStream(false); + MessageConsoleStream mcsError = cm.getMessageConsoleStream(); + MessageConsoleStream mcs = cm.getMessageConsoleStream(); RPMPackageCommander.addRepositoryForRootstrap(repo.getName(), repo.getUri(), target, mcs, mcsError); repo.setCheckDirty(false); } @@ -239,7 +240,8 @@ public class BuildSystemTab { }); Button remove_bt = new Button( parent, SWT.PUSH ); - remove_bt.setText(resources.getString("PkgMgr.Button.RemoveRepo")); + remove_bt.setText(resources.getString("PkgMgr.Button.RemoveRepo")); + remove_bt.setToolTipText(resources.getString("PkgMgr.Button.RemoveRepo.Tooltip")); remove_bt.addMouseListener(new MouseListener() { @Override @@ -259,8 +261,8 @@ public class BuildSystemTab { list.remove(repo); ConsoleManager cm = new ConsoleManager(resources.getString("PkgMgr.Console.Name"), true); cm.clear(); - MessageConsoleStream mcsError = cm.getMessageConsoleStream(true); - MessageConsoleStream mcs = cm.getMessageConsoleStream(false); + MessageConsoleStream mcsError = cm.getMessageConsoleStream(); + MessageConsoleStream mcs = cm.getMessageConsoleStream(); RPMPackageCommander.removeRepositoryForRootstrap(repo.getName(), target, mcs, mcsError); } } @@ -283,6 +285,7 @@ public class BuildSystemTab { Button refresh_bt = new Button( parent, SWT.PUSH ); refresh_bt.setText(resources.getString("PkgMgr.Button.RefreshRepo")); + refresh_bt.setToolTipText(resources.getString("PkgMgr.Button.RefreshRepo.Tooltip")); refresh_bt.addMouseListener(new MouseListener(){ @Override @@ -302,8 +305,8 @@ public class BuildSystemTab { monitor.beginTask(resources.getString("PkgMgr.Message.Refreshing"), -1); ConsoleManager cm = new ConsoleManager(resources.getString("PkgMgr.Console.Name"), true); cm.clear(); - MessageConsoleStream mcsError = cm.getMessageConsoleStream(true); - MessageConsoleStream mcs = cm.getMessageConsoleStream(false); + MessageConsoleStream mcsError = cm.getMessageConsoleStream(); + MessageConsoleStream mcs = cm.getMessageConsoleStream(); RPMPackageCommander.refreshRepositoryForRootstrap(target, mcs, mcsError); } }); @@ -348,6 +351,7 @@ public class BuildSystemTab { { 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(){ @Override @@ -400,6 +404,7 @@ public class BuildSystemTab { 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() { @@ -478,6 +483,7 @@ public class BuildSystemTab { 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 @@ -514,6 +520,7 @@ public class BuildSystemTab { 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(){ @Override @@ -552,12 +559,12 @@ public class BuildSystemTab { ConsoleManager cm = new ConsoleManager(resources.getString("PkgMgr.Console.Name"), true); cm.clear(); - MessageConsoleStream mcsError = cm.getMessageConsoleStream(true); - MessageConsoleStream mcs = cm.getMessageConsoleStream(false); - MessageConsoleStream mcsError1 = cm.getMessageConsoleStream(true); - MessageConsoleStream mcs1 = cm.getMessageConsoleStream(false); - MessageConsoleStream mcsError2 = cm.getMessageConsoleStream(true); - MessageConsoleStream mcs2 = cm.getMessageConsoleStream(false); + MessageConsoleStream mcsError = cm.getMessageConsoleStream(); + MessageConsoleStream mcs = cm.getMessageConsoleStream(); + MessageConsoleStream mcsError1 = cm.getMessageConsoleStream(); + MessageConsoleStream mcs1 = cm.getMessageConsoleStream(); + MessageConsoleStream mcsError2 = cm.getMessageConsoleStream(); + MessageConsoleStream mcs2 = cm.getMessageConsoleStream(); for (Package pkg : pkgs) { if (pkg instanceof LocalPackage) { diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/DeviceTab.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/DeviceTab.java index 2b79d59..029ecad 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/DeviceTab.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/DeviceTab.java @@ -207,6 +207,7 @@ public class DeviceTab { { Button add_bt = new Button( parent, SWT.PUSH ); add_bt.setText(resources.getString("PkgMgr.Button.AddRepo")); + add_bt.setToolTipText(resources.getString("PkgMgr.Button.AddRepo.Tooltip")); add_bt.addMouseListener(new MouseListener(){ @Override @@ -244,7 +245,8 @@ public class DeviceTab { }); Button remove_bt = new Button( parent, SWT.PUSH ); - remove_bt.setText(resources.getString("PkgMgr.Button.RemoveRepo")); + remove_bt.setText(resources.getString("PkgMgr.Button.RemoveRepo")); + remove_bt.setToolTipText(resources.getString("PkgMgr.Button.RemoveRepo.Tooltip")); remove_bt.addMouseListener(new MouseListener() { @Override @@ -285,6 +287,7 @@ public class DeviceTab { Button refresh_bt = new Button( parent, SWT.PUSH ); refresh_bt.setText(resources.getString("PkgMgr.Button.RefreshRepo")); + refresh_bt.setToolTipText(resources.getString("PkgMgr.Button.RefreshRepo.Tooltip")); refresh_bt.addMouseListener(new MouseListener(){ @Override @@ -345,6 +348,7 @@ public class DeviceTab { { 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(){ @Override @@ -398,6 +402,7 @@ public class DeviceTab { 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() { @@ -478,6 +483,7 @@ public class DeviceTab { 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 @@ -513,6 +519,7 @@ public class DeviceTab { 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(){ @Override @@ -546,8 +553,8 @@ public class DeviceTab { String newPath = null; ConsoleManager cm = new ConsoleManager(resources.getString("PkgMgr.Console.Name"), true); cm.clear(); - MessageConsoleStream mcsError = cm.getMessageConsoleStream(true); - MessageConsoleStream mcs = cm.getMessageConsoleStream(false); + MessageConsoleStream mcsError = cm.getMessageConsoleStream(); + MessageConsoleStream mcs = cm.getMessageConsoleStream(); PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver(); rec.setMessageConsoleStream(mcs); String localPkgList = ""; @@ -879,8 +886,8 @@ public class DeviceTab { private PackageManagerOuputReceiver getNewOuputReceiver() { ConsoleManager cm = new ConsoleManager(resources.getString("PkgMgr.Console.Name"), true); cm.clear(); - MessageConsoleStream mcsError = cm.getMessageConsoleStream(true); - MessageConsoleStream mcs = cm.getMessageConsoleStream(false); + MessageConsoleStream mcsError = cm.getMessageConsoleStream(); + MessageConsoleStream mcs = cm.getMessageConsoleStream(); PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver(); rec.setMessageConsoleStream(mcs); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/PkgMgrUIMessages.properties b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/PkgMgrUIMessages.properties index 7895406..76e1b31 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/PkgMgrUIMessages.properties +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/PkgMgrUIMessages.properties @@ -8,15 +8,23 @@ PkgMgr.Console.Name = Package Manager PkgMgr.Error.Noselected = - Any project is not selected and any device is not connected,\n- or project is not \"PLATFORM PROJECT\" PkgMgr.Error.Noselected.Package = There is no selected package. PkgMgr.Error.Failtransfer.File = Failed to move file from %s to %s +PkgMgr.Warn.Notset.Proxy = (Warning: HTTP Proxy environment variable(OBS_HTTP_PROXY) is not set) PkgMgr.Label.Configuration = Selected Configuration: PkgMgr.Label.Connection = Selected Connection: PkgMgr.Button.AddRepo = Add +PkgMgr.Button.AddRepo.Tooltip = Add repository PkgMgr.Button.RemoveRepo = Remove +PkgMgr.Button.RemoveRepo.Tooltip = Remove selected repositories PkgMgr.Button.RefreshRepo = Refresh +PkgMgr.Button.RefreshRepo.Tooltip = Refresh all repositories PkgMgr.Button.AddRPackage = Add Remote Package +PkgMgr.Button.AddRPackage.Tooltip = Add remote package(s) from repositories PkgMgr.Button.AddLPackage = Add Local Package +PkgMgr.Button.AddLPackage.Tooltip = Add local package(s) from file system PkgMgr.Button.RemoveList = Remove List +PkgMgr.Button.RemoveList.Tooltip = Remove selected packages from list PkgMgr.Button.Install = Install Package +PkgMgr.Button.Install.Tooltip = Install selected package(s) PkgMgr.Message.Refreshing = Refreshing repository... PkgMgr.Message.Adding.Package = Adding packages to list... PkgMgr.Message.Getting.RemotePackage = Getting remote package list... diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RPMPackageDialog.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RPMPackageDialog.java index e371be3..5538371 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RPMPackageDialog.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RPMPackageDialog.java @@ -80,6 +80,7 @@ public class RPMPackageDialog extends Dialog { private boolean enableRootstrapTab = true; private boolean enableTargetTab = true; private int tabIndex = 0; + private String http_proxy = ""; private int x = 0; private int y = 0; @@ -102,8 +103,9 @@ public class RPMPackageDialog extends Dialog { if (enableRootstrap) { IProject _project = CurrentEnabledProject.getCurrentProject(); IConfiguration config = ManagedBuildManager.getBuildInfo( _project ).getDefaultConfiguration(); - this.configuration = config.getName(); - RPMPackageCommander.setHttpProxy(getHttpProxy(_project)); + this.configuration = config.getName(); + this.http_proxy = getHttpProxy(_project); + RPMPackageCommander.setHttpProxy(this.http_proxy); } if (enableTarget) { this.device = ConnectionPlugin.getDefault().getCurrentDevice(); @@ -199,6 +201,7 @@ public class RPMPackageDialog extends Dialog { { Composite comp_descrip = new Composite(composite, SWT.NONE); Color whiteColor = new Color(composite.getDisplay(), 255, 255, 255); + Color warningColor = composite.getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION); comp_descrip.setLayout(new GridLayout(1, false)); GridData comp_descrip_gd = new GridData(GridData.FILL_HORIZONTAL); @@ -209,6 +212,13 @@ public class RPMPackageDialog extends Dialog { Label label = new Label(comp_descrip, SWT.NONE); label.setText(resources.getString("PkgMgr.Frame.Description")); label.setBackground(whiteColor); + + if ("".equals(http_proxy)) { + Label warning_label = new Label(comp_descrip, SWT.NONE); + warning_label.setText(resources.getString("PkgMgr.Warn.Notset.Proxy")); + warning_label.setBackground(whiteColor); + warning_label.setForeground(warningColor); + } } private void createTabs( Composite parent ) -- 2.7.4