summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/gui/tabs/outcome/form/OutcomeEditor.java
diff options
context:
space:
mode:
authorabranson <andrew.branson@cern.ch>2011-08-04 00:42:34 +0200
committerabranson <andrew.branson@cern.ch>2011-08-04 00:42:34 +0200
commit0ec8481c10cd8277d84c7c1a785483a0a739e5a0 (patch)
tree5f6e5d9ae75193e67e6f3b3dfa488960c5cde1d5 /source/com/c2kernel/gui/tabs/outcome/form/OutcomeEditor.java
parent036cbdba66f804743c4c838ed598d6972c4b3e17 (diff)
More code cleanup:
Refactored Entity Proxy Subscription to handle generics better Rewrote RemoteMap to use TreeMap instead of the internal array for order. It now sorts its keys by number if they parse, else as strings. Removed a no-longer-in-progress outcome form class
Diffstat (limited to 'source/com/c2kernel/gui/tabs/outcome/form/OutcomeEditor.java')
-rw-r--r--[-rwxr-xr-x]source/com/c2kernel/gui/tabs/outcome/form/OutcomeEditor.java40
1 files changed, 22 insertions, 18 deletions
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;
}