diff options
Diffstat (limited to 'source/com/c2kernel/gui/tabs/collection/CollectionHistoryWindow.java')
| -rw-r--r-- | source/com/c2kernel/gui/tabs/collection/CollectionHistoryWindow.java | 192 |
1 files changed, 0 insertions, 192 deletions
diff --git a/source/com/c2kernel/gui/tabs/collection/CollectionHistoryWindow.java b/source/com/c2kernel/gui/tabs/collection/CollectionHistoryWindow.java deleted file mode 100644 index ee168b0..0000000 --- a/source/com/c2kernel/gui/tabs/collection/CollectionHistoryWindow.java +++ /dev/null @@ -1,192 +0,0 @@ -package com.c2kernel.gui.tabs.collection;
-
-import java.awt.HeadlessException;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.util.ArrayList;
-
-import javax.swing.JFrame;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.table.AbstractTableModel;
-
-import com.c2kernel.collection.Aggregation;
-import com.c2kernel.collection.Collection;
-import com.c2kernel.common.ObjectNotFoundException;
-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;
-import com.c2kernel.lookup.EntityPath;
-import com.c2kernel.lookup.InvalidEntityPathException;
-import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.persistency.outcome.Outcome;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.CastorXMLUtility;
-import com.c2kernel.utils.Language;
-import com.c2kernel.utils.Logger;
-
-public class CollectionHistoryWindow extends JFrame {
-
- JTable historyTable;
- HistoryTableModel historyModel;
-
- public CollectionHistoryWindow(ItemProxy item, Aggregation coll) throws HeadlessException {
- super("Collection History");
- historyModel = new HistoryTableModel(item, coll);
- historyTable = new JTable(historyModel);
- this.getContentPane().add(new JScrollPane(historyTable));
- historyTable.addMouseListener(new HistoryTableListener(item));
- this.pack();
- super.toFront();
- this.validate();
- this.show();
- }
-
- private class HistoryTableModel extends AbstractTableModel implements EntityProxyObserver<Event> {
-
- ItemProxy item;
- ArrayList<Event> collEvents;
- ArrayList<Object> collEventData;
- Aggregation coll;
- public HistoryTableModel(ItemProxy item, Aggregation coll) {
- this.item = item;
- this.coll = coll;
- collEvents = new ArrayList<Event>();
- collEventData = new ArrayList<Object>();
- 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");
- case 1: return Language.translate("Operation");
- case 2: return Language.translate("Slot");
- 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 = collEvents.get(rowIndex);
- switch (columnIndex) {
- case 0:
- return ev.getTimeString();
- case 1:
- if (ev.getStepName().equals("AssignItemToSlot"))
- return "Item Assigned";
- else
- return "Collection replaced";
- case 2:
- if (ev.getStepName().equals("AssignItemToSlot"))
- return ((String[])collEventData.get(rowIndex))[1];
- return "";
- case 3:
- if (ev.getStepName().equals("AddC2KObject"))
- return "Click to view";
- String name;
- try {
- EntityProxy childItem = Gateway.getProxyManager().getProxy(new EntityPath(Integer.parseInt(((String[])collEventData.get(rowIndex))[2])));
- name = childItem.getName();
- } catch (NumberFormatException e) {
- name = "Invalid entity key: "+((String[])collEventData.get(rowIndex))[2];
- } catch (ObjectNotFoundException e) {
- name = "Item deleted: "+((String[])collEventData.get(rowIndex))[2];
- } catch (InvalidEntityPathException e) {
- name = "Invalid entity key: "+((String[])collEventData.get(rowIndex))[2];
- }
- return name;
- default:
- return "";
- }
- }
- public Object getEventData(int row) {
- return collEventData.get(row);
- }
- @Override
- public void add(Event thisEv) {
- if (thisEv.getStepName().equals("AssignItemToSlot") || thisEv.getStepName().equals("AddC2KObject")) {
- String[] params;
- try {
- Outcome oc = (Outcome)item.getObject(ClusterStorage.OUTCOME+"/PredefinedStepOutcome/0/"+thisEv.getID());
- params = PredefinedStep.getDataList(oc.getData());
- } catch (ObjectNotFoundException ex) { return; }
- if (thisEv.getStepName().equals("AssignItemToSlot")) {
- if (params[0].equals(coll.getName()))
- collEventData.add(params);
- else return;
- }
- else {
- Object obj;
- try {
- obj = CastorXMLUtility.unmarshall(params[0]);
- } catch (Exception e) {
- Logger.error(e);
- return;
- }
- 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) {
- }
- }
-
- private class HistoryTableListener extends MouseAdapter {
-
- ItemProxy item;
- public HistoryTableListener(ItemProxy item) {
- 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 Aggregation) {
- showColl((Aggregation)data);
- }
- else {
- String[] params = (String[])data;
- try {
- EntityProxy childItem = Gateway.getProxyManager().getProxy(new EntityPath(Integer.parseInt(params[2])));
- MainFrame.itemFinder.pushNewKey(childItem.getName());
- } catch (Exception ex) { }
- }
- }
- }
- public void showColl(Aggregation coll) {
- JFrame newFrame = new JFrame();
- AggregationView newView = new AggregationView();
- newView.setCollection(coll);
- newView.setItem(item);
- newFrame.getContentPane().add(newView);
- newFrame.pack();
- newFrame.toFront();
- newFrame.validate();
- newFrame.show();
- }
- }
-}
|
