KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > workfloweditor > flowchart > AttributeMouseHandler


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * 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 JavaDoc;
22 import java.util.Iterator JavaDoc;
23
24 import javax.swing.event.MouseInputAdapter JavaDoc;
25
26 import org.openharmonise.workfloweditor.flowchart.shapes.*;
27
28
29 /**
30  * Deals with mouse clicks on the workflow
31  * diagram that are targeted are elements of the workflow instance
32  * shapes.
33  *
34  * @author Matthew Large
35  * @version $Revision: 1.1 $
36  *
37  */

38 public class AttributeMouseHandler extends MouseInputAdapter JavaDoc {
39
40     /**
41      * The workflow diagram.
42      */

43     private FlowChart m_chart = null;
44
45     /**
46      * Constructs a new attribute mouse handler.
47      *
48      * @param chart Workflow diagram
49      */

50     public AttributeMouseHandler(FlowChart chart) {
51         super();
52         this.m_chart = chart;
53     }
54
55     /* (non-Javadoc)
56      * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
57      */

58     public void mouseDragged(MouseEvent JavaDoc me) {
59
60     }
61
62     /* (non-Javadoc)
63      * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
64      */

65     public void mousePressed(MouseEvent JavaDoc me) {
66         Iterator JavaDoc itor = this.m_chart.getShapes().iterator();
67         while (itor.hasNext()) {
68             AbstractWorkflowShape shape = (AbstractWorkflowShape) itor.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(stageShape.getStage());
74                     break;
75                 } else if(stageShape.contains(me.getX(), me.getY())) {
76                     stageShape.mouseClicked(me.getX(), me.getY());
77                     break;
78                 }
79             }
80         }
81         this.m_chart.repaint();
82     }
83
84     /* (non-Javadoc)
85      * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
86      */

87     public void mouseReleased(MouseEvent JavaDoc me) {
88
89     }
90
91 }
92
Popular Tags