ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r988035 - in /ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse: ./ cpcontainer/ retrieve/ ui/preferences/
Date Mon, 23 Aug 2010 08:58:08 GMT
Author: hibou
Date: Mon Aug 23 08:58:08 2010
New Revision: 988035

URL: http://svn.apache.org/viewvc?rev=988035&view=rev
Log:
IVYDE-56: ...work still in progress...
* implement a manager of standalone retrieve setup

Added:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/RetrieveSetupManager.java
  (with props)
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSerializer.java
      - copied, changed from r988027, ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/StandaloneRetrieveSerializer.java
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetup.java
      - copied, changed from r988023, ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/StandaloneRetrieveSetup.java
Removed:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/StandaloneRetrieveSetup.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/src/java/org/apache/ivyde/eclipse/IvyPlugin.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

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=988035&r1=988034&r2=988035&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
Mon Aug 23 08:58:08 2010
@@ -30,6 +30,7 @@ import org.apache.ivyde.eclipse.cpcontai
 import org.apache.ivyde.eclipse.cpcontainer.IvyResolveJob;
 import org.apache.ivyde.eclipse.cpcontainer.fragmentinfo.IPackageFragmentExtraInfo;
 import org.apache.ivyde.eclipse.cpcontainer.fragmentinfo.PreferenceStoreInfo;
+import org.apache.ivyde.eclipse.retrieve.RetrieveSetupManager;
 import org.apache.ivyde.eclipse.ui.console.IvyConsole;
 import org.apache.ivyde.eclipse.ui.editors.xml.ColorManager;
 import org.apache.ivyde.eclipse.ui.preferences.IvyDEPreferenceStoreHelper;
@@ -87,6 +88,8 @@ public class IvyPlugin extends AbstractU
 
     private IvyResolveJob ivyResolveJob;
 
+    private RetrieveSetupManager retrieveSetupManager;
+
     /**
      * The constructor.
      */
@@ -103,10 +106,16 @@ public class IvyPlugin extends AbstractU
         this.bundleContext = context;
         log(IStatus.INFO, "starting IvyDE plugin", null);
         ivyResolveJob = new IvyResolveJob();
+        
+        retrieveSetupManager = new RetrieveSetupManager();
+
         javaModel = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
+        
         colorManager = new ColorManager();
         colorManager.refreshFromStore(getPreferenceStore());
+
         prefStoreHelper = new IvyDEPreferenceStoreHelper(getPreferenceStore());
+
         getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
             public void propertyChange(PropertyChangeEvent event) {
                 try {
@@ -160,6 +169,7 @@ public class IvyPlugin extends AbstractU
         resourceBundle = null;
         colorManager = null;
         ivyResolveJob = null;
+        retrieveSetupManager = null;
         // if (console != null)
         // console.shutdown();
     }
@@ -348,4 +358,8 @@ public class IvyPlugin extends AbstractU
     public IvyResolveJob getIvyResolveJob() {
         return ivyResolveJob;
     }
+
+    public RetrieveSetupManager getRetrieveSetupManager() {
+        return retrieveSetupManager;
+    }
 }

Added: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/RetrieveSetupManager.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/RetrieveSetupManager.java?rev=988035&view=auto
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/RetrieveSetupManager.java
(added)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/RetrieveSetupManager.java
Mon Aug 23 08:58:08 2010
@@ -0,0 +1,81 @@
+/*
+ *  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.retrieve;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ivyde.eclipse.IvyPlugin;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.osgi.service.prefs.BackingStoreException;
+
+public class RetrieveSetupManager {
+
+    private static final String PREF_ID = "org.apache.ivyde.eclipse.standlaoneretrieve";
+
+    public List/* <StandaloneRetrieveSetup> */getSetup(IProject project) throws IOException
{
+        IScopeContext projectScope = new ProjectScope(project);
+        IEclipsePreferences projectNode = projectScope.getNode(IvyPlugin.ID);
+        String retrieveSetup = projectNode.get(PREF_ID, null);
+        if (retrieveSetup == null) {
+            return new ArrayList();
+        }
+        List/* <StandaloneRetrieveSetup> */retrieveSetups;
+
+        StandaloneRetrieveSerializer serializer = new StandaloneRetrieveSerializer();
+        ByteArrayInputStream in = new ByteArrayInputStream(retrieveSetup.getBytes());
+        try {
+            retrieveSetups = serializer.read(in);
+        } finally {
+            try {
+                in.close();
+            } catch (IOException e) {
+                // we don't care
+            }
+        }
+        return retrieveSetups;
+    }
+
+    public void save(IProject project, List/* <StandaloneRetrieveSetup> */retrieveSetups)
+            throws IOException, BackingStoreException {
+        StandaloneRetrieveSerializer serializer = new StandaloneRetrieveSerializer();
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        try {
+            serializer.write(out, retrieveSetups);
+        } 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);
+        projectNode.flush();
+    }
+}

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

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

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

