summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/gui/tabs/HistoryPane.java
diff options
context:
space:
mode:
Diffstat (limited to 'source/com/c2kernel/gui/tabs/HistoryPane.java')
-rw-r--r--source/com/c2kernel/gui/tabs/HistoryPane.java73
1 files changed, 45 insertions, 28 deletions
diff --git a/source/com/c2kernel/gui/tabs/HistoryPane.java b/source/com/c2kernel/gui/tabs/HistoryPane.java
index be7f8b2..5b3d536 100644
--- a/source/com/c2kernel/gui/tabs/HistoryPane.java
+++ b/source/com/c2kernel/gui/tabs/HistoryPane.java
@@ -21,8 +21,8 @@ import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.entity.C2KLocalObject;
import com.c2kernel.entity.proxy.EntityProxyObserver;
+import com.c2kernel.entity.proxy.MemberSubscription;
import com.c2kernel.events.Event;
import com.c2kernel.events.History;
import com.c2kernel.lifecycle.instance.stateMachine.Transitions;
@@ -36,7 +36,7 @@ import com.c2kernel.utils.Logger;
* @version $Revision: 1.22 $ $Date: 2005/04/26 06:48:13 $
* @author $Author: abranson $
*/
-public class HistoryPane extends EntityTabPane implements ActionListener, EntityProxyObserver {
+public class HistoryPane extends EntityTabPane implements ActionListener, EntityProxyObserver<Event> {
History history;
HistoryTableModel model;
@@ -47,7 +47,7 @@ public class HistoryPane extends EntityTabPane implements ActionListener, Entity
JButton endButton = new JButton(">>");
public static final int SIZE = 30;
int currentSize = SIZE;
-
+
public HistoryPane() {
super("History", "Event History");
initPanel();
@@ -56,18 +56,18 @@ public class HistoryPane extends EntityTabPane implements ActionListener, Entity
Box navBox = Box.createHorizontalBox();
navBox.add(startButton); navBox.add(prevButton);
navBox.add(nextButton); navBox.add(endButton);
-
+
// setup buttons
//startButton.setEnabled(false); nextButton.setEnabled(false);
//prevButton.setEnabled(false); endButton.setEnabled(false);
startButton.setActionCommand("start");
startButton.addActionListener(this);
prevButton.setActionCommand("prev");
- prevButton.addActionListener(this);
+ prevButton.addActionListener(this);
nextButton.setActionCommand("next");
- nextButton.addActionListener(this);
+ nextButton.addActionListener(this);
endButton.setActionCommand("end");
- endButton.addActionListener(this);
+ endButton.addActionListener(this);
getGridBagConstraints();
c.gridx = 0; c.gridy = 1;
c.anchor = GridBagConstraints.NORTHWEST;
@@ -76,27 +76,29 @@ public class HistoryPane extends EntityTabPane implements ActionListener, Entity
gridbag.setConstraints(navBox, c);
add(navBox);
-
+
// Create table
eventTable = new JTable();
JScrollPane eventScroll= new JScrollPane(eventTable);
c.weightx = 1.0; c.weighty = 1.0;
- c.fill = GridBagConstraints.BOTH; c.gridy++;
+ c.fill = GridBagConstraints.BOTH; c.gridy++;
gridbag.setConstraints(eventScroll, c);
add(eventScroll);
-
+
}
- public void reload() {
+ @Override
+ public void reload() {
history.clear();
jumpToEnd();
}
- public void run() {
+ @Override
+ public void run() {
Thread.currentThread().setName("History Pane Builder");
try {
history = (History)sourceEntity.getEntity().getObject(ClusterStorage.HISTORY);
- sourceEntity.getEntity().subscribe(this, ClusterStorage.HISTORY, false);
+ sourceEntity.getEntity().subscribe(new MemberSubscription<Event>(this, ClusterStorage.HISTORY, false));
} catch (ObjectNotFoundException e) {
Logger.error(e);
}
@@ -104,7 +106,7 @@ public class HistoryPane extends EntityTabPane implements ActionListener, Entity
eventTable.setModel(model);
jumpToEnd();
}
-
+
public void jumpToEnd() {
int lastEvent = history.getLastId();
int firstEvent = 0; currentSize = SIZE;
@@ -113,28 +115,31 @@ public class HistoryPane extends EntityTabPane implements ActionListener, Entity
Logger.msg(5, "HistoryPane.run() - init table start "+firstEvent+" for "+currentSize);
model.setView(firstEvent, currentSize);
}
-
- public void add(C2KLocalObject contents) {
+
+ @Override
+ public void add(Event contents) {
jumpToEnd();
}
- public void remove(String id) {
+ @Override
+ public void remove(String id) {
// don't have to deal with this normally
- }
-
+ }
+
+ @Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("end")) {
jumpToEnd();
return;
}
-
+
int lastEvent = history.getLastId();
int startEvent = model.getStartId();
if (e.getActionCommand().equals("start")) {
currentSize = SIZE;
startEvent = 0;
}
-
+
else if (e.getActionCommand().equals("prev")) {
currentSize = SIZE;
startEvent-=currentSize;
@@ -151,19 +156,19 @@ public class HistoryPane extends EntityTabPane implements ActionListener, Entity
}
model.setView(startEvent, currentSize);
- }
-
+ }
+
private class HistoryTableModel extends AbstractTableModel {
Event[] event;
Integer[] ids;
int loaded = 0;
int startId = 0;
-
+
public HistoryTableModel() {
event = new Event[0];
ids = new Integer[0];
- }
-
+ }
+
public int getStartId() {
return startId;
}
@@ -182,6 +187,7 @@ public class HistoryPane extends EntityTabPane implements ActionListener, Entity
/**
* @see javax.swing.table.TableModel#getColumnClass(int)
*/
+ @Override
public Class<?> getColumnClass(int columnIndex) {
switch(columnIndex) {
case 0:
@@ -194,6 +200,7 @@ public class HistoryPane extends EntityTabPane implements ActionListener, Entity
/**
* @see javax.swing.table.TableModel#getColumnCount()
*/
+ @Override
public int getColumnCount() {
return 6;
}
@@ -201,6 +208,7 @@ public class HistoryPane extends EntityTabPane implements ActionListener, Entity
/**
* @see javax.swing.table.TableModel#getColumnName(int)
*/
+ @Override
public String getColumnName(int columnIndex) {
switch(columnIndex) {
case 0: return Language.translate("ID");
@@ -216,6 +224,7 @@ public class HistoryPane extends EntityTabPane implements ActionListener, Entity
/**
* @see javax.swing.table.TableModel#getRowCount()
*/
+ @Override
public int getRowCount() {
return loaded;
}
@@ -223,6 +232,7 @@ public class HistoryPane extends EntityTabPane implements ActionListener, Entity
/**
* @see javax.swing.table.TableModel#getValueAt(int, int)
*/
+ @Override
public Object getValueAt(int rowIndex, int columnIndex) {
if (event.length <= rowIndex || event[rowIndex] == null)
return "";
@@ -234,8 +244,8 @@ public class HistoryPane extends EntityTabPane implements ActionListener, Entity
case 3: return event[rowIndex].getTimeString();
case 4: return event[rowIndex].getAgentName();
case 5: return event[rowIndex].getAgentRole();
- default: return "";
- }
+ default: return "";
+ }
} catch (Exception e) {
return null;
}
@@ -244,10 +254,17 @@ public class HistoryPane extends EntityTabPane implements ActionListener, Entity
/**
* @see javax.swing.table.TableModel#isCellEditable(int, int)
*/
+ @Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return false;
}
}
+ @Override
+ public void control(String control, String msg) {
+ // TODO Auto-generated method stub
+
+ }
+
}