ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r988027 - 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/preferences/
Date Mon, 23 Aug 2010 08:32:02 GMT
Author: hibou
Date: Mon Aug 23 08:32:01 2010
New Revision: 988027

URL: http://svn.apache.org/viewvc?rev=988027&view=rev
Log:
IVYDE-56 ...work still in progress...
 * make the ivy project preference work 

Modified:
    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/RetrieveSetup.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/IvySettingsTab.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/EditStandaloneRetrieveDialog.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEProjectPreferences.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/StandaloneRetrieveSerializer.java

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=988027&r1=988026&r2=988027&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/plugin.xml (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/plugin.xml Mon Aug 23 08:32:01 2010
@@ -442,6 +442,7 @@
    <extension
          point="org.eclipse.ui.propertyPages">
       <page
+            adaptable="true"
             class="org.apache.ivyde.eclipse.ui.preferences.IvyDEProjectPreferences"
             id="org.apache.ivyde.eclipse.projectpreferences"
             name="Ivy"

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/RetrieveSetup.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/RetrieveSetup.java?rev=988027&r1=988026&r2=988027&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/RetrieveSetup.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/RetrieveSetup.java
Mon Aug 23 08:32:01 2010
@@ -25,7 +25,7 @@ public class RetrieveSetup {
 
     private boolean doRetrieve;
 
-    private String retrievePattern;
+    private String retrievePattern = "lib/[artifact]-[revision].[ext]";
 
     private boolean retrieveSync = false;
 

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/IvySettingsTab.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/IvySettingsTab.java?rev=988027&r1=988026&r2=988027&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/IvySettingsTab.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/IvySettingsTab.java
Mon Aug 23 08:32:01 2010
@@ -106,6 +106,7 @@ public class IvySettingsTab {
         } else {
             settingsProjectSpecificButton.setSelection(false);
             settingsEditor.init(IvyPlugin.getPreferenceStoreHelper().getIvySettingsSetup());
+            settingsEditor.setEnabled(false);
         }
     }
 

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/EditStandaloneRetrieveDialog.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/EditStandaloneRetrieveDialog.java?rev=988027&r1=988026&r2=988027&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/EditStandaloneRetrieveDialog.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/EditStandaloneRetrieveDialog.java
Mon Aug 23 08:32:01 2010
@@ -48,6 +48,8 @@ public class EditStandaloneRetrieveDialo
 
     private IvySettingsTab settingsTab;
 
+    private StandaloneRetrieveSetup setup;
+
     protected EditStandaloneRetrieveDialog(Shell parentShell, IProject project,
             StandaloneRetrieveSetup retrieveSetup) {
         super(parentShell);
@@ -100,14 +102,17 @@ public class EditStandaloneRetrieveDialo
 
         return body;
     }
-
-    public StandaloneRetrieveSetup getStandaloneRetrieveSetup() {
-        StandaloneRetrieveSetup setup = new StandaloneRetrieveSetup();
+    protected void okPressed() {
+        setup = new StandaloneRetrieveSetup();
         setup.setName(nameText.getText());
         setup.setSettingsProjectSpecific(settingsTab.isProjectSpecific());
         setup.setIvySettingsSetup(settingsTab.getSettingsEditor().getIvySettingsSetup());
         setup.setIvyXmlPath(ivyFilePathText.getIvyFilePath());
         setup.setRetrieveSetup(retrieveComposite.getRetrieveSetup());
+        super.okPressed();
+    }
+
+    public StandaloneRetrieveSetup getStandaloneRetrieveSetup() {
         return setup;
     }
 }

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEProjectPreferences.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEProjectPreferences.java?rev=988027&r1=988026&r2=988027&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEProjectPreferences.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEProjectPreferences.java
Mon Aug 23 08:32:01 2010
@@ -17,12 +17,20 @@
  */
 package org.apache.ivyde.eclipse.ui.preferences;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.ivyde.eclipse.IvyPlugin;
 import org.apache.ivyde.eclipse.cpcontainer.StandaloneRetrieveSetup;
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.DoubleClickEvent;
@@ -42,6 +50,7 @@ import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPropertyPage;
 import org.eclipse.ui.dialogs.PropertyPage;
 
@@ -49,15 +58,23 @@ public class IvyDEProjectPreferences ext
 
     private static final int NUM_COLUMNS = 3;
 
+    private ListViewer listViewer;
+
+    public void init(IWorkbench workbench) {
+        setPreferenceStore(IvyPlugin.getDefault().getPreferenceStore());
+    }
+
     protected Control createContents(Composite parent) {
         Composite composite = new Composite(parent, SWT.NONE);
         composite.setLayout(new GridLayout(1, false));
 
-        Label label = new Label(parent, SWT.NONE);
+        final IProject project = (IProject) IvyPlugin.adapt(getElement(), IProject.class);
+
+        Label label = new Label(composite, SWT.NONE);
         label.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
         label.setText("Retrieve list:");
 
-        final ListViewer listViewer = new ListViewer(composite);
+        listViewer = new ListViewer(composite);
         listViewer.getList().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true,
true));
         listViewer.setContentProvider(ArrayContentProvider.getInstance());
         listViewer.setLabelProvider(new LabelProvider());
