Author: adietish
Date: 2011-10-05 13:02:22 -0400 (Wed, 05 Oct 2011)
New Revision: 35380
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/databinding/DataBindingUtils.java
Log:
[JBIDE-9805] improved button enablement binding util
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/databinding/DataBindingUtils.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/databinding/DataBindingUtils.java 2011-10-05
17:01:06 UTC (rev 35379)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/databinding/DataBindingUtils.java 2011-10-05
17:02:22 UTC (rev 35380)
@@ -23,7 +23,7 @@
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.common.ui.CommonUIMessages;
@@ -44,13 +44,18 @@
* @param dbc
* the data binding context to use when binding
*/
- public static void bindButtonEnablementToValidationStatus(final Button button,
+ public static void bindEnablementToValidationStatus(final Control control,
DataBindingContext dbc, Binding... bindings) {
+ bindEnablementToValidationStatus(control, dbc, IStatus.ERROR, bindings);
+ }
+
+ public static void bindEnablementToValidationStatus(final Control control,
+ DataBindingContext dbc, int severity, Binding... bindings) {
dbc.bindValue(
- WidgetProperties.enabled().observe(button),
+ WidgetProperties.enabled().observe(control),
createAggregateValidationStatus(dbc, bindings),
new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
- new UpdateValueStrategy().setConverter(new Status2BooleanConverter(IStatus.ERROR)));
+ new UpdateValueStrategy().setConverter(new Status2BooleanConverter(severity)));
}
/**
@@ -68,16 +73,21 @@
DataBindingContext dbc, Binding... bindings) {
AggregateValidationStatus aggregatedValidationStatus;
if (bindings.length == 0) {
- aggregatedValidationStatus = new AggregateValidationStatus(dbc,
AggregateValidationStatus.MAX_SEVERITY);
+ aggregatedValidationStatus =
+ new AggregateValidationStatus(
+ dbc, AggregateValidationStatus.MAX_SEVERITY);
} else {
- aggregatedValidationStatus = new AggregateValidationStatus(
- toObservableCollection(bindings), AggregateValidationStatus.MAX_SEVERITY);
+ aggregatedValidationStatus =
+ new AggregateValidationStatus(
+ toObservableCollection(bindings),
+ AggregateValidationStatus.MAX_SEVERITY);
}
return aggregatedValidationStatus;
}
/**
- * Returns an observable collection for a given array of validation status providers.
+ * Returns an observable collection for a given array of validation status
+ * providers.
*
* @param observableValue
* the array of observable values
Show replies by date