Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.m2e.core.ui')
-rw-r--r--org.eclipse.m2e.core.ui/plugin.xml25
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/M2EUIPluginActivator.java3
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenRepositorySearchDialog.java2
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/MavenRepositoryView.java9
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/RepositoryViewLabelProvider.java9
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactFileNode.java67
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactNode.java43
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java81
8 files changed, 148 insertions, 91 deletions
diff --git a/org.eclipse.m2e.core.ui/plugin.xml b/org.eclipse.m2e.core.ui/plugin.xml
index 8b54e497..06f215a1 100644
--- a/org.eclipse.m2e.core.ui/plugin.xml
+++ b/org.eclipse.m2e.core.ui/plugin.xml
@@ -29,10 +29,7 @@
state="true">
<description>%m2.decorator.description</description>
<enablement>
- <or>
- <objectState name="nature" value="org.eclipse.m2e.core.maven2Nature"/>
- <!--objectState name="name" value="pom.xml"/-->
- </or>
+ <objectState name="nature" value="org.eclipse.m2e.core.maven2Nature"/>
</enablement>
</decorator>
@@ -44,10 +41,7 @@
state="false">
<description>%m2.decorator.version.description</description>
<enablement>
- <or>
- <objectState name="nature" value="org.eclipse.m2e.core.maven2Nature"/>
- <!--objectState name="name" value="pom.xml"/-->
- </or>
+ <objectState name="nature" value="org.eclipse.m2e.core.maven2Nature"/>
</enablement>
</decorator>
</extension>
@@ -550,4 +544,17 @@
file="helpContext.xml">
</contexts>
</extension>
-</plugin> \ No newline at end of file
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.m2e.core.ui.internal.views.nodes.IndexedArtifactFileNode"
+ class="org.eclipse.m2e.core.ui.internal.views.nodes.IndexedArtifactFileNode$AdapterFactory">
+ <adapter
+ type="org.eclipse.m2e.core.internal.index.IndexedArtifactFile">
+ </adapter>
+ <adapter
+ type="org.eclipse.m2e.core.embedder.ArtifactKey">
+ </adapter>
+ </factory>
+ </extension>
+</plugin>
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 37e3411e..3118f996 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
@@ -26,6 +26,7 @@ import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.internal.IMavenConstants;
+import org.eclipse.m2e.core.internal.index.filter.FilteredIndex;
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;
@@ -105,7 +106,7 @@ public class M2EUIPluginActivator extends AbstractUIPlugin {
}
public SearchEngine getSearchEngine(IProject project) throws CoreException {
- return new IndexSearchEngine(MavenPlugin.getIndexManager().getIndex(project));
+ return new IndexSearchEngine(new FilteredIndex(project, MavenPlugin.getIndexManager().getIndex(project)));
}
@SuppressWarnings({"rawtypes", "unchecked"})
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenRepositorySearchDialog.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenRepositorySearchDialog.java
index cc503bb0..5f5b65f8 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenRepositorySearchDialog.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/MavenRepositorySearchDialog.java
@@ -222,7 +222,7 @@ public class MavenRepositorySearchDialog extends AbstractMavenDialog {
}
pomSelectionComponent = new MavenPomSelectionComponent(composite, SWT.NONE);
- pomSelectionComponent.init(queryText, queryType, artifacts, managed);
+ pomSelectionComponent.init(queryText, queryType, project, artifacts, managed);
pomSelectionComponent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/MavenRepositoryView.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/MavenRepositoryView.java
index e47b790e..36a0471c 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/MavenRepositoryView.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/MavenRepositoryView.java
@@ -32,6 +32,7 @@ import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelection;
@@ -80,6 +81,7 @@ import org.eclipse.m2e.core.ui.internal.views.nodes.RepositoryNode;
*
* @author dyocum
*/
+@SuppressWarnings("restriction")
public class MavenRepositoryView extends ViewPart {
/**
@@ -137,8 +139,11 @@ public class MavenRepositoryView extends ViewPart {
viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
contentProvider = new RepositoryViewContentProvider();
viewer.setContentProvider(contentProvider);
- viewer.setLabelProvider(new RepositoryViewLabelProvider(viewer.getTree().getFont()));
-
+
+ RepositoryViewLabelProvider labelProvider = new RepositoryViewLabelProvider(viewer.getTree().getFont());
+ viewer.setLabelProvider(new DecoratingStyledCellLabelProvider(labelProvider, PlatformUI.getWorkbench()
+ .getDecoratorManager().getLabelDecorator(), null));
+
viewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/RepositoryViewLabelProvider.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/RepositoryViewLabelProvider.java
index f65adaf6..e83707bf 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/RepositoryViewLabelProvider.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/RepositoryViewLabelProvider.java
@@ -11,9 +11,12 @@
package org.eclipse.m2e.core.ui.internal.views;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+
import org.eclipse.m2e.core.ui.internal.util.M2EUIUtils;
import org.eclipse.m2e.core.ui.internal.views.nodes.IMavenRepositoryNode;
import org.eclipse.m2e.core.ui.internal.views.nodes.RepositoryNode;
@@ -31,7 +34,7 @@ import org.eclipse.ui.PlatformUI;
*
* @author dyocum
*/
-public class RepositoryViewLabelProvider extends LabelProvider implements IColorProvider, IFontProvider {
+public class RepositoryViewLabelProvider extends LabelProvider implements IStyledLabelProvider, IColorProvider, IFontProvider {
private Font italicFont;
public RepositoryViewLabelProvider(Font treeFont){
@@ -93,4 +96,8 @@ public class RepositoryViewLabelProvider extends LabelProvider implements IColor
return null;
}
+ public StyledString getStyledText(Object element) {
+ return new StyledString(getText(element));
+ }
+
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactFileNode.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactFileNode.java
index 95a0c3f6..2dcc4eec 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactFileNode.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactFileNode.java
@@ -12,40 +12,39 @@
package org.eclipse.m2e.core.ui.internal.views.nodes;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.swt.graphics.Image;
+
import org.eclipse.m2e.core.embedder.ArtifactKey;
import org.eclipse.m2e.core.internal.index.IIndex;
import org.eclipse.m2e.core.internal.index.IndexedArtifactFile;
import org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager;
import org.eclipse.m2e.core.ui.internal.MavenImages;
-import org.eclipse.swt.graphics.Image;
+
/**
* IndexedArtifactFileNode
- *
+ *
* @author dyocum
*/
-public class IndexedArtifactFileNode implements IMavenRepositoryNode, IArtifactNode, IAdaptable {
+@SuppressWarnings("restriction")
+public class IndexedArtifactFileNode extends PlatformObject implements IMavenRepositoryNode, IArtifactNode, IAdaptable {
private IndexedArtifactFile artifactFile;
- public IndexedArtifactFileNode(IndexedArtifactFile artifactFile){
+ public IndexedArtifactFileNode(IndexedArtifactFile artifactFile) {
this.artifactFile = artifactFile;
}
-
- public IndexedArtifactFile getIndexedArtifactFile(){
+
+ public IndexedArtifactFile getIndexedArtifactFile() {
return this.artifactFile;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.m2e.ui.internal.views.IMavenRepositoryNode#getChildren()
- */
+
public Object[] getChildren() {
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.m2e.ui.internal.views.IMavenRepositoryNode#getName()
- */
public String getName() {
String label = artifactFile.artifact;
if(artifactFile.classifier != null) {
@@ -57,16 +56,10 @@ public class IndexedArtifactFileNode implements IMavenRepositoryNode, IArtifactN
return label;
}
- /* (non-Javadoc)
- * @see org.eclipse.m2e.ui.internal.views.IMavenRepositoryNode#hasChildren()
- */
public boolean hasChildren() {
return false;
}
- /* (non-Javadoc)
- * @see org.eclipse.m2e.ui.internal.views.nodes.IMavenRepositoryNode#getImage()
- */
public Image getImage() {
if(artifactFile.sourcesExists == IIndex.PRESENT) {
return MavenImages.IMG_VERSION_SRC;
@@ -75,28 +68,36 @@ public class IndexedArtifactFileNode implements IMavenRepositoryNode, IArtifactN
}
- /* (non-Javadoc)
- * @see org.eclipse.m2e.ui.internal.views.nodes.IArtifactNode#getDocumentKey()
- */
public String getDocumentKey() {
return NexusIndexManager.getDocumentKey(artifactFile.getArtifactKey());
}
- /* (non-Javadoc)
- * @see org.eclipse.m2e.ui.internal.views.nodes.IMavenRepositoryNode#isUpdating()
- */
public boolean isUpdating() {
return false;
}
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class adapter) {
- if (ArtifactKey.class.equals(adapter)) {
- return new ArtifactKey(artifactFile.group, artifactFile.artifact, artifactFile.version, artifactFile.classifier);
+ @SuppressWarnings("rawtypes")
+ public static class AdapterFactory implements IAdapterFactory {
+
+ private static final Class[] ADAPTERS = new Class[] {ArtifactKey.class, IndexedArtifactFile.class};
+
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if(adaptableObject instanceof IndexedArtifactFileNode) {
+ IndexedArtifactFileNode node = (IndexedArtifactFileNode) adaptableObject;
+ IndexedArtifactFile artifactFile = node.artifactFile;
+ if(ArtifactKey.class.equals(adapterType)) {
+ return new ArtifactKey(artifactFile.group, artifactFile.artifact, artifactFile.version,
+ artifactFile.classifier);
+ } else if(IndexedArtifactFile.class.equals(adapterType)) {
+ return artifactFile;
+ }
+ }
+ return null;
}
- return null;
- }
+ public Class[] getAdapterList() {
+ return ADAPTERS;
+ }
+
+ }
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactNode.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactNode.java
index d0778c62..f9f3d22d 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactNode.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactNode.java
@@ -14,77 +14,66 @@ package org.eclipse.m2e.core.ui.internal.views.nodes;
import java.util.ArrayList;
import java.util.Set;
+import org.eclipse.swt.graphics.Image;
+
import org.eclipse.m2e.core.internal.index.IndexedArtifact;
import org.eclipse.m2e.core.internal.index.IndexedArtifactFile;
-import org.eclipse.m2e.core.ui.internal.Messages;
import org.eclipse.m2e.core.ui.internal.MavenImages;
-import org.eclipse.swt.graphics.Image;
+import org.eclipse.m2e.core.ui.internal.Messages;
+
/**
* IndexedArtifactNode
- *
+ *
* @author dyocum
*/
+@SuppressWarnings("restriction")
public class IndexedArtifactNode implements IMavenRepositoryNode, IArtifactNode {
private IndexedArtifact artifact;
+
private Object[] kids = null;
- public IndexedArtifactNode(IndexedArtifact artifact){
+
+ public IndexedArtifactNode(IndexedArtifact artifact) {
this.artifact = artifact;
}
- /* (non-Javadoc)
- * @see org.eclipse.m2e.ui.internal.views.IMavenRepositoryNode#getChildren()
- */
+
public Object[] getChildren() {
Set<IndexedArtifactFile> files = artifact.getFiles();
- if(files == null){
+ if(files == null) {
return new Object[0];
}
ArrayList<Object> fileList = new ArrayList<Object>();
- for(IndexedArtifactFile iaf : files){
+ for(IndexedArtifactFile iaf : files) {
fileList.add(new IndexedArtifactFileNode(iaf));
}
kids = fileList.toArray(new IndexedArtifactFileNode[fileList.size()]);
return kids;
}
- /* (non-Javadoc)
- * @see org.eclipse.m2e.ui.internal.views.IMavenRepositoryNode#getName()
- */
public String getName() {
// return a.group + ":" + a.artifact;
String pkg = artifact.getPackaging();
- if(pkg == null){
+ if(pkg == null) {
pkg = Messages.IndexedArtifactNode_no_pack;
}
return artifact.getArtifactId() + " - " + pkg; //$NON-NLS-1$
}
- /* (non-Javadoc)
- * @see org.eclipse.m2e.ui.internal.views.IMavenRepositoryNode#hasChildren()
- */
public boolean hasChildren() {
//return kids != null && kids.length > 0;
return true;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.m2e.ui.internal.views.nodes.IMavenRepositoryNode#getImage()
- */
+
public Image getImage() {
return MavenImages.IMG_JAR;
}
- /* (non-Javadoc)
- * @see org.eclipse.m2e.ui.internal.views.nodes.IArtifactNode#getDocumentKey()
- */
+
public String getDocumentKey() {
return artifact.getArtifactId();
}
- /* (non-Javadoc)
- * @see org.eclipse.m2e.ui.internal.views.nodes.IMavenRepositoryNode#isUpdating()
- */
+
public boolean isUpdating() {
- // TODO Auto-generated method isUpdating
return false;
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java
index 146d9943..74e17928 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java
@@ -11,18 +11,23 @@
package org.eclipse.m2e.core.ui.internal.wizards;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import com.ibm.icu.text.DateFormat;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider;
+import org.eclipse.jface.viewers.DecorationContext;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IDecoration;
@@ -54,17 +59,21 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.PlatformUI;
import org.apache.lucene.search.BooleanQuery;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.ArtifactKey;
import org.eclipse.m2e.core.internal.IMavenConstants;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.index.IIndex;
import org.eclipse.m2e.core.internal.index.IndexManager;
import org.eclipse.m2e.core.internal.index.IndexedArtifact;
import org.eclipse.m2e.core.internal.index.IndexedArtifactFile;
import org.eclipse.m2e.core.internal.index.UserInputSearchExpression;
+import org.eclipse.m2e.core.internal.index.filter.ArtifactFilterManager;
+import org.eclipse.m2e.core.ui.internal.M2EUIPluginActivator;
import org.eclipse.m2e.core.ui.internal.MavenImages;
import org.eclipse.m2e.core.ui.internal.Messages;
@@ -74,8 +83,12 @@ import org.eclipse.m2e.core.ui.internal.Messages;
*
* @author Eugene Kuleshov
*/
+@SuppressWarnings("restriction")
public class MavenPomSelectionComponent extends Composite {
+ public static final String PROP_DECORATION_CONTEXT_PROJECT = M2EUIPluginActivator.PLUGIN_ID
+ + ".decorationContextProject"; //$NON-NLS-1$
+
/* (non-Javadoc)
* @see org.eclipse.swt.widgets.Widget#dispose()
*/
@@ -123,6 +136,8 @@ public class MavenPomSelectionComponent extends Composite {
final HashSet<String> artifactKeys = new HashSet<String>();
final HashSet<String> managedKeys = new HashSet<String>();
+ private IProject project;
+
public MavenPomSelectionComponent(Composite parent, int style) {
super(parent, style);
createSearchComposite();
@@ -199,8 +214,10 @@ public class MavenPomSelectionComponent extends Composite {
}
- public void init(String queryText, String queryType, Set<ArtifactKey> artifacts, Set<ArtifactKey> managed) {
+ public void init(String queryText, String queryType, IProject project, Set<ArtifactKey> artifacts,
+ Set<ArtifactKey> managed) {
this.queryType = queryType;
+ this.project = project;
if(queryText != null) {
searchText.setText(queryText);
@@ -220,13 +237,36 @@ public class MavenPomSelectionComponent extends Composite {
}
searchResultViewer.setContentProvider(new SearchResultContentProvider());
- searchResultViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new SearchResultLabelProvider(artifactKeys, managedKeys)));
+
+ SearchResultLabelProvider labelProvider = new SearchResultLabelProvider(artifactKeys, managedKeys);
+ DecoratingStyledCellLabelProvider decoratingLabelProvider = new DecoratingStyledCellLabelProvider(labelProvider,
+ PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(), null);
+ DecorationContext decorationContext = new DecorationContext();
+ if(project != null) {
+ decorationContext.putProperty(PROP_DECORATION_CONTEXT_PROJECT, project);
+ }
+ decoratingLabelProvider.setDecorationContext(decorationContext);
+ searchResultViewer.setLabelProvider(decoratingLabelProvider);
+
searchResultViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if(!selection.isEmpty()) {
- if(selection.size() == 1) {
- IndexedArtifactFile f = getSelectedIndexedArtifactFile(selection.getFirstElement());
+ List<IndexedArtifactFile> files = getSelectedIndexedArtifactFiles(selection);
+
+ ArtifactFilterManager filterManager = MavenPluginActivator.getDefault().getArifactFilterManager();
+
+ for (IndexedArtifactFile file : files) {
+ ArtifactKey key = (ArtifactKey) file.getAdapter(ArtifactKey.class);
+ IStatus status = filterManager.filter(MavenPomSelectionComponent.this.project, key);
+ if (!status.isOK()) {
+ setStatus(IStatus.ERROR, status.getMessage());
+ return; // TODO not nice to exit method like this
+ }
+ }
+
+ if(files.size() == 1) {
+ IndexedArtifactFile f = files.get(0);
// int severity = artifactKeys.contains(f.group + ":" + f.artifact) ? IStatus.ERROR : IStatus.OK;
int severity = IStatus.OK;
String date = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(f.date);
@@ -284,25 +324,32 @@ public class MavenPomSelectionComponent extends Composite {
}
public IndexedArtifactFile getIndexedArtifactFile() {
- IStructuredSelection selection = (IStructuredSelection) searchResultViewer.getSelection();
- return getSelectedIndexedArtifactFile(selection.getFirstElement());
+ List<IndexedArtifactFile> files = getSelectedIndexedArtifactFiles((IStructuredSelection) searchResultViewer.getSelection());
+ return !files.isEmpty()? files.get(0): null;
}
- IndexedArtifactFile getSelectedIndexedArtifactFile(Object element) {
- if(element instanceof IndexedArtifact) {
- //the idea here is that if we have a managed version for something, then the IndexedArtifact shall
- //represent that value..
- IndexedArtifact ia = (IndexedArtifact)element;
- if (managedKeys.contains(getKey(ia))) {
- for (IndexedArtifactFile file : ia.getFiles()) {
- if (managedKeys.contains(getKey(file))) {
- return file;
+ List<IndexedArtifactFile> getSelectedIndexedArtifactFiles(IStructuredSelection selection) {
+ ArrayList<IndexedArtifactFile> result = new ArrayList<IndexedArtifactFile>();
+ for(Object element : selection.toList()) {
+ if(element instanceof IndexedArtifact) {
+ //the idea here is that if we have a managed version for something, then the IndexedArtifact shall
+ //represent that value..
+ IndexedArtifact ia = (IndexedArtifact) element;
+ if(managedKeys.contains(getKey(ia))) {
+ for(IndexedArtifactFile file : ia.getFiles()) {
+ if(managedKeys.contains(getKey(file))) {
+ result.add(file);
+ }
}
+ } else {
+ result.add(ia.getFiles().iterator().next());
}
+ } else if(element instanceof IndexedArtifactFile) {
+ result.add((IndexedArtifactFile) element);
}
- return ia.getFiles().iterator().next();
}
- return (IndexedArtifactFile) element;
+
+ return result;
}
void scheduleSearch(String query, boolean delay) {

Back to the top