Copied: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSerializer.java
(from r988027, 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/retrieve/StandaloneRetrieveSerializer.java?p2=ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSerializer.java&p1=ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/StandaloneRetrieveSerializer.java&r1=988027&r2=988035&rev=988035&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/retrieve/StandaloneRetrieveSerializer.java
Mon Aug 23 08:58:08 2010
@@ -15,7 +15,7 @@
  *  limitations under the License.
  *
  */
-package org.apache.ivyde.eclipse.ui.preferences;
+package org.apache.ivyde.eclipse.retrieve;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -36,7 +36,6 @@ import javax.xml.transform.stream.Stream
 
 import org.apache.ivyde.eclipse.cpcontainer.IvySettingsSetup;
 import org.apache.ivyde.eclipse.cpcontainer.RetrieveSetup;
-import org.apache.ivyde.eclipse.cpcontainer.StandaloneRetrieveSetup;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.NamedNodeMap;

Copied: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetup.java
(from r988023, ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/StandaloneRetrieveSetup.java)
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetup.java?p2=ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetup.java&p1=ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/StandaloneRetrieveSetup.java&r1=988023&r2=988035&rev=988035&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/StandaloneRetrieveSetup.java
(original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/retrieve/StandaloneRetrieveSetup.java
Mon Aug 23 08:58:08 2010
@@ -15,7 +15,10 @@
  *  limitations under the License.
  *
  */
-package org.apache.ivyde.eclipse.cpcontainer;
+package org.apache.ivyde.eclipse.retrieve;
+
+import org.apache.ivyde.eclipse.cpcontainer.IvySettingsSetup;
+import org.apache.ivyde.eclipse.cpcontainer.RetrieveSetup;
 
 public class StandaloneRetrieveSetup {
 

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=988035&r1=988034&r2=988035&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:58:08 2010
@@ -17,7 +17,7 @@
  */
 package org.apache.ivyde.eclipse.ui.preferences;
 
-import org.apache.ivyde.eclipse.cpcontainer.StandaloneRetrieveSetup;
+import org.apache.ivyde.eclipse.retrieve.StandaloneRetrieveSetup;
 import org.apache.ivyde.eclipse.ui.IvyFilePathText;
 import org.apache.ivyde.eclipse.ui.IvySettingsTab;
 import org.apache.ivyde.eclipse.ui.RetrieveComposite;

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=988035&r1=988034&r2=988035&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:58:08 2010
@@ -17,48 +17,51 @@
  */
 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.apache.ivyde.eclipse.retrieve.RetrieveSetupManager;
+import org.apache.ivyde.eclipse.retrieve.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.BaseLabelProvider;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.window.Window;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 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.swt.widgets.TableColumn;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPropertyPage;
 import org.eclipse.ui.dialogs.PropertyPage;
+import org.osgi.service.prefs.BackingStoreException;
 
 public class IvyDEProjectPreferences extends PropertyPage implements IWorkbenchPropertyPage
{
 
-    private static final int NUM_COLUMNS = 3;
+    private TableViewer table;
 
-    private ListViewer listViewer;
+    private RetrieveSetupManager retrieveSetupManager;
+
+    public IvyDEProjectPreferences() {
+        noDefaultAndApplyButton();
+        retrieveSetupManager = IvyPlugin.getDefault().getRetrieveSetupManager();
+    }
 
     public void init(IWorkbench workbench) {
         setPreferenceStore(IvyPlugin.getDefault().getPreferenceStore());
@@ -66,138 +69,153 @@ public class IvyDEProjectPreferences ext
 
     protected Control createContents(Composite parent) {
         Composite composite = new Composite(parent, SWT.NONE);
-        composite.setLayout(new GridLayout(1, false));
+        composite.setLayout(new GridLayout(2, false));
 
         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.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 0));
         label.setText("Retrieve list:");
 
-        listViewer = new ListViewer(composite);
-        listViewer.getList().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true,
true));
-        listViewer.setContentProvider(ArrayContentProvider.getInstance());
-        listViewer.setLabelProvider(new LabelProvider());
+        table = new TableViewer(composite);
+        table.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        table.setContentProvider(ArrayContentProvider.getInstance());
+        table.setLabelProvider(new RetrieveTableLabelProvider());
+        table.getTable().setHeaderVisible(true);
+        TableColumn col1 = new TableColumn(table.getTable(), SWT.NONE);
+        col1.setText("Name");
+        // CheckStyle:MagicNumber| OFF
+        col1.setWidth(100);
+        TableColumn col2 = new TableColumn(table.getTable(), SWT.NONE);
+        col2.setText("Pattern");
+        col2.setWidth(200);
+        TableColumn col3 = new TableColumn(table.getTable(), SWT.NONE);
+        col3.setText("Confs");
+        col3.setWidth(50);
+        TableColumn col4 = new TableColumn(table.getTable(), SWT.NONE);
+        col4.setText("Types");
+        col4.setWidth(50);
+        // CheckStyle:MagicNumber| ON
+        table.setColumnProperties(new String[] {"Name", "Pattern", "Confs", "Types"});
 
         Composite buttons = new Composite(composite, SWT.NONE);
-        buttons.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
-        buttons.setLayout(new GridLayout(NUM_COLUMNS, false));
+        buttons.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
+        buttons.setLayout(new GridLayout(1, false));
 
-        Composite empty = new Composite(buttons, SWT.NONE);
-        empty.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
-
-        Button addButton = new Button(buttons, SWT.PUSH);
-        addButton.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, true, false));
-        addButton.setText("Add...");
-        addButton.addSelectionListener(new SelectionAdapter() {
+        Button newButton = new Button(buttons, SWT.PUSH);
+        newButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+        newButton.setText("New...");
+        newButton.addSelectionListener(new SelectionAdapter() {
             public void widgetSelected(SelectionEvent e) {
                 StandaloneRetrieveSetup setup = new StandaloneRetrieveSetup();
                 EditStandaloneRetrieveDialog editDialog = new EditStandaloneRetrieveDialog(
                         getShell(), project, setup);
                 if (editDialog.open() == Window.OK) {
-                    List list = ((List) listViewer.getInput());
+                    List list = ((List) table.getInput());
                     list.add(editDialog.getStandaloneRetrieveSetup());
-                    listViewer.refresh();
+                    table.refresh();
                 }
             }
         });
 
+        Button editButton = new Button(buttons, SWT.PUSH);
+        editButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+        editButton.setText("Edit...");
+        editButton.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                openEdit((IStructuredSelection) table.getSelection(), project);
+            }
+        });
+
         final Button removeButton = new Button(buttons, SWT.PUSH);
-        removeButton.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, true, false));
-        removeButton.setText("Remove...");
+        removeButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
+        removeButton.setText("Remove");
         removeButton.addSelectionListener(new SelectionAdapter() {
             public void widgetSelected(SelectionEvent e) {
-                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()) {
-                        list.remove(it.next());
-                    }
-                    listViewer.refresh();
+                List list = ((List) table.getInput());
+                Iterator it = ((IStructuredSelection) table.getSelection()).iterator();
+                while (it.hasNext()) {
+                    list.remove(it.next());
                 }
+                table.refresh();
             }
         });
         removeButton.setEnabled(false);
 
