ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r781194 - in /ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse: cpcontainer/IvydeContainerPage.java ui/ConfTableViewer.java ui/NewIvyDEContainerWizard.java ui/actions/CreateContainerAction.java
Date Tue, 02 Jun 2009 22:35:51 GMT
Author: hibou
Date: Tue Jun  2 22:35:51 2009
New Revision: 781194

URL: http://svn.apache.org/viewvc?rev=781194&view=rev
Log:
fix a bug introduced in the implementation of IVYDE-164: it was preventing from editing a
classpath container

Modified:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/ConfTableViewer.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/NewIvyDEContainerWizard.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/CreateContainerAction.java

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java?rev=781194&r1=781193&r2=781194&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java
Tue Jun  2 22:35:51 2009
@@ -30,12 +30,14 @@
 import org.apache.ivyde.eclipse.ui.IvyFilePathText;
 import org.apache.ivyde.eclipse.ui.RetrieveComposite;
 import org.apache.ivyde.eclipse.ui.SettingsEditor;
+import org.apache.ivyde.eclipse.ui.ConfTableViewer.ConfTableListener;
 import org.apache.ivyde.eclipse.ui.IvyFilePathText.IvyXmlPathListener;
 import org.apache.ivyde.eclipse.ui.SettingsEditor.SettingsEditorListener;
 import org.apache.ivyde.eclipse.ui.preferences.ClasspathPreferencePage;
 import org.apache.ivyde.eclipse.ui.preferences.IvyDEPreferenceStoreHelper;
 import org.apache.ivyde.eclipse.ui.preferences.RetrievePreferencePage;
 import org.apache.ivyde.eclipse.ui.preferences.SettingsPreferencePage;
+import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jdt.core.IClasspathEntry;
 import org.eclipse.jdt.core.IJavaProject;
@@ -98,6 +100,12 @@
 
     private boolean exported;
 
+    private boolean newContainer = false;
+
+    private String oldIvyFile;
+
+    private List oldConfs;
+
     /**
      * Constructor
      */
