summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/gui/tabs/DomainPathAdmin.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/DomainPathAdmin.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/DomainPathAdmin.java')
-rw-r--r--source/com/c2kernel/gui/tabs/DomainPathAdmin.java69
1 files changed, 41 insertions, 28 deletions
diff --git a/source/com/c2kernel/gui/tabs/DomainPathAdmin.java b/source/com/c2kernel/gui/tabs/DomainPathAdmin.java
index 2e81121..408a32c 100644
--- a/source/com/c2kernel/gui/tabs/DomainPathAdmin.java
+++ b/source/com/c2kernel/gui/tabs/DomainPathAdmin.java
@@ -5,7 +5,12 @@ import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Enumeration;
-import javax.swing.*;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JOptionPane;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import com.c2kernel.entity.proxy.ItemProxy;
@@ -30,10 +35,10 @@ public class DomainPathAdmin extends Box implements ActionListener {
DomainPathTableModel model;
JButton addButton;
JButton removeButton;
-
+
public DomainPathAdmin() {
super(BoxLayout.Y_AXIS);
-
+
model = new DomainPathTableModel(this);
table = new JTable(model);
add(new JScrollPane(table));
@@ -47,19 +52,20 @@ public class DomainPathAdmin extends Box implements ActionListener {
buttonBox.add(removeButton);
buttonBox.add(Box.createHorizontalGlue());
add(buttonBox);
-
+
addButton.setActionCommand("add");
addButton.addActionListener(this);
removeButton.setActionCommand("remove");
- removeButton.addActionListener(this);
+ removeButton.addActionListener(this);
}
-
+
public void setEntity(ItemProxy entity) {
this.entity = entity;
model.loadPaths();
}
- public void actionPerformed(ActionEvent e) {
+ @Override
+public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("add")) {
String newPath = JOptionPane.showInputDialog(this, "Enter new path,", "Add Domain Path", JOptionPane.PLAIN_MESSAGE);
addDomainPath(new DomainPath(newPath));
@@ -73,23 +79,23 @@ public class DomainPathAdmin extends Box implements ActionListener {
}
}
}
-
+
public boolean removeDomainPath(DomainPath oldPath) {
return alterDomainPath(oldPath, "Remove");
}
-
+
public boolean addDomainPath(DomainPath newPath) {
return alterDomainPath(newPath, "Add");
- }
-
+ }
+
public boolean alterDomainPath(DomainPath path, String action) {
- if (JOptionPane.showConfirmDialog(this,
- action+" "+path+"?",
- action+" Domain Path",
+ if (JOptionPane.showConfirmDialog(this,
+ action+" "+path+"?",
+ action+" Domain Path",
JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
return false;
-
+
String[] params = new String[1];
params[0] = path.toString();
try {
@@ -100,7 +106,7 @@ public class DomainPathAdmin extends Box implements ActionListener {
}
return true;
}
-
+
private class DomainPathTableModel extends AbstractTableModel {
ArrayList<DomainPath> domPaths;
DomainPathAdmin parent;
@@ -108,10 +114,10 @@ public class DomainPathAdmin extends Box implements ActionListener {
this.parent = parent;
domPaths = new ArrayList<DomainPath>();
}
-
+
public void loadPaths() {
domPaths.clear();
- for (Enumeration currentPaths = Gateway.getLDAPLookup().search(new DomainPath(), entity.getName()); currentPaths.hasMoreElements();) {
+ for (Enumeration<?> currentPaths = Gateway.getLDAPLookup().search(new DomainPath(), entity.getName()); currentPaths.hasMoreElements();) {
DomainPath thisPath = (DomainPath)currentPaths.nextElement();
if (thisPath.getSysKey() == entity.getSystemKey())
domPaths.add(thisPath);
@@ -120,10 +126,11 @@ public class DomainPathAdmin extends Box implements ActionListener {
}
public DomainPath getPath(int rowIndex) {
- return (DomainPath)domPaths.get(rowIndex);
+ return domPaths.get(rowIndex);
}
- public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
- DomainPath oldPath = (DomainPath)domPaths.get(rowIndex);
+ @Override
+ public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
+ DomainPath oldPath = domPaths.get(rowIndex);
DomainPath newPath = new DomainPath((String)aValue);
boolean success = parent.addDomainPath(newPath);
if (success)
@@ -133,28 +140,34 @@ public class DomainPathAdmin extends Box implements ActionListener {
fireTableDataChanged();
}
}
-
- public Class<?> getColumnClass(int columnIndex) {
+
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
return String.class;
}
- public int getColumnCount() {
+ @Override
+ public int getColumnCount() {
return 1;
}
- public String getColumnName(int column) {
+ @Override
+ public String getColumnName(int column) {
return "Path";
}
- public int getRowCount() {
+ @Override
+ public int getRowCount() {
return domPaths.size();
}
- public Object getValueAt(int rowIndex, int columnIndex) {
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
return domPaths.get(rowIndex).toString();
}
- public boolean isCellEditable(int rowIndex, int columnIndex) {
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
return true;
}
}