diff options
Diffstat (limited to 'source/com/c2kernel/gui/tabs/outcome')
23 files changed, 555 insertions, 466 deletions
diff --git a/source/com/c2kernel/gui/tabs/outcome/BasicOutcomeEditor.java b/source/com/c2kernel/gui/tabs/outcome/BasicOutcomeEditor.java index 451b393..5ab5245 100755..100644 --- a/source/com/c2kernel/gui/tabs/outcome/BasicOutcomeEditor.java +++ b/source/com/c2kernel/gui/tabs/outcome/BasicOutcomeEditor.java @@ -29,7 +29,7 @@ public class BasicOutcomeEditor extends JPanel implements OutcomeHandler { PlainDocument doc;
JTextArea textarea;
boolean unsaved;
-
+
public BasicOutcomeEditor() {
super();
this.setLayout(new GridLayout(1,1));
@@ -39,14 +39,18 @@ public class BasicOutcomeEditor extends JPanel implements OutcomeHandler { textarea.setFont(Font.decode("monospaced"));
add(new JScrollPane(textarea));
doc.addDocumentListener(new DocumentListener() {
- public void changedUpdate(DocumentEvent e) { unsaved = true; }
- public void insertUpdate(DocumentEvent e) { unsaved = true; }
- public void removeUpdate(DocumentEvent e) { unsaved = true; }
-
+ @Override
+ public void changedUpdate(DocumentEvent e) { unsaved = true; }
+ @Override
+ public void insertUpdate(DocumentEvent e) { unsaved = true; }
+ @Override
+ public void removeUpdate(DocumentEvent e) { unsaved = true; }
+
});
}
- public void setOutcome(String outcome) throws InvalidOutcomeException {
+ @Override
+ public void setOutcome(String outcome) throws InvalidOutcomeException {
try {
doc.insertString(0, outcome, null);
unsaved = false;
@@ -55,14 +59,17 @@ public class BasicOutcomeEditor extends JPanel implements OutcomeHandler { }
}
- public void setDescription(String description) throws InvalidSchemaException { }
+ @Override
+ public void setDescription(String description) throws InvalidSchemaException { }
- public void setReadOnly(boolean readOnly) {
+ @Override
+ public void setReadOnly(boolean readOnly) {
textarea.setEditable(!readOnly);
}
- public JPanel getPanel() throws OutcomeNotInitialisedException {
+ @Override
+ public JPanel getPanel() throws OutcomeNotInitialisedException {
return this;
}
@@ -70,7 +77,8 @@ public class BasicOutcomeEditor extends JPanel implements OutcomeHandler { *
*/
- public String getOutcome() throws OutcomeException {
+ @Override
+ public String getOutcome() throws OutcomeException {
try {
return doc.getText(0, doc.getLength());
} catch (Exception ex) {
@@ -82,18 +90,22 @@ public class BasicOutcomeEditor extends JPanel implements OutcomeHandler { *
*/
- public void run() {
+ @Override
+ public void run() {
}
- public boolean isUnsaved() {
+ @Override
+ public boolean isUnsaved() {
return unsaved;
}
-
- public void saved() {
+
+ @Override
+ public void saved() {
unsaved = false;
}
+ @Override
public void export(File targetFile) throws Exception {
FileStringUtility.string2File(targetFile, getOutcome());
}
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/AttributeList.java b/source/com/c2kernel/gui/tabs/outcome/form/AttributeList.java index 015bd9a..3d6cc6e 100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/AttributeList.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/AttributeList.java @@ -26,7 +26,7 @@ public class AttributeList extends JPanel { ElementDecl model;
Element myElement;
boolean readOnly;
- static Font labelFont;
+ static Font labelFont;
public AttributeList(ElementDecl model, boolean readOnly, HelpPane helpPane) {
super();
@@ -44,7 +44,7 @@ public class AttributeList extends JPanel { // simple types have no attributes
return;
}
-
+
ComplexType content = (ComplexType)model.getType();
// place on panel
@@ -53,9 +53,9 @@ public class AttributeList extends JPanel { c.anchor = GridBagConstraints.NORTHWEST;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1.0; c.weighty = 1.0; c.gridx = 0;
- c.ipadx = 5; c.ipady = 0;
+ c.ipadx = 5; c.ipady = 0;
- for (Enumeration fields = content.getAttributeDecls(); fields.hasMoreElements();) {
+ for (Enumeration<?> fields = content.getAttributeDecls(); fields.hasMoreElements();) {
c.gridy = 0;
thisDecl = (AttributeDecl)fields.nextElement();
Logger.msg(8, "Includes Attribute "+thisDecl.getName());
@@ -70,11 +70,11 @@ public class AttributeList extends JPanel { // read help
String helpText;
String doc = OutcomeStructure.extractHelp(thisDecl);
- if (doc.length() > 0)
+ if (doc.length() > 0)
helpText = doc.toString();
else
helpText = "<i>No help is available for this attribute</i>";
-
+
c.gridy++;
@@ -91,7 +91,7 @@ public class AttributeList extends JPanel { entry.setToolTipText(e.getMessage());
gridbag.setConstraints(entry, c);
this.add(entry);
- }
+ }
c.gridx++;
@@ -100,26 +100,25 @@ public class AttributeList extends JPanel { public void setInstance(Element data) throws StructuralException {
this.myElement = data;
- for (Iterator e = attrSet.iterator(); e.hasNext();) {
- StringEditField thisField = (StringEditField)e.next();
+ for (StringEditField thisField : attrSet) {
Logger.msg(8, "Populating Attribute "+thisField.getName());
Attr thisAttr = myElement.getAttributeNode(thisField.getName());
- if (thisAttr == null)
+ if (thisAttr == null)
thisAttr = newAttribute(myElement, (AttributeDecl)thisField.getModel());
thisField.setData(thisAttr);
}
}
-
+
public Attr newAttribute(Element parent, AttributeDecl attr) {
-
+
parent.setAttribute(attr.getName(), attr.getFixedValue()!=null?attr.getFixedValue():attr.getDefaultValue());
return parent.getAttributeNode(attr.getName());
}
-
+
public String validateAttributes() {
if (model.getType().isComplexType()) {
ComplexType content = (ComplexType)model.getType();
- for (Enumeration fields = content.getAttributeDecls(); fields.hasMoreElements();) {
+ for (Enumeration<?> fields = content.getAttributeDecls(); fields.hasMoreElements();) {
AttributeDecl thisDecl = (AttributeDecl)fields.nextElement();
String attrVal = myElement.getAttribute(thisDecl.getName());
if (attrVal.length() == 0 && thisDecl.isOptional()) {
@@ -129,20 +128,20 @@ public class AttributeList extends JPanel { }
return null;
}
-
+
public void initNew(Element parent) {
AttributeDecl thisDecl;
StringEditField thisField;
Attr thisAttr;
this.myElement = parent;
-
+
if (model.getType().isSimpleType()) return; // no attributes in simple types
-
+
ComplexType content = (ComplexType)model.getType();
-
- for (Iterator e = attrSet.iterator(); e.hasNext();) {
- thisField = (StringEditField)e.next();
-
+
+ for (Iterator<StringEditField> e = attrSet.iterator(); e.hasNext();) {
+ thisField = e.next();
+
thisDecl = content.getAttributeDecl(thisField.getName());
thisAttr = newAttribute(myElement, thisDecl);
// add into parent - fill in field
@@ -151,8 +150,9 @@ public class AttributeList extends JPanel { } catch (Exception ex) { } // impossible name mismatch
}
}
- public void grabFocus() {
+ @Override
+ public void grabFocus() {
if (attrSet.size() > 0)
- ((StringEditField)attrSet.get(0)).grabFocus();
+ attrSet.get(0).grabFocus();
}
}
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/DataRecord.java b/source/com/c2kernel/gui/tabs/outcome/form/DataRecord.java index 9d0b633..7477ecd 100755..100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/DataRecord.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/DataRecord.java @@ -4,7 +4,6 @@ import java.awt.GridBagConstraints; import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.ArrayList;
-import java.util.Iterator;
import javax.swing.JLabel;
import javax.swing.JTabbedPane;
@@ -26,7 +25,7 @@ public class DataRecord extends OutcomeStructure implements ChangeListener { AttributeList myAttributes;
JTabbedPane DRPanel = null;
boolean deferred;
- ArrayList deferredChildren = new ArrayList();
+ ArrayList<?> deferredChildren = new ArrayList<Object>();
Document parentDoc;
GridBagConstraints position;
GridBagLayout gridbag;
@@ -36,7 +35,7 @@ public class DataRecord extends OutcomeStructure implements ChangeListener { this.deferred = deferred;
if (!deferred) setupPanel();
}
-
+
public synchronized void activate() {
deferred = false;
try {
@@ -84,7 +83,8 @@ public class DataRecord extends OutcomeStructure implements ChangeListener { }
}
- public void addStructure(OutcomeStructure newElement) throws OutcomeException {
+ @Override
+ public void addStructure(OutcomeStructure newElement) throws OutcomeException {
super.addStructure(newElement);
if (newElement == null) return;
if (newElement instanceof DataRecord) {
@@ -127,7 +127,7 @@ public class DataRecord extends OutcomeStructure implements ChangeListener { position.gridy--;
position.gridheight=2;
position.weightx=0;
- position.fill=GridBagConstraints.NONE;
+ position.fill=GridBagConstraints.NONE;
gridbag.setConstraints(newField.getAttributes(), position);
this.add(newField.getAttributes());
position.gridx=0;
@@ -135,7 +135,7 @@ public class DataRecord extends OutcomeStructure implements ChangeListener { position.gridy++;
}
else {
- position.fill=GridBagConstraints.HORIZONTAL;
+ position.fill=GridBagConstraints.HORIZONTAL;
position.gridwidth=3;
position.weightx=1.0;
position.gridy++;
@@ -146,48 +146,49 @@ public class DataRecord extends OutcomeStructure implements ChangeListener { }
}
- public void addInstance(Element myElement, Document parentDoc) throws OutcomeException {
+ @Override
+ public void addInstance(Element myElement, Document parentDoc) throws OutcomeException {
Logger.msg(8, "Accepting DR "+myElement.getTagName());
if (this.myElement != null) throw new CardinalException("DataRecord "+this.getName()+" cannot repeat.");
this.myElement = myElement;
this.parentDoc = parentDoc;
-
+
if (!deferred)
populateInstance();
}
-
+
public void populateInstance() throws OutcomeException {
myAttributes.setInstance(myElement);
-
+
NodeList childElements = myElement.getChildNodes();
-
+
for (int i=0; i<childElements.getLength();i++) {
if (!(childElements.item(i) instanceof Element)) // ignore chardata here
continue;
Element thisElement = (Element) childElements.item(i);
// find the child structure with this name
- OutcomeStructure thisStructure = (OutcomeStructure)subStructure.get(thisElement.getTagName());
- if (thisStructure == null)
+ OutcomeStructure thisStructure = subStructure.get(thisElement.getTagName());
+ if (thisStructure == null)
throw new StructuralException("DR "+model.getName()+" not expecting "+thisElement.getTagName());
thisStructure.addInstance(thisElement, parentDoc);
}
-
+
// make sure any dimensions have the minimum
- for (Iterator e=subStructure.keySet().iterator(); e.hasNext();) {
- String structureName = (String)e.next();
- OutcomeStructure thisStructure = (OutcomeStructure)subStructure.get(structureName);
+ for (Object name2 : subStructure.keySet()) {
+ String structureName = (String)name2;
+ OutcomeStructure thisStructure = subStructure.get(structureName);
int count = 0;
-
- if (thisStructure instanceof Dimension) {
+
+ if (thisStructure instanceof Dimension) {
Dimension thisDimension = (Dimension)thisStructure;
thisDimension.setParentElement(myElement);
count = thisDimension.getChildCount();
}
- else
+ else
count = thisStructure.getElement()==null?0:1;
-
+
int total = thisStructure.getModel().getMinOccurs();
//if (total == 0) total++;
for (int i = count;i<total;i++) {
@@ -195,25 +196,26 @@ public class DataRecord extends OutcomeStructure implements ChangeListener { }
}
}
-
- public Element initNew(Document parent) {
+
+ @Override
+ public Element initNew(Document parent) {
Logger.msg(6, "Creating DR "+model.getName());
if (deferred) activate();
-
+
// make a new Element
myElement = parent.createElement(model.getName());
// populate
- for (Iterator e=order.iterator(); e.hasNext();) {
- String structureName = (String)e.next();
- OutcomeStructure thisStructure = (OutcomeStructure)subStructure.get(structureName);
- if (thisStructure instanceof Dimension)
+ for (Object name2 : order) {
+ String structureName = (String)name2;
+ OutcomeStructure thisStructure = subStructure.get(structureName);
+ if (thisStructure instanceof Dimension)
((Dimension)thisStructure).setParentElement(myElement);
int count = 0;
while (count < thisStructure.getModel().getMinOccurs()) {
myElement.appendChild(thisStructure.initNew(parent));
count++;
}
- }
+ }
// set up attributes
myAttributes.initNew(myElement);
@@ -222,28 +224,31 @@ public class DataRecord extends OutcomeStructure implements ChangeListener { }
- public void stateChanged(ChangeEvent e) {
+ @Override
+ public void stateChanged(ChangeEvent e) {
JTabbedPane targetPane = (JTabbedPane)e.getSource();
DataRecord targetTab = (DataRecord)targetPane.getSelectedComponent();
if (targetTab == this) {
helpPane.setHelp(getName(), getHelp());
if (deferred) SwingUtilities.invokeLater(
new Thread(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
activate();
}
}
));
}
}
-
+
/**
* sets focus to first editable child
*/
- public void grabFocus() {
+ @Override
+ public void grabFocus() {
if (myAttributes.attrSet.size() > 0)
myAttributes.grabFocus();
else if (order.size()> 0)
- ((OutcomeStructure)subStructure.get(order.get(0))).grabFocus();
+ subStructure.get(order.get(0)).grabFocus();
}
}
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/Dimension.java b/source/com/c2kernel/gui/tabs/outcome/form/Dimension.java index 8de306b..c91c5df 100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/Dimension.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/Dimension.java @@ -1,6 +1,6 @@ package com.c2kernel.gui.tabs.outcome.form;
-import java.awt.*;
import java.awt.FlowLayout;
+import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
@@ -11,7 +11,15 @@ import java.awt.event.FocusListener; import java.util.ArrayList;
import java.util.Iterator;
-import javax.swing.*;
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTabbedPane;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
import javax.swing.border.EtchedBorder;
import javax.swing.table.JTableHeader;
@@ -38,7 +46,7 @@ public class Dimension extends OutcomeStructure implements ActionListener { Box tableBox;
ArrayList<DimensionInstance> instances = new ArrayList<DimensionInstance>(); // stores DimensionInstances if tabs
ArrayList<Element> elements = new ArrayList<Element>(); // stores current children
-
+
JButton addButton;
JButton delButton;
@@ -61,17 +69,17 @@ public class Dimension extends OutcomeStructure implements ActionListener { position.insets = new Insets(0,0,0,0);
// TODO: an element or attribute of the dimension can be flagged as an index, so it can be used as a title for a tab
-
+
// set up the border
setBorder(BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), model.getName()));
-
+
msg = new JLabel("No elements");
msg.setFont(new Font("SansSerif", Font.ITALIC, msg.getFont().getSize()));
gridbag.setConstraints(msg, position);
add(msg);
position.gridy++;
-
+
// decide whether a table or tabs
try {
tableModel = new DimensionTableModel(model, readOnly);
@@ -90,10 +98,10 @@ public class Dimension extends OutcomeStructure implements ActionListener { gridbag.setConstraints(tableBox, position);
add(tableBox);
tableBox.setVisible(false);
-
+
} catch (StructuralException e) {
// use tabs
- Logger.msg(8, "DIM "+model.getName()+" - Will be tabs: "+e.getMessage());
+ Logger.msg(8, "DIM "+model.getName()+" - Will be tabs: "+e.getMessage());
mode = TABS;
tabs = new JTabbedPane();
gridbag.setConstraints(tabs, position);
@@ -101,7 +109,7 @@ public class Dimension extends OutcomeStructure implements ActionListener { tabs.setVisible(false);
}
if (!readOnly) {
- JPanel rowAdjust = new JPanel(new FlowLayout());
+ JPanel rowAdjust = new JPanel(new FlowLayout());
addButton = new JButton("+");
addButton.setActionCommand("add");
addButton.addActionListener(this);
@@ -113,19 +121,20 @@ public class Dimension extends OutcomeStructure implements ActionListener { delButton.setEnabled(false);
rowAdjust.add(delButton);
-
+
position.gridy++; position.weighty=0; position.weightx=0;
gridbag.setConstraints(rowAdjust, position);
this.add(rowAdjust);
}
-
+
}
-
+
public void setParentElement(Element parent) {
this.parent = parent;
}
- public void addInstance(Element myElement, Document parentDoc) throws OutcomeException {
+ @Override
+ public void addInstance(Element myElement, Document parentDoc) throws OutcomeException {
if (Logger.doLog(6))
Logger.msg(6, "DIM - adding instance "+ (elements.size()+1) +" for "+myElement.getTagName());
if (parent == null) setParentElement((Element)myElement.getParentNode());
@@ -134,24 +143,24 @@ public class Dimension extends OutcomeStructure implements ActionListener { tableModel.addInstance(myElement, -1);
elements.add(myElement);
}
- else {
+ else {
DimensionInstance target;
elements.add(myElement);
if (instances.size() < elements.size())
target = newInstance();
else
- target = (DimensionInstance)instances.get(elements.size()-1);
+ target = instances.get(elements.size()-1);
target.addInstance(myElement, parentDoc);
}
checkButtons();
}
-
+
public int getChildCount() {
return elements.size();
}
public DimensionInstance newInstance() {
- DimensionInstance newInstance = null;
+ DimensionInstance newInstance = null;
try {
newInstance = new DimensionInstance(model, readOnly, helpPane, deferChild);
instances.add(newInstance);
@@ -166,37 +175,38 @@ public class Dimension extends OutcomeStructure implements ActionListener { }
return newInstance;
}
-
- public String validateStructure() {
+
+ @Override
+ public String validateStructure() {
if (mode == TABLE)
return table.validateStructure();
else {
StringBuffer errors = new StringBuffer();
- for (Iterator iter = instances.iterator(); iter.hasNext();) {
- OutcomeStructure element = (OutcomeStructure)iter.next();
+ for (Iterator<DimensionInstance> iter = instances.iterator(); iter.hasNext();) {
+ OutcomeStructure element = iter.next();
errors.append(element.validateStructure());
}
- return errors.toString();
+ return errors.toString();
}
}
-
+
public void checkButtons() {
// check if data visible
boolean dataVisible = elements.size() > 0;
if (mode == TABS) tabs.setVisible(dataVisible);
else tableBox.setVisible(dataVisible);
msg.setVisible(!dataVisible);
-
+
if (readOnly) return;
-
+
if (elements.size() <= model.getMinOccurs() || elements.size() == 0) {
- delButton.setEnabled(false);
+ delButton.setEnabled(false);
delButton.setToolTipText("Minimum row count of "+model.getMinOccurs()+" reached.");
} else {
- delButton.setEnabled(true);
+ delButton.setEnabled(true);
delButton.setToolTipText(null);
}
-
+
if (elements.size() < model.getMaxOccurs() || model.getMaxOccurs() == Particle.UNBOUNDED) {
addButton.setEnabled(true);
addButton.setToolTipText(null);
@@ -205,8 +215,9 @@ public class Dimension extends OutcomeStructure implements ActionListener { addButton.setToolTipText("Maximum row count of "+model.getMaxOccurs()+" reached.");
}
}
-
- public Element initNew(Document parent) {
+
+ @Override
+ public Element initNew(Document parent) {
Element newElement;
if (mode == TABLE) {
@@ -220,19 +231,20 @@ public class Dimension extends OutcomeStructure implements ActionListener { if (instances.size() < elements.size()+1)
newTab = newInstance();
else
- newTab = (DimensionInstance)instances.get(elements.size()-1);
+ newTab = instances.get(elements.size()-1);
newElement = newTab.initNew(parent);
elements.add(newElement);
- checkButtons();
+ checkButtons();
return newElement;
}
}
-
- public void actionPerformed(ActionEvent e) {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
int index;
if (mode == TABS) index = tabs.getSelectedIndex();
else {
- index = table.getSelectedRow();
+ index = table.getSelectedRow();
if (index == -1) index = tableModel.getRowCount();
}
try {
@@ -246,16 +258,16 @@ public class Dimension extends OutcomeStructure implements ActionListener { JOptionPane.showMessageDialog(null, ex.getMessage(), "Table error", JOptionPane.ERROR_MESSAGE);
}
}
-
+
public void addRow(int index) throws CardinalException {
- if (elements.size() == model.getMaxOccurs())
+ if (elements.size() == model.getMaxOccurs())
throw new CardinalException("Maximum size of table reached");
-
+
if (mode == TABLE) {
Element newRow = tableModel.initNew(parent.getOwnerDocument(), index);
elements.add(index, newRow);
try {
- Element following = (Element)elements.get(index+1);
+ Element following = elements.get(index+1);
parent.insertBefore(newRow, following);
} catch (IndexOutOfBoundsException ex) {
parent.appendChild(newRow);
@@ -268,9 +280,9 @@ public class Dimension extends OutcomeStructure implements ActionListener { parent.appendChild(newTab);
}
checkButtons();
-
- }
-
+
+ }
+
public void removeRow(int index) throws CardinalException {
if (elements.size() <= model.getMinOccurs())
throw new CardinalException("Minimum size of table reached");
@@ -284,12 +296,12 @@ public class Dimension extends OutcomeStructure implements ActionListener { }
}
else {
- Element elementToGo = (Element)elements.get(index);
+ Element elementToGo = elements.get(index);
parent.removeChild(elementToGo);
instances.remove(index);
tabs.remove(index);
for (int i = index; i<instances.size(); i++) {
- DimensionInstance thisInstance = (DimensionInstance)instances.get(i);
+ DimensionInstance thisInstance = instances.get(i);
thisInstance.setTabNumber(i+1);
tabs.setTitleAt(i, thisInstance.getName());
}
@@ -297,9 +309,9 @@ public class Dimension extends OutcomeStructure implements ActionListener { elements.remove(index);
checkButtons();
}
-
+
private class DomKeyPushTable extends JTable implements DomainKeyConsumer, FocusListener {
-
+
Dimension dim;
public DomKeyPushTable(DimensionTableModel model, Dimension parent) {
super(model);
@@ -307,11 +319,13 @@ public class Dimension extends OutcomeStructure implements ActionListener { this.dim = parent;
}
- public void push(DomainPath key) {
+ @Override
+ public void push(DomainPath key) {
push(key.getName());
}
- public void push(String name) {
+ @Override
+ public void push(String name) {
int col = getSelectedColumn();
int row = getSelectedRow();
if (cellEditor != null)
@@ -333,27 +347,30 @@ public class Dimension extends OutcomeStructure implements ActionListener { if (row+1 < getRowCount()) {
Logger.msg(8, "Shifting selection to row "+(row+1));
changeSelection(row+1, col, false, false);
- }
+ }
}
}
-
- public void focusGained(FocusEvent e) {
+
+ @Override
+ public void focusGained(FocusEvent e) {
if (!readOnly)
MainFrame.itemFinder.setConsumer(this, "Insert");
}
- public void focusLost(FocusEvent e) {
+ @Override
+ public void focusLost(FocusEvent e) {
// release the itemFinder
- if (!readOnly)
+ if (!readOnly)
MainFrame.itemFinder.clearConsumer(this);
}
-
+
public String validateStructure() {
if (cellEditor != null)
cellEditor.stopCellEditing();
return null;
}
+ @Override
public void changeSelection( int rowIndex, int columnIndex, boolean toggle, boolean extend) {
super.changeSelection(rowIndex, columnIndex, toggle, extend);
DimensionTableModel dimModel = (DimensionTableModel)dataModel;
@@ -361,8 +378,9 @@ public class Dimension extends OutcomeStructure implements ActionListener { }
}
-
- public void grabFocus() {
+
+ @Override
+ public void grabFocus() {
if (mode == TABLE) {
if (table.getSelectedRow() == -1 && table.getRowCount() > 0) {
table.changeSelection(0, 0, false, false);
@@ -371,7 +389,7 @@ public class Dimension extends OutcomeStructure implements ActionListener { table.requestFocus();
}
else if (instances.size()> 0)
- ((DimensionInstance)instances.get(0)).grabFocus();
+ instances.get(0).grabFocus();
}
}
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/DimensionInstance.java b/source/com/c2kernel/gui/tabs/outcome/form/DimensionInstance.java index 07fbe1b..649886b 100755..100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/DimensionInstance.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/DimensionInstance.java @@ -9,7 +9,7 @@ public class DimensionInstance extends DataRecord { Dimension parentDimension;
int tabNumber;
String tabName = null;
-
+
public DimensionInstance(ElementDecl model, boolean readOnly , HelpPane help, boolean deferred) throws OutcomeException {
super(model, readOnly, help, deferred);
}
@@ -17,14 +17,15 @@ public class DimensionInstance extends DataRecord { public void setTabNumber(int tabNumber) {
this.tabNumber=tabNumber;
}
-
+
public void setParent(Dimension parent) {
this.parentDimension = parent;
}
-
- public String getName() {
+
+ @Override
+ public String getName() {
//TODO appinfo for picking out attributes or child elements for tab name
- if (tabName == null)
+ if (tabName == null)
return Integer.toString(tabNumber);
else
return tabName;
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/DimensionTableModel.java b/source/com/c2kernel/gui/tabs/outcome/form/DimensionTableModel.java index 1a606fb..45bdbc8 100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/DimensionTableModel.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/DimensionTableModel.java @@ -4,15 +4,29 @@ import java.util.Enumeration; import javax.swing.table.AbstractTableModel;
-import org.exolab.castor.xml.schema.*;
-import org.w3c.dom.*;
+import org.exolab.castor.xml.schema.Annotated;
+import org.exolab.castor.xml.schema.AttributeDecl;
+import org.exolab.castor.xml.schema.ComplexType;
+import org.exolab.castor.xml.schema.ContentModelGroup;
+import org.exolab.castor.xml.schema.ElementDecl;
+import org.exolab.castor.xml.schema.Group;
+import org.exolab.castor.xml.schema.Order;
+import org.exolab.castor.xml.schema.Particle;
+import org.exolab.castor.xml.schema.SimpleType;
+import org.exolab.castor.xml.schema.SimpleTypesFactory;
+import org.exolab.castor.xml.schema.XMLType;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
import com.c2kernel.gui.tabs.outcome.OutcomeException;
import com.c2kernel.utils.Language;
import com.c2kernel.utils.Logger;
public class DimensionTableModel extends AbstractTableModel {
-
+
ElementDecl model;
ArrayList<String> columnHeadings = new ArrayList<String>();
ArrayList<Class<?>> columnClasses = new ArrayList<Class<?>>();
@@ -25,7 +39,7 @@ public class DimensionTableModel extends AbstractTableModel { public DimensionTableModel(ElementDecl model, boolean readOnly) throws StructuralException {
XMLType modelContent = model.getType();
-
+
this.model = model;
this.readOnly = readOnly;
// use text node for simple types
@@ -47,7 +61,7 @@ public class DimensionTableModel extends AbstractTableModel { addColumn(model.getName(), baseType, typeCode, new Boolean(model.getFixedValue() != null));
}
// process attributes
- for (Enumeration e = elementType.getAttributeDecls(); e.hasMoreElements();) {
+ for (Enumeration<?> e = elementType.getAttributeDecls(); e.hasMoreElements();) {
AttributeDecl thisAttr = (AttributeDecl)e.nextElement();
addColumn(thisAttr.getName(), thisAttr, thisAttr.getSimpleType().getTypeCode(), new Boolean(thisAttr.isFixed()));
}
@@ -63,30 +77,30 @@ public class DimensionTableModel extends AbstractTableModel { columnDecls.add(decl);
columnClasses.add(OutcomeStructure.getJavaClass(typeCode));
colReadOnly.add(readOnly);
-
+
// read help
String helpText;
if (decl instanceof SimpleType)
helpText = OutcomeStructure.extractHelp(model);
else
helpText = OutcomeStructure.extractHelp(decl);
-
- if (helpText.length() == 0)
+
+ if (helpText.length() == 0)
helpText = "<i>"+Language.translate("No help is available for this cell")+"</i>";
-
+
colHelp.add(helpText);
}
public void enumerateElements(ContentModelGroup group) throws StructuralException {
- for (Enumeration childElements = group.enumerate(); childElements.hasMoreElements(); ) {
+ for (Enumeration<?> childElements = group.enumerate(); childElements.hasMoreElements(); ) {
Particle thisParticle = (Particle)childElements.nextElement();
String extraHeader = "";
if (thisParticle instanceof Group) {
Group thisGroup = (Group)thisParticle;
Order order = thisGroup.getOrder();
- if (order == Order.sequence || order == Order.all)
+ if (order == Order.sequence || order == Order.all)
enumerateElements(thisGroup);
else // we only support sequences in data structures such as these
throw new StructuralException("Element "+thisGroup.getName()+". Expecting sequence or all. Got "+thisGroup.getOrder());
@@ -101,9 +115,9 @@ public class DimensionTableModel extends AbstractTableModel { if (elementType.getParticleCount() > 0 ||
thisElement.getMaxOccurs() > 1)
throw new StructuralException("Too deep for a table");
- for (Enumeration attrs = elementType.getAttributeDecls(); attrs.hasMoreElements();) {
+ for (Enumeration<?> attrs = elementType.getAttributeDecls(); attrs.hasMoreElements();) {
AttributeDecl thisAttr = (AttributeDecl)attrs.nextElement();
- if (!thisAttr.isFixed())
+ if (!thisAttr.isFixed())
throw new StructuralException("Non-fixed attributes of child elements not supported in tables.");
else
extraHeader=extraHeader+" ("+thisAttr.getName()+":"+(thisAttr.getFixedValue()!=null?thisAttr.getFixedValue():thisAttr.getDefaultValue())+")";
@@ -118,7 +132,7 @@ public class DimensionTableModel extends AbstractTableModel { else
typeCode = ((SimpleType)thisElement.getType()).getTypeCode();
}
-
+
//add to list
addColumn(thisElement.getName()+extraHeader, thisElement, typeCode, new Boolean(thisElement.getFixedValue() != null));
}
@@ -139,35 +153,35 @@ public class DimensionTableModel extends AbstractTableModel { if (childElement.hasChildNodes()) {
Node thisNode = childElement.getFirstChild();
if (thisNode.getNodeType() == Node.TEXT_NODE)
- newRow[i] = OutcomeStructure.getTypedValue(((Text)thisNode).getData(), (Class)columnClasses.get(i));
+ newRow[i] = OutcomeStructure.getTypedValue(((Text)thisNode).getData(), columnClasses.get(i));
else
throw new StructuralException("First child of Field " + thisElementDecl.getName() + " was not Text. (NodeType:"+thisNode.getNodeType()+")");
}
else { // create text node
- newRow[i] = this.setupDefaultElement(thisElementDecl, childElement, (Class)columnClasses.get(i));
+ newRow[i] = this.setupDefaultElement(thisElementDecl, childElement, columnClasses.get(i));
}
break;
case 0: // element is missing - create it
Element newElement = myElement.getOwnerDocument().createElement(thisElementDecl.getName());
myElement.appendChild(newElement); //TODO: not in the right place in sequence. should insert it
- newRow[i] = setupDefaultElement(thisElementDecl, newElement, (Class)columnClasses.get(i));
- break;
+ newRow[i] = setupDefaultElement(thisElementDecl, newElement, columnClasses.get(i));
+ break;
default:
throw new CardinalException("Element "+thisElementDecl.getName()+" appeared more than once.");
}
}
else if (columnDecls.get(i) instanceof AttributeDecl) { //attribute
AttributeDecl thisAttrDecl = (AttributeDecl)columnDecls.get(i);
- newRow[i] = OutcomeStructure.getTypedValue(myElement.getAttribute(thisAttrDecl.getName()), (Class)columnClasses.get(i));
+ newRow[i] = OutcomeStructure.getTypedValue(myElement.getAttribute(thisAttrDecl.getName()), columnClasses.get(i));
}
- else { // first child node
+ else { // first child node
Node thisNode = myElement.getFirstChild();
if (thisNode == null) {
thisNode = myElement.getOwnerDocument().createTextNode("");
myElement.appendChild(thisNode);
}
if (thisNode.getNodeType() == Node.TEXT_NODE || thisNode.getNodeType() == Node.CDATA_SECTION_NODE)
- newRow[i] = OutcomeStructure.getTypedValue(((Text)thisNode).getData(), (Class)columnClasses.get(i));
+ newRow[i] = OutcomeStructure.getTypedValue(((Text)thisNode).getData(), columnClasses.get(i));
else
throw new StructuralException("First child of Column " + myElement.getTagName() + " was not Text");
}
@@ -176,31 +190,37 @@ public class DimensionTableModel extends AbstractTableModel { rows.add(index, newRow);
fireTableRowsInserted(index, index);
}
- public Class<?> getColumnClass(int columnIndex) {
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
return columnClasses.get(columnIndex);
}
- public String getColumnName(int columnIndex) {
- return (String)columnHeadings.get(columnIndex);
+ @Override
+ public String getColumnName(int columnIndex) {
+ return columnHeadings.get(columnIndex);
}
- public int getRowCount() {
+ @Override
+ public int getRowCount() {
return rows.size();
}
- public int getColumnCount() {
+ @Override
+ public int getColumnCount() {
return columnHeadings.size();
}
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- boolean isReadOnly = readOnly || ((Boolean)colReadOnly.get(columnIndex)).booleanValue();
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ boolean isReadOnly = readOnly || colReadOnly.get(columnIndex).booleanValue();
return !isReadOnly;
}
- public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
- Object[] thisRow = (Object[])rows.get(rowIndex);
+ @Override
+ public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
+ Object[] thisRow = rows.get(rowIndex);
thisRow[columnIndex]=aValue;
- Element myElement = (Element)elements.get(rowIndex);
+ Element myElement = elements.get(rowIndex);
// update node
if (columnDecls.get(columnIndex) instanceof ElementDecl) { // sub element
ElementDecl thisDecl = (ElementDecl)columnDecls.get(columnIndex);
@@ -213,7 +233,7 @@ public class DimensionTableModel extends AbstractTableModel { AttributeDecl thisDecl = (AttributeDecl) columnDecls.get(columnIndex);
myElement.setAttribute(thisDecl.getName(), aValue.toString());
}
- else { // first child node
+ else { // first child node
Text textNode = (Text)myElement.getFirstChild();
textNode.setData(aValue.toString());
}
@@ -221,14 +241,14 @@ public class DimensionTableModel extends AbstractTableModel { }
public Element removeRow(int rowIndex) {
- Element elementToGo = (Element)elements.get(rowIndex);
+ Element elementToGo = elements.get(rowIndex);
elements.remove(rowIndex);
rows.remove(rowIndex);
fireTableRowsDeleted(rowIndex,rowIndex);
return elementToGo;
}
-
- public Object setupDefaultElement(ElementDecl thisDecl, Element parent, Class type) {
+
+ public Object setupDefaultElement(ElementDecl thisDecl, Element parent, Class<?> type) {
Object newValue;
String defaultValue = thisDecl.getFixedValue();
if (defaultValue == null)
@@ -237,13 +257,13 @@ public class DimensionTableModel extends AbstractTableModel { newValue = "";
else
newValue = OutcomeStructure.getTypedValue(defaultValue, type);
-
+
Text newNode = parent.getOwnerDocument().createTextNode(newValue.toString());
parent.appendChild(newNode);
// fixed attributes
try {
ComplexType content = (ComplexType)thisDecl.getType();
- for (Enumeration attrs = content.getAttributeDecls(); attrs.hasMoreElements();) {
+ for (Enumeration<?> attrs = content.getAttributeDecls(); attrs.hasMoreElements();) {
AttributeDecl thisAttr = (AttributeDecl)attrs.nextElement();
parent.setAttribute(thisAttr.getName(), thisAttr.getFixedValue()!=null?thisAttr.getFixedValue():thisAttr.getDefaultValue());
}
@@ -251,16 +271,17 @@ public class DimensionTableModel extends AbstractTableModel { return newValue;
}
- public Object getValueAt(int rowIndex, int columnIndex) {
- Object[] thisRow = (Object[])rows.get(rowIndex);
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ Object[] thisRow = rows.get(rowIndex);
if (!(getColumnClass(columnIndex).equals(thisRow[columnIndex].getClass())))
Logger.warning(thisRow[columnIndex]+" should be "+getColumnClass(columnIndex)+" is a "+thisRow[columnIndex].getClass().getName());
return thisRow[columnIndex];
}
-
+
public String validateStructure() { // remove empty rows
for (int j=0; j < rows.size(); j++) {
- Object[] elems = (Object[])rows.get(j);
+ Object[] elems = rows.get(j);
boolean empty = true;
for (int i = 0; i < elems.length && empty; i++)
empty &= OutcomeStructure.isEmpty(elems[i]);
@@ -272,37 +293,37 @@ public class DimensionTableModel extends AbstractTableModel { }
return null;
}
-
+
public Element initNew(Document parent, int index) {
if (index == -1) index = elements.size();
Object[] newRow = new Object[columnHeadings.size()];
Element myElement = parent.createElement(model.getName());
for (int i=0; i<columnDecls.size(); i++) {
- if (columnDecls.get(i) instanceof ElementDecl) { // sub element
+ if (columnDecls.get(i) instanceof ElementDecl) { // sub element
ElementDecl childElementDecl = (ElementDecl)columnDecls.get(i);
Element childElement = parent.createElement(childElementDecl.getName());
- Object newValue = setupDefaultElement(childElementDecl, childElement, (Class)columnClasses.get(i));
+ Object newValue = setupDefaultElement(childElementDecl, childElement, columnClasses.get(i));
myElement.appendChild(childElement);
newRow[i] = newValue;
}
else if (columnDecls.get(i) instanceof AttributeDecl) { //attribute
AttributeDecl thisAttrDecl = (AttributeDecl)columnDecls.get(i);
String newValue = thisAttrDecl.getFixedValue()!=null?thisAttrDecl.getFixedValue():thisAttrDecl.getDefaultValue();
- newRow[i] = OutcomeStructure.getTypedValue(newValue, (Class)columnClasses.get(i));
+ newRow[i] = OutcomeStructure.getTypedValue(newValue, columnClasses.get(i));
myElement.setAttribute(thisAttrDecl.getName(), newRow[i].toString());
}
- else { // first child node
- newRow[i] = setupDefaultElement(model, myElement, (Class)columnClasses.get(i));
+ else { // first child node
+ newRow[i] = setupDefaultElement(model, myElement, columnClasses.get(i));
}
}
elements.add(index,myElement);
rows.add(index, newRow);
fireTableRowsInserted(index,index);
return myElement;
- }
-
+ }
+
public String getHelp(int i) {
- return (String)colHelp.get(i);
+ return colHelp.get(i);
}
-
+
}
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/Field.java b/source/com/c2kernel/gui/tabs/outcome/form/Field.java index e1bc35c..9d21c97 100755..100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/Field.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/Field.java @@ -58,16 +58,18 @@ public class Field extends OutcomeStructure { return myAttributes;
}
- public void addStructure(OutcomeStructure newElement) throws StructuralException {
+ @Override
+ public void addStructure(OutcomeStructure newElement) throws StructuralException {
throw new StructuralException("Field "+model.getName()+" cannot have child structures");
}
- public void addInstance(Element myElement, Document parentDoc) throws OutcomeException {
+ @Override
+ public void addInstance(Element myElement, Document parentDoc) throws OutcomeException {
Logger.msg(6, "Accepting Field "+myElement.getTagName());
if (this.myElement != null) throw new CardinalException("Field "+this.getName()+" cannot repeat");
this.myElement = myElement;
- try {
+ try {
if (myElementPanel == null)
Logger.error("Field should be empty. Discarding contents.");
else {
@@ -77,9 +79,9 @@ public class Field extends OutcomeStructure { textNode = parentDoc.createTextNode(getDefaultValue());
myElement.appendChild(textNode);
}
-
+
myElementPanel.setData(textNode);
- }
+ }
} catch (ClassCastException ex) {
throw new StructuralException("First child node of Field " + this.getName() + " was not Text: "+myElement.getFirstChild().getNodeType());
}
@@ -88,7 +90,8 @@ public class Field extends OutcomeStructure { // check if valid
- public String validateStructure() {
+ @Override
+ public String validateStructure() {
myAttributes.validateAttributes();
if (myElementPanel != null) myElementPanel.updateNode();
Text contents = (Text)myElement.getFirstChild();
@@ -99,7 +102,8 @@ public class Field extends OutcomeStructure { return null;
}
- public Element initNew(Document parent) {
+ @Override
+ public Element initNew(Document parent) {
Logger.msg(6, "Creating Field "+this.getName());
// make a new Element
@@ -119,7 +123,7 @@ public class Field extends OutcomeStructure { return myElement;
}
-
+
private String getDefaultValue() {
String defaultValue = model.getFixedValue();
if (defaultValue == null) defaultValue = model.getDefaultValue();
@@ -127,7 +131,8 @@ public class Field extends OutcomeStructure { return defaultValue;
}
- public void grabFocus() {
+ @Override
+ public void grabFocus() {
if (myElementPanel != null)
myElementPanel.grabFocus();
else
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/HelpPane.java b/source/com/c2kernel/gui/tabs/outcome/form/HelpPane.java index 0f0f812..aa8e13e 100755..100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/HelpPane.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/HelpPane.java @@ -15,9 +15,9 @@ import com.c2kernel.utils.Language; **************************************************************************/
public class HelpPane extends JEditorPane {
-
+
public static final String header = "<h2><font color=\"blue\">"+Language.translate("Help")+"</font></h2>";
-
+
public HelpPane() {
super();
setEditable(false);
@@ -25,24 +25,24 @@ public class HelpPane extends JEditorPane { setContentType("text/html");
setPreferredSize(new java.awt.Dimension(200,400));
}
-
+
public void setHelp(String title, String helpText) {
setText(header+"<h3>"+title+"</h3><br>"+toHTML(helpText));
}
-
+
/**
* Unfortunately JEditorPane will only display HTML3.2, whereas to embed HTML in an xsd we must
* use XHTML so it will be valid XML. This method does a quick and dirty removal of stuff that
* the JEditorPane cannot display
- *
+ *
* @param xhtml
* @return
*/
public static String toHTML(String xhtml) {
int startPos, endPos;
//remove xml header
- while((startPos = xhtml.indexOf("<?")) != -1 &&
+ while((startPos = xhtml.indexOf("<?")) != -1 &&
(endPos = xhtml.indexOf("?>")) != -1) {
xhtml = xhtml.substring(0,startPos)+xhtml.substring(endPos+2);
}
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/MultiLinePasteAdapter.java b/source/com/c2kernel/gui/tabs/outcome/form/MultiLinePasteAdapter.java index d9f6b55..3c5da27 100755..100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/MultiLinePasteAdapter.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/MultiLinePasteAdapter.java @@ -1,12 +1,19 @@ package com.c2kernel.gui.tabs.outcome.form;
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
+import java.awt.Toolkit;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.StringSelection;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.util.StringTokenizer;
-import com.c2kernel.utils.Logger;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+import javax.swing.JTable;
+import javax.swing.KeyStroke;
-import java.awt.datatransfer.*;
-import java.util.*;
+import com.c2kernel.utils.Logger;
/**
* ExcelAdapter enables Copy-Paste Clipboard functionality on JTables.
* The clipboard data format used by the adapter is compatible with
@@ -64,7 +71,8 @@ public class MultiLinePasteAdapter implements ActionListener { * Paste is done by aligning the upper left corner of the selection with the
* 1st element in the current selection of the JTable.
*/
- public void actionPerformed(ActionEvent e) {
+ @Override
+ public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().compareTo("Copy") == 0) {
StringBuffer sbf = new StringBuffer();
// Check to ensure we have selected only a contiguous block of
@@ -127,7 +135,7 @@ public class MultiLinePasteAdapter implements ActionListener { } catch (Exception ex) {
Logger.exceptionDialog(ex);
}
-
+
}
}
}
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/OutcomeEditor.java b/source/com/c2kernel/gui/tabs/outcome/form/OutcomeEditor.java index 10c3542..7809480 100755..100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/OutcomeEditor.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/OutcomeEditor.java @@ -27,14 +27,14 @@ class OutcomeEditor extends JFrame implements ActionListener { JFileChooser chooser;
OutcomePanel outcome;
OutcomeValidator thisValid;
-
+
public OutcomeEditor(File schema, File instance, boolean readOnly) {
URL schemaURL = null;
URL instanceURL = null;
schemaFile = schema;
instanceFile = instance;
this.readOnly = readOnly;
-
+
try {
chooser = new JFileChooser();
chooser.setCurrentDirectory(new File(new File(".").getCanonicalPath()));
@@ -47,12 +47,13 @@ class OutcomeEditor extends JFrame implements ActionListener { this.setTitle("Outcome Editor");
GridBagLayout gridbag = new GridBagLayout();
getContentPane().setLayout(gridbag);
-
+
addWindowListener(
new java.awt.event.WindowAdapter() {
- public void windowClosing(java.awt.event.WindowEvent evt) {
+ @Override
+ public void windowClosing(java.awt.event.WindowEvent evt) {
System.exit(0);
- }
+ }
}
);
// select files if url is empty
@@ -64,12 +65,12 @@ class OutcomeEditor extends JFrame implements ActionListener { System.exit(1);
}
}
-
+
try {
schemaURL = schemaFile.toURL();
- } catch (Exception e) {
+ } catch (Exception e) {
System.out.println("Invalid schema URL");
- System.exit(1);
+ System.exit(1);
}
if (instanceFile == null) { // prompt for schema
@@ -79,7 +80,7 @@ class OutcomeEditor extends JFrame implements ActionListener { try {
instanceURL = instanceFile.toURL();
} catch (Exception e) { }
-
+
try {
if (instanceFile != null && instanceFile.exists())
outcome = new OutcomePanel(schemaURL, instanceURL, readOnly);
@@ -93,14 +94,14 @@ class OutcomeEditor extends JFrame implements ActionListener { thisValid = OutcomeValidator.getValidator(thisSchema);
} catch (Exception e) { e.printStackTrace(); System.exit(0);}
-
-
+
+
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0; c.gridy = 0;
c.anchor = GridBagConstraints.NORTHWEST;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1.0; c.weighty = 1.0;
- c.gridwidth = 2; c.ipadx = 5; c.ipady = 5;
+ c.gridwidth = 2; c.ipadx = 5; c.ipady = 5;
gridbag.setConstraints(outcome, c);
this.getContentPane().add(outcome);
@@ -111,7 +112,7 @@ class OutcomeEditor extends JFrame implements ActionListener { gridbag.setConstraints(saveButton, c);
this.getContentPane().add(saveButton);
if (readOnly) saveButton.setEnabled(false);
-
+
JButton saveAsButton = new JButton("Save As");
saveAsButton.setActionCommand("saveas");
saveAsButton.addActionListener(this);
@@ -165,18 +166,19 @@ class OutcomeEditor extends JFrame implements ActionListener { new OutcomeEditor(schema, instance, readOnly);
}
- public void actionPerformed(ActionEvent e) {
+ @Override
+ public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().indexOf("save") == 0) {
String output;
output = outcome.getOutcome();
-
+
String errors = thisValid.validate(output);
if (errors != null && errors.length() > 0) {
int choice = JOptionPane.showConfirmDialog(null, errors+"\n\nSave anyway?", "Errors validating document", JOptionPane.YES_NO_OPTION);
if (choice != JOptionPane.YES_OPTION)
return;
}
-
+
if (instanceFile == null || e.getActionCommand().equals("saveas")) {
instanceFile = getFile("Choose Instance File", "xml");
if (instanceFile == null) {
@@ -200,11 +202,13 @@ class OutcomeEditor extends JFrame implements ActionListener { this.extension = extension;
}
- public String getDescription() {
+ @Override
+ public String getDescription() {
return extension.toUpperCase()+" Files";
}
- public boolean accept(File f) {
+ @Override
+ public boolean accept(File f) {
if ((f.isFile() && f.getName().endsWith(extension.toLowerCase())) || f.isDirectory()) {
return true;
}
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/OutcomePanel.java b/source/com/c2kernel/gui/tabs/outcome/form/OutcomePanel.java index 4bb7347..6d20183 100755..100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/OutcomePanel.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/OutcomePanel.java @@ -89,7 +89,7 @@ public class OutcomePanel extends JPanel implements OutcomeHandler splitPane.setDividerSize(9);
pane = splitPane;
}
-
+
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
@@ -165,8 +165,9 @@ public class OutcomePanel extends JPanel implements OutcomeHandler this.setOutcome(outcomeURL);
}
- // Parse from Strings
- public void setOutcome(String outcome) throws InvalidOutcomeException
+ // Parse from Strings
+ @Override
+ public void setOutcome(String outcome) throws InvalidOutcomeException
{
try
@@ -179,7 +180,8 @@ public class OutcomePanel extends JPanel implements OutcomeHandler }
}
- public void setDescription(String schema) throws InvalidSchemaException
+ @Override
+ public void setDescription(String schema) throws InvalidSchemaException
{
if (schema == null)
throw new InvalidSchemaException("Null schema supplied");
@@ -194,7 +196,8 @@ public class OutcomePanel extends JPanel implements OutcomeHandler }
- public void setReadOnly(boolean readOnly)
+ @Override
+ public void setReadOnly(boolean readOnly)
{
this.readOnly = readOnly;
}
@@ -218,7 +221,8 @@ public class OutcomePanel extends JPanel implements OutcomeHandler }
}
- public void run()
+ @Override
+ public void run()
{
Thread.currentThread().setName("Outcome Panel Builder");
try
@@ -271,7 +275,7 @@ public class OutcomePanel extends JPanel implements OutcomeHandler ElementDecl rootElementDecl = null;
docElement = (outcomeDOM == null) ? null : outcomeDOM.getDocumentElement();
- for (Enumeration globalElements = schemaSOM.getElementDecls(); globalElements.hasMoreElements();)
+ for (Enumeration<?> globalElements = schemaSOM.getElementDecls(); globalElements.hasMoreElements();)
{
rootElementDecl = (ElementDecl) globalElements.nextElement();
// REVISIT: We don't detect which is the most likely root element if there is more than one root decl
@@ -284,7 +288,7 @@ public class OutcomePanel extends JPanel implements OutcomeHandler if (rootElementDecl == null)
throw new InvalidSchemaException("No root elements defined");
documentRoot = new DataRecord(rootElementDecl, readOnly, help, false);
-
+
Logger.msg(5, "Finished structure. Populating...");
if (docElement == null)
{
@@ -302,7 +306,7 @@ public class OutcomePanel extends JPanel implements OutcomeHandler outcomeTab.addTab(rootElementDecl.getName(), documentRoot);
outcomeTab.setSelectedIndex(0);
- scrollpane.setViewportView(outcomeTab);
+ scrollpane.setViewportView(outcomeTab);
panelBuilt = true;
revalidate();
@@ -311,12 +315,14 @@ public class OutcomePanel extends JPanel implements OutcomeHandler documentRoot.grabFocus();
}
- public JPanel getPanel() throws OutcomeNotInitialisedException
+ @Override
+ public JPanel getPanel() throws OutcomeNotInitialisedException
{
return this;
}
- public String getOutcome()
+ @Override
+ public String getOutcome()
{
if (useForm)
{
@@ -348,14 +354,17 @@ public class OutcomePanel extends JPanel implements OutcomeHandler return serializedDoc;
}
- public boolean isUnsaved() {
+ @Override
+ public boolean isUnsaved() {
return unsaved;
}
-
- public void saved() {
+
+ @Override
+ public void saved() {
unsaved = false;
}
-
+
+ @Override
public void export(File targetFile) throws Exception {
FileStringUtility.string2File(targetFile, getOutcome());
}
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/OutcomeStructure.java b/source/com/c2kernel/gui/tabs/outcome/form/OutcomeStructure.java index a535da6..aee09df 100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/OutcomeStructure.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/OutcomeStructure.java @@ -4,7 +4,6 @@ import java.math.BigInteger; import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
-import java.util.Iterator;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
@@ -49,11 +48,11 @@ public abstract class OutcomeStructure extends JPanel { subStructure = new HashMap<String, OutcomeStructure>();
Logger.msg(8, "Creating " + model.getName() + " structure as " +
this.getClass().getName().substring(this.getClass().getName().lastIndexOf('.') + 1));
-
+
String doc = extractHelp(model);
if (doc.length() > 0) help = doc;
}
-
+
public boolean getReadOnly() {
return readOnly;
}
@@ -69,21 +68,21 @@ public abstract class OutcomeStructure extends JPanel { public OutcomeStructure createStructure(ElementDecl model, boolean readOnly, HelpPane help) throws OutcomeException {
XMLType elementType = model.getType();
ComplexType elementComplexType;
-
+
if (model.getMaxOccurs() == 0) return null;
-
+
// if more than one can occur - dimension
- if (model.getMaxOccurs() > 1
- || model.getMaxOccurs() == Particle.UNBOUNDED
- || model.getMinOccurs() == 0)
+ if (model.getMaxOccurs() > 1
+ || model.getMaxOccurs() == Particle.UNBOUNDED
+ || model.getMinOccurs() == 0)
return new Dimension(model, readOnly, help);
-
+
// must have a type from now on
if (elementType == null)
throw new StructuralException("Element "+model.getName()+" is elementary yet has no type.");
// simple types will be fields
if (elementType instanceof SimpleType) return new Field(model, readOnly, help);
-
+
// otherwise is a complex type
try {
elementComplexType = (ComplexType)elementType;
@@ -91,10 +90,10 @@ public abstract class OutcomeStructure extends JPanel { catch (ClassCastException e) {
throw new StructuralException("Unknown XMLType for element " + model.getName());
}
-
+
//when no element children - field
if (elementComplexType.getParticleCount() == 0) return new Field(model, readOnly, help);
-
+
//everything else is a data record
return new DataRecord(model, readOnly, help, deferChild);
}
@@ -113,11 +112,11 @@ public abstract class OutcomeStructure extends JPanel { enumerateElements((ComplexType)base);
}
- for (Enumeration elements = group.enumerate(); elements.hasMoreElements(); ) {
+ for (Enumeration<?> elements = group.enumerate(); elements.hasMoreElements(); ) {
Particle thisParticle = (Particle)elements.nextElement();
if (thisParticle instanceof Group) {
Group thisGroup = (Group)thisParticle;
- if (thisGroup instanceof ModelGroup) {
+ if (thisGroup instanceof ModelGroup) {
// HACK: Castor strangeness - model groups don't seem to resolve their own references. If fixed, this will still work
ModelGroup thisModel = (ModelGroup)thisGroup;
if (thisModel.hasReference()) thisGroup = thisModel.getReference();
@@ -152,39 +151,39 @@ public abstract class OutcomeStructure extends JPanel { public Element getElement() {
return myElement;
}
-
- public String getName() {
+
+ @Override
+ public String getName() {
if (model == null) return null;
return model.getName();
}
-
+
public ElementDecl getModel() {
return model;
}
-
+
public String getHelp() {
return help;
}
-
+
public String validateStructure() {
StringBuffer errors = new StringBuffer();
- for (Iterator iter = subStructure.values().iterator(); iter.hasNext();) {
- OutcomeStructure element = (OutcomeStructure)iter.next();
+ for (OutcomeStructure element : subStructure.values()) {
errors.append(element.validateStructure());
}
return errors.toString();
}
-
+
public abstract Element initNew(Document parent);
-
+
public static String extractHelp(Annotated model) {
- Enumeration e = model.getAnnotations();
+ Enumeration<?> e = model.getAnnotations();
StringBuffer doc = new StringBuffer();
if (e.hasMoreElements()) { // look for HTML
Annotation note = (Annotation)e.nextElement();
- for (Enumeration g = note.getDocumentation(); g.hasMoreElements();) {
+ for (Enumeration<?> g = note.getDocumentation(); g.hasMoreElements();) {
Documentation thisDoc = (Documentation)g.nextElement();
- for (Enumeration h = thisDoc.getObjects(); h.hasMoreElements();) {
+ for (Enumeration<?> h = thisDoc.getObjects(); h.hasMoreElements();) {
AnyNode node = (AnyNode)h.nextElement();
String line = node.toString();
if (line.length() == 0)
@@ -193,21 +192,22 @@ public abstract class OutcomeStructure extends JPanel { doc.append(line).append("\n");
}
}
- }
+ }
}
-
+
return doc.toString();
}
-
- public abstract void grabFocus();
- public static Class getJavaClass(int typeCode) {
+ @Override
+ public abstract void grabFocus();
+
+ public static Class<?> getJavaClass(int typeCode) {
switch (typeCode) {
-
+
// boolean
case SimpleTypesFactory.BOOLEAN_TYPE:
return Boolean.class;
-
+
// integers
case SimpleTypesFactory.INTEGER_TYPE:
case SimpleTypesFactory.NON_POSITIVE_INTEGER_TYPE:
@@ -216,7 +216,7 @@ public abstract class OutcomeStructure extends JPanel { case SimpleTypesFactory.POSITIVE_INTEGER_TYPE:
case SimpleTypesFactory.INT_TYPE:
case SimpleTypesFactory.UNSIGNED_INT_TYPE:
- case SimpleTypesFactory.SHORT_TYPE:
+ case SimpleTypesFactory.SHORT_TYPE:
case SimpleTypesFactory.UNSIGNED_SHORT_TYPE:
case SimpleTypesFactory.LONG_TYPE:
case SimpleTypesFactory.UNSIGNED_LONG_TYPE:
@@ -228,19 +228,19 @@ public abstract class OutcomeStructure extends JPanel { case SimpleTypesFactory.DOUBLE_TYPE:
case SimpleTypesFactory.DECIMAL_TYPE:
return BigDecimal.class;
-
+
// images
case SimpleTypesFactory.BASE64BINARY_TYPE:
case SimpleTypesFactory.HEXBINARY_TYPE:
return ImageIcon.class;
-
- // everything else is a string for now
+
+ // everything else is a string for now
default:
return String.class;
}
}
-
- public static Object getTypedValue(String value, Class type) {
+
+ public static Object getTypedValue(String value, Class<?> type) {
try {
if (type.equals(Boolean.class))
if (value == null || value.equals(""))
@@ -250,7 +250,7 @@ public abstract class OutcomeStructure extends JPanel { else if (type.equals(BigInteger.class))
if (value == null || value.equals(""))
return new BigInteger("0");
- else
+ else
return new BigInteger(value);
else if (type.equals(BigDecimal.class))
if (value == null || value.equals(""))
@@ -262,10 +262,10 @@ public abstract class OutcomeStructure extends JPanel { }
return value==null?"":value;
}
-
+
public static boolean isEmpty(Object value) {
if (value == null) return true;
-
+
if (value instanceof String) {
if (((String)value).length() == 0) return true;
}
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/field/ArrayEditField.java b/source/com/c2kernel/gui/tabs/outcome/form/field/ArrayEditField.java index e7dc8bc..742d1b4 100755..100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/field/ArrayEditField.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/field/ArrayEditField.java @@ -25,7 +25,7 @@ import com.c2kernel.utils.Language; **************************************************************************/
public class ArrayEditField extends StringEditField implements ActionListener {
-
+
Box arrayBox;
Box expandBox;
Box editBox;
@@ -34,20 +34,20 @@ public class ArrayEditField extends StringEditField implements ActionListener { JButton expandButton;
JButton contractButton;
JButton addButton;
- JButton removeButton;
+ JButton removeButton;
ArrayTableModel arrayModel;
JLabel arrayLabel = new JLabel("Array");
boolean panelShown = false;
boolean readOnly = false;
-
+
public ArrayEditField(SimpleType type) {
- arrayBox = Box.createVerticalBox();
+ arrayBox = Box.createVerticalBox();
arrayBox.add(arrayLabel);
arrayButton = new JButton(Language.translate("Show"));
arrayButton.addActionListener(this);
arrayButton.setActionCommand("toggle");
arrayBox.add(arrayButton);
-
+
expandBox = Box.createHorizontalBox();
expandButton = new JButton(">>");
expandButton.setToolTipText("Increase the number of columns displaying this array");
@@ -58,15 +58,15 @@ public class ArrayEditField extends StringEditField implements ActionListener { contractButton.setToolTipText("Decrease the number of columns displaying this array");
contractButton.addActionListener(this);
contractButton.setActionCommand("contract");
-
+
expandBox.add(contractButton);
expandBox.add(Box.createHorizontalGlue());
expandBox.add(expandButton);
-
+
arrayModel = new ArrayTableModel(type);
if (arrayModel.getColumnCount() < 2) contractButton.setEnabled(false);
arrayView = new JScrollPane(new JTable(arrayModel));
-
+
editBox = Box.createHorizontalBox();
addButton = new JButton("+");
addButton.setToolTipText("Add a field to the end of this array");
@@ -75,7 +75,7 @@ public class ArrayEditField extends StringEditField implements ActionListener { removeButton = new JButton("-");
removeButton.setToolTipText("Remove the last field from this array");
removeButton.addActionListener(this);
- removeButton.setActionCommand("remove");
+ removeButton.setActionCommand("remove");
editBox.add(addButton);
editBox.add(Box.createHorizontalGlue());
editBox.add(removeButton);
@@ -83,32 +83,37 @@ public class ArrayEditField extends StringEditField implements ActionListener { /**
*
*/
- public String getDefaultValue() {
+ @Override
+ public String getDefaultValue() {
return "";
}
/**
*
*/
- public String getText() {
+ @Override
+ public String getText() {
return arrayModel.getData();
}
/**
*
*/
- public void setText(String text) {
+ @Override
+ public void setText(String text) {
arrayModel.setData(text);
arrayLabel.setText("Array ("+arrayModel.getArrayLength()+" values)");
}
/**
*
*/
- public Component getControl() {
+ @Override
+ public Component getControl() {
return arrayBox;
}
/**
*
*/
- public void actionPerformed(ActionEvent e) {
+ @Override
+ public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("toggle")) {
arrayBox.removeAll();
if (panelShown) {
@@ -122,7 +127,7 @@ public class ArrayEditField extends StringEditField implements ActionListener { arrayBox.add(Box.createVerticalStrut(7));
arrayBox.add(arrayButton);
arrayBox.add(Box.createVerticalStrut(7));
- arrayBox.add(expandBox);
+ arrayBox.add(expandBox);
arrayBox.add(Box.createVerticalStrut(7));
arrayBox.add(arrayView);
if (!readOnly) arrayBox.add(editBox);
@@ -138,7 +143,7 @@ public class ArrayEditField extends StringEditField implements ActionListener { else if (e.getActionCommand().equals("remove")) {
arrayModel.removeField();
arrayLabel.setText("Array ("+arrayModel.getArrayLength()+" values)");
- }
+ }
else {
int currentCols = arrayModel.getColumnCount();
if (e.getActionCommand().equals("extend"))
@@ -154,10 +159,12 @@ public class ArrayEditField extends StringEditField implements ActionListener { /**
*
*/
- public JTextComponent makeTextField() {
+ @Override
+ public JTextComponent makeTextField() {
// not used by array
return null;
}
+ @Override
public void setEditable(boolean editable) {
readOnly = !editable;
arrayModel.setReadOnly(!readOnly);
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/field/ArrayTableModel.java b/source/com/c2kernel/gui/tabs/outcome/form/field/ArrayTableModel.java index c7934c0..341c33a 100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/field/ArrayTableModel.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/field/ArrayTableModel.java @@ -23,10 +23,10 @@ import com.c2kernel.utils.Language; public class ArrayTableModel extends AbstractTableModel {
ArrayList<Object> contents = new ArrayList<Object>();
- Class type;
+ Class<?> type;
int numCols = 1;
boolean readOnly = false;
-
+
public ArrayTableModel(SimpleType type) {
super();
this.type = OutcomeStructure.getJavaClass(type.getTypeCode());
@@ -35,7 +35,7 @@ public class ArrayTableModel extends AbstractTableModel { public void setReadOnly(boolean readOnly) {
this.readOnly = readOnly;
}
-
+
public void setData(String data) {
contents.clear();
StringTokenizer tok = new StringTokenizer(data);
@@ -43,16 +43,16 @@ public class ArrayTableModel extends AbstractTableModel { contents.add(OutcomeStructure.getTypedValue(tok.nextToken(), type));
fireTableStructureChanged();
}
-
+
public String getData() {
if (contents.size() == 0) return "";
- Iterator iter = contents.iterator();
+ Iterator<Object> iter = contents.iterator();
StringBuffer result = new StringBuffer(iter.next().toString());
while (iter.hasNext())
result.append(" ").append(iter.next().toString());
return result.toString();
}
-
+
public void addField() {
contents.add(OutcomeStructure.getTypedValue("", type));
fireTableStructureChanged();
@@ -62,45 +62,52 @@ public class ArrayTableModel extends AbstractTableModel { contents.remove(contents.size()-1);
fireTableStructureChanged();
}
-
- public Class<?> getColumnClass(int columnIndex) {
+
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
return type;
}
- public int getColumnCount() {
+ @Override
+ public int getColumnCount() {
return numCols;
}
-
+
public int getArrayLength() {
return contents.size();
}
-
+
public void setColumnCount(int newCols) {
numCols = newCols;
fireTableStructureChanged();
}
- public String getColumnName(int column) {
+ @Override
+ public String getColumnName(int column) {
return Language.translate("Value");
}
- public int getRowCount() {
+ @Override
+ public int getRowCount() {
return (contents.size()/numCols)+1;
}
- public Object getValueAt(int arg0, int arg1) {
+ @Override
+ public Object getValueAt(int arg0, int arg1) {
int index = arg1+(arg0 * numCols);
if (index >= contents.size())
return null;
return contents.get(arg1+(arg0 * numCols));
}
- public boolean isCellEditable(int rowIndex, int columnIndex) {
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
if (columnIndex+(rowIndex*numCols) > contents.size()-1) return false;
return !readOnly;
}
- public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
+ @Override
+ public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
contents.set(columnIndex+(rowIndex*numCols), aValue);
}
}
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/field/BooleanEditField.java b/source/com/c2kernel/gui/tabs/outcome/form/field/BooleanEditField.java index 5776f73..c831eb4 100755..100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/field/BooleanEditField.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/field/BooleanEditField.java @@ -17,51 +17,58 @@ import com.c2kernel.utils.Logger; * All rights reserved.
**************************************************************************/
public class BooleanEditField extends StringEditField {
-
+
JCheckBox checkbox;
-
+
public BooleanEditField() {
checkbox = new JCheckBox();
checkbox.setSelected(false);
checkbox.addFocusListener(this);
}
-
- public String getText() {
+
+ @Override
+ public String getText() {
return String.valueOf(checkbox.isSelected());
}
- public void setText(String text) {
+ @Override
+ public void setText(String text) {
boolean newState = false;
try {
newState = Boolean.valueOf(text).booleanValue();
} catch (Exception ex) {
Logger.error("Invalid value for checkbox: "+text);
}
- checkbox.setSelected(newState);
+ checkbox.setSelected(newState);
}
- public void setEditable(boolean editable) {
+ @Override
+ public void setEditable(boolean editable) {
super.setEditable(editable);
checkbox.setEnabled(editable);
}
- public Component getControl() {
+ @Override
+ public Component getControl() {
return checkbox;
}
-
- public String getDefaultValue() {
+
+ @Override
+ public String getDefaultValue() {
return "false";
- }
-
+ }
+
/** don't reserve the item finder for a boolean */
- public void focusGained(FocusEvent e) {
+ @Override
+ public void focusGained(FocusEvent e) {
helpPane.setHelp(name, helpText);
}
-
+
/**
*
*/
- public JTextComponent makeTextField() {
+ @Override
+ public JTextComponent makeTextField() {
// not used by boolean
return null;
}
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/field/ComboField.java b/source/com/c2kernel/gui/tabs/outcome/form/field/ComboField.java index 303a870..ef56046 100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/field/ComboField.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/field/ComboField.java @@ -19,9 +19,9 @@ 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.
******************************************************************************/
@@ -40,28 +40,33 @@ public class ComboField extends StringEditField { this.listNode = listNode;
createLOV();
}
-
- public String getDefaultValue() {
+
+ @Override
+ public String getDefaultValue() {
if (vals.getDefaultKey() != null)
return vals.get(vals.getDefaultKey()).toString();
else
return "";
}
- public String getText() {
+ @Override
+ public String getText() {
return vals.get(comboModel.getSelectedItem()).toString();
}
- public JTextComponent makeTextField() {
+ @Override
+ public JTextComponent makeTextField() {
// not used by this control
return null;
}
- public void setText(String text) {
+ @Override
+ public void setText(String text) {
comboModel.setSelectedItem(text);
}
- public Component getControl() {
+ @Override
+ public Component getControl() {
return comboField;
}
@@ -76,12 +81,12 @@ public class ComboField extends StringEditField { 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 enums = content.getFacets(Facet.ENUMERATION);
+ Enumeration<?> enums = content.getFacets(Facet.ENUMERATION);
while (enums.hasMoreElements()) {
Facet thisEnum = (Facet)enums.nextElement();
vals.put(thisEnum.getValue(), thisEnum.getValue(), false);
@@ -99,8 +104,8 @@ public class ComboField extends StringEditField { */
private void populateLOVFromLDAP(String param) {
// TODO '/root/path;prop=val;prop=val'
-
-
+
+
}
private void populateLOVFromScript(String scriptName) {
@@ -116,12 +121,14 @@ public class ComboField extends StringEditField { }
}
- public void setDecl(AttributeDecl model) throws StructuralException {
+ @Override
+ public void setDecl(AttributeDecl model) throws StructuralException {
super.setDecl(model);
createLOV();
}
- public void setDecl(ElementDecl model) throws StructuralException {
+ @Override
+ public void setDecl(ElementDecl model) throws StructuralException {
super.setDecl(model);
createLOV();
}
@@ -130,7 +137,8 @@ public class ComboField extends StringEditField { *
*/
- public void setEditable(boolean editable) {
+ @Override
+ public void setEditable(boolean editable) {
comboField.setEditable(editable);
}
}
\ No newline at end of file diff --git a/source/com/c2kernel/gui/tabs/outcome/form/field/DecimalEditField.java b/source/com/c2kernel/gui/tabs/outcome/form/field/DecimalEditField.java index d77dff3..fabaed8 100755..100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/field/DecimalEditField.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/field/DecimalEditField.java @@ -26,44 +26,50 @@ public class DecimalEditField extends StringEditField { field.setToolTipText("This field must contains a decimal number e.g. 3.14159265");
}
- public String getText() {
+ @Override
+ public String getText() {
return field.getText();
}
- public void setText(String text) {
+ @Override
+ public void setText(String text) {
field.setText(text);
}
-
- public String getDefaultValue() {
+
+ @Override
+ public String getDefaultValue() {
return "0.0";
- }
-
- public JTextComponent makeTextField() {
+ }
+
+ @Override
+ public JTextComponent makeTextField() {
return new DecimalTextField();
}
-
+
private class DecimalTextField extends JTextField {
public DecimalTextField() {
super();
setHorizontalAlignment(RIGHT);
}
- protected Document createDefaultModel() {
+ @Override
+ protected Document createDefaultModel() {
return new Decimal();
}
}
-
+
private class Decimal extends PlainDocument {
BigDecimal currentVal = new BigDecimal(0.0);
- public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
+ @Override
+ public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
if (str == null || str.equals("")) {
return;
}
-
+
String proposedResult = null;
if (getLength() == 0) {
@@ -73,23 +79,24 @@ public class DecimalEditField extends StringEditField { currentBuffer.insert(offs, str);
proposedResult = currentBuffer.toString();
}
-
+
try {
currentVal = parse(proposedResult);
super.insertString(offs, str, a);
} catch (Exception e) {
Toolkit.getDefaultToolkit().beep();
}
-
+
}
- public void remove(int offs, int len) throws BadLocationException {
+ @Override
+ public void remove(int offs, int len) throws BadLocationException {
String currentText = this.getText(0, getLength());
String beforeOffset = currentText.substring(0, offs);
String afterOffset = currentText.substring(len + offs, currentText.length());
String proposedResult = beforeOffset + afterOffset;
-
+
if (proposedResult.length() == 0) { // empty is ok
super.remove(offs, len);
return;
@@ -97,17 +104,17 @@ public class DecimalEditField extends StringEditField { try {
currentVal = parse(proposedResult);
super.remove(offs, len);
- } catch (Exception e) {
+ } catch (Exception e) {
Toolkit.getDefaultToolkit().beep();
}
- }
+ }
public BigDecimal parse(String proposedResult) throws NumberFormatException {
BigDecimal value = new BigDecimal(0);
if ( proposedResult.length() != 0) {
- value = new BigDecimal(proposedResult);
+ value = new BigDecimal(proposedResult);
}
return value;
}
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/field/FieldConstraints.java b/source/com/c2kernel/gui/tabs/outcome/form/field/FieldConstraints.java deleted file mode 100755 index d09cd91..0000000 --- a/source/com/c2kernel/gui/tabs/outcome/form/field/FieldConstraints.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.c2kernel.gui.tabs.outcome.form.field;
-
-import java.util.Enumeration;
-
-import org.exolab.castor.types.AnyNode;
-import org.exolab.castor.xml.schema.Annotation;
-import org.exolab.castor.xml.schema.AppInfo;
-import org.exolab.castor.xml.schema.XMLType;
-
-/**************************************************************************
- *
- * $Revision: 1.1 $
- * $Date: 2005/04/26 06:48:12 $
- *
- * Copyright (C) 2003 CERN - European Organization for Nuclear Research
- * All rights reserved.
- **************************************************************************/
-
-public class FieldConstraints {
-
- XMLType content;
- ListOfValues lov;
- int rows = 1;
-
- public FieldConstraints(XMLType content) {
- this.content = content;
- Enumeration e = content.getAnnotations();
- while (e.hasMoreElements()) {
- Annotation note = (Annotation)e.nextElement();
- for (Enumeration f = note.getAppInfo(); f.hasMoreElements();) {
- addAppInfo((AppInfo)f.nextElement());
- }
- }
- }
-
- private void addAppInfo(AppInfo element) {
- Enumeration e = element.getObjects();
- while (e.hasMoreElements()) {
- AnyNode node = (AnyNode)e.nextElement();
-
- }
- }
-
- public ListOfValues getLOV() {
- return lov;
- }
-
- public int getRows() {
- return rows;
- }
-}
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/field/ImageEditField.java b/source/com/c2kernel/gui/tabs/outcome/form/field/ImageEditField.java index b0bb079..716a073 100755..100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/field/ImageEditField.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/field/ImageEditField.java @@ -31,15 +31,17 @@ public class ImageEditField extends StringEditField { static JFileChooser chooser = new JFileChooser();
static {
chooser.addChoosableFileFilter(new javax.swing.filechooser.FileFilter() {
+ @Override
public String getDescription() {
return "Image Files";
}
+ @Override
public boolean accept(File f) {
return (f.isDirectory() || (f.isFile() && (f.getName()
.endsWith(".gif")
|| f.getName().endsWith(".jpg")
- || f.getName().endsWith(".jpeg")
+ || f.getName().endsWith(".jpeg")
|| f.getName().endsWith(".png"))));
}
});
@@ -51,6 +53,7 @@ public class ImageEditField extends StringEditField { imagePanel = Box.createVerticalBox();
browseButton = new JButton("Browse");
browseButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
int returnVal = chooser.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
@@ -77,18 +80,22 @@ public class ImageEditField extends StringEditField { imagePanel.add(browseButton);
}
+ @Override
public String getDefaultValue() {
return "";
}
+ @Override
public Component getControl() {
return imagePanel;
}
+ @Override
public String getText() {
return encodedImage == null ? "" : encodedImage;
}
+ @Override
public void setText(String text) {
encodedImage = text;
if (text != null && text.length() > 0) {
@@ -98,6 +105,7 @@ public class ImageEditField extends StringEditField { }
}
+ @Override
public void setEditable(boolean editable) {
browseButton.setVisible(false);
}
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/field/IntegerEditField.java b/source/com/c2kernel/gui/tabs/outcome/form/field/IntegerEditField.java index 7c858a4..e2c3df4 100755..100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/field/IntegerEditField.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/field/IntegerEditField.java @@ -19,44 +19,50 @@ import javax.swing.text.PlainDocument; * All rights reserved.
**************************************************************************/
public class IntegerEditField extends StringEditField {
-
+
public IntegerEditField() {
super();
field.setToolTipText("This field must contains a whole number e.g. 3");
}
- public String getText() {
+ @Override
+ public String getText() {
return field.getText();
}
- public void setText(String text) {
+ @Override
+ public void setText(String text) {
field.setText(text);
}
- public String getDefaultValue() {
+ @Override
+ public String getDefaultValue() {
return "0";
}
-
- public JTextComponent makeTextField() {
+
+ @Override
+ public JTextComponent makeTextField() {
return new IntegerTextField();
}
-
+
private class IntegerTextField extends JTextField {
public IntegerTextField() {
super();
setHorizontalAlignment(RIGHT);
}
- protected Document createDefaultModel() {
+ @Override
+ protected Document createDefaultModel() {
return new IntegerDocument();
}
}
-
+
private class IntegerDocument extends PlainDocument {
BigInteger currentVal = new BigInteger("0");
- public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
+ @Override
+ public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
if (str == null || str.equals("")) {
return;
@@ -71,17 +77,18 @@ public class IntegerEditField extends StringEditField { currentBuffer.insert(offs, str);
proposedResult = currentBuffer.toString();
}
-
+
try {
currentVal = parse(proposedResult);
super.insertString(offs, str, a);
} catch (Exception e) {
Toolkit.getDefaultToolkit().beep();
}
-
+
}
- public void remove(int offs, int len) throws BadLocationException {
+ @Override
+ public void remove(int offs, int len) throws BadLocationException {
String currentText = this.getText(0, getLength());
String beforeOffset = currentText.substring(0, offs);
@@ -95,17 +102,17 @@ public class IntegerEditField extends StringEditField { try {
currentVal = parse(proposedResult);
super.remove(offs, len);
- } catch (Exception e) {
+ } catch (Exception e) {
Toolkit.getDefaultToolkit().beep();
}
- }
+ }
public BigInteger parse(String proposedResult) throws NumberFormatException {
BigInteger value = new BigInteger("0");
if ( proposedResult.length() != 0) {
- value = new BigInteger(proposedResult);
+ value = new BigInteger(proposedResult);
}
return value;
}
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/field/ListOfValues.java b/source/com/c2kernel/gui/tabs/outcome/form/field/ListOfValues.java index 3204766..f95c5c9 100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/field/ListOfValues.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/field/ListOfValues.java @@ -18,14 +18,14 @@ public class ListOfValues extends HashMap<String, Object> { public ListOfValues() {
super();
}
-
+
public String put(String key, String value, boolean isDefaultKey) {
if (isDefaultKey) defaultKey = key;
return (String)super.put(key, value);
}
-
+
public String getDefaultKey() {
return defaultKey;
}
-
+
}
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/field/LongStringEditField.java b/source/com/c2kernel/gui/tabs/outcome/form/field/LongStringEditField.java index b782c65..140d7f2 100755..100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/field/LongStringEditField.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/field/LongStringEditField.java @@ -26,10 +26,12 @@ public class LongStringEditField extends StringEditField { field.setToolTipText(Language.translate("This field can contain any string."));
}
- public JTextComponent makeTextField() {
+ @Override
+ public JTextComponent makeTextField() {
return new JTextArea();
}
- public Component getControl() {
+ @Override
+ public Component getControl() {
if (bigScroller == null) {
bigScroller = new JScrollPane(field);
}
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();
}
|