@@ -106,31 +114,45 @@
     }
 
     void checkCompleted() {
-        String error;
+        String error = null;
         if (ivyFilePathText.getIvyFilePath().length() == 0) {
             error = "Choose an ivy file";
         } else {
-            error = null;
-            // check that the chosen configuration doesn't already exist
-            // the uniqueness is for xmlivyPath + conf
-            List/* <IvyClasspathContainer> */containers = IvyClasspathUtil
-                    .getIvyClasspathContainers(project);
-            if (containers != null) {
-                Iterator/* <IvyClasspathContainer> */itContainers = containers.iterator();
-                while (error == null && itContainers.hasNext()) {
-                    IvyClasspathContainer ivycp = (IvyClasspathContainer) itContainers.next();
-                    IvyClasspathContainerConfiguration cpc = ivycp.getConf();
-                    if (cpc.ivyXmlPath.equals(ivyFilePathText.getIvyFilePath())) {
-                        List/* <String> */selecteds = confTableViewer.getSelectedConfigurations();
-                        if (selecteds.isEmpty() || cpc.confs.contains("*")) {
-                            error = "A container already exists for the selected conf of
"
-                                    + "the module descriptor";
-                        } else {
-                            ArrayList list = new ArrayList(cpc.confs);
-                            list.retainAll(selecteds);
-                            if (!list.isEmpty()) {
+            String ivyFilePath = ivyFilePathText.getIvyFilePath();
+            List selectedConfigurations = confTableViewer.getSelectedConfigurations();
+
+            // we will check if there are duplicate if we are creating a new container
+            boolean checkDuplicate = newContainer;
+            if (!checkDuplicate) {
+                // or we are editing a classpath with different ivy and confs than the initial
ones
+                checkDuplicate = !ivyFilePath.equals(oldIvyFile)
+                        || (selectedConfigurations.size() != oldConfs.size()
+                        || !oldConfs.containsAll(selectedConfigurations));              
 
+            }
+
+            if (checkDuplicate) {
+                // check that the chosen configuration doesn't already exist
+                // the uniqueness is for xmlivyPath + conf
+                List/* <IvyClasspathContainer> */containers = IvyClasspathUtil
+                        .getIvyClasspathContainers(project);
+                if (containers != null) {
+                    Iterator/* <IvyClasspathContainer> */itContainers = containers.iterator();
+                    while (error == null && itContainers.hasNext()) {
+                        IvyClasspathContainer ivycp = (IvyClasspathContainer) itContainers.next();
+                        IvyClasspathContainerConfiguration cpc = ivycp.getConf();
+                        if (cpc.ivyXmlPath.equals(ivyFilePath)) {
+                            if (selectedConfigurations.isEmpty()
+                                    || selectedConfigurations.contains("*") || cpc.confs.isEmpty()
+                                    || cpc.confs.contains("*")) {
                                 error = "A container already exists for the selected conf
of "
                                         + "the module descriptor";
+                            } else {
+                                ArrayList list = new ArrayList(cpc.confs);
+                                list.retainAll(selectedConfigurations);
+                                if (!list.isEmpty()) {
+                                    error = "A container already exists for the selected
conf of "
+                                            + "the module descriptor";
+                                }
                             }
                         }
                     }
@@ -222,6 +244,17 @@
             conf = new IvyClasspathContainerConfiguration(project, entry.getPath(), true);
             exported = entry.isExported();
         }
+        oldIvyFile = conf.ivyXmlPath;
+        oldConfs = conf.confs;
+    }
+
+    public void setSelection(IFile ivyfile) {
+        newContainer  = true;
+        conf = new IvyClasspathContainerConfiguration(project, ivyfile.getProjectRelativePath()
+                .toString(), true);
+        exported = false;
+        oldIvyFile = conf.ivyXmlPath;
+        oldConfs = conf.confs;
     }
 
     public void createControl(Composite parent) {
@@ -330,6 +363,11 @@
         // table for configuration selection
         confTableViewer = new ConfTableViewer(configComposite, SWT.NONE);
         confTableViewer.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
+        confTableViewer.addListener(new ConfTableListener() {
+            public void confTableUpdated(List confs) {
+                checkCompleted();
+            }
+        });
 
         // refresh
         Button refreshConf = new Button(configComposite, SWT.NONE);

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/ConfTableViewer.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/ConfTableViewer.java?rev=781194&r1=781193&r2=781194&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/ConfTableViewer.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/ConfTableViewer.java
Tue Jun  2 22:35:51 2009
@@ -19,14 +19,17 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Iterator;
 import java.util.List;
 
 import org.apache.ivy.core.module.descriptor.Configuration;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.IStructuredContentProvider;
 import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
@@ -46,6 +49,8 @@
 
     private Link select;
 
+    private final List listeners = new ArrayList();
+
     public ConfTableViewer(Composite parent, int style) {
         super(parent, style);
         GridLayout layout = new GridLayout();
@@ -84,6 +89,11 @@
             }
         });
         confTableViewer.setLabelProvider(new ConfigurationLabelProvider());
+        confTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+            public void selectionChanged(SelectionChangedEvent event) {
+                confTableUpdated();
+            }
+        });
 
         select = new Link(this, SWT.PUSH);
         select.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
@@ -148,6 +158,31 @@
         }
     }
 
+    public interface ConfTableListener {
+        void confTableUpdated(List confs);
+    }
+
+    public void addListener(ConfTableListener listener) {
+        synchronized (listeners) {
+            listeners.add(listener);
+        }
+    }
+
+    public void remodeListener(ConfTableListener listener) {
+        synchronized (listeners) {
+            listeners.remove(listener);
+        }
+    }
+
+    void confTableUpdated() {
+        synchronized (listeners) {
+            Iterator it = listeners.iterator();
+            while (it.hasNext()) {
+                ((ConfTableListener) it.next()).confTableUpdated(getSelectedConfigurations());
+            }
+        }
+    }
+
     public void setEnabled(boolean enabled) {
         super.setEnabled(enabled);
         confTableViewer.getTable().setEnabled(enabled);

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/NewIvyDEContainerWizard.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/NewIvyDEContainerWizard.java?rev=781194&r1=781193&r2=781194&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/NewIvyDEContainerWizard.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/NewIvyDEContainerWizard.java
Tue Jun  2 22:35:51 2009
@@ -25,6 +25,7 @@
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
 import org.apache.ivyde.eclipse.cpcontainer.IvydeContainerPage;
+import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jdt.core.IClasspathContainer;
@@ -38,10 +39,10 @@
 
     private IvydeContainerPage containerPage;
 
-    public NewIvyDEContainerWizard(IJavaProject project, IClasspathEntry entry) {
+    public NewIvyDEContainerWizard(IJavaProject project, IFile ivyfile) {
         containerPage = new IvydeContainerPage();
         containerPage.initialize(project, null);
-        containerPage.setSelection(entry);
+        containerPage.setSelection(ivyfile);
     }
 
     public void addPages() {

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/CreateContainerAction.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/CreateContainerAction.java?rev=781194&r1=781193&r2=781194&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/CreateContainerAction.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/actions/CreateContainerAction.java
Tue Jun  2 22:35:51 2009
@@ -18,10 +18,8 @@
 package org.apache.ivyde.eclipse.ui.actions;
 
 import org.apache.ivyde.eclipse.IvyPlugin;
-import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainerConfiguration;
 import org.apache.ivyde.eclipse.ui.NewIvyDEContainerWizard;
 import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.core.IClasspathEntry;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
 import org.eclipse.jface.action.IAction;
@@ -33,13 +31,6 @@
 import org.eclipse.ui.PlatformUI;
 
 public class CreateContainerAction implements IWorkbenchWindowActionDelegate {
-    private IWorkbenchWindow window;
-
-    /**
-     * The constructor.
-     */
-    public CreateContainerAction() {
-    }
 
     public void run(IAction action) {
         ISelection sel = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService()
@@ -50,11 +41,8 @@
             if (o instanceof IFile) {
                 IFile f = (IFile) o;
                 IJavaProject javaProject = JavaCore.create(f.getProject());
-                IvyClasspathContainerConfiguration conf = new IvyClasspathContainerConfiguration(
-                        javaProject, f.getProjectRelativePath().toString(), false);
-                IClasspathEntry entry = JavaCore.newContainerEntry(conf.getPath());
                 WizardDialog dialog = new WizardDialog(IvyPlugin.getActiveWorkbenchShell(),
-                        new NewIvyDEContainerWizard(javaProject, entry));
+                        new NewIvyDEContainerWizard(javaProject, f));
                 dialog.open();
             }
         }
@@ -69,6 +57,6 @@
     }
 
     public void init(IWorkbenchWindow window) {
-        this.window = window;
+        // nothing to initialize
     }
 }



Mime
View raw message