ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1035618 - in /ant/ivy/ivyde/trunk: doc/release-notes.html org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/ConfTableViewer.java
Date Tue, 16 Nov 2010 12:53:49 GMT
Author: hibou
Date: Tue Nov 16 12:53:48 2010
New Revision: 1035618

URL: http://svn.apache.org/viewvc?rev=1035618&view=rev
Log:
IVYDE-159 : add buttons to change the order of the configurations

Modified:
    ant/ivy/ivyde/trunk/doc/release-notes.html
    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

Modified: ant/ivy/ivyde/trunk/doc/release-notes.html
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/doc/release-notes.html?rev=1035618&r1=1035617&r2=1035618&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/doc/release-notes.html (original)
+++ ant/ivy/ivyde/trunk/doc/release-notes.html Tue Nov 16 12:53:48 2010
@@ -128,6 +128,7 @@ List of changes since <a href="/ivy/ivyd
     <li>NEW: Add branch comparison to workspace resolver (IVYDE-234) (thanks to Jeffrey
M. Metcalf)</li>
     <li>NEW: Look for ivysettings.xml file in project root copying the behavior of
ivy ant task (IVYDE-258)</li>
     <li>NEW: IvyDE can now resolve in an offline mode, where Ivy use only the caches
(Ivy 2.3 required)</li>
+    <li>NEW: Explicit ordering of configurations (IVYDE-159)</li>
 </ul><ul>
     <li>IMPROVE: let IvyDE refresh workspace after a resolve (IVYDE-27) (thanks to
Clint Burghduff)</li>
     <li>IMPROVE: IvyDE now resolve by batch, then preventing too many workspace build
(IVYDE-177)</li>

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=1035618&r1=1035617&r2=1035618&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 Nov 16 12:53:48 2010
@@ -339,7 +339,7 @@ public class IvydeContainerPage extends 
 
         // CheckStyle:MagicNumber| OFF
         Composite configComposite = new Composite(composite, SWT.NONE);
-        configComposite.setLayout(new GridLayout(3, false));
+        configComposite.setLayout(new GridLayout(2, false));
         configComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
 
         // Label for ivy file field
@@ -353,8 +353,7 @@ public class IvydeContainerPage extends 
                 checkIvyXmlPath();
             }
         });
-        ivyFilePathText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true,
false, 2,
-                1));
+        ivyFilePathText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true,
false));
 
         // Label for ivy configurations field
         Label confLabel = new Label(configComposite, SWT.NONE);
@@ -371,8 +370,8 @@ public class IvydeContainerPage extends 
 
         // refresh
         Button refreshConf = new Button(configComposite, SWT.NONE);
-        refreshConf.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false));
-        refreshConf.setText("Refresh");
+        refreshConf.setLayoutData(new GridData(GridData.END, GridData.CENTER, true, false,
2, 1));
+        refreshConf.setText("Reload the list of configurations");
         refreshConf.addSelectionListener(new SelectionAdapter() {
             public void widgetSelected(SelectionEvent ev) {
                 ModuleDescriptor md;

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=1035618&r1=1035617&r2=1035618&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 Nov 16 12:53:48 2010
@@ -24,40 +24,54 @@ 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.ArrayContentProvider;
 import org.eclipse.jface.viewers.CheckboxTableViewer;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
 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;
 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.Link;
 import org.eclipse.swt.widgets.TableColumn;
 
 public class ConfTableViewer extends Composite {
 
     private CheckboxTableViewer confTableViewer;
 
-    private ModuleDescriptor md;
+    private final List listeners = new ArrayList();
 
-    private Link select;
+    private Button selectAll;
 
-    private final List listeners = new ArrayList();
+    private Button up;
+
+    private Button down;
+
+    private Configuration[] orderedConfigurations = new Configuration[0];
 
     public ConfTableViewer(Composite parent, int style) {
         super(parent, style);
-        GridLayout layout = new GridLayout();
+        GridLayout layout = new GridLayout(2, false);
         layout.marginHeight = 0;
         layout.marginWidth = 0;
         setLayout(layout);
 
+        selectAll = new Button(this, SWT.CHECK);
+        selectAll.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2,
1));
+        selectAll.setText("Select every configuration");
+        selectAll.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                confTableViewer.getTable().setEnabled(!selectAll.getSelection());
+                confTableUpdated();
+            }
+        });
+
         confTableViewer = CheckboxTableViewer.newCheckList(this, SWT.BORDER | SWT.H_SCROLL
                 | SWT.V_SCROLL);
         confTableViewer.getTable().setHeaderVisible(true);
@@ -74,70 +88,100 @@ public class ConfTableViewer extends Com
         confTableViewer.setColumnProperties(new String[] {"Name", "Description"});
         confTableViewer.getTable().setLayoutData(
             new GridData(GridData.FILL, GridData.FILL, true, true));
-        confTableViewer.setContentProvider(new IStructuredContentProvider() {
-            public Object[] getElements(Object inputElement) {
-                if (md != null) {
-                    return md.getConfigurations();
-                }
-                return new Configuration[0];
-            }
-
-            public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-                // nothing to do
-            }
-
-            public void dispose() {
-                // nothing to do
-            }
-        });
+        confTableViewer.setContentProvider(ArrayContentProvider.getInstance());
         confTableViewer.setLabelProvider(new ConfigurationLabelProvider());
         confTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
             public void selectionChanged(SelectionChangedEvent event) {
+                updateUpDownEnableButtons();
                 confTableUpdated();
             }
         });
 
-        select = new Link(this, SWT.PUSH);
-        select.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
-        select.setText("<A>All</A>/<A>None</A>");
-        select.addSelectionListener(new SelectionAdapter() {
+        Composite upDownButtons = new Composite(this, SWT.NONE);
+        upDownButtons.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, true));
+        upDownButtons.setLayout(new GridLayout());
+
+        up = new Button(upDownButtons, SWT.PUSH);
+        up.setText("Up");
+        up.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
+        up.addSelectionListener(new SelectionAdapter() {
             public void widgetSelected(SelectionEvent e) {
-                if (e.text.equals("All") && md != null) {
-                    confTableViewer.setCheckedElements(md.getConfigurations());
-                } else {
-                    confTableViewer.setCheckedElements(new Configuration[0]);
-                }
+                int i = getSelectedConfigurationIndex();
+                Configuration c = orderedConfigurations[i];
+                orderedConfigurations[i] = orderedConfigurations[i - 1];
+                orderedConfigurations[i - 1] = c;
+                confTableViewer.refresh();
+                updateUpDownEnableButtons();
+            }
+        });
+
+        down = new Button(upDownButtons, SWT.PUSH);
+        down.setText("Down");
+        down.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
+        down.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                int i = getSelectedConfigurationIndex();
+                Configuration c = orderedConfigurations[i];
+                orderedConfigurations[i] = orderedConfigurations[i + 1];
+                orderedConfigurations[i + 1] = c;
+                confTableViewer.refresh();
+                updateUpDownEnableButtons();
             }
         });
     }
 
+    private int getSelectedConfigurationIndex() {
+        IStructuredSelection selection = (IStructuredSelection) confTableViewer.getSelection();
+        Configuration c = (Configuration) selection.getFirstElement();
+        for (int i = 0; i < orderedConfigurations.length; i++) {
+            if (orderedConfigurations[i] == c) {
+                return i;
+            }
+        }
+        return -1;
+    }
+
+    private void updateUpDownEnableButtons() {
+        boolean selected = confTableViewer.getTable().getSelectionCount() != 0;
+        int i = getSelectedConfigurationIndex();
+        up.setEnabled(selected && i > 0);
+        down.setEnabled(selected && i < orderedConfigurations.length - 1);
+    }
+
     public void setModuleDescriptor(ModuleDescriptor md) {
-        this.md = md;
-        confTableViewer.setInput(md);
+        orderedConfigurations = md.getConfigurations();
+        confTableViewer.setInput(orderedConfigurations);
     }
 
     public void init(List/* <String> */confs) {
-        if (md != null) {
-            Configuration[] configurations = md.getConfigurations();
-            if (confs.size() != 0 && "*".equals(confs.get(0))) {
-                confTableViewer.setCheckedElements(configurations);
-            } else {
-                for (int i = 0; i < confs.size(); i++) {
-                    Configuration configuration = md.getConfiguration((String) confs.get(i));
-                    if (configuration != null) {
-                        confTableViewer.setChecked(configuration, true);
+        if (confs.size() == 1 && "*".equals(confs.get(0))) {
+            selectAll.setSelection(true);
+            for (int i = 0; i < orderedConfigurations.length; i++) {
+                confTableViewer.setChecked(orderedConfigurations[i], true);
+            }
+        } else {
+            selectAll.setSelection(false);
+            for (int i = 0; i < confs.size(); i++) {
+                String c = (String) confs.get(i);
+                for (int j = 0; j < orderedConfigurations.length; j++) {
+                    if (orderedConfigurations[j].getName().equals(c)) {
+                        confTableViewer.setChecked(orderedConfigurations[j], true);
+                        break;
                     }
                 }
             }
         }
+        confTableViewer.getTable().setEnabled(!selectAll.getSelection());
+        boolean selected = confTableViewer.getTable().getSelectionCount() != 0;
+        up.setEnabled(!selectAll.getSelection() && selected);
+        down.setEnabled(!selectAll.getSelection() && selected);
     }
 
     public List getSelectedConfigurations() {
-        Object[] confs = confTableViewer.getCheckedElements();
-        int total = confTableViewer.getTable().getItemCount();
-        if (confs.length == total) {
+        if (selectAll.getSelection()) {
             return Arrays.asList(new String[] {"*"});
         }
+        Object[] confs = confTableViewer.getCheckedElements();
         List confList = new ArrayList();
         for (int i = 0; i < confs.length; i++) {
             Configuration c = (Configuration) confs[i];
@@ -187,7 +231,10 @@ public class ConfTableViewer extends Com
 
     public void setEnabled(boolean enabled) {
         super.setEnabled(enabled);
-        confTableViewer.getTable().setEnabled(enabled);
-        select.setEnabled(enabled);
+        confTableViewer.getTable().setEnabled(enabled && !selectAll.getSelection());
+        boolean selected = confTableViewer.getTable().getSelectionCount() != 0;
+        up.setEnabled(enabled && !selectAll.getSelection() && selected);
+        down.setEnabled(enabled && !selectAll.getSelection() && selected);
+        selectAll.setEnabled(enabled);
     }
 }



Mime
View raw message