@@ -76,9 +93,11 @@ public class IvyDEProjectPreferences ext
             public void widgetSelected(SelectionEvent e) {
                 StandaloneRetrieveSetup setup = new StandaloneRetrieveSetup();
                 EditStandaloneRetrieveDialog editDialog = new EditStandaloneRetrieveDialog(
-                        getShell(), (IProject) getElement(), setup);
+                        getShell(), project, setup);
                 if (editDialog.open() == Window.OK) {
-                    listViewer.add(editDialog.getStandaloneRetrieveSetup());
+                    List list = ((List) listViewer.getInput());
+                    list.add(editDialog.getStandaloneRetrieveSetup());
+                    listViewer.refresh();
                 }
             }
         });
@@ -91,17 +110,20 @@ public class IvyDEProjectPreferences ext
                 boolean confirmed = MessageDialog.openConfirm(getShell(), "Delete retrieve
setup",
                     "Do you really want to delete the selected retrieve configuration ?");
                 if (confirmed) {
+                    List list = ((List) listViewer.getInput());
                     Iterator it = ((IStructuredSelection) listViewer.getSelection()).iterator();
                     while (it.hasNext()) {
-                        listViewer.remove(it.next());
+                        list.remove(it.next());
                     }
+                    listViewer.refresh();
                 }
             }
         });
+        removeButton.setEnabled(false);
 
         listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
             public void selectionChanged(SelectionChangedEvent event) {
-                removeButton.setEnabled(event.getSelection().isEmpty());
+                removeButton.setEnabled(!event.getSelection().isEmpty());
             }
         });
 
@@ -111,24 +133,71 @@ public class IvyDEProjectPreferences ext
                 StandaloneRetrieveSetup setup = (StandaloneRetrieveSetup) selection
                         .getFirstElement();
                 EditStandaloneRetrieveDialog editDialog = new EditStandaloneRetrieveDialog(
-                        getShell(), (IProject) getElement(), setup);
+                        getShell(), project, setup);
                 if (editDialog.open() == Window.OK) {
-                    listViewer.remove(setup);
-                    listViewer.add(editDialog.getStandaloneRetrieveSetup());
+                    List list = ((List) listViewer.getInput());
+                    list.set(list.indexOf(setup), editDialog.getStandaloneRetrieveSetup());
+                    listViewer.refresh();
                 }
             }
         });
 
