Author: hibou
Date: Thu Oct 27 16:56:55 2011
New Revision: 1189870
URL: http://svn.apache.org/viewvc?rev=1189870&view=rev
Log:
IVYDE-286:
- add the All/None links back
Modified:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/ConfTableViewer.java
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=1189870&r1=1189869&r2=1189870&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
Thu Oct 27 16:56:55 2011
@@ -39,6 +39,7 @@ 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 {
@@ -55,6 +56,10 @@ public class ConfTableViewer extends Com
private Configuration[] orderedConfigurations = new Configuration[0];
+ private Button all;
+
+ private Button none;
+
public ConfTableViewer(Composite parent, int style) {
super(parent, style);
GridLayout layout = new GridLayout(2, false);
@@ -67,7 +72,10 @@ public class ConfTableViewer extends Com
selectAll.setText("Select every configuration");
selectAll.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
-
confTableViewer.getTable().setEnabled(!selectAll.getSelection());
+ boolean enabled = !selectAll.getSelection();
+ confTableViewer.getTable().setEnabled(enabled);
+ updateAllNoneEnableButtons(enabled);
+ updateUpDownEnableButtons(enabled);
confTableUpdated();
}
});
@@ -92,7 +100,8 @@ public class ConfTableViewer extends Com
confTableViewer.setLabelProvider(new ConfigurationLabelProvider());
confTableViewer.addSelectionChangedListener(new
ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
- updateUpDownEnableButtons();
+ updateUpDownEnableButtons(true);
+ updateAllNoneEnableButtons(true);
confTableUpdated();
}
});
@@ -101,6 +110,26 @@ public class ConfTableViewer extends Com
upDownButtons.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
false, true));
upDownButtons.setLayout(new GridLayout());
+ all = new Button(upDownButtons, SWT.PUSH);
+ all.setText("All");
+ all.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING,
true, false));
+ all.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ confTableViewer.setCheckedElements(orderedConfigurations);
+ updateAllNoneEnableButtons(true);
+ }
+ });
+
+ none = new Button(upDownButtons, SWT.PUSH);
+ none.setText("None");
+ none.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING,
true, false));
+ none.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ confTableViewer.setCheckedElements(new Configuration[0]);
+ updateAllNoneEnableButtons(true);
+ }
+ });
+
up = new Button(upDownButtons, SWT.PUSH);
up.setText("Up");
up.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true,
false));
@@ -111,7 +140,7 @@ public class ConfTableViewer extends Com
orderedConfigurations[i] = orderedConfigurations[i - 1];
orderedConfigurations[i - 1] = c;
confTableViewer.refresh();
- updateUpDownEnableButtons();
+ updateUpDownEnableButtons(true);
}
});
@@ -125,7 +154,7 @@ public class ConfTableViewer extends Com
orderedConfigurations[i] = orderedConfigurations[i + 1];
orderedConfigurations[i + 1] = c;
confTableViewer.refresh();
- updateUpDownEnableButtons();
+ updateUpDownEnableButtons(true);
}
});
}
@@ -141,11 +170,17 @@ public class ConfTableViewer extends Com
return -1;
}
- private void updateUpDownEnableButtons() {
+ private void updateUpDownEnableButtons(boolean enabled) {
boolean selected = confTableViewer.getTable().getSelectionCount() != 0;
int i = getSelectedConfigurationIndex();
- up.setEnabled(selected && i > 0);
- down.setEnabled(selected && i < orderedConfigurations.length - 1);
+ up.setEnabled(enabled && selected && i > 0);
+ down.setEnabled(enabled && selected && i <
orderedConfigurations.length - 1);
+ }
+
+ private void updateAllNoneEnableButtons(boolean enabled) {
+ int nbChecked = confTableViewer.getCheckedElements().length;
+ all.setEnabled(!selectAll.getSelection() && nbChecked !=
orderedConfigurations.length);
+ none.setEnabled(!selectAll.getSelection() && nbChecked > 0);
}
public void setModuleDescriptor(ModuleDescriptor md) {
@@ -158,12 +193,15 @@ public class ConfTableViewer extends Com
}
public void init(List/* <String> */confs) {
+ boolean enabled;
if (confs.size() == 1 && "*".equals(confs.get(0))) {
+ enabled = true;
selectAll.setSelection(true);
for (int i = 0; i < orderedConfigurations.length; i++) {
confTableViewer.setChecked(orderedConfigurations[i], true);
}
} else {
+ enabled = false;
selectAll.setSelection(false);
for (int i = 0; i < confs.size(); i++) {
String c = (String) confs.get(i);
@@ -176,9 +214,8 @@ public class ConfTableViewer extends Com
}
}
confTableViewer.getTable().setEnabled(!selectAll.getSelection());
- boolean selected = confTableViewer.getTable().getSelectionCount() != 0;
- up.setEnabled(!selectAll.getSelection() && selected);
- down.setEnabled(!selectAll.getSelection() && selected);
+ updateAllNoneEnableButtons(enabled);
+ updateUpDownEnableButtons(enabled);
}
public List getSelectedConfigurations() {
@@ -235,10 +272,8 @@ public class ConfTableViewer extends Com
public void setEnabled(boolean enabled) {
super.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);
+ updateUpDownEnableButtons(enabled);
+ updateAllNoneEnableButtons(enabled);
}
}