ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r771432 - in /ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse: ./ src/java/org/apache/ivyde/eclipse/cpcontainer/ src/java/org/apache/ivyde/eclipse/ui/ src/java/org/apache/ivyde/eclipse/ui/actions/
Date Mon, 04 May 2009 20:40:15 GMT
Author: hibou
Date: Mon May  4 20:40:14 2009
New Revision: 771432

URL: http://svn.apache.org/viewvc?rev=771432&view=rev
Log:
IVYDE-164:
 - now the "Add Library" will open the wizard with pre-filled fields
 - the uniqueness of a container in a project is by configuration and ivy.xml

Added:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/NewIvyDEContainerWizard.java
  (with props)
Modified:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt
    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/IvyClasspathUtil.java
    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/actions/CreateContainerAction.java

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt?rev=771432&r1=771431&r2=771432&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/CHANGES.txt Mon May  4 20:40:14 2009
@@ -33,6 +33,7 @@
 - FIX: ResolveAllAction does not resolve multiple IvyDE containers in a single project (IVYDE-175)
 - FIX: The sources/javadocs are not added for dependencies which don't have a fixed revision
(IVYDE-174)
 - FIX: Refresh action is detaching javadoc and sources (IVYDE-176)
+- FIX: Add Ivy Library command adds classpath container even though it already exists (IVYDE-164)
 
   version 2.0.0 beta1
 ==========================

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=771432&r1=771431&r2=771432&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/plugin.xml (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/plugin.xml Mon May  4 20:40:14 2009
@@ -106,7 +106,7 @@
          nameFilter="*.xml"> 
          <action
             id="org.apache.ivyde.eclipse.ui.actions.CreateContainerAction" 
-            label="Add &amp;Ivy Library"
+            label="Add &amp;Ivy Library..."
             class="org.apache.ivyde.eclipse.ui.actions.CreateContainerAction" 
             enablesFor="1"
 			/> 

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java?rev=771432&r1=771431&r2=771432&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathUtil.java
Mon May  4 20:40:14 2009
@@ -20,16 +20,13 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 
 import org.apache.ivyde.eclipse.IvyPlugin;
 import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
 import org.eclipse.jdt.core.IClasspathAttribute;
 import org.eclipse.jdt.core.IClasspathContainer;
 import org.eclipse.jdt.core.IClasspathEntry;
@@ -46,37 +43,6 @@
     }
 
     /**
-     * Adds an Ivy classpath container to the list of existing classpath entries in the given
-     * project.
-     * 
-     * @param project
-     *            the project to which the classpath container should be added
-     * @param projectRelativePath
-     *            the path relative to the project of the module descriptor file to use for
the
-     *            classpath container
-     * @param confs
-     *            the configurations to use in the classpath container.
-     */
-    public static void addCPContainer(IJavaProject project, IPath projectRelativePath, String
confs) {
-        try {
-            IClasspathEntry newEntry = JavaCore.newContainerEntry(new Path(
-                    IvyClasspathContainer.CONTAINER_ID).append(projectRelativePath).append(confs));
-
-            IClasspathEntry[] entries = project.getRawClasspath();
-
-            List newEntries = new ArrayList(Arrays.asList(entries));
-            newEntries.add(newEntry);
-            entries = (IClasspathEntry[]) newEntries
-                    .toArray(new IClasspathEntry[newEntries.size()]);
-
-            project.setRawClasspath(entries, project.getOutputLocation(), null);
-        } catch (CoreException e) {
-            // unless there are issues with the JDT, this should never happen
-            IvyPlugin.log(e);
-        }
-    }
-
-    /**
      * Get the Ivy classpath container from the selection in the Java package view
      * 
      * @param selection

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=771432&r1=771431&r2=771432&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
Mon May  4 20:40:14 2009
@@ -17,7 +17,10 @@
  */
 package org.apache.ivyde.eclipse.cpcontainer;
 
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
 
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivyde.eclipse.IvyDEException;
@@ -108,6 +111,31 @@
             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()) {
+                                error = "A container already exists for the selected conf
of "
+                                        + "the module descriptor";
+                            }
+                        }
+                    }
+                }
+            }
         }
         setErrorMessage(error);
         setPageComplete(error == null);
@@ -178,6 +206,10 @@
         return true;
     }
 
+    public IJavaProject getProject() {
+        return project;
+    }
+
     public IClasspathEntry getSelection() {
         return entry;
     }
@@ -259,6 +291,7 @@
         Label horizontalLine = new Label(headerComposite, SWT.SEPARATOR | SWT.HORIZONTAL);
         horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false,
2, 1));
 
+        //CheckStyle:MagicNumber| OFF
         Composite configComposite = new Composite(composite, SWT.NONE);
         configComposite.setLayout(new GridLayout(3, false));
         configComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
