Author: hibou
Date: Tue Sep 1 14:59:56 2009
New Revision: 810082
URL: http://svn.apache.org/viewvc?rev=810082&view=rev
Log:
IVYDE-194 : Add "Resolve Dependencies" extension to Java Project in the Package
Explorer
Added:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/IvyDEProjectAction.java
(with props)
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/IvyDEProjectMenuAction.java
(with props)
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/ProjectResolveAction.java
(with props)
Modified:
ant/ivy/ivyde/trunk/CHANGES.txt
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/plugin.xml
Modified: ant/ivy/ivyde/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/CHANGES.txt?rev=810082&r1=810081&r2=810082&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/CHANGES.txt (original)
+++ ant/ivy/ivyde/trunk/CHANGES.txt Tue Sep 1 14:59:56 2009
@@ -4,6 +4,7 @@
version 2.1.0
==========================
- NEW: Inclusion of Ivy related schemas into the Eclipse XML Catalog
(IVYDE-190) (thanks to Miguel Griffa)
+- NEW: Add "Resolve Dependencies" extension to Java Project in the Package
Explorer (IVYDE-153) (thanks to Jon Schneider and Troy Gaines)
- FIX: "Ivy Settings Path" Browse button results in an incorrectly formatted
URL (IVYDE-191) (thanks to Jon Schneider)
- FIX: Workspace Resolver Prevents Source Download (IVYDE-188) (thanks to
Phillip Webb)
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/plugin.xml
URL:
http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/plugin.xml?rev=810082&r1=810081&r2=810082&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/plugin.xml (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/plugin.xml Tue Sep 1 14:59:56
2009
@@ -89,6 +89,20 @@
class="org.apache.ivyde.eclipse.ui.actions.ResolveAction"
enablesFor="1"
/>
+ </objectContribution>
+ <objectContribution
+ adaptable="true"
+ id="org.apache.ivyde.eclipse.ui.actions.ProjectMenuAction"
+ nameFilter="*"
+ objectClass="org.eclipse.core.resources.IProject">
+ <action
+
class="org.apache.ivyde.eclipse.ui.actions.IvyDEProjectMenuAction"
+ enablesFor="+"
+ id="org.apache.ivyde.eclipse.ui.actions.IvyDEProjectMenuAction"
+ label="Ivy"
+ menubarPath="additions"
+ tooltip="Ivy Dependency Manager">
+ </action>
</objectContribution>
<objectContribution
id="org.apache.ivyde.eclipse.ui.actions.OpenIvyFileAction"
Added:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/IvyDEProjectAction.java
URL:
http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/IvyDEProjectAction.java?rev=810082&view=auto
==============================================================================
---
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/IvyDEProjectAction.java
(added)
+++
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/IvyDEProjectAction.java
Tue Sep 1 14:59:56 2009
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ivyde.eclipse.ui.actions;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IActionDelegate;
+
+/**
+ * Abstract class for helping with project delegation of actions <br>
+ */
+public abstract class IvyDEProjectAction implements IActionDelegate {
+ protected abstract void selectionChanged(IAction action, IProject[]
projects);
+
+ /**
+ * @see
org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
+ * org.eclipse.jface.viewers.ISelection)
+ */
+ public final void selectionChanged(IAction action, ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ Collection/*<IProject>*/ projects = new ArrayList/*<IProject>*/();
+
+ for (Iterator it = ((IStructuredSelection) selection).iterator();
it.hasNext();) {
+ Object element = it.next();
+ IProject project = null;
+ if (element instanceof IProject) {
+ project = (IProject) element;
+ } else if (element instanceof IAdaptable) {
+ project = (IProject) ((IAdaptable)
element).getAdapter(IProject.class);
+ }
+
+ if (project != null) {
+ // TODO validate a project's "Ivy nature" here (has an
ivy.xml or an ivy classpath container)
+ projects.add(project);
+ }
+ }
+
+ if(projects.size() > 0) {
+ action.setEnabled(true);
+ selectionChanged(action, (IProject[]) projects.toArray(new
IProject[projects.size()]));
+ }
+ else {
+ action.setEnabled(false);
+ }
+ }
+ }
+}
Propchange:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/IvyDEProjectAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/IvyDEProjectAction.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/IvyDEProjectAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/IvyDEProjectMenuAction.java
URL:
http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/IvyDEProjectMenuAction.java?rev=810082&view=auto
==============================================================================
---
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/IvyDEProjectMenuAction.java
(added)
+++
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/IvyDEProjectMenuAction.java
Tue Sep 1 14:59:56 2009
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ivyde.eclipse.ui.actions;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.events.MenuListener;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+
+public class IvyDEProjectMenuAction extends IvyDEProjectAction implements
IMenuCreator {
+ private boolean selectionChanged;
+ private IAction proxyAction;
+ private IProject[] projects;
+
+ private MenuListener menuListener = new MenuAdapter() {
+ public void menuShown(MenuEvent e) {
+ if (selectionChanged) {
+ Menu m = (Menu) e.widget;
+ MenuItem[] items = m.getItems();
+ for (int i = 0; i < items.length; i++) {
+ items[i].dispose();
+ }
+ fill(m, projects);
+ selectionChanged = false;
+ }
+ }
+ };
+
+ protected void fill(Menu menu, IProject[] projects) {
+ ProjectResolveAction resolveAction = new
ProjectResolveAction(projects);
+ new ActionContributionItem(resolveAction).fill(menu, -1);
+ }
+
+ public Menu getMenu(Control parent) {
+ Menu menu = new Menu(parent);
+ fill(menu, projects);
+ menu.addMenuListener(menuListener);
+ return menu;
+ }
+
+ public Menu getMenu(Menu parent) {
+ Menu menu = new Menu(parent);
+ fill(menu, projects);
+ menu.addMenuListener(menuListener);
+ return menu;
+ }
+
+ protected void selectionChanged(IAction a, IProject[] projects) {
+ this.projects = projects;
+ selectionChanged = true;
+ if (proxyAction != a) {
+ proxyAction = a;
+ proxyAction.setMenuCreator(this);
+ }
+ }
+
+ public void run(IAction action) {
+ // nothing to run
+ }
+
+ public void dispose() {
+ // nothing to dispose
+ }
+}
Propchange:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/IvyDEProjectMenuAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/IvyDEProjectMenuAction.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/IvyDEProjectMenuAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/ProjectResolveAction.java
URL:
http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/ProjectResolveAction.java?rev=810082&view=auto
==============================================================================
---
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/ProjectResolveAction.java
(added)
+++
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/ProjectResolveAction.java
Tue Sep 1 14:59:56 2009
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ivyde.eclipse.ui.actions;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
+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.SubProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.action.Action;
+
+public class ProjectResolveAction extends Action {
+ IProject[] projects;
+
+ public ProjectResolveAction(IProject[] projects) {
+ this.projects = projects;
+ this.setText("Resolve");
+ }
+
+ public void run() {
+ final IProject[] finalProjects = projects;
+
+ Job multipleResolveJob = new Job("Resolving dependencies") {
+ protected IStatus run(IProgressMonitor monitor) {
+ for (int i = 0; i < finalProjects.length; i++) {
+ IJavaProject javaProject =
JavaCore.create(finalProjects[i]);
+ if (javaProject == null)
+ continue;
+
+ List/* <IvyClasspathContainer> */classpathContainers =
IvyClasspathUtil
+ .getIvyClasspathContainers(javaProject);
+
+ Iterator containerIterator =
classpathContainers.iterator();
+ while (containerIterator.hasNext()) {
+ if (monitor.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ }
+ SubProgressMonitor subMonitor = new
SubProgressMonitor(monitor, 1);
+ IvyClasspathContainer container =
(IvyClasspathContainer) containerIterator
+ .next();
+ container.launchResolve(false, true, subMonitor);
+ }
+ }
+
+ return Status.OK_STATUS;
+ }
+ };
+
+ multipleResolveJob.setUser(true);
+ multipleResolveJob.schedule();
+ }
+}
Propchange:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/ProjectResolveAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/ProjectResolveAction.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/ProjectResolveAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain