Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan Franklin2010-09-02 21:16:59 +0000
committerSusan Franklin2010-09-02 21:16:59 +0000
commitbc9ccb48d23eb62ed13e7de5f42328fdd68fb9a1 (patch)
treea3fa74d08902e2ef1b40c81ae5c519d3f8d1f216
parent643b5a7d0a1402deebb46c5dc91d054e76261131 (diff)
downloadrt.equinox.p2-bc9ccb48d23eb62ed13e7de5f42328fdd68fb9a1.tar.gz
rt.equinox.p2-bc9ccb48d23eb62ed13e7de5f42328fdd68fb9a1.tar.xz
rt.equinox.p2-bc9ccb48d23eb62ed13e7de5f42328fdd68fb9a1.zip
Bug 320613 - [ui] [admin] - problem installing with vague error message
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/AllTests.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/InstallActionTest.java83
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/InstallAction.java (renamed from bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/InstallAction.java)62
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/InstallIUDropAdapter.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ProfileModificationAction.java11
6 files changed, 64 insertions, 99 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/AllTests.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/AllTests.java
index f96bc729c..ecb8f5727 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/AllTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/AllTests.java
@@ -20,7 +20,6 @@ public class AllTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite(AllTests.class.getName());
suite.addTestSuite(UninstallActionTest.class);
- suite.addTestSuite(InstallActionTest.class);
suite.addTestSuite(UpdateActionTest.class);
suite.addTestSuite(RemoveColocatedRepositoryActionTest.class);
suite.addTestSuite(ElementUtilsTest.class);
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/InstallActionTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/InstallActionTest.java
deleted file mode 100644
index 0091e6ae4..000000000
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/InstallActionTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.p2.tests.ui.actions;
-
-import java.util.List;
-import org.eclipse.equinox.internal.p2.ui.actions.InstallAction;
-import org.eclipse.equinox.internal.p2.ui.model.AvailableIUElement;
-import org.eclipse.equinox.internal.p2.ui.model.IIUElement;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-
-/**
- * @since 3.5
- *
- */
-public class InstallActionTest extends ProfileModificationActionTest {
-
- class TestInstallAction extends InstallAction {
- TestInstallAction(Object[] sel) {
- super(InstallActionTest.this.getProvisioningUI(), InstallActionTest.this.getSelectionProvider(sel), profile.getProfileId());
- }
-
- public List<IInstallableUnit> getSelectedIUs() {
- return super.getSelectedIUs();
- }
- }
-
- public void testEmptySelection() {
- TestInstallAction action = new TestInstallAction(getEmptySelection());
- assertFalse("Should not be enabled with empty selection", action.isEnabled());
- assertEquals(0, action.getSelectedIUs().size());
- }
-
- public void testIUs() {
- TestInstallAction action = new TestInstallAction(getTopLevelIUs());
- assertTrue("Should be enabled", action.isEnabled());
- assertEquals(2, action.getSelectedIUs().size());
- }
-
- public void testElements() {
- TestInstallAction action = new TestInstallAction(getTopLevelIUElements());
- assertTrue("Should be enabled", action.isEnabled());
- assertEquals(2, action.getSelectedIUs().size());
- }
-
- public void testMixedIUsAndNonIUs() {
- TestInstallAction action = new TestInstallAction(getMixedIUsAndNonIUs());
- assertTrue("Mixed selections allowed", action.isEnabled());
- assertEquals(2, action.getSelectedIUs().size());
- }
-
- public void testMixedIUsAndElements() {
- TestInstallAction action = new TestInstallAction(getMixedIUsAndElements());
- assertTrue("Should be enabled", action.isEnabled());
- assertEquals(2, action.getSelectedIUs().size());
- }
-
- public void testParentIsCategory() {
- TestInstallAction action = new TestInstallAction(getCategoryAndChildIUElements());
- assertTrue("Should be enabled", action.isEnabled());
- // Only the non-category should be considered a selection
- assertEquals(1, action.getSelectedIUs().size());
- }
-
- public void testParentIsNestedCategory() {
- TestInstallAction action = new TestInstallAction(getNestedCategoriesAndChildIUElements());
- assertTrue("Should be enabled", action.isEnabled());
- // Only the non-category should be considered a selection
- assertEquals(1, action.getSelectedIUs().size());
- }
-
- protected IIUElement element(IInstallableUnit iu) {
- return new AvailableIUElement(null, iu, profile.getProfileId(), true);
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/InstallAction.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/InstallAction.java
index 8d9133213..3948c5eda 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/InstallAction.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/InstallAction.java
@@ -10,21 +10,31 @@
* Sonatype, Inc. - ongoing development
*******************************************************************************/
-package org.eclipse.equinox.internal.p2.ui.actions;
+package org.eclipse.equinox.internal.p2.ui.admin;
import java.util.Collection;
import org.eclipse.equinox.internal.p2.ui.ProvUI;
+import org.eclipse.equinox.internal.p2.ui.actions.ProfileModificationAction;
+import org.eclipse.equinox.internal.p2.ui.admin.dialogs.AddProfileDialog;
import org.eclipse.equinox.internal.p2.ui.model.*;
+import org.eclipse.equinox.internal.p2.ui.viewers.ProvElementContentProvider;
+import org.eclipse.equinox.internal.p2.ui.viewers.ProvElementLabelProvider;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.operations.InstallOperation;
import org.eclipse.equinox.p2.operations.ProfileChangeOperation;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ui.dialogs.ListDialog;
public class InstallAction extends ProfileModificationAction {
- public InstallAction(ProvisioningUI ui, ISelectionProvider selectionProvider, String profileId) {
- super(ui, ProvUI.INSTALL_COMMAND_LABEL, selectionProvider, profileId);
+ String userChosenProfileId;
+
+ public InstallAction(ProvisioningUI ui, ISelectionProvider selectionProvider) {
+ super(ui, ProvUI.INSTALL_COMMAND_LABEL, selectionProvider, null);
setToolTipText(ProvUI.INSTALL_COMMAND_TOOLTIP);
}
@@ -58,13 +68,53 @@ public class InstallAction extends ProfileModificationAction {
}
protected int performAction(ProfileChangeOperation operation, Collection<IInstallableUnit> ius) {
- return getProvisioningUI().openInstallWizard(ius, (InstallOperation) operation, null);
+ ProvisioningUI ui = ProvAdminUIActivator.getDefault().getProvisioningUI(userChosenProfileId);
+ operation.setProfileId(userChosenProfileId);
+ int ret = ui.openInstallWizard(ius, (InstallOperation) operation, null);
+ userChosenProfileId = null;
+ return ret;
}
protected ProfileChangeOperation getProfileChangeOperation(Collection<IInstallableUnit> ius) {
InstallOperation op = new InstallOperation(getSession(), ius);
- op.setProfileId(profileId);
- // op.setRootMarkerKey(getPolicy().getQueryContext().getVisibleInstalledIUProperty());
+ op.setProfileId(userChosenProfileId);
return op;
}
+
+ protected boolean isInvalidProfileId() {
+ if (userChosenProfileId == null) {
+ userChosenProfileId = getUserChosenProfileId();
+ }
+ return userChosenProfileId == null;
+ }
+
+ private String getUserChosenProfileId() {
+ IProfileRegistry registry = ProvAdminUIActivator.getDefault().getProfileRegistry();
+ if (registry.getProfiles().length == 0) {
+ AddProfileDialog dialog = new AddProfileDialog(getShell(), new String[0]);
+ if (dialog.open() == Window.OK) {
+ return dialog.getAddedProfileId();
+ }
+ return null;
+ }
+
+ ListDialog dialog = new ListDialog(getShell());
+ dialog.setTitle("Choose a Profile");
+ dialog.setLabelProvider(new ProvElementLabelProvider());
+ dialog.setInput(new Profiles(getProvisioningUI()));
+ dialog.setContentProvider(new ProvElementContentProvider());
+ dialog.open();
+ Object[] result = dialog.getResult();
+ if (result != null && result.length > 0) {
+ IProfile profile = ProvUI.getAdapter(result[0], IProfile.class);
+ if (profile != null)
+ return profile.getProfileId();
+ }
+ return null;
+ }
+
+ protected void runCanceled() {
+ super.runCanceled();
+ userChosenProfileId = null;
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/InstallIUDropAdapter.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/InstallIUDropAdapter.java
index 367aa5fbe..b5257c7aa 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/InstallIUDropAdapter.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/InstallIUDropAdapter.java
@@ -14,7 +14,6 @@ import java.util.*;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.ui.*;
-import org.eclipse.equinox.internal.p2.ui.actions.InstallAction;
import org.eclipse.equinox.internal.p2.ui.model.InstalledIUElement;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
@@ -133,7 +132,7 @@ public class InstallIUDropAdapter extends ViewerDropAdapter {
throw new UnsupportedOperationException("This ISelectionProvider is static, and cannot be modified."); //$NON-NLS-1$
}
};
- InstallAction action = new InstallAction(ProvAdminUIActivator.getDefault().getProvisioningUI(profileId), selectionProvider, profileId);
+ InstallAction action = new InstallAction(ProvAdminUIActivator.getDefault().getProvisioningUI(profileId), selectionProvider);
if (DEBUG)
System.out.println("Running install action"); //$NON-NLS-1$
action.run();
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java
index d4092e1f1..8fed364f2 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java
@@ -14,7 +14,6 @@ package org.eclipse.equinox.internal.p2.ui.admin;
import java.util.List;
import org.eclipse.equinox.internal.p2.ui.ProvUIProvisioningListener;
import org.eclipse.equinox.internal.p2.ui.QueryableMetadataRepositoryManager;
-import org.eclipse.equinox.internal.p2.ui.actions.InstallAction;
import org.eclipse.equinox.internal.p2.ui.admin.dialogs.AddMetadataRepositoryDialog;
import org.eclipse.equinox.internal.p2.ui.admin.preferences.PreferenceConstants;
import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositories;
@@ -81,7 +80,7 @@ public class MetadataRepositoriesView extends RepositoriesView {
protected void makeActions() {
super.makeActions();
- installAction = new InstallAction(getProvisioningUI(), viewer, null);
+ installAction = new InstallAction(getProvisioningUI(), viewer);
}
protected void fillContextMenu(IMenuManager manager) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ProfileModificationAction.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ProfileModificationAction.java
index 8231c4bdd..7ff6ad328 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ProfileModificationAction.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ProfileModificationAction.java
@@ -35,7 +35,6 @@ import org.eclipse.ui.statushandlers.StatusManager;
public abstract class ProfileModificationAction extends ProvisioningAction {
public static final int ACTION_NOT_RUN = -1;
String profileId;
- String userChosenProfileId;
int result = ACTION_NOT_RUN;
protected ProfileModificationAction(ProvisioningUI ui, String text, ISelectionProvider selectionProvider, String profileId) {
@@ -48,7 +47,7 @@ public abstract class ProfileModificationAction extends ProvisioningAction {
public void run() {
Collection<IInstallableUnit> ius = getSelectedIUs();
// No ius or no profile?
- if (profileId == null || ius.size() == 0) {
+ if (isInvalidProfileId() || ius.size() == 0) {
ProvUI.reportStatus(getNoProfileOrSelectionStatus(profileId, ius), StatusManager.BLOCK);
runCanceled();
return;
@@ -56,6 +55,10 @@ public abstract class ProfileModificationAction extends ProvisioningAction {
run(ius, profileId);
}
+ protected boolean isInvalidProfileId() {
+ return profileId == null;
+ }
+
public IProfile getProfile() {
String id = profileId == null ? ui.getProfileId() : profileId;
return ProvUI.getProfileRegistry(ui.getSession()).getProfile(id);
@@ -81,7 +84,6 @@ public abstract class ProfileModificationAction extends ProvisioningAction {
public void run() {
if (validateOperation(operation))
performAction(operation, ius);
- userChosenProfileId = null;
}
});
}
@@ -202,10 +204,9 @@ public abstract class ProfileModificationAction extends ProvisioningAction {
return profile.getInstallableUnitProperty(iu, propertyName);
}
- private void runCanceled() {
+ protected void runCanceled() {
// The action was canceled, do any cleanup needed before
// it is run again.
- userChosenProfileId = null;
result = Window.CANCEL;
}
}

Back to the top