diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2012-05-30 08:37:45 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2012-05-30 08:37:45 +0200 |
| commit | b086f57f56bf0eb9dab9cf321a0f69aaaae84347 (patch) | |
| tree | 8e6e26e8b7eed6abad7a17b093bdbb55c5e6b1ba /source/com/c2kernel/gui/tabs/outcome/form/field/ComboField.java | |
| parent | 22088ae8d2d5ff390518dbe1c4372325ffb3a647 (diff) | |
Initial Maven Conversion
Diffstat (limited to 'source/com/c2kernel/gui/tabs/outcome/form/field/ComboField.java')
| -rw-r--r-- | source/com/c2kernel/gui/tabs/outcome/form/field/ComboField.java | 144 |
1 files changed, 0 insertions, 144 deletions
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/field/ComboField.java b/source/com/c2kernel/gui/tabs/outcome/form/field/ComboField.java deleted file mode 100644 index 2c4ce05..0000000 --- a/source/com/c2kernel/gui/tabs/outcome/form/field/ComboField.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.c2kernel.gui.tabs.outcome.form.field;
-
-import java.awt.Component;
-import java.util.Enumeration;
-import java.util.StringTokenizer;
-
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.JComboBox;
-import javax.swing.text.JTextComponent;
-
-import org.exolab.castor.types.AnyNode;
-import org.exolab.castor.xml.schema.AttributeDecl;
-import org.exolab.castor.xml.schema.ElementDecl;
-import org.exolab.castor.xml.schema.Facet;
-import org.exolab.castor.xml.schema.SimpleType;
-
-import com.c2kernel.gui.tabs.outcome.form.StructuralException;
-import com.c2kernel.scripting.Script;
-import com.c2kernel.utils.Logger;
-
-/*******************************************************************************
- *
- * $Revision: 1.4 $ $Date: 2005/08/16 13:59:56 $
- *
- * Copyright (C) 2003 CERN - European Organization for Nuclear Research All
- * rights reserved.
- ******************************************************************************/
-
-public class ComboField extends StringEditField {
-
- JComboBox comboField;
- ListOfValues vals;
- DefaultComboBoxModel comboModel;
- AnyNode listNode;
-
- public ComboField(SimpleType type, AnyNode listNode) {
- super();
- comboField = new JComboBox();
- content = type;
- this.listNode = listNode;
- createLOV();
- }
-
- @Override
- public String getDefaultValue() {
- if (vals.getDefaultKey() != null)
- return vals.get(vals.getDefaultKey()).toString();
- else
- return "";
- }
-
- @Override
- public String getText() {
- return vals.get(comboModel.getSelectedItem()).toString();
- }
-
- @Override
- public JTextComponent makeTextField() {
- // not used by this control
- return null;
- }
-
- @Override
- public void setText(String text) {
- comboModel.setSelectedItem(text);
- }
-
- @Override
- public Component getControl() {
- return comboField;
- }
-
- private void createLOV() {
- vals = new ListOfValues();
-
- if (listNode != null) { // schema instructions for list building
- String lovType = listNode.getLocalName();
- String param = listNode.getFirstChild().getStringValue();
- if (lovType.equals("ScriptList"))
- populateLOVFromScript(param);
- if (lovType.equals("PathList"))
- populateLOVFromLDAP(param);
- }
-
- // handle enumerations
- // TODO: should be ANDed with above results
- if (content.hasFacet(Facet.ENUMERATION)) {
- //ListOfValues andList = new ListOfValues();
- Enumeration<Facet> enums = content.getFacets(Facet.ENUMERATION);
- while (enums.hasMoreElements()) {
- Facet thisEnum = enums.nextElement();
- vals.put(thisEnum.getValue(), thisEnum.getValue(), false);
- }
- }
-
- String[] keyArray = new String[vals.keySet().size()];
- comboModel = new DefaultComboBoxModel(vals.keySet().toArray(keyArray));
- comboModel.setSelectedItem(vals.getDefaultKey());
- comboField.setModel(comboModel);
- }
-
- /**
- * @param param
- */
- private void populateLOVFromLDAP(String param) {
- // TODO List of Values from LDAP properties, eg '/root/path;prop=val;prop=val'
-
-
- }
-
- private void populateLOVFromScript(String scriptName) {
- try {
- StringTokenizer tok = new StringTokenizer(scriptName, "_");
- if (tok.countTokens() != 2)
- throw new Exception("Invalid LOVScript name");
- Script lovscript = new Script(tok.nextToken(), Integer.parseInt(tok.nextToken()));
- lovscript.setInputParamValue("LOV", vals);
- lovscript.execute();
- } catch (Exception ex) {
- Logger.exceptionDialog(ex);
- }
- }
-
- @Override
- public void setDecl(AttributeDecl model) throws StructuralException {
- super.setDecl(model);
- createLOV();
- }
-
- @Override
- public void setDecl(ElementDecl model) throws StructuralException {
- super.setDecl(model);
- createLOV();
- }
-
- /**
- *
- */
-
- @Override
- public void setEditable(boolean editable) {
- comboField.setEditable(editable);
- }
-}
\ No newline at end of file |