-        // TODO find a way to store this in the preference store...
-        getPreferenceStore().getString("StandaloneRetrieveSetup");
-        List/* <StandaloneRetrieveSetup> */retrieveSetups = new ArrayList();
+        List/* <StandaloneRetrieveSetup> */retrieveSetups;
+
+        IScopeContext projectScope = new ProjectScope(project);
+        IEclipsePreferences projectNode = projectScope.getNode(IvyPlugin.ID);
+        String retrieveSetup = projectNode.get("StandaloneRetrieveSetup", null);
+        if (retrieveSetup != null) {
+            StandaloneRetrieveSerializer serializer = new StandaloneRetrieveSerializer();
+            ByteArrayInputStream in = new ByteArrayInputStream(retrieveSetup.getBytes());
+            try {
+                try {
+                    retrieveSetups = serializer.read(in);
+                } catch (IOException e) {
+                    throw new RuntimeException(e);
+                }
+            } finally {
+                try {
+                    in.close();
+                } catch (IOException e) {
+                    // we don't care
+                }
+            }
+        } else {
+            retrieveSetups = new ArrayList();
+        }
+
         listViewer.setInput(retrieveSetups);
 
         return composite;
     }
 
     public boolean performOk() {
-        // TODO Auto-generated method stub
+        final IProject project = (IProject) IvyPlugin.adapt(getElement(), IProject.class);
+
+        List/* <StandaloneRetrieveSetup> */retrieveSetups = (List) listViewer.getInput();
+
+        StandaloneRetrieveSerializer serializer = new StandaloneRetrieveSerializer();
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        try {
+            serializer.write(out, retrieveSetups);
+        } catch (IOException e) {
+            IvyPlugin.log(IStatus.ERROR, "Enable to write the retrieve setup", e);
+            return false;
+        } finally {
+            try {
+                out.close();
+            } catch (IOException e) {
+                // we don't care
+            }
+        }
+
+        String retrieveSetup = new String(out.toByteArray());
+
+        IScopeContext projectScope = new ProjectScope(project);
+        IEclipsePreferences projectNode = projectScope.getNode(IvyPlugin.ID);
+        projectNode.put("StandaloneRetrieveSetup", retrieveSetup);
+
         return true;
     }
 }

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/StandaloneRetrieveSerializer.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/StandaloneRetrieveSerializer.java?rev=988027&r1=988026&r2=988027&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/StandaloneRetrieveSerializer.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/StandaloneRetrieveSerializer.java
Mon Aug 23 08:32:01 2010
@@ -189,7 +189,7 @@ public class StandaloneRetrieveSerialize
             DocumentBuilder parser = factory.newDocumentBuilder();
             Document document = parser.parse(source);
 
-            NodeList elements = document.getElementsByTagName(ROOT);
+            NodeList elements = document.getElementsByTagName(SETUP);
 
             List/* <StandaloneRetrieveSetup> */setupList = new ArrayList();
 
@@ -203,15 +203,15 @@ public class StandaloneRetrieveSerialize
                 setup.setName(getAttribute(attributes, SETUP_NAME));
 
                 NodeList children = node.getChildNodes();
-                for (int j = 0; j != children.getLength(); j++) {
+                for (int j = 0; j < children.getLength(); j++) {
                     Node item = children.item(j);
-                    if (item.getLocalName().equals(IVYSETTINGS)) {
+                    if (item.getNodeName().equals(IVYSETTINGS)) {
                         IvySettingsSetup ivySettingsSetup = readIvySettingsSetup(item);
                         setup.setIvySettingsSetup(ivySettingsSetup);
-                    } else if (item.getLocalName().equals(IVYXML)) {
+                    } else if (item.getNodeName().equals(IVYXML)) {
                         String ivyXmlPath = readIvyXmlPath(item);
                         setup.setIvyXmlPath(ivyXmlPath);
-                    } else if (item.getLocalName().equals(RETRIEVE)) {
+                    } else if (item.getNodeName().equals(RETRIEVE)) {
                         RetrieveSetup retrieveSetup = readRetrieveSetup(item);
                         setup.setRetrieveSetup(retrieveSetup);
                     }
@@ -227,9 +227,9 @@ public class StandaloneRetrieveSerialize
             if (t instanceof IOException) {
                 throw (IOException) t;
             } else if (t != null) {
-                throw new IOException(t.getMessage());
+                throw new IOException(t.getMessage(), t);
             } else {
-                throw new IOException(e.getMessage());
+                throw new IOException(e.getMessage(), e);
             }
         }
 
@@ -259,7 +259,7 @@ public class StandaloneRetrieveSerialize
         NodeList children = node.getChildNodes();
         for (int j = 0; j != children.getLength(); j++) {
             Node item = children.item(j);
-            if (item.getLocalName().equals(PROPERTYFILE)) {
+            if (item.getNodeName().equals(PROPERTYFILE)) {
                 attributes = node.getAttributes();
 
                 path = getAttribute(attributes, PROPERTYFILE_PATH);



Mime
View raw message