Source Code Cross Referenced for WorkflowDropTarget.java in  » Content-Management-System » harmonise » org » openharmonise » him » dnd » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » harmonise » org.openharmonise.him.dnd 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the 
003:         * Mozilla Public License Version 1.1 (the "License"); 
004:         * you may not use this file except in compliance with the License. 
005:         * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
009:         * See the License for the specific language governing rights and 
010:         * limitations under the License.
011:         *
012:         * The Initial Developer of the Original Code is Simulacra Media Ltd.
013:         * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014:         *
015:         * All Rights Reserved.
016:         *
017:         * Contributor(s):
018:         */
019:        package org.openharmonise.him.dnd;
020:
021:        import java.awt.*;
022:        import java.awt.dnd.*;
023:        import java.util.*;
024:
025:        import org.openharmonise.commons.xml.namespace.*;
026:        import org.openharmonise.him.*;
027:        import org.openharmonise.him.context.StateHandler;
028:        import org.openharmonise.him.swing.resourcetree.*;
029:        import org.openharmonise.him.window.messages.*;
030:        import org.openharmonise.vfs.*;
031:        import org.openharmonise.vfs.context.*;
032:        import org.openharmonise.vfs.metadata.*;
033:        import org.openharmonise.vfs.metadata.value.*;
034:        import org.openharmonise.vfs.servers.ServerList;
035:        import org.openharmonise.vfs.status.*;
036:        import org.openharmonise.workfloweditor.flowchart.*;
037:        import org.openharmonise.workfloweditor.flowchart.shapes.*;
038:        import org.openharmonise.workfloweditor.vfs.*;
039:
040:        /**
041:         * Drop target for workflow editor diagram. Used when dragging stages
042:         * from the resource tree into the diagram.
043:         * 
044:         * @author Matthew Large
045:         * @version $Revision: 1.2 $
046:         *
047:         */
048:        public class WorkflowDropTarget implements  DropTargetListener {
049:
050:            DropTarget m_target;
051:            FlowChart m_chart;
052:            ResourceTree m_tree;
053:
054:            private boolean bDisplayErrorMessage = true;
055:
056:            private StageShape m_stageShape = null;
057:
058:            /**
059:             * Constructs a new workflow drop target.
060:             * 
061:             * @param chart Workflow diagram
062:             * @param tree Resource tree
063:             */
064:            public WorkflowDropTarget(FlowChart chart, ResourceTree tree) {
065:                m_chart = chart;
066:                m_tree = tree;
067:                m_target = new DropTarget(m_chart, this );
068:            }
069:
070:            /* (non-Javadoc)
071:             * @see java.awt.dnd.DropTargetListener#dragEnter(java.awt.dnd.DropTargetDragEvent)
072:             */
073:            public void dragEnter(DropTargetDragEvent arg0) {
074:            }
075:
076:            /* (non-Javadoc)
077:             * @see java.awt.dnd.DropTargetListener#dragOver(java.awt.dnd.DropTargetDragEvent)
078:             */
079:            public void dragOver(DropTargetDragEvent dtde) {
080:                Point pt = dtde.getLocation();
081:                if (this .m_stageShape == null) {
082:                    VirtualFile vfFile = m_tree.getSelectedResource();
083:
084:                    VFSWorkflowModel model = (VFSWorkflowModel) m_chart
085:                            .getModel();
086:
087:                    boolean bDuplicate = false;
088:
089:                    Iterator itor = model.getWorkflowStages().iterator();
090:                    while (itor.hasNext()) {
091:                        VFSWorkflowStage stage = (VFSWorkflowStage) itor.next();
092:                        VirtualFile stageFile = ServerList.getInstance()
093:                                .getHarmoniseServer().getVFS().getVirtualFile(
094:                                        stage.getPath()).getResource();
095:                        if (stageFile != null
096:                                && stageFile.getFileName().equals(
097:                                        vfFile.getFileName())) {
098:                            bDuplicate = true;
099:                        }
100:                    }
101:
102:                    if (!bDuplicate) {
103:                        AbstractVirtualFileSystem vfs = vfFile.getVFS();
104:
105:                        VFSWorkflowStageDefinition stageDefn = new VFSWorkflowStageDefinition(
106:                                vfFile, (VFSWorkflowModel) this .m_chart
107:                                        .getModel());
108:                        VirtualFile vfStagesCollection = model
109:                                .getStagesCollection();
110:                        String sNewPath = vfStagesCollection.getFullPath()
111:                                + "/" + vfFile.getFileName();
112:
113:                        VirtualFile vfNewFile = new VirtualFile(sNewPath);
114:                        vfNewFile.setContent(null);
115:                        if (vfs.addVirtualFile(sNewPath, vfNewFile) != null) {
116:                            VersionedVirtualFile vfStageFile = (VersionedVirtualFile) vfs
117:                                    .getVirtualFile(sNewPath).getResource();
118:                            PropertyInstance propInst = vfStageFile
119:                                    .getProperty(NamespaceType.OHRM.getURI(),
120:                                            "WORKFLOW_RELN");
121:                            ResourceValue value = (ResourceValue) propInst
122:                                    .getNewValueInstance();
123:                            value.setValue(stageDefn.getPath());
124:                            propInst.addValue(value);
125:
126:                            PropertyInstance propInst2 = vfStageFile
127:                                    .getProperty(NamespaceType.OHRM.getURI(),
128:                                            "WORKFLOW_MAND");
129:                            BooleanValue value2 = (BooleanValue) propInst2
130:                                    .getNewValueInstance();
131:                            value2.setValue(true);
132:                            propInst2.addValue(value2);
133:
134:                            StatusData status = vfStageFile.sync();
135:
136:                            StateHandler.getInstance().addWait("WORKFLOWSAVE");
137:                            try {
138:                                itor = model.getWorkflowStages().iterator();
139:
140:                                while (itor.hasNext()) {
141:                                    VFSWorkflowStage stage = (VFSWorkflowStage) itor
142:                                            .next();
143:                                    VersionedVirtualFile vfFile2 = (VersionedVirtualFile) vfs
144:                                            .getVirtualFile(stage.getPath())
145:                                            .getResource();
146:                                    if (vfFile2.isChanged()) {
147:                                        StatusData status2 = vfFile2.sync();
148:                                        status.addStatusData(status2);
149:                                        if (status2.isOK()) {
150:                                            //vfFile = (VersionedVirtualFile) vfs.getVirtualFile(stage.getPath());
151:                                            if (vfFile2.getState() == VirtualFile.STATE_LIVE
152:                                                    && vfFile2
153:                                                            .getPendingVersionPath() != null) {
154:                                                VersionedVirtualFile vfPending = (VersionedVirtualFile) vfs
155:                                                        .getVirtualFile(
156:                                                                vfFile2
157:                                                                        .getPendingVersionPath())
158:                                                        .getResource();
159:                                                if (vfPending != null) {
160:                                                    vfPending.checkin();
161:                                                }
162:                                            } else if (vfFile2.getState() == VirtualFile.STATE_PENDING) {
163:                                                vfFile2.checkin();
164:                                            }
165:                                        } else {
166:                                            //System.err.println("STAGE SYNC FAILED!!!!!!");
167:                                        }
168:                                    }
169:                                }
170:                            } catch (Exception e) {
171:                                e.printStackTrace();
172:                            } finally {
173:                                StateHandler.getInstance().removeWait(
174:                                        "WORKFLOWSAVE");
175:                            }
176:
177:                            if (status.isOK()) {
178:                                vfStageFile = (VersionedVirtualFile) vfs
179:                                        .getVirtualFile(sNewPath).getResource();
180:                                StatusData status2 = vfStageFile.checkin();
181:                                if (status2.isOK()) {
182:                                    vfStageFile = (VersionedVirtualFile) vfs
183:                                            .getVirtualFile(sNewPath)
184:                                            .getResource();
185:
186:                                    VFSWorkflowStage stage = new VFSWorkflowStage(
187:                                            model, vfStageFile);
188:                                    stage.setDefinition(stageDefn);
189:
190:                                    this .m_chart.getModel().addWorkflowStage(
191:                                            stage);
192:
193:                                    m_stageShape = new StageShape(100, 100,
194:                                            stage);
195:                                    this .m_chart.addShape(m_stageShape);
196:                                }
197:                            }
198:
199:                        }
200:                        this .m_stageShape.setX(pt.x);
201:                        this .m_stageShape.setY(pt.y);
202:                    } else {
203:                        if (bDisplayErrorMessage) {
204:                            MessageHandler
205:                                    .getInstance()
206:                                    .fireMessageEvent(
207:                                            "You cannot have two Workflow Stages with the same name in a single Workflow.",
208:                                            MessageHandler.TYPE_ERROR);
209:                            this .bDisplayErrorMessage = false;
210:                        }
211:                    }
212:
213:                }
214:                this .m_chart.repaint();
215:            }
216:
217:            /* (non-Javadoc)
218:             * @see java.awt.dnd.DropTargetListener#dropActionChanged(java.awt.dnd.DropTargetDragEvent)
219:             */
220:            public void dropActionChanged(DropTargetDragEvent arg0) {
221:            }
222:
223:            /* (non-Javadoc)
224:             * @see java.awt.dnd.DropTargetListener#drop(java.awt.dnd.DropTargetDropEvent)
225:             */
226:            public void drop(DropTargetDropEvent dtde) {
227:                this .m_stageShape = null;
228:                this .bDisplayErrorMessage = true;
229:            }
230:
231:            /* (non-Javadoc)
232:             * @see java.awt.dnd.DropTargetListener#dragExit(java.awt.dnd.DropTargetEvent)
233:             */
234:            public void dragExit(DropTargetEvent arg0) {
235:            }
236:
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.