Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Piggott2011-04-12 17:10:21 -0400
committerMatthew Piggott2011-04-12 17:10:47 -0400
commit416af3a5f8c49e6e8f89a62bd094eb9a29563927 (patch)
tree11367686d3d96dd2be5fcfd6495f0d3fbe35c47b /org.eclipse.m2e.editor
parent82f98e04fecbff44ddda2d95c76a8cb14569a254 (diff)
downloadm2e-core-416af3a5f8c49e6e8f89a62bd094eb9a29563927.tar.gz
m2e-core-416af3a5f8c49e6e8f89a62bd094eb9a29563927.tar.xz
m2e-core-416af3a5f8c49e6e8f89a62bd094eb9a29563927.zip
Added support for choosing pom in hierarchy to ignore goal
Diffstat (limited to 'org.eclipse.m2e.editor')
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java3
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/ParentGatherer.java64
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/PomHierarchyComposite.java233
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/ManageDependenciesDialog.java2
4 files changed, 3 insertions, 299 deletions
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java
index e23bf0d1..8a315f8c 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java
@@ -46,9 +46,10 @@ import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.IMavenProjectRegistry;
import org.eclipse.m2e.core.ui.internal.dialogs.EditDependencyDialog;
import org.eclipse.m2e.core.ui.internal.dialogs.MavenRepositorySearchDialog;
-import org.eclipse.m2e.core.ui.internal.editing.PomHelper;
import org.eclipse.m2e.core.ui.internal.editing.PomEdits.Operation;
import org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple;
+import org.eclipse.m2e.core.ui.internal.editing.PomHelper;
+import org.eclipse.m2e.core.ui.internal.util.ParentGatherer;
import org.eclipse.m2e.editor.MavenEditorImages;
import org.eclipse.m2e.editor.MavenEditorPlugin;
import org.eclipse.m2e.editor.dialogs.ManageDependenciesDialog;
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/ParentGatherer.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/ParentGatherer.java
deleted file mode 100644
index 7801a0e7..00000000
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/ParentGatherer.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Sonatype, Inc.
- * 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:
- * Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.m2e.editor.composites;
-
-import java.util.LinkedList;
-
-import org.apache.maven.execution.MavenExecutionRequest;
-import org.apache.maven.project.MavenProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.m2e.core.MavenPlugin;
-import org.eclipse.m2e.core.embedder.IMaven;
-import org.eclipse.m2e.core.project.IMavenProjectFacade;
-import org.eclipse.m2e.core.project.IMavenProjectRegistry;
-
-/**
- * Helper class to get the parent chain given a pom
- */
-public class ParentGatherer {
- private MavenProject mavenProject;
-
- private IMavenProjectFacade projectFacade;
-
- public ParentGatherer(MavenProject leafProject, IMavenProjectFacade facade) {
- this.mavenProject = leafProject;
- this.projectFacade = facade;
- }
-
- /**
- * Return the list of parents for a give pom
- * @param monitor
- * @return list of {@link MavenProject} from the given project to its ultimate parent.
- * The first entry is the given pom, the last one the ultimate parent.
- * @throws CoreException
- */
- public LinkedList<MavenProject> getParentHierarchy(IProgressMonitor monitor) throws CoreException {
- LinkedList<MavenProject> hierarchy = new LinkedList<MavenProject>();
- IMaven maven = MavenPlugin.getDefault().getMaven();
- IMavenProjectRegistry projectManager = MavenPlugin.getDefault().getMavenProjectRegistry();
- maven.detachFromSession(mavenProject);
-
- hierarchy.add(mavenProject);
-
- MavenProject project = mavenProject;
- while(project.getModel().getParent() != null) {
- if(monitor.isCanceled()) {
- return null;
- }
- MavenExecutionRequest request = projectManager.createExecutionRequest(projectFacade, monitor);
- project = maven.resolveParentProject(request, project, monitor);
- hierarchy.add(project);
- }
- return hierarchy;
- }
-}
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/PomHierarchyComposite.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/PomHierarchyComposite.java
deleted file mode 100644
index 64294320..00000000
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/PomHierarchyComposite.java
+++ /dev/null
@@ -1,233 +0,0 @@
-
-package org.eclipse.m2e.editor.composites;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.apache.maven.project.MavenProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.IColorProvider;
-import org.eclipse.jface.viewers.IInputSelectionProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.m2e.core.MavenPlugin;
-import org.eclipse.m2e.core.project.IMavenProjectFacade;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class PomHierarchyComposite extends Composite implements IInputSelectionProvider {
- private static final Logger LOG = LoggerFactory.getLogger(PomHierarchyComposite.class);
-
- private TreeViewer pomsViewer;
-
- private List<MavenProject> hierarchy;
-
- public PomHierarchyComposite(Composite parent, int style) {
- super(parent, style);
- build();
- }
-
- private void build() {
- setLayout(new FillLayout(SWT.HORIZONTAL));
- pomsViewer = new TreeViewer(this, SWT.NULL);
- pomsViewer.setLabelProvider(new DepLabelProvider());
- pomsViewer.setContentProvider(new PomHeirarchyContentProvider());
- }
-
- public void setEnabled(boolean bool) {
- pomsViewer.getTree().setEnabled(bool);
- super.setEnabled(bool);
- }
-
- public void computeHeirarchy(final IMavenProjectFacade project, IRunnableContext context) {
- try {
- if(context != null) {
- context.run(false, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- computeHeirarchy(project, monitor);
- } catch(CoreException e) {
- throw new InvocationTargetException(e);
- }
- }
- });
- } else {
- computeHeirarchy(project, new NullProgressMonitor());
- }
- } catch(Exception e) {
- LOG.error("An error occurred building pom heirarchy", e);
- }
- }
-
- private void computeHeirarchy(IMavenProjectFacade projectFacade, IProgressMonitor monitor) throws CoreException {
- LinkedList<MavenProject> hierarchy = new LinkedList<MavenProject>();
- hierarchy.addAll(new ParentGatherer(projectFacade.getMavenProject(), projectFacade).getParentHierarchy(monitor));
- setHierarchy(hierarchy);
- }
-
- public void setHierarchy(LinkedList<MavenProject> hierarchy) {
- this.hierarchy = hierarchy;
- pomsViewer.setInput(hierarchy);
- pomsViewer.expandAll();
- }
-
- public static class DepLabelProvider extends LabelProvider implements IColorProvider {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
- */
- @Override
- public String getText(Object element) {
- MavenProject project = null;
- if(element instanceof MavenProject) {
- project = (MavenProject) element;
- } else if(element instanceof Object[]) {
- project = (MavenProject) ((Object[]) element)[0];
- } else {
- return ""; //$NON-NLS-1$
- }
- StringBuffer buffer = new StringBuffer();
- buffer.append(project.getGroupId() + " : " + project.getArtifactId() + " : " + project.getVersion()); //$NON-NLS-1$ //$NON-NLS-2$
- return buffer.toString();
- }
-
- public Color getForeground(Object element) {
- if(element instanceof MavenProject) {
- MavenProject project = (MavenProject) element;
- IMavenProjectFacade search = MavenPlugin.getDefault().getMavenProjectRegistry()
- .getMavenProject(project.getGroupId(), project.getArtifactId(), project.getVersion());
- if(search == null) {
- // This project is not in the workspace
- return Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY);
- }
- }
- return null;
- }
-
- public Color getBackground(Object element) {
- return null;
- }
- }
-
- public static class PomHeirarchyContentProvider implements ITreeContentProvider {
- private LinkedList<MavenProject> projects;
-
- public PomHeirarchyContentProvider() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if(newInput instanceof LinkedList) {
- this.projects = (LinkedList<MavenProject>) newInput;
- }
- }
-
- public void dispose() {
- }
-
- public boolean hasChildren(Object element) {
- Object[] children = getChildren(element);
-
- return children.length != 0;
- }
-
- public Object getParent(Object element) {
- if(element instanceof MavenProject) {
- MavenProject project = (MavenProject) element;
- return project.getParent();
- }
- return null;
- }
-
- /*
- * Return root element (non-Javadoc)
- *
- * @see
- * org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang
- * .Object)
- */
- public Object[] getElements(Object inputElement) {
-
- if(inputElement instanceof LinkedList) {
- LinkedList<MavenProject> projects = (LinkedList<MavenProject>) inputElement;
- if(projects.isEmpty()) {
- return new Object[0];
- }
- return new Object[] {projects.getLast()};
- }
- return new Object[0];
- }
-
- public Object[] getChildren(Object parentElement) {
- if(parentElement instanceof MavenProject) {
- /*
- * Walk the hierarchy list until we find the parentElement and
- * return the previous element, which is the child.
- */
- MavenProject parent = (MavenProject) parentElement;
-
- if(projects.size() == 1) {
- // No parent exists, only one element in the tree
- return new Object[0];
- }
-
- if(projects.getFirst().equals(parent)) {
- // We are the final child
- return new Object[0];
- }
-
- ListIterator<MavenProject> iter = projects.listIterator();
- while(iter.hasNext()) {
- MavenProject next = iter.next();
- if(next.equals(parent)) {
- iter.previous();
- MavenProject previous = iter.previous();
- return new Object[] {previous};
- }
- }
- }
- return new Object[0];
- }
- }
-
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- pomsViewer.addSelectionChangedListener(listener);
- }
-
- public Object getInput() {
- return pomsViewer.getInput();
- }
-
- public ISelection getSelection() {
- return pomsViewer.getSelection();
- }
-
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- pomsViewer.removeSelectionChangedListener(listener);
- }
-
- public void setSelection(ISelection selection) {
- pomsViewer.setSelection(selection);
- }
-
- public List<MavenProject> getHierarchy() {
- return hierarchy;
- }
-}
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/ManageDependenciesDialog.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/ManageDependenciesDialog.java
index 444b6304..6e19c569 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/ManageDependenciesDialog.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/ManageDependenciesDialog.java
@@ -46,6 +46,7 @@ import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.m2e.core.ui.internal.components.PomHierarchyComposite;
import org.eclipse.m2e.core.ui.internal.dialogs.AbstractMavenDialog;
import org.eclipse.m2e.core.ui.internal.editing.PomEdits.CompoundOperation;
import org.eclipse.m2e.core.ui.internal.editing.PomEdits.Operation;
@@ -54,7 +55,6 @@ import org.eclipse.m2e.core.ui.internal.editing.PomHelper;
import org.eclipse.m2e.editor.MavenEditorPlugin;
import org.eclipse.m2e.editor.composites.DependencyLabelProvider;
import org.eclipse.m2e.editor.composites.ListEditorContentProvider;
-import org.eclipse.m2e.editor.composites.PomHierarchyComposite;
import org.eclipse.m2e.editor.pom.ValueProvider;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;

Back to the top