-        listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+        table.addSelectionChangedListener(new ISelectionChangedListener() {
             public void selectionChanged(SelectionChangedEvent event) {
                 removeButton.setEnabled(!event.getSelection().isEmpty());
             }
         });
 
-        listViewer.addDoubleClickListener(new IDoubleClickListener() {
+        table.addDoubleClickListener(new IDoubleClickListener() {
             public void doubleClick(DoubleClickEvent event) {
-                IStructuredSelection selection = (IStructuredSelection) event.getSelection();
-                StandaloneRetrieveSetup setup = (StandaloneRetrieveSetup) selection
-                        .getFirstElement();
-                EditStandaloneRetrieveDialog editDialog = new EditStandaloneRetrieveDialog(
-                        getShell(), project, setup);
-                if (editDialog.open() == Window.OK) {
-                    List list = ((List) listViewer.getInput());
-                    list.set(list.indexOf(setup), editDialog.getStandaloneRetrieveSetup());
-                    listViewer.refresh();
-                }
+                openEdit((IStructuredSelection) event.getSelection(), project);
             }
         });
 
-        List/* <StandaloneRetrieveSetup> */retrieveSetups;
+        List retrieveSetups;
+        try {
+            retrieveSetups = retrieveSetupManager.getSetup(project);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        table.setInput(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();
+        return composite;
+    }
+
+    private void openEdit(IStructuredSelection selection, IProject project) {
+        StandaloneRetrieveSetup setup = (StandaloneRetrieveSetup) selection.getFirstElement();
+        EditStandaloneRetrieveDialog editDialog = new EditStandaloneRetrieveDialog(getShell(),
+                project, setup);
+        if (editDialog.open() == Window.OK) {
+            List list = ((List) table.getInput());
+            list.set(list.indexOf(setup), editDialog.getStandaloneRetrieveSetup());
+            table.refresh();
         }
+    }
 
-        listViewer.setInput(retrieveSetups);
+    private class RetrieveTableLabelProvider extends BaseLabelProvider implements
+            ITableLabelProvider {
+
+        public Image getColumnImage(Object element, int columnIndex) {
+            return null;
+        }
+
+        public String getColumnText(Object element, int columnIndex) {
+            StandaloneRetrieveSetup setup = (StandaloneRetrieveSetup) element;
+            switch (columnIndex) {
+                case 0:
+                    return setup.getName();
+                case 1:
+                    return setup.getRetrieveSetup().getRetrievePattern();
+                case 2:
+                    return setup.getRetrieveSetup().getRetrieveConfs();
+                case 3:
+                    return setup.getRetrieveSetup().getRetrieveTypes();
+            }
+            return null;
+        }
 
-        return composite;
     }
 
     public boolean performOk() {
         final IProject project = (IProject) IvyPlugin.adapt(getElement(), IProject.class);
 
-        List/* <StandaloneRetrieveSetup> */retrieveSetups = (List) listViewer.getInput();
+        List/* <StandaloneRetrieveSetup> */retrieveSetups = (List) table.getInput();
 
-        StandaloneRetrieveSerializer serializer = new StandaloneRetrieveSerializer();
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
         try {
-            serializer.write(out, retrieveSetups);
+            retrieveSetupManager.save(project, 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
-            }
+        } catch (BackingStoreException e) {
+            IvyPlugin.log(IStatus.ERROR, "Failed to store the project preference of "
+                    + project.getName(), e);
+            return false;
         }
 
-        String retrieveSetup = new String(out.toByteArray());
-
-        IScopeContext projectScope = new ProjectScope(project);
-        IEclipsePreferences projectNode = projectScope.getNode(IvyPlugin.ID);
-        projectNode.put("StandaloneRetrieveSetup", retrieveSetup);
-
         return true;
     }
 }



Mime
View raw message