You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by hi...@apache.org on 2010/08/21 22:20:33 UTC
svn commit: r987823 [1/2] - in
/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse: ./ META-INF/
src/java/org/apache/ivyde/eclipse/
src/java/org/apache/ivyde/eclipse/conditions/
src/java/org/apache/ivyde/eclipse/cpcontainer/
src/java/org/apache/ivyde/eclipse...
Author: hibou
Date: Sat Aug 21 20:20:32 2010
New Revision: 987823
URL: http://svn.apache.org/viewvc?rev=987823&view=rev
Log:
Some refactoring about IvyDE's context menu:
* use eclipse 3.3 extension menu, said to be more flexible
* add an Ivy nature
* menus are now the same for classpath containers, projects and working sets
Use eclipse 3.3 extension menu, said to be more flexible
Added:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyNature.java (with props)
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/conditions/
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/conditions/IvyDEConditionTester.java (with props)
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/AbstractIvyDEHandler.java (with props)
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/AddIvyNatureHandler.java (with props)
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/CreateContainerHandler.java (with props)
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/OpenIvyFileHandler.java (with props)
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RefreshHandler.java (with props)
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ReloadSettingsHandler.java (with props)
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RemoveIvyNatureHandler.java (with props)
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveAllHandler.java (with props)
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveHandler.java (with props)
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ViewReverseDependenciesHandler.java (with props)
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/CleanCacheAction.java (with props)
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/CleanCacheContributionItem.java (with props)
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/IvyMenuAction.java (with props)
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/IvyMenuContributionItem.java (with props)
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/IvyMenuSeparator.java (with props)
Removed:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/
Modified:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/META-INF/MANIFEST.MF
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/plugin.xml
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/META-INF/MANIFEST.MF?rev=987823&r1=987822&r2=987823&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/META-INF/MANIFEST.MF (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/META-INF/MANIFEST.MF Sat Aug 21 20:20:32 2010
@@ -9,7 +9,6 @@ Bundle-Vendor: Apache Software Foundatio
Export-Package: org.apache.ivyde.eclipse,
org.apache.ivyde.eclipse.cpcontainer,
org.apache.ivyde.eclipse.cpcontainer.fragmentinfo,
- org.apache.ivyde.eclipse.ui.actions,
org.apache.ivyde.eclipse.ui.console,
org.apache.ivyde.eclipse.ui.core,
org.apache.ivyde.eclipse.ui.editors,
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=987823&r1=987822&r2=987823&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/plugin.xml (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/plugin.xml Sat Aug 21 20:20:32 2010
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
+<?eclipse version="3.3"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -58,86 +58,6 @@
</classpathContainerInitializer>
</extension>
- <extension point="org.eclipse.ui.popupMenus">
- <objectContribution
- adaptable="false"
- id="org.apache.ivyde.eclipse.ui.actions.ReloadSettingsAction"
- objectClass="org.eclipse.jdt.internal.ui.packageview.ClassPathContainer">
- <action
- class="org.apache.ivyde.eclipse.ui.actions.ReloadSettingsAction"
- enablesFor="1"
- id="org.apache.ivyde.eclipse.ui.actions.ReloadSettingsAction"
- label="Reload &settings">
- </action>
- </objectContribution>
- <objectContribution
- id="org.apache.ivyde.eclipse.ui.actions.RefreshAction"
- objectClass="org.eclipse.jdt.internal.ui.packageview.ClassPathContainer">
- <action
- id="org.apache.ivyde.eclipse.ui.actions.RefreshAction"
- label="Re&fresh"
- class="org.apache.ivyde.eclipse.ui.actions.RefreshAction"
- enablesFor="1"
- />
- </objectContribution>
- <objectContribution
- id="org.apache.ivyde.eclipse.ui.actions.ResolveAction"
- objectClass="org.eclipse.jdt.internal.ui.packageview.ClassPathContainer">
- <action
- id="org.apache.ivyde.eclipse.ui.actions.ResolveAction"
- label="&Resolve"
- 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="+"
- icon="icons/logo16x16.gif"
- id="org.apache.ivyde.eclipse.ui.actions.IvyDEProjectMenuAction"
- label="Ivy"
- menubarPath="additions"
- style="pulldown"
- tooltip="Ivy Dependency Manager">
- </action>
- </objectContribution>
- <objectContribution
- id="org.apache.ivyde.eclipse.ui.actions.OpenIvyFileAction"
- objectClass="org.eclipse.jdt.internal.ui.packageview.ClassPathContainer">
- <action
- id="org.apache.ivyde.eclipse.ui.actions.OpenIvyFileAction"
- label="&Edit"
- class="org.apache.ivyde.eclipse.ui.actions.OpenIvyFileAction"
- enablesFor="1"
- />
- </objectContribution>
- <objectContribution
- id="org.apache.ivyde.eclipse.ui.actions.CreateContainerAction"
- objectClass="org.eclipse.core.resources.IFile"
- nameFilter="*.xml">
- <action
- id="org.apache.ivyde.eclipse.ui.actions.CreateContainerAction"
- label="Add &Ivy Library..."
- class="org.apache.ivyde.eclipse.ui.actions.CreateContainerAction"
- enablesFor="1"
- />
- </objectContribution>
- <objectContribution
- adaptable="false"
- id="org.apache.ivyde.eclipse.ui.actions.CleanCacheMenuAction"
- objectClass="org.eclipse.jdt.internal.ui.packageview.ClassPathContainer">
- <action
- class="org.apache.ivyde.eclipse.ui.actions.CleanCacheMenuAction"
- id="org.apache.ivyde.eclipse.ui.actions.CleanCacheMenuAction"
- label="Clean Ivy cache">
- </action>
- </objectContribution>
- </extension>
<extension
point="org.eclipse.ui.editors">
@@ -241,28 +161,7 @@
</view>
</extension>
- <extension point = "org.eclipse.ui.actionSets">
- <actionSet id="org.apache.ivyde.eclipse.ui.actions.actionSet"
- label="IvyDE Actions"
- visible="true">
- <action id="org.apache.ivyde.eclipse.ui.actions.resolveAll"
- toolbarPath="readme"
- label="Resolve All Dependencies"
- icon="icons/resolve-all.gif"
- class="org.apache.ivyde.eclipse.ui.actions.ResolveAllAction"
- definitionID="org.apache.ivyde.eclipse.ui.actions.resolveAll">
- </action>
- </actionSet>
- </extension>
- <extension point="org.eclipse.ui.commands">
- <command
- name="Resolve All Dependencies"
- description="Resolve All Project Dependencies with Ivy"
- categoryId="org.eclipse.ui.category.project"
- id="org.apache.ivyde.eclipse.ui.actions.resolveAll">
- </command>
- </extension>
<extension
point="org.eclipse.help.toc">
<toc
@@ -308,6 +207,238 @@
variable="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER">
</runtimeClasspathEntryResolver>
</extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <category
+ id="org.apache.ivyde.commands"
+ name="IvyDE commands">
+ </category>
+ <command
+ categoryId="org.apache.ivyde.commands"
+ id="org.apache.ivyde.commands.resolve"
+ name="Resolve">
+ </command>
+ <command
+ categoryId="org.apache.ivyde.commands"
+ id="org.apache.ivyde.commands.refresh"
+ name="Refresh">
+ </command>
+ <command
+ categoryId="org.apache.ivyde.commands"
+ id="org.apache.ivyde.commands.reloadsettings"
+ name="Reload settings">
+ </command>
+ <command
+ categoryId="org.apache.ivyde.commands"
+ id="org.apache.ivyde.commands.resolveall"
+ name="Resolve All">
+ </command>
+ <command
+ categoryId="org.apache.ivyde.commands"
+ id="org.apache.ivyde.commands.openivyfile"
+ name="Open Ivy file">
+ </command>
+ <command
+ categoryId="org.apache.ivyde.commands"
+ id="org.apache.ivyde.commands.revdepexplorer"
+ name="Show in Reverse Dependency Explorer">
+ </command>
+ <command
+ categoryId="org.apache.ivyde.commands"
+ id="org.apache.ivyde.commands.createcontainer"
+ name="Add Ivy Library...">
+ </command>
+ <command
+ categoryId="org.apache.ivyde.commands"
+ id="org.apache.ivyde.commands.addivynature"
+ name="Add Ivy dependency management">
+ </command>
+ <command
+ categoryId="org.apache.ivyde.commands"
+ id="org.apache.ivyde.commands.removeivynature"
+ name="Remove Ivy dependency management...">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.apache.ivyde.eclipse.handlers.ResolveHandler"
+ commandId="org.apache.ivyde.commands.resolve">
+ </handler>
+ <handler
+ class="org.apache.ivyde.eclipse.handlers.RefreshHandler"
+ commandId="org.apache.ivyde.commands.refresh">
+ </handler>
+ <handler
+ class="org.apache.ivyde.eclipse.handlers.ReloadSettingsHandler"
+ commandId="org.apache.ivyde.commands.reloadsettings">
+ </handler>
+ <handler
+ class="org.apache.ivyde.eclipse.handlers.ResolveAllHandler"
+ commandId="org.apache.ivyde.commands.resolveall">
+ </handler>
+ <handler
+ class="org.apache.ivyde.eclipse.handlers.OpenIvyFileHandler"
+ commandId="org.apache.ivyde.commands.openivyfile">
+ </handler>
+ <handler
+ class="org.apache.ivyde.eclipse.handlers.ViewReverseDependenciesHandler"
+ commandId="org.apache.ivyde.commands.revdepexplorer">
+ </handler>
+ <handler
+ class="org.apache.ivyde.eclipse.handlers.CreateContainerHandler"
+ commandId="org.apache.ivyde.commands.createcontainer">
+ </handler>
+ <handler
+ class="org.apache.ivyde.eclipse.handlers.AddIvyNatureHandler"
+ commandId="org.apache.ivyde.commands.addivynature">
+ </handler>
+ <handler
+ class="org.apache.ivyde.eclipse.handlers.RemoveIvyNatureHandler"
+ commandId="org.apache.ivyde.commands.removeivynature">
+ </handler>
+ </extension>
+ <extension
+ point="org.eclipse.core.expressions.definitions">
+ <definition
+ id="org.apache.ivyde.definition.ivyproject">
+ <iterate
+ ifEmpty="false"
+ operator="or">
+ <adapt
+ type="org.eclipse.core.resources.IProject">
+ <test
+ property="org.eclipse.core.resources.projectNature"
+ value="org.apache.ivyde.eclipse.ivyNature">
+ </test>
+ </adapt>
+ </iterate>
+ </definition>
+ <definition
+ id="org.apache.ivyde.definition.nonivyproject">
+ <iterate>
+ <adapt
+ type="org.eclipse.core.resources.IProject">
+ <not>
+ <test
+ property="org.eclipse.core.resources.projectNature"
+ value="org.apache.ivyde.eclipse.ivyNature">
+ </test>
+ </not>
+ </adapt>
+ </iterate>
+ </definition>
+ <definition
+ id="org.apache.ivyde.definition.ivycontainer">
+ <iterate
+ ifEmpty="false"
+ operator="or">
+ <instanceof
+ value="org.eclipse.jdt.internal.ui.packageview.ClassPathContainer">
+ </instanceof>
+ </iterate>
+ </definition>
+ <definition
+ id="org.apache.ivyde.definition.workingset">
+ <iterate
+ ifEmpty="false"
+ operator="or">
+ <adapt
+ type="org.eclipse.ui.IWorkingSet">
+ </adapt>
+ </iterate>
+ </definition>
+ <definition
+ id="org.apache.ivyde.definition.ivyfile">
+ <and>
+ <iterate
+ ifEmpty="false"
+ operator="or">
+ <adapt
+ type="org.eclipse.core.resources.IFile">
+ <test
+ property="org.eclipse.core.resources.name"
+ value="*.xml">
+ </test>
+ </adapt>
+ </iterate>
+ <count
+ value="1">
+ </count>
+ </and>
+ </definition>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.eclipse.ui.popup.any?after=additions">
+ <command
+ commandId="org.apache.ivyde.commands.createcontainer"
+ label="Add Ivy Library..."
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.apache.ivyde.definition.ivyfile">
+ </reference>
+ </visibleWhen>
+ </command>
+ <dynamic
+ class="org.apache.ivyde.eclipse.ui.menu.IvyMenuContributionItem"
+ id="org.apache.ivyde.eclipse.ivymenu">
+ <visibleWhen
+ checkEnabled="false">
+ <or>
+ <reference
+ definitionId="org.apache.ivyde.definition.ivyproject">
+ </reference>
+ <reference
+ definitionId="org.apache.ivyde.definition.ivycontainer">
+ </reference>
+ <reference
+ definitionId="org.apache.ivyde.definition.workingset">
+ </reference>
+ </or>
+ </visibleWhen>
+ </dynamic>
+ </menuContribution>
+ <menuContribution
+ locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
+ <toolbar
+ id="org.apache.ivyde.eclipse.toolbar">
+ <command
+ commandId="org.apache.ivyde.commands.resolveall"
+ icon="icons/resolve-all.gif"
+ label="Resolve all"
+ style="push">
+ </command>
+ </toolbar>
+ </menuContribution>
+ <menuContribution
+ locationURI="popup:org.eclipse.ui.projectConfigure?after=additions">
+ <command
+ commandId="org.apache.ivyde.commands.addivynature"
+ label="Add Ivy dependency management"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <reference
+ definitionId="org.apache.ivyde.definition.nonivyproject">
+ </reference>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+ <extension
+ id="ivyNature"
+ name="Ivy nature"
+ point="org.eclipse.core.resources.natures">
+ <runtime>
+ <run
+ class="org.apache.ivyde.eclipse.IvyNature">
+ </run>
+ </runtime>
+ </extension>
<!--
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyNature.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyNature.java?rev=987823&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyNature.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyNature.java Sat Aug 21 20:20:32 2010
@@ -0,0 +1,145 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+
+public class IvyNature implements IProjectNature {
+
+ public static final String IVY_NATURE = "org.apache.ivyde.eclipse.ivyNature";
+
+ private IProject project;
+
+ public IProject getProject() {
+ return project;
+ }
+
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+ public void configure() throws CoreException {
+ // nothin to do
+ }
+
+ public void deconfigure() throws CoreException {
+ IJavaProject javaProject = JavaCore.create(project);
+ if (!javaProject.exists()) {
+ return;
+ }
+ IClasspathEntry[] classpathEntries = javaProject.getRawClasspath();
+ List newEntries = new ArrayList();
+
+ for (int i = 0; i < classpathEntries.length; i++) {
+ if (!IvyClasspathUtil.isIvyClasspathContainer(classpathEntries[i].getPath())) {
+ newEntries.add(classpathEntries[i]);
+ }
+ }
+
+ if (newEntries.size() != classpathEntries.length) {
+ IClasspathEntry[] newClasspathEntries = (IClasspathEntry[]) newEntries
+ .toArray(new IClasspathEntry[newEntries.size()]);
+ javaProject.setRawClasspath(newClasspathEntries, null);
+ }
+ }
+
+ public static boolean hasNature(IProject project) {
+ try {
+ return project.hasNature(IVY_NATURE);
+ } catch (CoreException e) {
+ IvyPlugin.log(IStatus.ERROR, "Unable to get the Ivy nature of the project "
+ + project.getName(), e);
+ return false;
+ }
+ }
+
+ public static void addNature(final IProject project) {
+ try {
+ if (hasNature(project)) {
+ return;
+ }
+
+ final IProjectDescription description = project.getDescription();
+ final String[] ids = description.getNatureIds();
+
+ final String[] newIds = new String[ids == null ? 1 : ids.length + 1];
+ if (ids != null) {
+ System.arraycopy(ids, 0, newIds, 0, ids.length);
+ }
+ newIds[ids == null ? 0 : ids.length] = IVY_NATURE;
+
+ description.setNatureIds(newIds);
+ project.setDescription(description, null);
+ } catch (Exception e) {
+ IvyPlugin.log(IStatus.ERROR, "Failed to add Ivy dependency management on "
+ + project.getName(), e);
+ }
+ }
+
+ public static void removeNature(final IProject project) {
+ try {
+ if (!hasNature(project)) {
+ return;
+ }
+
+ final IProjectDescription description = project.getDescription();
+ final String[] ids = description.getNatureIds();
+ if (ids == null || ids.length == 0) {
+ // wtf ? it has the Ivy nature but there is none ?
+ return;
+ }
+
+ int i;
+ for (i = 0; i < ids.length; i++) {
+ if (IVY_NATURE.equals(ids[i])) {
+ break;
+ }
+ }
+ if (i == ids.length) {
+ // wtf ? it has the Ivy nature but we cannot find it ?
+ return;
+ }
+
+ final String[] newIds = new String[ids.length - 1];
+ if (i > 0) {
+ System.arraycopy(ids, 0, newIds, 0, i);
+ }
+ if (i < ids.length - 1) {
+ System.arraycopy(ids, i + 1, newIds, i, ids.length - i - 1);
+ }
+
+ description.setNatureIds(newIds);
+ project.setDescription(description, null);
+ } catch (Exception e) {
+ IvyPlugin.log(IStatus.ERROR, "Failed to remove Ivy dependency management on "
+ + project.getName(), e);
+ }
+ }
+
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyNature.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyNature.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyNature.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/conditions/IvyDEConditionTester.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/conditions/IvyDEConditionTester.java?rev=987823&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/conditions/IvyDEConditionTester.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/conditions/IvyDEConditionTester.java Sat Aug 21 20:20:32 2010
@@ -0,0 +1,42 @@
+/*
+ * 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.conditions;
+
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.internal.ui.packageview.ClassPathContainer;
+
+public class IvyDEConditionTester extends PropertyTester {
+
+ public static final String PROPERTY_IVYPROJECT = "ivyproject"; //$NON-NLS-1$
+
+ public static final String PROPERTY_IVYCP = "ivycp"; //$NON-NLS-1$
+
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if (property.equals(PROPERTY_IVYPROJECT)) {
+ IProject project = (IProject) receiver;
+ return !IvyClasspathUtil.getIvyClasspathContainers(project).isEmpty();
+ } else if (property.equals(PROPERTY_IVYCP)) {
+ ClassPathContainer cp = (ClassPathContainer) receiver;
+ return IvyClasspathUtil.isIvyClasspathContainer(cp.getClasspathEntry().getPath());
+ }
+ return false;
+ }
+
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/conditions/IvyDEConditionTester.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/conditions/IvyDEConditionTester.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/conditions/IvyDEConditionTester.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java?rev=987823&r1=987822&r2=987823&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java Sat Aug 21 20:20:32 2010
@@ -27,6 +27,7 @@ import java.util.Collections;
import java.util.List;
import org.apache.ivyde.eclipse.FakeProjectManager;
+import org.apache.ivyde.eclipse.IvyNature;
import org.apache.ivyde.eclipse.IvyPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
@@ -58,6 +59,9 @@ public final class IvyClasspathContainer
loadV1(conf, path);
}
conf.setAttributes(attributes);
+
+ // ensure that the project has the Ivy nature
+ IvyNature.addNature(conf.getJavaProject().getProject());
}
/**
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/AbstractIvyDEHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/AbstractIvyDEHandler.java?rev=987823&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/AbstractIvyDEHandler.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/AbstractIvyDEHandler.java Sat Aug 21 20:20:32 2010
@@ -0,0 +1,123 @@
+/*
+ * 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.handlers;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.internal.ui.packageview.ClassPathContainer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public abstract class AbstractIvyDEHandler extends AbstractHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (!(selection instanceof IStructuredSelection)) {
+ return null;
+ }
+
+ Map/* <IProject, Set<IvyClasspathContainer>> */projects = getProjectAndContainers((IStructuredSelection) selection);
+
+ if (projects.size() > 0) {
+ handleProjects(projects);
+ }
+
+ return null;
+ }
+
+ public static Map/* <IProject, Set<IvyClasspathContainer>> */getProjectAndContainers(
+ IStructuredSelection selection) {
+ Map/* <IProject, Set<IvyClasspathContainer>> */projects = new HashMap();
+
+ Iterator it = selection.iterator();
+ while (it.hasNext()) {
+ Object element = it.next();
+ if (element instanceof IWorkingSet) {
+ IAdaptable[] elements = ((IWorkingSet) element).getElements();
+ for (int i = 0; i < elements.length; i++) {
+ addElement(projects, elements[i]);
+ }
+ } else if (element instanceof ClassPathContainer) {
+ IvyClasspathContainer ivycp = IvyClasspathUtil
+ .jdt2IvyCPC(((ClassPathContainer) element));
+ IJavaProject javaProject = ivycp.getConf().getJavaProject();
+ Set/* <IvyClasspathContainer> */cplist = (Set) projects.get(javaProject
+ .getProject());
+ if (cplist == null) {
+ cplist = new HashSet();
+ projects.put(javaProject.getProject(), cplist);
+ }
+ cplist.add(ivycp);
+ } else {
+ addElement(projects, element);
+ }
+ }
+
+ return projects;
+ }
+
+ private static void addElement(Map/* <IProject, Set<IvyClasspathContainer>> */projects,
+ Object adaptableProject) {
+ IProject project = null;
+ if (adaptableProject instanceof IProject) {
+ project = (IProject) adaptableProject;
+ } else if (adaptableProject instanceof IAdaptable) {
+ project = (IProject) ((IAdaptable) adaptableProject).getAdapter(IProject.class);
+ }
+ if (project != null) {
+ // check that there is an IvyDE container
+ List containers = IvyClasspathUtil.getIvyClasspathContainers(project);
+ if (!containers.isEmpty()) {
+ projects.put(project, new HashSet(containers));
+ }
+ }
+ }
+
+ protected void handleProjects(Map projects) {
+ Iterator it = projects.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry entry = (Entry) it.next();
+ Iterator itContainers = ((Set) entry.getValue()).iterator();
+ while (itContainers.hasNext()) {
+ handleContainer((IProject) entry.getKey(), (IvyClasspathContainer) itContainers
+ .next());
+ }
+ }
+ }
+
+ protected void handleContainer(IProject project, IvyClasspathContainer cp) {
+ throw new UnsupportedOperationException();
+ }
+
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/AbstractIvyDEHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/AbstractIvyDEHandler.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/AbstractIvyDEHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/AddIvyNatureHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/AddIvyNatureHandler.java?rev=987823&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/AddIvyNatureHandler.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/AddIvyNatureHandler.java Sat Aug 21 20:20:32 2010
@@ -0,0 +1,70 @@
+/*
+ * 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.handlers;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.ivyde.eclipse.IvyNature;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class AddIvyNatureHandler extends AbstractHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (!(selection instanceof IStructuredSelection)) {
+ return null;
+ }
+
+ List/* <IProject> */projects = new LinkedList();
+ IStructuredSelection newSelection = (IStructuredSelection) selection;
+ Iterator iter = newSelection.iterator();
+ while (iter.hasNext()) {
+ Object object = iter.next();
+ if (object instanceof IAdaptable) {
+ IProject project = (IProject) ((IAdaptable) object).getAdapter(IProject.class);
+ if (project != null) {
+ projects.add(project);
+ } else {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ if (projects.size() > 0) {
+ Iterator itProject = projects.iterator();
+ while (itProject.hasNext()) {
+ IProject project = (IProject) itProject.next();
+ IvyNature.addNature(project);
+ }
+ }
+
+ return null;
+ }
+
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/AddIvyNatureHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/AddIvyNatureHandler.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/AddIvyNatureHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/CreateContainerHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/CreateContainerHandler.java?rev=987823&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/CreateContainerHandler.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/CreateContainerHandler.java Sat Aug 21 20:20:32 2010
@@ -0,0 +1,54 @@
+/*
+ * 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.handlers;
+
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.apache.ivyde.eclipse.ui.NewIvyDEContainerWizard;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class CreateContainerHandler extends AbstractHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (!(selection instanceof IStructuredSelection)) {
+ return null;
+ }
+
+ IStructuredSelection s = (IStructuredSelection) selection;
+ Object o = s.getFirstElement();
+ if (o instanceof IFile) {
+ IFile f = (IFile) o;
+ IJavaProject javaProject = JavaCore.create(f.getProject());
+ WizardDialog dialog = new WizardDialog(IvyPlugin.getActiveWorkbenchShell(),
+ new NewIvyDEContainerWizard(javaProject, f));
+ dialog.open();
+ }
+
+ return null;
+ }
+
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/CreateContainerHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/CreateContainerHandler.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/CreateContainerHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/OpenIvyFileHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/OpenIvyFileHandler.java?rev=987823&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/OpenIvyFileHandler.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/OpenIvyFileHandler.java Sat Aug 21 20:20:32 2010
@@ -0,0 +1,76 @@
+/*
+ * 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.handlers;
+
+import org.apache.ivyde.eclipse.FakeProjectManager;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainerConfiguration;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.part.FileEditorInput;
+
+public class OpenIvyFileHandler extends AbstractIvyDEHandler {
+
+ public static final String COMMAND_ID = "org.apache.ivyde.commands.openivyfile";
+
+ protected void handleContainer(IProject project, IvyClasspathContainer cp) {
+ IvyClasspathContainerConfiguration conf = cp.getConf();
+ if (FakeProjectManager.isFake(conf.getJavaProject())) {
+ return;
+ }
+ IFile file = conf.getJavaProject().getProject().getFile(conf.getIvyXmlPath());
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ if (file != null) {
+ try {
+ String editorId = "org.apache.ivyde.editors.IvyEditor";
+ page.openEditor(new FileEditorInput(file), editorId, true);
+ // only remember the default editor if the open succeeds
+ IDE.setDefaultEditor(file, editorId);
+ } catch (PartInitException e) {
+ Shell parent = page.getWorkbenchWindow().getShell();
+ String title = "Problems Opening Editor";
+ String message = e.getMessage();
+ // Check for a nested CoreException
+ CoreException nestedException = null;
+ IStatus status = e.getStatus();
+ if (status != null && status.getException() instanceof CoreException) {
+ nestedException = (CoreException) status.getException();
+ }
+ if (nestedException != null) {
+ // Open an error dialog and include the extra
+ // status information from the nested CoreException
+ ErrorDialog.openError(parent, title, message, nestedException.getStatus());
+ } else {
+ // Open a regular error dialog since there is no
+ // extra information to display
+ MessageDialog.openError(parent, title, message);
+ }
+ }
+ }
+ }
+
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/OpenIvyFileHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/OpenIvyFileHandler.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/OpenIvyFileHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RefreshHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RefreshHandler.java?rev=987823&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RefreshHandler.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RefreshHandler.java Sat Aug 21 20:20:32 2010
@@ -0,0 +1,41 @@
+/*
+ * 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.handlers;
+
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+import org.apache.ivyde.eclipse.cpcontainer.IvyResolveJob;
+import org.apache.ivyde.eclipse.cpcontainer.ResolveRequest;
+import org.eclipse.core.resources.IProject;
+
+public class RefreshHandler extends AbstractIvyDEHandler {
+
+ public static final String COMMAND_ID = "org.apache.ivyde.commands.refresh";
+
+ private IvyResolveJob resolveJob;
+
+ public RefreshHandler() {
+ resolveJob = IvyPlugin.getDefault().getIvyResolveJob();
+ }
+
+ protected void handleContainer(IProject project, IvyClasspathContainer ivycp) {
+ ResolveRequest request = new ResolveRequest(ivycp, true);
+ resolveJob.addRequest(request);
+ }
+
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RefreshHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RefreshHandler.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RefreshHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ReloadSettingsHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ReloadSettingsHandler.java?rev=987823&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ReloadSettingsHandler.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ReloadSettingsHandler.java Sat Aug 21 20:20:32 2010
@@ -0,0 +1,31 @@
+/*
+ * 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.handlers;
+
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+import org.eclipse.core.resources.IProject;
+
+public class ReloadSettingsHandler extends AbstractIvyDEHandler {
+
+ public static final String COMMAND_ID = "org.apache.ivyde.commands.reloadsettings";
+
+ protected void handleContainer(IProject project, IvyClasspathContainer cp) {
+ cp.reloadSettings();
+ }
+
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ReloadSettingsHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ReloadSettingsHandler.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ReloadSettingsHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RemoveIvyNatureHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RemoveIvyNatureHandler.java?rev=987823&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RemoveIvyNatureHandler.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RemoveIvyNatureHandler.java Sat Aug 21 20:20:32 2010
@@ -0,0 +1,84 @@
+/*
+ * 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.handlers;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.ivyde.eclipse.IvyNature;
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class RemoveIvyNatureHandler extends AbstractHandler {
+
+ public static final String COMMAND_ID = "org.apache.ivyde.commands.removeivynature";
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (!(selection instanceof IStructuredSelection)) {
+ return null;
+ }
+
+ List/* <IProject> */projects = new LinkedList();
+ IStructuredSelection newSelection = (IStructuredSelection) selection;
+ Iterator iter = newSelection.iterator();
+ while (iter.hasNext()) {
+ Object object = iter.next();
+ if (object instanceof IAdaptable) {
+ IProject project = (IProject) ((IAdaptable) object).getAdapter(IProject.class);
+ if (project != null) {
+ if (IvyNature.hasNature(project)) {
+ projects.add(project);
+ }
+ } else {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ if (projects.size() > 0) {
+ Shell shell = IvyPlugin.getActiveWorkbenchShell();
+ boolean doRemove = MessageDialog.openQuestion(shell,
+ "Remove Ivy dependency management",
+ "Do you want to remove the Ivy dependency management ?\n\n"
+ + "The configuration of the classpath containers will be lost.\n"
+ + "This operation cannot be undone.");
+ if (doRemove) {
+ Iterator itProject = projects.iterator();
+ while (itProject.hasNext()) {
+ IProject project = (IProject) itProject.next();
+ IvyNature.removeNature(project);
+ }
+ }
+ }
+
+ return null;
+ }
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RemoveIvyNatureHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RemoveIvyNatureHandler.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/RemoveIvyNatureHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveAllHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveAllHandler.java?rev=987823&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveAllHandler.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveAllHandler.java Sat Aug 21 20:20:32 2010
@@ -0,0 +1,61 @@
+/*
+ * 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.handlers;
+
+import java.util.Iterator;
+
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
+import org.apache.ivyde.eclipse.cpcontainer.IvyResolveJob;
+import org.apache.ivyde.eclipse.cpcontainer.ResolveRequest;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jdt.core.IJavaModel;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+
+public class ResolveAllHandler extends AbstractHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
+ IJavaProject[] projects;
+ try {
+ projects = model.getJavaProjects();
+ } catch (JavaModelException e) {
+ // TODO deal with it properly
+ return null;
+ }
+
+ IvyResolveJob resolveJob = IvyPlugin.getDefault().getIvyResolveJob();
+ for (int i = 0; i < projects.length; i++) {
+ Iterator it = IvyClasspathUtil.getIvyClasspathContainers(projects[i]).iterator();
+ while (it.hasNext()) {
+ IvyClasspathContainer ivycp = (IvyClasspathContainer) it.next();
+ ResolveRequest request = new ResolveRequest(ivycp, false);
+ resolveJob.addRequest(request);
+ }
+ }
+
+ return null;
+ }
+
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveAllHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveAllHandler.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveAllHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveHandler.java?rev=987823&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveHandler.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveHandler.java Sat Aug 21 20:20:32 2010
@@ -0,0 +1,41 @@
+/*
+ * 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.handlers;
+
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+import org.apache.ivyde.eclipse.cpcontainer.IvyResolveJob;
+import org.apache.ivyde.eclipse.cpcontainer.ResolveRequest;
+import org.eclipse.core.resources.IProject;
+
+public class ResolveHandler extends AbstractIvyDEHandler {
+
+ public static final String COMMAND_ID = "org.apache.ivyde.commands.resolve";
+
+ private IvyResolveJob resolveJob;
+
+ public ResolveHandler() {
+ resolveJob = IvyPlugin.getDefault().getIvyResolveJob();
+ }
+
+ protected void handleContainer(IProject project, IvyClasspathContainer ivycp) {
+ ResolveRequest request = new ResolveRequest(ivycp, false);
+ resolveJob.addRequest(request);
+ }
+
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveHandler.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ResolveHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ViewReverseDependenciesHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ViewReverseDependenciesHandler.java?rev=987823&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ViewReverseDependenciesHandler.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ViewReverseDependenciesHandler.java Sat Aug 21 20:20:32 2010
@@ -0,0 +1,44 @@
+/*
+ * 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.handlers;
+
+import java.util.Map;
+
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.apache.ivyde.eclipse.ui.views.ReverseDependencyExplorerView;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+
+public class ViewReverseDependenciesHandler extends AbstractIvyDEHandler {
+
+ public static final String COMMAND_ID = "org.apache.ivyde.commands.revdepexplorer";
+
+ protected void handleProjects(Map projects) {
+ try {
+ ReverseDependencyExplorerView.setSelectedProjects((IProject[]) projects.keySet()
+ .toArray());
+ IWorkbenchPage page = IvyPlugin.getActivePage();
+ page.showView("org.apache.ivyde.eclipse.ui.views.ReverseDependencyExplorer");
+ ReverseDependencyExplorerView.refresh(true);
+ } catch (PartInitException e) {
+ IvyPlugin.log(IStatus.ERROR, "Error creating Reverse Dependency Explorer", e);
+ }
+ }
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ViewReverseDependenciesHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ViewReverseDependenciesHandler.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/handlers/ViewReverseDependenciesHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/CleanCacheAction.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/CleanCacheAction.java?rev=987823&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/CleanCacheAction.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/CleanCacheAction.java Sat Aug 21 20:20:32 2010
@@ -0,0 +1,103 @@
+/*
+ * 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.menu;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.ivy.core.cache.RepositoryCacheManager;
+import org.apache.ivy.core.cache.ResolutionCacheManager;
+import org.apache.ivyde.eclipse.IvyPlugin;
+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.action.Action;
+
+public class CleanCacheAction extends Action {
+
+ private final List/* <Cleanable> */cleanables;
+
+ public abstract static class Cleanable {
+ public void launchClean() {
+ Job cleanJob = new Job("Cleaning cache " + getName()) {
+ protected IStatus run(IProgressMonitor monitor) {
+ clean();
+ return Status.OK_STATUS;
+ }
+ };
+
+ cleanJob.setUser(true);
+ cleanJob.schedule();
+ }
+
+ protected abstract void clean();
+
+ public abstract String getName();
+ }
+
+ public static class ResolutionCacheCleanable extends Cleanable {
+ private final ResolutionCacheManager manager;
+
+ public ResolutionCacheCleanable(ResolutionCacheManager manager) {
+ this.manager = manager;
+ }
+
+ protected void clean() {
+ manager.clean();
+ }
+
+ public String getName() {
+ return "resolution";
+ }
+ }
+
+ public static class RepositoryCacheCleanable extends Cleanable {
+ private final RepositoryCacheManager manager;
+
+ public RepositoryCacheCleanable(RepositoryCacheManager manager) {
+ this.manager = manager;
+ }
+
+ protected void clean() {
+ manager.clean();
+ }
+
+ public String getName() {
+ return manager.getName();
+ }
+ }
+
+ public CleanCacheAction(List/* <Cleanable> */cleanables) {
+ this.cleanables = cleanables;
+ }
+
+ public void run() {
+ StringBuffer builder = new StringBuffer("Ivy cache cleaned: ");
+ Iterator itCleanable = cleanables.iterator();
+ while (itCleanable.hasNext()) {
+ Cleanable cleanable = (Cleanable) itCleanable.next();
+ cleanable.launchClean();
+ builder.append(cleanable.getName());
+ if (itCleanable.hasNext()) {
+ builder.append(", ");
+ }
+ }
+ IvyPlugin.log(IStatus.INFO, builder.toString(), null);
+ }
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/CleanCacheAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/CleanCacheAction.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/CleanCacheAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/CleanCacheContributionItem.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/CleanCacheContributionItem.java?rev=987823&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/CleanCacheContributionItem.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/CleanCacheContributionItem.java Sat Aug 21 20:20:32 2010
@@ -0,0 +1,175 @@
+/*
+ * 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.menu;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ivy.Ivy;
+import org.apache.ivy.core.cache.RepositoryCacheManager;
+import org.apache.ivy.core.cache.ResolutionCacheManager;
+import org.apache.ivyde.eclipse.IvyDEException;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+import org.apache.ivyde.eclipse.handlers.AbstractIvyDEHandler;
+import org.apache.ivyde.eclipse.ui.menu.CleanCacheAction.Cleanable;
+import org.apache.ivyde.eclipse.ui.menu.CleanCacheAction.RepositoryCacheCleanable;
+import org.apache.ivyde.eclipse.ui.menu.CleanCacheAction.ResolutionCacheCleanable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.actions.CompoundContributionItem;
+import org.eclipse.ui.menus.IWorkbenchContribution;
+import org.eclipse.ui.services.IServiceLocator;
+
+public class CleanCacheContributionItem extends CompoundContributionItem implements
+ IWorkbenchContribution {
+
+ private IServiceLocator serviceLocator;
+
+ public CleanCacheContributionItem() {
+ // nothing to do
+ }
+
+ public CleanCacheContributionItem(String id) {
+ super(id);
+ }
+
+ public void initialize(IServiceLocator serviceLocator) {
+ this.serviceLocator = serviceLocator;
+ }
+
+ protected IContributionItem[] getContributionItems() {
+ ISelectionService selectionService = (ISelectionService) serviceLocator
+ .getService(ISelectionService.class);
+ if (selectionService == null) {
+ return new IContributionItem[0];
+ }
+ ISelection selection = selectionService.getSelection();
+ if (selection == null || !(selection instanceof IStructuredSelection)) {
+ return new IContributionItem[0];
+ }
+
+ Map/* <IProject, Set<IvyClasspathContainer>> */projects = AbstractIvyDEHandler
+ .getProjectAndContainers((IStructuredSelection) selection);
+
+ List/* <IContributionItem> */items = new ArrayList();
+
+ if (projects.size() == 1 && ((Set) projects.values().iterator().next()).size() == 1) {
+ // only one container
+ IvyClasspathContainer ivycp = (IvyClasspathContainer) ((Set) projects.values()
+ .iterator().next()).iterator().next();
+ Ivy ivy = getSafelyIvy(ivycp);
+ if (ivy == null) {
+ return new IContributionItem[0];
+ }
+ fillForSingleContainer(items, ivy);
+ } else {
+ fillForManyContainers(items, projects.values());
+ }
+
+ return (IContributionItem[]) items.toArray(new IContributionItem[items.size()]);
+ }
+
+ private Ivy getSafelyIvy(IvyClasspathContainer ivycp) {
+ try {
+ return ivycp.getState().getCachedIvy();
+ } catch (IvyDEException e) {
+ e.log(IStatus.WARNING, "Cache deletion actions could not be populated for "
+ + ivycp.getConf().toString());
+ return null;
+ }
+ }
+
+ private void fillForSingleContainer(List/* <IContributionItem> */items, Ivy ivy) {
+ List/* <Cleanable> */allCleanables = new ArrayList();
+ List/* <Cleanable> */repositoryCleanables = new ArrayList();
+ List/* <Cleanable> */resolutionCleanables = new ArrayList();
+
+ addResolutionCleanable(allCleanables, ivy);
+ addResolutionCleanable(resolutionCleanables, ivy);
+
+ addRepositoryCleanable(allCleanables, ivy);
+ addRepositoryCleanable(repositoryCleanables, ivy);
+
+ add(items, "Clean all caches", allCleanables);
+ add(items, "Clean the resolution cache", resolutionCleanables);
+ add(items, "Clean every repository cache", repositoryCleanables);
+ Iterator itCleanble = resolutionCleanables.iterator();
+ while (itCleanble.hasNext()) {
+ Cleanable cleanable = (Cleanable) itCleanble.next();
+ add(items, "Clean the cache '" + cleanable.getName() + "'", Collections.singletonList(cleanable));
+ }
+ }
+
+ private void fillForManyContainers(List/* <IContributionItem> */items,
+ Collection/*
+ * <Set<IvyClasspathContainer >>
+ */containerSets) {
+ List/* <Cleanable> */allCleanables = new ArrayList();
+ List/* <Cleanable> */repositoryCleanables = new ArrayList();
+ List/* <Cleanable> */resolutionCleanables = new ArrayList();
+
+ Iterator itSet = containerSets.iterator();
+ while (itSet.hasNext()) {
+ Set set = (Set) itSet.next();
+ Iterator itContainer = set.iterator();
+ while (itContainer.hasNext()) {
+ IvyClasspathContainer ivycp = (IvyClasspathContainer) itContainer.next();
+ Ivy ivy = getSafelyIvy(ivycp);
+ if (ivy != null) {
+ addResolutionCleanable(allCleanables, ivy);
+ addResolutionCleanable(resolutionCleanables, ivy);
+
+ addRepositoryCleanable(allCleanables, ivy);
+ addRepositoryCleanable(repositoryCleanables, ivy);
+ }
+ }
+ }
+ add(items, "Clean all caches", allCleanables);
+ add(items, "Clean every resolution cache", resolutionCleanables);
+ add(items, "Clean every repository cache", repositoryCleanables);
+ }
+
+ private void addResolutionCleanable(List/* <Cleanable> */cleanables, Ivy ivy) {
+ ResolutionCacheManager manager = ivy.getSettings().getResolutionCacheManager();
+ cleanables.add(new ResolutionCacheCleanable(manager));
+ }
+
+ private void addRepositoryCleanable(List/* <Cleanable> */cleanables, Ivy ivy) {
+ RepositoryCacheManager[] managers = ivy.getSettings().getRepositoryCacheManagers();
+ for (int i = 0; i < managers.length; i++) {
+ cleanables.add(new RepositoryCacheCleanable(managers[i]));
+ }
+ }
+
+ public void add(List/* <IContributionItem> */items, String name,
+ List/* <Cleanable> */cleanables) {
+ CleanCacheAction action = new CleanCacheAction(cleanables);
+ action.setText(name);
+ items.add(new ActionContributionItem(action));
+ }
+
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/CleanCacheContributionItem.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/CleanCacheContributionItem.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/CleanCacheContributionItem.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/IvyMenuAction.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/IvyMenuAction.java?rev=987823&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/IvyMenuAction.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/IvyMenuAction.java Sat Aug 21 20:20:32 2010
@@ -0,0 +1,35 @@
+/*
+ * 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.menu;
+
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.ui.actions.CompoundContributionItem;
+
+public class IvyMenuAction extends CompoundContributionItem {
+
+ private final IContributionItem[] items;
+
+ public IvyMenuAction(IContributionItem[] items) {
+ this.items = items;
+ }
+
+ protected IContributionItem[] getContributionItems() {
+ return items;
+ }
+
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/IvyMenuAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/IvyMenuAction.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/menu/IvyMenuAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain