diff options
| author | abranson <andrew.branson@cern.ch> | 2011-08-04 00:42:34 +0200 |
|---|---|---|
| committer | abranson <andrew.branson@cern.ch> | 2011-08-04 00:42:34 +0200 |
| commit | 0ec8481c10cd8277d84c7c1a785483a0a739e5a0 (patch) | |
| tree | 5f6e5d9ae75193e67e6f3b3dfa488960c5cde1d5 /source/com/c2kernel/gui/tabs/PropertiesPane.java | |
| parent | 036cbdba66f804743c4c838ed598d6972c4b3e17 (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/PropertiesPane.java')
| -rw-r--r-- | source/com/c2kernel/gui/tabs/PropertiesPane.java | 73 |
1 files changed, 44 insertions, 29 deletions
diff --git a/source/com/c2kernel/gui/tabs/PropertiesPane.java b/source/com/c2kernel/gui/tabs/PropertiesPane.java index 6b21804..2411296 100644 --- a/source/com/c2kernel/gui/tabs/PropertiesPane.java +++ b/source/com/c2kernel/gui/tabs/PropertiesPane.java @@ -17,11 +17,16 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener;
import java.util.HashMap;
-import javax.swing.*;
+import javax.swing.Box;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.SwingConstants;
-import com.c2kernel.entity.C2KLocalObject;
import com.c2kernel.entity.proxy.EntityProxyObserver;
import com.c2kernel.entity.proxy.ItemProxy;
+import com.c2kernel.entity.proxy.MemberSubscription;
import com.c2kernel.gui.MainFrame;
import com.c2kernel.gui.data.NodeAgent;
import com.c2kernel.persistency.ClusterStorage;
@@ -36,7 +41,7 @@ import com.c2kernel.utils.Logger; * @version $Revision: 1.44 $ $Date: 2005/08/31 07:21:20 $
* @author $Author: abranson $
*/
-public class PropertiesPane extends EntityTabPane implements EntityProxyObserver, ActionListener {
+public class PropertiesPane extends EntityTabPane implements EntityProxyObserver<Property>, ActionListener {
Box propertyBox;
boolean subbed = false;
@@ -66,15 +71,15 @@ public class PropertiesPane extends EntityTabPane implements EntityProxyObserver domTitle.setForeground(headingColor);
gridbag.setConstraints(domTitle, c);
add(domTitle);
-
+
c.gridy++;
c.fill = GridBagConstraints.BOTH;
c.weighty=1.0;
domAdmin = new DomainPathAdmin();
gridbag.setConstraints(domAdmin, c);
- add(domAdmin);
-
-
+ add(domAdmin);
+
+
if ("true".equals(Gateway.getProperty("EnableItemErase"))) {
c.gridy++;
c.fill = GridBagConstraints.NONE;
@@ -87,13 +92,15 @@ public class PropertiesPane extends EntityTabPane implements EntityProxyObserver }
}
- public void reload() {
+ @Override
+ public void reload() {
Gateway.getStorage().clearCache(sourceEntity.getSysKey(), ClusterStorage.PROPERTY);
loadedProps = new HashMap<String, JLabel>();
initForEntity(sourceEntity);
}
- public void run() {
+ @Override
+ public void run() {
Thread.currentThread().setName("Property Pane Builder");
if (sourceEntity instanceof NodeAgent) {
remove(domAdmin);
@@ -104,16 +111,15 @@ public class PropertiesPane extends EntityTabPane implements EntityProxyObserver propertyBox.removeAll();
propertyBox.add(Box.createGlue());
revalidate();
- sourceEntity.getEntity().subscribe(this, ClusterStorage.PROPERTY, true);
-
+ sourceEntity.getEntity().subscribe(new MemberSubscription<Property>(this, ClusterStorage.PROPERTY, true));
+
}
/**
*
*/
- public void add(C2KLocalObject contents) {
- if (!(contents instanceof Property)) return;
- Property newProp = (Property) contents;
- JLabel propLabel = (JLabel)loadedProps.get(newProp.getName());
+ @Override
+ public void add(Property newProp) {
+ JLabel propLabel = loadedProps.get(newProp.getName());
if (propLabel == null) { // new prop
JPanel summaryPanel = new JPanel(new GridLayout(0,2));
summaryPanel.add(new JLabel(Language.translate(newProp.getName()) + ":"));
@@ -126,9 +132,10 @@ public class PropertiesPane extends EntityTabPane implements EntityProxyObserver editButton.setMargin(new Insets(0,0,0,0));
editButton.setActionCommand(newProp.getName());
editButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e){
- String oldVal = ((JLabel)loadedProps.get(e.getActionCommand())).getText();
- String newVal = (String)JOptionPane.showInputDialog(null, "Enter new value for "+e.getActionCommand(), "Edit Property",
+ @Override
+ public void actionPerformed(ActionEvent e){
+ String oldVal = loadedProps.get(e.getActionCommand()).getText();
+ String newVal = (String)JOptionPane.showInputDialog(null, "Enter new value for "+e.getActionCommand(), "Edit Property",
JOptionPane.QUESTION_MESSAGE, null, null, oldVal);
if (newVal!=null && !(newVal.equals(oldVal))) {
try {
@@ -151,23 +158,25 @@ public class PropertiesPane extends EntityTabPane implements EntityProxyObserver revalidate();
}
- public void remove(String id) {
+ @Override
+ public void remove(String id) {
String propName = id.substring(id.lastIndexOf("/")+1);
- JLabel propbox = (JLabel)loadedProps.get(propName);
- if (propbox!= null) propbox.setText("DELETED");
- revalidate();
+ JLabel propbox = loadedProps.get(propName);
+ if (propbox!= null) propbox.setText("DELETED");
+ revalidate();
}
- public void actionPerformed(ActionEvent e) {
+ @Override
+ public void actionPerformed(ActionEvent e) {
String[] params;
String predefStep;
-
- if (JOptionPane.showConfirmDialog(this,
- "Are you sure?",
- e.getActionCommand(),
+
+ if (JOptionPane.showConfirmDialog(this,
+ "Are you sure?",
+ e.getActionCommand(),
JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
return;
-
+
if (e.getActionCommand().equals("Erase Item")) {
params = new String[0];
predefStep = "Erase";
@@ -176,10 +185,16 @@ public class PropertiesPane extends EntityTabPane implements EntityProxyObserver return;
try {
- MainFrame.userAgent.execute((ItemProxy)sourceEntity.getEntity(), predefStep, params);
+ MainFrame.userAgent.execute((ItemProxy)sourceEntity.getEntity(), predefStep, params);
} catch (Exception ex) {
Logger.exceptionDialog(ex);
}
}
+ @Override
+ public void control(String control, String msg) {
+ // TODO Auto-generated method stub
+
+ }
+
}
|
