summaryrefslogtreecommitdiff
path: root/NET/worlds/console/AttributeSortPanel.java
diff options
context:
space:
mode:
Diffstat (limited to 'NET/worlds/console/AttributeSortPanel.java')
-rw-r--r--NET/worlds/console/AttributeSortPanel.java160
1 files changed, 160 insertions, 0 deletions
diff --git a/NET/worlds/console/AttributeSortPanel.java b/NET/worlds/console/AttributeSortPanel.java
new file mode 100644
index 0000000..6856e7b
--- /dev/null
+++ b/NET/worlds/console/AttributeSortPanel.java
@@ -0,0 +1,160 @@
+package NET.worlds.console;
+
+import java.awt.Button;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Event;
+import java.awt.Frame;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Label;
+import java.awt.Point;
+import java.awt.TextField;
+
+public class AttributeSortPanel extends Frame implements MainCallback, MainTerminalCallback {
+ private static final long serialVersionUID = -7230661745931320369L;
+ private AttributeList list;
+ private Button addButton = new Button("Add");
+ private Button deleteButton = new Button("Delete");
+ private Button moveUpButton = new Button("MoveUp");
+ private Button moveDownButton = new Button("MoveDown");
+ private Button okButton = new Button("Ok");
+ private Button cancelButton = new Button("Cancel");
+ private Button clearButton = new Button("Clear");
+ private TextField attNameField = new TextField(32);
+ private Label attNameLabel = new Label("Attribute Name: ");
+
+ public AttributeSortPanel(java.awt.Window parent) {
+ super("Attribute Sorting");
+ this.list = new AttributeList(10);
+ GridBagLayout gbag = new GridBagLayout();
+ GridBagConstraints c = new GridBagConstraints();
+ this.setLayout(gbag);
+ this.setBackground(Color.gray);
+ c.gridx = 1;
+ c.gridy = 1;
+ c.gridheight = 7;
+ c.gridwidth = 3;
+ c.anchor = 18;
+ gbag.setConstraints(this.list, c);
+ this.add(this.list);
+ c.gridx = 4;
+ c.gridy = 1;
+ c.gridwidth = 1;
+ c.gridheight = 1;
+ gbag.setConstraints(this.moveUpButton, c);
+ this.add(this.moveUpButton);
+ c.gridx = 4;
+ c.gridy = 2;
+ c.gridwidth = 1;
+ c.gridheight = 1;
+ gbag.setConstraints(this.moveDownButton, c);
+ this.add(this.moveDownButton);
+ c.gridx = 4;
+ c.gridy = 5;
+ c.gridheight = 1;
+ c.gridwidth = 3;
+ gbag.setConstraints(this.attNameLabel, c);
+ this.add(this.attNameLabel);
+ c.gridy = 6;
+ c.gridheight = 1;
+ c.gridwidth = 3;
+ gbag.setConstraints(this.attNameField, c);
+ this.add(this.attNameField);
+ c.gridx = 7;
+ c.gridy = 6;
+ c.gridheight = 1;
+ c.gridwidth = 1;
+ gbag.setConstraints(this.addButton, c);
+ this.add(this.addButton);
+ c.gridx = 7;
+ c.gridy = 1;
+ c.gridwidth = 1;
+ c.gridheight = 1;
+ gbag.setConstraints(this.deleteButton, c);
+ this.add(this.deleteButton);
+ c.gridx = 7;
+ c.gridy = 2;
+ gbag.setConstraints(this.clearButton, c);
+ this.add(this.clearButton);
+ c.gridx = 5;
+ c.gridy = 8;
+ gbag.setConstraints(this.okButton, c);
+ this.add(this.okButton);
+ c.gridx = 7;
+ gbag.setConstraints(this.cancelButton, c);
+ this.add(this.cancelButton);
+ this.pack();
+ Point loc = parent.location();
+ Dimension size = parent.getSize();
+ this.reshape(loc.x + (size.width - 512) / 2, loc.y + (size.height - 240) / 2, 512, 240);
+ this.show();
+ Main.register(this);
+ }
+
+ @Override
+ public boolean handleEvent(Event ev) {
+ switch (ev.id) {
+ case 201:
+ this.dispose();
+ return true;
+ default:
+ return super.handleEvent(ev);
+ }
+ }
+
+ @Override
+ public boolean action(Event e, Object o) {
+ if (e.target == this.addButton) {
+ String attToAdd = this.attNameField.getText();
+ if (attToAdd != "") {
+ this.list.add(attToAdd);
+ }
+
+ this.attNameField.setText("");
+ return true;
+ } else if (e.target == this.deleteButton) {
+ this.list.remove(this.list.getSelectedIndex());
+ return true;
+ } else if (e.target == this.moveUpButton) {
+ int index = this.list.getSelectedIndex();
+ if (index > 0) {
+ String toPutBack = this.list.getItem(index - 1);
+ this.list.remove(index - 1);
+ this.list.add(toPutBack, index);
+ }
+
+ return true;
+ } else if (e.target == this.moveDownButton) {
+ int index = this.list.getSelectedIndex();
+ if (index < this.list.getItemCount()) {
+ String toPutBack = this.list.getItem(index + 1);
+ this.list.remove(index + 1);
+ this.list.add(toPutBack, index);
+ }
+
+ return true;
+ } else if (e.target == this.cancelButton) {
+ this.dispose();
+ return true;
+ } else if (e.target == this.clearButton) {
+ this.list.removeAll();
+ return true;
+ } else if (e.target == this.okButton) {
+ this.list.save();
+ this.dispose();
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public void mainCallback() {
+ }
+
+ @Override
+ public void terminalCallback() {
+ Main.unregister(this);
+ }
+}