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 --- .../gui/tabs/collection/AggregationView.java | 7 +++- .../tabs/collection/CollectionHistoryWindow.java | 44 +++++++++++++--------- .../gui/tabs/collection/CollectionView.java | 10 ++--- .../gui/tabs/collection/DependencyView.java | 3 +- 4 files changed, 39 insertions(+), 25 deletions(-) mode change 100755 => 100644 source/com/c2kernel/gui/tabs/collection/AggregationView.java mode change 100755 => 100644 source/com/c2kernel/gui/tabs/collection/CollectionView.java mode change 100755 => 100644 source/com/c2kernel/gui/tabs/collection/DependencyView.java (limited to 'source/com/c2kernel/gui/tabs/collection') diff --git a/source/com/c2kernel/gui/tabs/collection/AggregationView.java b/source/com/c2kernel/gui/tabs/collection/AggregationView.java old mode 100755 new mode 100644 index 8a97c6c..3291906 --- a/source/com/c2kernel/gui/tabs/collection/AggregationView.java +++ b/source/com/c2kernel/gui/tabs/collection/AggregationView.java @@ -47,7 +47,8 @@ public class AggregationView extends CollectionView mEditorPanel.setEditable(MainFrame.isAdmin); } - public void setCollection(Collection contents) + @Override + public void setCollection(Collection contents) { thisColl = contents; Aggregation agg = (Aggregation)thisColl; @@ -70,6 +71,7 @@ public class AggregationView extends CollectionView { mSaveButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent ae) { saveCollection(); @@ -77,10 +79,11 @@ public class AggregationView extends CollectionView }); mHistoryButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent ae) { new CollectionHistoryWindow(item, thisColl); } - }); + }); } } 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); diff --git a/source/com/c2kernel/gui/tabs/collection/CollectionView.java b/source/com/c2kernel/gui/tabs/collection/CollectionView.java old mode 100755 new mode 100644 index 62a598c..8a97af5 --- a/source/com/c2kernel/gui/tabs/collection/CollectionView.java +++ b/source/com/c2kernel/gui/tabs/collection/CollectionView.java @@ -19,19 +19,19 @@ import com.c2kernel.utils.Logger; public abstract class CollectionView extends JPanel { - protected Collection thisColl; + protected Collection thisColl; protected ItemProxy item; public CollectionView() { super(); } - + public void setItem(ItemProxy entity) { this.item = entity; } - - public abstract void setCollection(Collection coll); - + + public abstract void setCollection(Collection coll); + protected void saveCollection() { try diff --git a/source/com/c2kernel/gui/tabs/collection/DependencyView.java b/source/com/c2kernel/gui/tabs/collection/DependencyView.java old mode 100755 new mode 100644 index 4465d6a..14e2af0 --- a/source/com/c2kernel/gui/tabs/collection/DependencyView.java +++ b/source/com/c2kernel/gui/tabs/collection/DependencyView.java @@ -19,7 +19,8 @@ public class DependencyView extends CollectionView createLayout(); } - public void setCollection(Collection contents) + @Override + public void setCollection(Collection contents) { thisColl = contents; } -- cgit v1.2.3