|
From: <bh...@us...> - 2006-10-04 01:43:34
|
Revision: 238
http://svn.sourceforge.net/cishell/?rev=238&view=rev
Author: bh2
Date: 2006-10-02 09:15:00 -0700 (Mon, 02 Oct 2006)
Log Message:
-----------
Added DataValidator checking for Algorithms on the menu
Modified Paths:
--------------
trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java
Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java
===================================================================
--- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java 2006-10-02 16:14:28 UTC (rev 237)
+++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java 2006-10-02 16:15:00 UTC (rev 238)
@@ -25,6 +25,7 @@
import org.cishell.framework.CIShellContext;
import org.cishell.framework.algorithm.AlgorithmFactory;
import org.cishell.framework.algorithm.AlgorithmProperty;
+import org.cishell.framework.algorithm.DataValidator;
import org.cishell.framework.data.Data;
import org.cishell.service.conversion.Converter;
import org.cishell.service.conversion.DataConversionService;
@@ -141,9 +142,34 @@
}
}
}
- setEnabled(data != null);
+ setEnabled(data != null && isValid());
}
+ private boolean isValid() {
+ String valid = null;
+ String[] classes = (String[]) ref.getProperty(Constants.OBJECTCLASS);
+
+ if (classes != null && data != null) {
+ for (int i=0; i < classes.length; i++) {
+ if (classes[i].equals(DataValidator.class.getName())) {
+ DataValidator validator = (DataValidator) bContext.getService(ref);
+
+ synchronized(this) {
+ for (int j=0; j < data.length; j++) {
+ if (converters[j] != null && converters[j].length > 0) {
+ data[j] = converters[j][0].convert(data[j]);
+ }
+ }
+
+ valid = validator.validate(data);
+ }
+ }
+ }
+ }
+
+ return valid == null || valid.length() == 0;
+ }
+
private boolean isAsignableFrom(String type, Data datum) {
Object data = datum.getData();
boolean assignable = false;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|