diff options
author | Matthew Piggott | 2011-04-06 22:16:00 +0000 |
---|---|---|
committer | Matthew Piggott | 2011-04-06 22:16:14 +0000 |
commit | 34f8c611dc55b1bc853e8b432a9f30b71c4b2db2 (patch) | |
tree | 0f669c4a9de9b06176b8d7268532cffaf8bfe2c4 /org.eclipse.m2e.core.ui | |
parent | eba8832b210dd3a390fa522642f5b41d4c66db8d (diff) | |
download | m2e-core-34f8c611dc55b1bc853e8b432a9f30b71c4b2db2.tar.gz m2e-core-34f8c611dc55b1bc853e8b432a9f30b71c4b2db2.tar.xz m2e-core-34f8c611dc55b1bc853e8b432a9f30b71c4b2db2.zip |
Bug 339968 - Support to change selected discovery proposal using Combo box
Diffstat (limited to 'org.eclipse.m2e.core.ui')
-rw-r--r-- | org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/M2EUIPluginActivator.java | 8 | ||||
-rw-r--r-- | org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/AbstractMavenProjectWizard.java | 4 | ||||
-rw-r--r-- | org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/IMavenDiscoveryUI.java (renamed from org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/IImportWizardPageFactory.java) | 4 | ||||
-rw-r--r-- | org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java | 164 | ||||
-rw-r--r-- | org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizard.java | 2 |
5 files changed, 101 insertions, 81 deletions
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/M2EUIPluginActivator.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/M2EUIPluginActivator.java index ab9eb581..88f286e7 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/M2EUIPluginActivator.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/M2EUIPluginActivator.java @@ -23,7 +23,7 @@ import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.IMavenDiscovery; import org.eclipse.m2e.core.ui.internal.console.MavenConsoleImpl; import org.eclipse.m2e.core.ui.internal.search.util.IndexSearchEngine; import org.eclipse.m2e.core.ui.internal.search.util.SearchEngine; -import org.eclipse.m2e.core.ui.internal.wizards.IImportWizardPageFactory; +import org.eclipse.m2e.core.ui.internal.wizards.IMavenDiscoveryUI; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.preferences.ScopedPreferenceStore; @@ -127,12 +127,12 @@ public class M2EUIPluginActivator extends AbstractUIPlugin { /** * @return */ - public IImportWizardPageFactory getImportWizardPageFactory() { + public IMavenDiscoveryUI getImportWizardPageFactory() { // TODO this leaks service references BundleContext context = getBundle().getBundleContext(); - ServiceReference serviceReference = context.getServiceReference(IImportWizardPageFactory.class.getName()); + ServiceReference serviceReference = context.getServiceReference(IMavenDiscoveryUI.class.getName()); if(serviceReference != null) { - return (IImportWizardPageFactory) context.getService(serviceReference); + return (IMavenDiscoveryUI) context.getService(serviceReference); } return null; } diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/AbstractMavenProjectWizard.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/AbstractMavenProjectWizard.java index a4c6a336..33eb20ca 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/AbstractMavenProjectWizard.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/AbstractMavenProjectWizard.java @@ -35,7 +35,7 @@ public abstract class AbstractMavenProjectWizard extends Wizard { private IMavenDiscovery discovery; - private IImportWizardPageFactory pageFactory; + private IMavenDiscoveryUI pageFactory; public void init(IWorkbench workbench, IStructuredSelection selection) { this.selection = selection; @@ -62,7 +62,7 @@ public abstract class AbstractMavenProjectWizard extends Wizard { return discovery; } - public IImportWizardPageFactory getPageFactory() { + public IMavenDiscoveryUI getPageFactory() { return pageFactory; } } diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/IImportWizardPageFactory.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/IMavenDiscoveryUI.java index d332c372..132e38aa 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/IImportWizardPageFactory.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/IMavenDiscoveryUI.java @@ -13,16 +13,16 @@ import java.util.List; import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.operation.IRunnableWithProgress; + import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.IMavenDiscoveryProposal; @SuppressWarnings("restriction") -public interface IImportWizardPageFactory { +public interface IMavenDiscoveryUI { /** * Returns true if postInstallHook has been scheduled for execution and false otherwise */ public boolean implement(List<IMavenDiscoveryProposal> proposals, IRunnableWithProgress postInstallHook, IRunnableContext context, Collection<String> projectsToConfigure); - } diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java index f50ee280..ac7f6f14 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java @@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.viewers.ILabelProviderListener; @@ -89,12 +88,14 @@ public class LifecycleMappingPage extends WizardPage { private TreeViewer treeViewer; - private Button btnNewButton; + private Button autoSelectButton; - private boolean loading = true; + private boolean loading; private Text details; + private Text license; + /** * Create the wizard. */ @@ -135,61 +136,67 @@ public class LifecycleMappingPage extends WizardPage { TreeViewerColumn columnViewerAction = new TreeViewerColumn(treeViewer, SWT.NONE); TreeColumn columnAction = columnViewerAction.getColumn(); columnAction.setText("Action"); - // columnViewerAction.setEditingSupport(new EditingSupport(treeViewer) { - // - // @Override - // protected void setValue(Object element, Object value) { - // if (element instanceof ILifecycleMappingLabelProvider) { - // ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider)element; - // Integer val = (Integer)value; - // List<IMavenDiscoveryProposal> all = mappingConfiguration.getProposals(prov.getKey()); - // IMavenDiscoveryProposal sel = all.get(val.intValue()); - // IMavenDiscoveryProposal prop = mappingConfiguration.getSelectedProposal(prov.getKey()); - // if (prop != null) { - // mappingConfiguration.removeSelectedProposal(prop); - // } - // if (sel != null) { - // mappingConfiguration.addSelectedProposal(sel); - // } - // } - // } - // - // @Override - // protected Object getValue(Object element) { - // if (element instanceof ILifecycleMappingLabelProvider) { - // ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider)element; - // IMavenDiscoveryProposal prop = mappingConfiguration.getSelectedProposal(prov.getKey()); - // List<IMavenDiscoveryProposal> all = mappingConfiguration.getProposals(prov.getKey()); - // return new Integer(all.indexOf(prop)); - // } - // return new Integer(0); - // } - // - // @Override - // protected CellEditor getCellEditor(Object element) { - // if (element instanceof ILifecycleMappingLabelProvider) { - // ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider)element; - // List<IMavenDiscoveryProposal> all = mappingConfiguration.getProposals(prov.getKey()); - // List<String> values = new ArrayList<String>(); - // for (IMavenDiscoveryProposal prop : all) { - // values.add(NLS.bind("Install {0}", prop.toString())); - // } - // ComboBoxCellEditor edit = new ComboBoxCellEditor(treeViewer.getTree(), values.toArray(new String[0])); - // return edit; - // } - // throw new IllegalStateException(); - // } - // - // @Override - // protected boolean canEdit(Object element) { - // if (element instanceof ILifecycleMappingLabelProvider) { - // ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider)element; - // List<IMavenDiscoveryProposal> all = mappingConfiguration.getProposals(prov.getKey()); - // return all != null && all.size() > 1; - // } - // return false; - // } - // }); + columnViewerAction.setEditingSupport(new EditingSupport(treeViewer) { + + @Override + protected void setValue(Object element, Object value) { + if(element instanceof ILifecycleMappingLabelProvider) { + ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) element; + Integer val = (Integer) value; + List<IMavenDiscoveryProposal> all = mappingConfiguration.getProposals(prov.getKey()); + IMavenDiscoveryProposal prop = mappingConfiguration.getSelectedProposal(prov.getKey()); + if(prop != null) { + mappingConfiguration.removeSelectedProposal(prop); + } + if(val.intValue() < all.size()) { + IMavenDiscoveryProposal sel = all.get(val.intValue()); + if(sel != null) { + mappingConfiguration.addSelectedProposal(sel); + } + } + getViewer().refresh(true); + //getViewer().update(element, null); + } + } + + @Override + protected Object getValue(Object element) { + if(element instanceof ILifecycleMappingLabelProvider) { + ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) element; + IMavenDiscoveryProposal prop = mappingConfiguration.getSelectedProposal(prov.getKey()); + List<IMavenDiscoveryProposal> all = mappingConfiguration.getProposals(prov.getKey()); + int index = all.indexOf(prop); + return index >= 0 ? Integer.valueOf(index) : Integer.valueOf(all.size()); + } + return Integer.valueOf(0); + } + + @Override + protected CellEditor getCellEditor(Object element) { + if(element instanceof ILifecycleMappingLabelProvider) { + ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) element; + List<IMavenDiscoveryProposal> all = mappingConfiguration.getProposals(prov.getKey()); + List<String> values = new ArrayList<String>(); + for(IMavenDiscoveryProposal prop : all) { + values.add(NLS.bind("Install {0}", prop.toString())); + } + values.add("Do nothing"); + ComboBoxCellEditor edit = new ComboBoxCellEditor(treeViewer.getTree(), values.toArray(new String[0])); + return edit; + } + throw new IllegalStateException(); + } + + @Override + protected boolean canEdit(Object element) { + if(element instanceof ILifecycleMappingLabelProvider) { + ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) element; + List<IMavenDiscoveryProposal> all = mappingConfiguration.getProposals(prov.getKey()); + return all != null && !all.isEmpty(); + } + return false; + } + }); treeViewer.setContentProvider(new ITreeContentProvider() { @@ -298,7 +305,7 @@ public class LifecycleMappingPage extends WizardPage { if(loading) { return EMPTY_STRING; } else { - return EMPTY_STRING;//"Nothing discovered"; + return mappingConfiguration.getProposals(prov.getKey()).isEmpty() ? EMPTY_STRING : "Do nothing";//"Nothing discovered"; } // List<IMavenDiscoveryProposal> all = mappingConfiguration.getProposals(prov.getKey()); // if (all.size() > 0) { @@ -334,11 +341,14 @@ public class LifecycleMappingPage extends WizardPage { ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider) ((IStructuredSelection) event .getSelection()).getFirstElement(); IMavenDiscoveryProposal proposal = mappingConfiguration.getSelectedProposal(prov.getKey()); - details.setText(proposal == null ? NLS.bind( + details.setText(proposal != null ? proposal.getDescription() : mappingConfiguration.getProposals( + prov.getKey()).isEmpty() ? NLS.bind( "Did not find marketplace entry to execute {0} in Eclipse. Please see Help for more information.", - prov.getMavenText()) : proposal.getDescription()); + prov.getMavenText()) : EMPTY_STRING); + license.setText(proposal == null ? EMPTY_STRING : proposal.getLicense()); } else { details.setText(EMPTY_STRING); + license.setText(EMPTY_STRING); } } }); @@ -358,14 +368,31 @@ public class LifecycleMappingPage extends WizardPage { }); btnNewButton_1.setText("Deselect all"); - btnNewButton = new Button(composite, SWT.NONE); - btnNewButton.addSelectionListener(new SelectionAdapter() { + autoSelectButton = new Button(composite, SWT.NONE); + autoSelectButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { discoverProposals(); } }); - btnNewButton.setText("Select from marketplace"); + autoSelectButton.setText("Auto Select"); + + // Provide a reasonable height for the details box + GC gc = new GC(container); + gc.setFont(JFaceResources.getDialogFont()); + FontMetrics fontMetrics = gc.getFontMetrics(); + gc.dispose(); + + Group grpLicense = new Group(container, SWT.NONE); + grpLicense.setLayout(new GridLayout(1, false)); + grpLicense.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + grpLicense.setText("License"); + + license = new Text(grpLicense, SWT.READ_ONLY); + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); + gd.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 1); + gd.minimumHeight = Dialog.convertHeightInCharsToPixels(fontMetrics, 1); + license.setLayoutData(gd); Group grpDetails = new Group(container, SWT.NONE); grpDetails.setLayout(new GridLayout(1, false)); @@ -373,14 +400,7 @@ public class LifecycleMappingPage extends WizardPage { grpDetails.setText("Details"); details = new Text(grpDetails, SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL); - - // Provide a reasonable height for the details box - GC gc = new GC(grpDetails); - gc.setFont(JFaceResources.getDialogFont()); - FontMetrics fontMetrics = gc.getFontMetrics(); - gc.dispose(); - GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); - gd.verticalIndent = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING); + gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 3); gd.minimumHeight = Dialog.convertHeightInCharsToPixels(fontMetrics, 1); details.setLayoutData(gd); diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizard.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizard.java index 6943c212..5b15a481 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizard.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizard.java @@ -155,7 +155,7 @@ public class MavenImportWizard extends AbstractMavenProjectWizard implements IIm boolean doImport = true; - IImportWizardPageFactory discovery = getPageFactory(); + IMavenDiscoveryUI discovery = getPageFactory(); if(discovery != null && !proposals.isEmpty()) { Set<String> projectsToConfigure = new HashSet<String>(); for(MavenProjectInfo projectInfo : projects) { |