summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/gui/tabs/collection/CollectionHistoryWindow.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/collection/CollectionHistoryWindow.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/collection/CollectionHistoryWindow.java')
-rw-r--r--source/com/c2kernel/gui/tabs/collection/CollectionHistoryWindow.java44
1 files changed, 27 insertions, 17 deletions
diff --git a/source/com/c2kernel/gui/tabs/collection/CollectionHistoryWindow.java b/source/com/c2kernel/gui/tabs/collection/CollectionHistoryWindow.java
index bb71cd8..7cb2753 100644
--- a/source/com/c2kernel/gui/tabs/collection/CollectionHistoryWindow.java
+++ b/source/com/c2kernel/gui/tabs/collection/CollectionHistoryWindow.java
@@ -12,10 +12,10 @@ import javax.swing.table.AbstractTableModel;
import com.c2kernel.collection.Collection;
import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.entity.C2KLocalObject;
import com.c2kernel.entity.proxy.EntityProxy;
import com.c2kernel.entity.proxy.EntityProxyObserver;
import com.c2kernel.entity.proxy.ItemProxy;
+import com.c2kernel.entity.proxy.MemberSubscription;
import com.c2kernel.events.Event;
import com.c2kernel.gui.MainFrame;
import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
@@ -32,8 +32,8 @@ public class CollectionHistoryWindow extends JFrame {
JTable historyTable;
HistoryTableModel historyModel;
-
- public CollectionHistoryWindow(ItemProxy item, Collection coll) throws HeadlessException {
+
+ public CollectionHistoryWindow(ItemProxy item, Collection<?> coll) throws HeadlessException {
super("Collection History");
historyModel = new HistoryTableModel(item, coll);
historyTable = new JTable(historyModel);
@@ -44,23 +44,25 @@ public class CollectionHistoryWindow extends JFrame {
this.validate();
this.show();
}
-
- private class HistoryTableModel extends AbstractTableModel implements EntityProxyObserver {
+
+ private class HistoryTableModel extends AbstractTableModel implements EntityProxyObserver<Event> {
ItemProxy item;
ArrayList<Object> collEvents, collEventData;
- Collection coll;
- public HistoryTableModel(ItemProxy item, Collection coll) {
+ Collection<?> coll;
+ public HistoryTableModel(ItemProxy item, Collection<?> coll) {
this.item = item;
this.coll = coll;
collEvents = new ArrayList<Object>();
collEventData = new ArrayList<Object>();
- item.subscribe(this, ClusterStorage.HISTORY, true);
+ item.subscribe(new MemberSubscription<Event>(this, ClusterStorage.HISTORY, true));
}
+ @Override
public int getColumnCount() {
return 4;
}
-
+
+ @Override
public String getColumnName(int columnIndex) {
switch(columnIndex) {
case 0: return Language.translate("Date");
@@ -69,10 +71,12 @@ public class CollectionHistoryWindow extends JFrame {
case 3: return Language.translate("Child");
default: return "";
}
- }
+ }
+ @Override
public int getRowCount() {
return collEvents.size();
}
+ @Override
public Object getValueAt(int rowIndex, int columnIndex) {
Event ev = (Event)collEvents.get(rowIndex);
switch (columnIndex) {
@@ -109,9 +113,8 @@ public class CollectionHistoryWindow extends JFrame {
public Object getEventData(int row) {
return collEventData.get(row);
}
- public void add(C2KLocalObject contents) {
- if (!(contents instanceof Event)) return;
- Event thisEv = (Event)contents;
+ @Override
+ public void add(Event thisEv) {
if (thisEv.getStepName().equals("AssignItemToSlot") || thisEv.getStepName().equals("AddC2KObject")) {
String[] params;
try {
@@ -134,16 +137,22 @@ public class CollectionHistoryWindow extends JFrame {
if (obj instanceof Collection)
collEventData.add(obj);
else return;
-
+
}
}
else return;
collEvents.add(thisEv);
fireTableRowsInserted(collEvents.size()-1, collEvents.size()-1);
}
+ @Override
public void remove(String id) { }
+ @Override
+ public void control(String control, String msg) {
+ // TODO Auto-generated method stub
+
+ }
}
-
+
private class HistoryTableListener extends MouseAdapter {
ItemProxy item;
@@ -151,12 +160,13 @@ public class CollectionHistoryWindow extends JFrame {
this.item = item;
}
+ @Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount()==2) {
int row = historyTable.getSelectedRow();
Object data = historyModel.getEventData(row);
if (data instanceof Collection) {
- showColl((Collection)data);
+ showColl((Collection<?>)data);
}
else {
String[] params = (String[])data;
@@ -167,7 +177,7 @@ public class CollectionHistoryWindow extends JFrame {
}
}
}
- public void showColl(Collection coll) {
+ public void showColl(Collection<?> coll) {
JFrame newFrame = new JFrame();
AggregationView newView = new AggregationView();
newView.setCollection(coll);