From 0ec8481c10cd8277d84c7c1a785483a0a739e5a0 Mon Sep 17 00:00:00 2001 From: abranson Date: Thu, 4 Aug 2011 00:42:34 +0200 Subject: 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 --- .../tabs/collection/CollectionHistoryWindow.java | 44 +++++++++++++--------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'source/com/c2kernel/gui/tabs/collection/CollectionHistoryWindow.java') 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 { ItemProxy item; ArrayList 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(); collEventData = new ArrayList(); - item.subscribe(this, ClusterStorage.HISTORY, true); + item.subscribe(new MemberSubscription(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); -- cgit v1.2.3