01: /*
02: * The contents of this file are subject to the
03: * Mozilla Public License Version 1.1 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
06: *
07: * Software distributed under the License is distributed on an "AS IS"
08: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
09: * See the License for the specific language governing rights and
10: * limitations under the License.
11: *
12: * The Initial Developer of the Original Code is Simulacra Media Ltd.
13: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14: *
15: * All Rights Reserved.
16: *
17: * Contributor(s):
18: */
19: package org.openharmonise.workfloweditor.flowchart;
20:
21: import java.awt.event.MouseEvent;
22: import java.util.Iterator;
23:
24: import javax.swing.event.MouseInputAdapter;
25:
26: import org.openharmonise.workfloweditor.flowchart.shapes.*;
27:
28: /**
29: * Deals with mouse clicks on the workflow
30: * diagram that are targeted are elements of the workflow instance
31: * shapes.
32: *
33: * @author Matthew Large
34: * @version $Revision: 1.1 $
35: *
36: */
37: public class AttributeMouseHandler extends MouseInputAdapter {
38:
39: /**
40: * The workflow diagram.
41: */
42: private FlowChart m_chart = null;
43:
44: /**
45: * Constructs a new attribute mouse handler.
46: *
47: * @param chart Workflow diagram
48: */
49: public AttributeMouseHandler(FlowChart chart) {
50: super ();
51: this .m_chart = chart;
52: }
53:
54: /* (non-Javadoc)
55: * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
56: */
57: public void mouseDragged(MouseEvent me) {
58:
59: }
60:
61: /* (non-Javadoc)
62: * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
63: */
64: public void mousePressed(MouseEvent me) {
65: Iterator itor = this .m_chart.getShapes().iterator();
66: while (itor.hasNext()) {
67: AbstractWorkflowShape shape = (AbstractWorkflowShape) itor
68: .next();
69: if (shape instanceof StageShape) {
70: StageShape stageShape = (StageShape) shape;
71: if (stageShape.closeContains(me.getX(), me.getY())) {
72: this .m_chart.removeShape(stageShape);
73: this .m_chart.getModel().removeWorkflowStage(
74: stageShape.getStage());
75: break;
76: } else if (stageShape.contains(me.getX(), me.getY())) {
77: stageShape.mouseClicked(me.getX(), me.getY());
78: break;
79: }
80: }
81: }
82: this .m_chart.repaint();
83: }
84:
85: /* (non-Javadoc)
86: * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
87: */
88: public void mouseReleased(MouseEvent me) {
89:
90: }
91:
92: }
|