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 2009/09/12 19:51:57 UTC
svn commit: r814215 - in /ant/ivy/ivyde/trunk: ./
org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/
org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/
org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/editors/
Author: hibou
Date: Sat Sep 12 17:51:56 2009
New Revision: 814215
URL: http://svn.apache.org/viewvc?rev=814215&view=rev
Log:
File resource listener on Ivy files launches resolve when it detects modifications (IVYDE-199) (thanks to Jon Schneider)
Added:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java (with props)
Modified:
ant/ivy/ivyde/trunk/CHANGES.txt
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/editors/IvyModuleDescriptorEditor.java
Modified: ant/ivy/ivyde/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/CHANGES.txt?rev=814215&r1=814214&r2=814215&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/CHANGES.txt (original)
+++ ant/ivy/ivyde/trunk/CHANGES.txt Sat Sep 12 17:51:56 2009
@@ -6,6 +6,7 @@
- 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)
- NEW: Add option to not launch a resolve after saving a file with the IvyEditor (IVYDE-197) (thanks to Jon Schneider)
+- NEW: File resource listener on Ivy files launches resolve when it detects modifications (IVYDE-199) (thanks to Jon Schneider)
- 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)
Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java?rev=814215&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java (added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java Sat Sep 12 17:51:56 2009
@@ -0,0 +1,95 @@
+/*
+ * 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.common.ivyfile;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+
+public class IvyFileResourceListener implements IResourceChangeListener {
+
+ private static class IvyVisitor implements IResourceDeltaVisitor, IResourceVisitor {
+
+ public boolean visit(IResource resource) throws CoreException {
+ resourceChanged(resource);
+ return true;
+ }
+
+ public boolean visit(IResourceDelta delta) {
+ IResource resource = delta.getResource();
+
+ if (IResourceDelta.CHANGED == delta.getKind()) {
+ if ((delta.getFlags() & IResourceDelta.CONTENT) == IResourceDelta.CONTENT) {
+ resourceChanged(resource);
+ }
+ }
+
+ return true;
+ }
+
+ private static void resourceChanged(IResource resource) {
+ if (resource instanceof IFile
+ && IvyPlugin.getPreferenceStoreHelper().getAutoResolveOnChange()) {
+ IFile resourceFile = (IFile) resource;
+ IJavaProject javaProject = JavaCore.create(resource.getProject());
+ if (javaProject != null) {
+ List/* <IvyClasspathContainer> */containers = IvyClasspathUtil
+ .getIvyClasspathContainers(javaProject);
+ Iterator containerIter = containers.iterator();
+ while (containerIter.hasNext()) {
+ IvyClasspathContainer container = (IvyClasspathContainer) containerIter
+ .next();
+ File containerIvyFile = container.getConf().getIvyFile();
+ if (containerIvyFile.equals(resourceFile.getLocation().toFile())) {
+ container.launchResolve(false, false, null);
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private static final IResourceDeltaVisitor visitor = new IvyVisitor();
+
+ public void resourceChanged(IResourceChangeEvent event) {
+ switch (event.getType()) {
+ case IResourceChangeEvent.PRE_BUILD:
+ try {
+ event.getDelta().accept(visitor);
+ } catch (CoreException e) {
+ IvyPlugin.log(e);
+ }
+ break;
+ }
+ }
+}
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java?rev=814215&r1=814214&r2=814215&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java Sat Sep 12 17:51:56 2009
@@ -24,6 +24,7 @@
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import org.apache.ivyde.common.ivyfile.IvyFileResourceListener;
import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
import org.apache.ivyde.eclipse.cpcontainer.fragmentinfo.IPackageFragmentExtraInfo;
@@ -32,6 +33,8 @@
import org.apache.ivyde.eclipse.ui.preferences.IvyDEPreferenceStoreHelper;
import org.apache.ivyde.eclipse.ui.preferences.PreferenceConstants;
import org.apache.ivyde.eclipse.workspaceresolver.WorkspaceResourceChangeListener;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
@@ -129,8 +132,11 @@
});
// Listen for project open/close events to auto-update inter-project dependencies
- ResourcesPlugin.getWorkspace().addResourceChangeListener(
- new WorkspaceResourceChangeListener());
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+
+ workspace.addResourceChangeListener(new WorkspaceResourceChangeListener());
+ workspace.addResourceChangeListener(new IvyFileResourceListener(),
+ IResourceChangeEvent.PRE_BUILD);
log(IStatus.INFO, "IvyDE plugin started", null);
}
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/editors/IvyModuleDescriptorEditor.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/editors/IvyModuleDescriptorEditor.java?rev=814215&r1=814214&r2=814215&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/editors/IvyModuleDescriptorEditor.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/editors/IvyModuleDescriptorEditor.java Sat Sep 12 17:51:56 2009
@@ -17,14 +17,9 @@
*/
package org.apache.ivyde.eclipse.ui.editors;
-import java.util.Iterator;
-import java.util.List;
-
import org.apache.ivyde.common.ivyfile.IvyModuleDescriptorModel;
import org.apache.ivyde.common.model.IvyModel;
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.ui.core.IvyFileEditorInput;
import org.apache.ivyde.eclipse.ui.editors.pages.OverviewFormPage;
import org.apache.ivyde.eclipse.ui.editors.xml.EclipseIvyModelSettings;
@@ -94,12 +89,7 @@
return new IvyModuleDescriptorModel(new EclipseIvyModelSettings(
file));
}
- }) {
- public void doSave(IProgressMonitor progressMonitor) {
- super.doSave(progressMonitor);
- triggerResolve();
- }
- };
+ });
xmlEditor.setFile(((IvyFileEditorInput) getEditorInput()).getFile());
int index = addPage(xmlEditor, getEditorInput());
setPageText(index, xmlEditor.getTitle());
@@ -161,19 +151,6 @@
xmlEditor.doSave(monitor);
}
- private void triggerResolve() {
- IFile file = ((IvyFileEditorInput) getEditorInput()).getFile();
- List/* <IvyClasspathContainer> */containers = IvyClasspathUtil
- .getIvyFileClasspathContainers(file);
- Iterator/* <IvyClasspathContainer> */itContainers = containers.iterator();
- if (IvyPlugin.getPreferenceStoreHelper().getAutoResolveOnChange()) {
- while (itContainers.hasNext()) {
- IvyClasspathContainer ivycp = (IvyClasspathContainer) itContainers.next();
- ivycp.launchResolve(false, true, null);
- }
- }
- }
-
/**
* Saves the multi-page editor's document as another file. Also updates the text for page 0's
* tab, and updates this multi-page editor's input to correspond to the nested editor's.