001: package org.pentaho.designstudio.widgets.flowtable;
002:
003: import org.eclipse.swt.events.MouseEvent;
004: import org.eclipse.swt.graphics.Point;
005: import org.eclipse.swt.widgets.Composite;
006: import org.pentaho.actionsequence.dom.AbstractIOElement;
007: import org.pentaho.actionsequence.dom.ActionControlStatement;
008: import org.pentaho.actionsequence.dom.ActionSequenceDocument;
009: import org.pentaho.actionsequence.dom.IActionSequenceDocumentListener;
010: import org.pentaho.actionsequence.dom.IActionSequenceElement;
011: import org.pentaho.actionsequence.dom.actions.ActionDefinition;
012:
013: import de.kupzog.ktable.KTable;
014: import de.kupzog.ktable.SWTX;
015:
016: public class ActionsFlowTable extends KTable implements
017: IActionSequenceDocumentListener {
018: ActionsFlowModel actionsFlowModel = new ActionsFlowModel();
019:
020: public ActionsFlowTable(Composite parent) {
021: super (parent, SWTX.AUTO_SCROLL | SWTX.FILL_WITH_LASTCOL);
022: this .setModel(actionsFlowModel);
023: }
024:
025: public void setActionSequence(ActionSequenceDocument document) {
026: if (actionsFlowModel.actionSequence != null) {
027: actionsFlowModel.actionSequence.removeListener(this );
028: }
029: actionsFlowModel.setActionSequence(document);
030: if (document != null) {
031: document.addListener(this );
032: }
033: redraw();
034: }
035:
036: public void actionAdded(ActionDefinition action) {
037: refresh();
038: }
039:
040: public void actionChanged(ActionDefinition action) {
041: refresh();
042: }
043:
044: public void actionRemoved(Object parent, ActionDefinition action) {
045: refresh();
046:
047: }
048:
049: public void actionRenamed(ActionDefinition action) {
050: refresh();
051: }
052:
053: public void ioAdded(AbstractIOElement io) {
054: refresh();
055: }
056:
057: public void ioChanged(AbstractIOElement io) {
058: refresh();
059: }
060:
061: public void ioRemoved(Object parent, AbstractIOElement io) {
062: refresh();
063: }
064:
065: public void ioRenamed(AbstractIOElement io) {
066: refresh();
067: }
068:
069: public void controlStatementAdded(
070: ActionControlStatement controlStatement) {
071: refresh();
072: }
073:
074: public void controlStatementChanged(
075: ActionControlStatement controlStatement) {
076: refresh();
077: }
078:
079: public void controlStatementRemoved(Object parent,
080: ActionControlStatement controlStatement) {
081: refresh();
082: }
083:
084: public void resourceAdded(Object resource) {
085: refresh();
086: }
087:
088: public void resourceChanged(Object resource) {
089: refresh();
090: }
091:
092: public void resourceRemoved(Object parent, Object resource) {
093: refresh();
094: }
095:
096: public void resourceRenamed(Object resource) {
097: refresh();
098: }
099:
100: public void headerChanged(
101: ActionSequenceDocument actionSequenceDocument) {
102: }
103:
104: public void refresh() {
105: actionsFlowModel.refresh();
106: redraw();
107: }
108:
109: protected void onMouseDown(MouseEvent e) {
110: if (e.button == 1) {
111: setCapture(true);
112: m_Capture = true;
113:
114: // Resize column?
115: int columnIndex = getColumnForResize(e.x, e.y);
116: if (columnIndex >= 0) {
117: m_ResizeColumnIndex = columnIndex;
118: m_ResizeColumnLeft = getColumnLeft(columnIndex);
119: m_NewColumnSize = m_Model.getColumnWidth(columnIndex);
120: return;
121: }
122:
123: Point cell = calcNonSpanColumnNum(e.x, e.y);
124: Object content = actionsFlowModel.getContentAt(cell.x,
125: cell.y);
126: if (content instanceof IActionSequenceElement) {
127: m_ClickColumnIndex = cell.x;
128: m_ClickRowIndex = cell.y;
129:
130: focusCell(cell.x, cell.y, e.stateMask);
131: }
132: }
133: }
134: }
|