summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/gui/tabs/outcome/form/field/StringEditField.java
diff options
context:
space:
mode:
Diffstat (limited to 'source/com/c2kernel/gui/tabs/outcome/form/field/StringEditField.java')
-rw-r--r--[-rwxr-xr-x]source/com/c2kernel/gui/tabs/outcome/form/field/StringEditField.java62
1 files changed, 33 insertions, 29 deletions
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/field/StringEditField.java b/source/com/c2kernel/gui/tabs/outcome/form/field/StringEditField.java
index 310ee2e..a9b55a4 100755..100644
--- a/source/com/c2kernel/gui/tabs/outcome/form/field/StringEditField.java
+++ b/source/com/c2kernel/gui/tabs/outcome/form/field/StringEditField.java
@@ -42,33 +42,33 @@ public class StringEditField implements FocusListener, DomainKeyConsumer {
HelpPane helpPane;
String helpText;
protected JTextComponent field;
-
+
boolean isValid = true;
boolean editable = true;
String name;
-
- public StringEditField() {
+
+ public StringEditField() {
field = makeTextField();
if (field != null)
field.addFocusListener(this);
}
-
+
private static StringEditField getFieldForType(SimpleType type) {
// handle lists special
- if (type instanceof ListType)
+ if (type instanceof ListType)
return new ArrayEditField(type.getBuiltInBaseType());
// is a combobox
if (type.hasFacet(Facet.ENUMERATION))
return new ComboField(type, null);
//find LOVscript
- Enumeration e = type.getAnnotations();
+ Enumeration<?> e = type.getAnnotations();
while (e.hasMoreElements()) {
Annotation note = (Annotation)e.nextElement();
- for (Enumeration f = note.getAppInfo(); f.hasMoreElements();) {
+ for (Enumeration<?> f = note.getAppInfo(); f.hasMoreElements();) {
AppInfo thisAppInfo = (AppInfo)f.nextElement();
- for (Enumeration g = thisAppInfo.getObjects(); g.hasMoreElements();) {
+ for (Enumeration<?> g = thisAppInfo.getObjects(); g.hasMoreElements();) {
AnyNode appInfoNode = (AnyNode)g.nextElement();
if (appInfoNode.getLocalName().equals("ScriptList")
|| appInfoNode.getLocalName().equals("LDAPList")) {
@@ -82,12 +82,12 @@ public class StringEditField implements FocusListener, DomainKeyConsumer {
if (type.getLength()!=null) length = type.getLength().longValue();
else if (type.getMaxLength()!=null) length = type.getMaxLength().longValue();
else if (type.getMinLength()!=null) length = type.getMinLength().longValue();
-
+
// find base type if derived
if (!(type.isBuiltInType()))
- type = type.getBuiltInBaseType();
+ type = type.getBuiltInBaseType();
// else derive the class
- Class contentClass = OutcomeStructure.getJavaClass(type.getTypeCode());
+ Class<?> contentClass = OutcomeStructure.getJavaClass(type.getTypeCode());
// disable list edits for the moment
if (contentClass.equals(Boolean.class))
return new BooleanEditField();
@@ -96,7 +96,7 @@ public class StringEditField implements FocusListener, DomainKeyConsumer {
else if (contentClass.equals(BigDecimal.class))
return new DecimalEditField();
else if (contentClass.equals(ImageIcon.class))
- return new ImageEditField();
+ return new ImageEditField();
else if (length > 60)
return new LongStringEditField();
else return new StringEditField();
@@ -107,7 +107,7 @@ public class StringEditField implements FocusListener, DomainKeyConsumer {
newField.setDecl(model);
return newField;
}
-
+
public static StringEditField getEditField(ElementDecl model) throws StructuralException {
try {
XMLType baseType = model.getType();
@@ -120,7 +120,7 @@ public class StringEditField implements FocusListener, DomainKeyConsumer {
throw new StructuralException("No type defined in model");
}
}
-
+
public void setDecl(AttributeDecl model) throws StructuralException {
this.model=model;
this.content=model.getSimpleType();
@@ -132,7 +132,7 @@ public class StringEditField implements FocusListener, DomainKeyConsumer {
this.model=model;
this.name = model.getName();
XMLType type = model.getType();
-
+
// derive base type
if (type.isSimpleType())
this.content = (SimpleType)type;
@@ -141,9 +141,9 @@ public class StringEditField implements FocusListener, DomainKeyConsumer {
if (this.content == null) throw new StructuralException("No declared base type of element");
- //
+ //
if (model.getFixedValue() != null) setEditable(false);
-
+
}
public void setData(Attr newData) throws StructuralException {
@@ -178,26 +178,28 @@ public class StringEditField implements FocusListener, DomainKeyConsumer {
public Node getData() {
return data;
}
-
+
public String getDefaultValue() {
return "";
}
-
+
public void setHelp(HelpPane helpPane, String helpText) {
this.helpPane = helpPane;
this.helpText = helpText;
}
- public void focusLost(FocusEvent e) {
+ @Override
+ public void focusLost(FocusEvent e) {
if (MainFrame.itemFinder != null)
MainFrame.itemFinder.clearConsumer(this);
updateNode();
}
- public void focusGained(FocusEvent e) {
+ @Override
+ public void focusGained(FocusEvent e) {
helpPane.setHelp(name, helpText);
if (editable && MainFrame.itemFinder != null)
- MainFrame.itemFinder.setConsumer(this, "Insert");
+ MainFrame.itemFinder.setConsumer(this, "Insert");
}
public void updateNode() {
@@ -213,23 +215,25 @@ public class StringEditField implements FocusListener, DomainKeyConsumer {
/**
* Read domkey from barcode input
*/
- public void push(DomainPath key) {
+ @Override
+ public void push(DomainPath key) {
setText(key.getName());
}
/**
* Read string from barcode input
*/
- public void push(String key) {
+ @Override
+ public void push(String key) {
setText(key);
}
-
+
public void setEditable(boolean editable) {
this.editable = editable;
if (field != null)
field.setEditable(editable);
}
-
+
public String getText() {
return field.getText();
}
@@ -237,15 +241,15 @@ public class StringEditField implements FocusListener, DomainKeyConsumer {
public void setText(String text) {
field.setText(text);
}
-
+
public JTextComponent makeTextField() {
return new JTextField();
}
-
+
public Component getControl() {
return field;
}
-
+
public void grabFocus() {
getControl().requestFocus();
}