@@ -274,7 +307,8 @@
 
         horizontalLine = new Label(configComposite, SWT.SEPARATOR | SWT.HORIZONTAL);
         horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false,
3, 1));
-
+        //CheckStyle:MagicNumber| OFN
+        
         // Label for ivy file field
         Label pathLabel = new Label(configComposite, SWT.NONE);
         pathLabel.setText("Ivy File");

Added: 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=771432&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/NewIvyDEContainerWizard.java
(added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/NewIvyDEContainerWizard.java
Mon May  4 20:40:14 2009
@@ -0,0 +1,78 @@
+/*
+ *  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;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathContainer;
+import org.apache.ivyde.eclipse.cpcontainer.IvydeContainerPage;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.wizard.Wizard;
+
+public class NewIvyDEContainerWizard extends Wizard {
+
+    private IvydeContainerPage containerPage;
+
+    public NewIvyDEContainerWizard(IJavaProject project, IClasspathEntry entry) {
+        containerPage = new IvydeContainerPage();
+        containerPage.initialize(project, null);
+        containerPage.setSelection(entry);
+    }
+
+    public void addPages() {
+        addPage(containerPage);
+    }
+
+    public boolean performFinish() {
+        containerPage.finish();
+        IClasspathEntry newEntry = containerPage.getSelection();
+        IPath path = newEntry.getPath();
+        IJavaProject project = containerPage.getProject();
+        try {
+            IvyClasspathContainer ivycp = new IvyClasspathContainer(project, path,
+                    new IClasspathEntry[0]);
+            JavaCore.setClasspathContainer(path, new IJavaProject[] {project},
+                new IClasspathContainer[] {ivycp}, null);
+            IClasspathEntry[] entries = project.getRawClasspath();
+            List newEntries = new ArrayList(Arrays.asList(entries));
+            newEntries.add(newEntry);
+            entries = (IClasspathEntry[]) newEntries
+                    .toArray(new IClasspathEntry[newEntries.size()]);
+            project.setRawClasspath(entries, project.getOutputLocation(), null);
+            ivycp.launchResolve(false, true, null);
+        } catch (JavaModelException e) {
+            IvyPlugin.log(e);
+            return false;
+        } catch (IOException e) {
+            IvyPlugin.log(IStatus.ERROR, "", e);
+            return false;
+        }
+        return true;
+    }
+
+}

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/NewIvyDEContainerWizard.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/NewIvyDEContainerWizard.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/NewIvyDEContainerWizard.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=771432&r1=771431&r2=771432&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
Mon May  4 20:40:14 2009
@@ -17,14 +17,17 @@
  */
 package org.apache.ivyde.eclipse.ui.actions;
 
-import org.apache.ivyde.eclipse.cpcontainer.IvyClasspathUtil;
+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.core.runtime.IPath;
+import org.eclipse.jdt.core.IClasspathEntry;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
 import org.eclipse.ui.PlatformUI;
@@ -38,12 +41,6 @@
     public CreateContainerAction() {
     }
 
-    /**
-     * The action has been activated. The argument of the method represents the 'real' action
-     * sitting in the workbench UI.
-     * 
-     * @see IWorkbenchWindowActionDelegate#run
-     */
     public void run(IAction action) {
         ISelection sel = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService()
                 .getSelection();
@@ -52,39 +49,25 @@
             Object o = s.getFirstElement();
             if (o instanceof IFile) {
                 IFile f = (IFile) o;
-
-                addCPContainer(JavaCore.create(f.getProject()), f.getProjectRelativePath(),
"*");
+                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));
+                dialog.open();
             }
         }
     }
 
-    private void addCPContainer(IJavaProject project, IPath projectRelativePath, String confs)
{
-        IvyClasspathUtil.addCPContainer(project, projectRelativePath, confs);
-    }
-
-    /**
-     * Selection in the workbench has been changed. We can change the state of the 'real'
action
-     * here if we want, but this can only happen after the delegate has been created.
-     * 
-     * @see IWorkbenchWindowActionDelegate#selectionChanged
-     */
     public void selectionChanged(IAction action, ISelection selection) {
+        // nothing to change
     }
 
-    /**
-     * We can use this method to dispose of any system resources we previously allocated.
-     * 
-     * @see IWorkbenchWindowActionDelegate#dispose
-     */
     public void dispose() {
+        // nothing to dispose
     }
 
-    /**
-     * We will cache window object in order to be able to provide parent shell for the message
-     * dialog.
-     * 
-     * @see IWorkbenchWindowActionDelegate#init
-     */
     public void init(IWorkbenchWindow window) {
         this.window = window;
     }



Mime
View raw message