Source Code Cross Referenced for SimpleNavigator.java in  » Workflow-Engines » JaWE » org » enhydra » jawe » components » simplenavigator » 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 » Workflow Engines » JaWE » org.enhydra.jawe.components.simplenavigator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.enhydra.jawe.components.simplenavigator;
002:
003:        import java.util.ArrayList;
004:        import java.util.List;
005:        import java.util.Observable;
006:        import java.util.Observer;
007:
008:        import javax.swing.JComponent;
009:        import javax.swing.event.TreeSelectionEvent;
010:        import javax.swing.event.TreeSelectionListener;
011:        import javax.swing.tree.TreePath;
012:
013:        import org.enhydra.jawe.JaWEComponent;
014:        import org.enhydra.jawe.JaWEComponentSettings;
015:        import org.enhydra.jawe.JaWEComponentView;
016:        import org.enhydra.jawe.JaWEManager;
017:        import org.enhydra.jawe.XPDLElementChangeInfo;
018:        import org.enhydra.jawe.components.XPDLTreeNode;
019:        import org.enhydra.shark.xpdl.XMLCollection;
020:        import org.enhydra.shark.xpdl.XMLElement;
021:        import org.enhydra.shark.xpdl.XMLElementChangeInfo;
022:        import org.enhydra.shark.xpdl.elements.Package;
023:
024:        /**
025:         *  Used to handle events in Package hierarchy tree.
026:         *
027:         *  @author Sasa Bojanic
028:         */
029:        public class SimpleNavigator implements  JaWEComponent, Observer,
030:                TreeSelectionListener {
031:
032:            protected String type = JaWEComponent.TREE_COMPONENT;
033:            protected SimpleNavigatorPanel panel;
034:
035:            protected boolean updateInProgress = false;
036:
037:            protected SimpleNavigatorSettings settings;
038:
039:            public SimpleNavigator(JaWEComponentSettings settings)
040:                    throws Exception {
041:                this .settings = (SimpleNavigatorSettings) settings;
042:                this .settings.init(this );
043:
044:                init();
045:                JaWEManager.getInstance().getJaWEController().addObserver(this );
046:            }
047:
048:            public JaWEComponentSettings getSettings() {
049:                return settings;
050:            }
051:
052:            public SimpleNavigatorSettings getNavigatorSettings() {
053:                return settings;
054:            }
055:
056:            public void update(Observable o, Object arg) {
057:                if (!(arg instanceof  XPDLElementChangeInfo))
058:                    return;
059:                XPDLElementChangeInfo info = (XPDLElementChangeInfo) arg;
060:                int action = info.getAction();
061:                if (!(action == XMLElementChangeInfo.UPDATED
062:                        || action == XMLElementChangeInfo.INSERTED
063:                        || action == XMLElementChangeInfo.REMOVED
064:                        || action == XMLElementChangeInfo.REPOSITIONED
065:                        || action == XPDLElementChangeInfo.SELECTED
066:                        || action == XPDLElementChangeInfo.UNDOABLE_ACTION_ENDED
067:                        || action == XPDLElementChangeInfo.UNDO || action == XPDLElementChangeInfo.REDO))
068:                    return;
069:
070:                long start = System.currentTimeMillis();
071:                JaWEManager.getInstance().getLoggingManager().info(
072:                        "SimpleNavigator -> update for event " + info
073:                                + " started ...");
074:                if (action == XPDLElementChangeInfo.UNDOABLE_ACTION_ENDED
075:                        || action == XPDLElementChangeInfo.UNDO
076:                        || action == XPDLElementChangeInfo.REDO) {
077:                    for (int i = 0; i < info.getChangedSubElements().size(); i++) {
078:                        update((XPDLElementChangeInfo) info
079:                                .getChangedSubElements().get(i));
080:                    }
081:                } else {
082:                    update(info);
083:                }
084:                JaWEManager.getInstance().getLoggingManager().info(
085:                        "SimpleNavigator -> update ended...");
086:                long end = System.currentTimeMillis();
087:                double diffs = (end - start) / 1000.0;
088:                JaWEManager.getInstance().getLoggingManager().debug(
089:                        "THE UPDATE OF NAVIG COMPONENT LASTED FOR " + diffs
090:                                + " SECONDS!");
091:            }
092:
093:            public void update(XPDLElementChangeInfo info) {
094:                if (updateInProgress)
095:                    return;
096:                if (info.getSource() == this ) {
097:                    return;
098:                }
099:
100:                updateInProgress = true;
101:                try {
102:                    panel.handleXPDLChangeEvent(info);
103:                } finally {
104:                    updateInProgress = false;
105:                }
106:            }
107:
108:            protected void init() {
109:                panel = new SimpleNavigatorPanel(this );
110:                panel.configure();
111:            }
112:
113:            public void valueChanged(TreeSelectionEvent e) {
114:                if (updateInProgress)
115:                    return;
116:                JaWEManager.getInstance().getLoggingManager().info(
117:                        "SimpleNavigator -> selection changed ...");
118:
119:                TreePath oldsel = e.getOldLeadSelectionPath();
120:
121:                TreePath[] sel = e.getPaths();
122:                List selection = new ArrayList();
123:                boolean hasAdded = false;
124:                boolean hasRemoved = false;
125:
126:                int j = 0;
127:                for (int i = 0; i < sel.length; i++) {
128:                    if (sel[i] == e.getNewLeadSelectionPath()) {
129:                        j = i;
130:                        break;
131:                    }
132:                }
133:
134:                TreePath temp = sel[j];
135:                sel[j] = sel[sel.length - 1];
136:                sel[sel.length - 1] = temp;
137:
138:                for (int i = 0; i < sel.length; i++) {
139:                    if (e.isAddedPath(sel[i]))
140:                        hasAdded = true;
141:                    else
142:                        hasRemoved = true;
143:                }
144:
145:                if (oldsel == null) {
146:                    hasAdded = false;
147:                    hasRemoved = false;
148:                }
149:
150:                for (int i = 0; i < sel.length; i++) {
151:                    if (e.isAddedPath(sel[i])) {
152:                        XPDLTreeNode node = (XPDLTreeNode) sel[i]
153:                                .getLastPathComponent();
154:                        if (node == null || node.getXPDLElement() == null)
155:                            return;
156:                        selection.add(node.getXPDLElement());
157:                    }
158:                }
159:
160:                if (hasAdded && hasRemoved) {
161:                    JaWEManager.getInstance().getJaWEController()
162:                            .getSelectionManager()
163:                            .setSelection(selection, true);
164:                } else if (hasAdded && !hasRemoved) {
165:                    JaWEManager.getInstance().getJaWEController()
166:                            .getSelectionManager().addToSelection(selection);
167:                } else {
168:                    selection.clear();
169:                    if (panel.tree.isSelectionEmpty()) {
170:                        selection.add(((XPDLTreeNode) sel[0]
171:                                .getLastPathComponent()).getXPDLElement());
172:                    } else {
173:                        sel = panel.tree.getSelectionPaths();
174:                        for (int i = 0; i < sel.length; i++) {
175:                            XPDLTreeNode node = (XPDLTreeNode) sel[i]
176:                                    .getLastPathComponent();
177:                            if (node == null || node.getXPDLElement() == null)
178:                                return;
179:                            selection.add(node.getXPDLElement());
180:                        }
181:                    }
182:                    JaWEManager.getInstance().getJaWEController()
183:                            .getSelectionManager()
184:                            .setSelection(selection, true);
185:                }
186:                JaWEManager
187:                        .getInstance()
188:                        .getLoggingManager()
189:                        .info(
190:                                "SimpleNavigator -> observers notified about selection changed!");// to " + node + ", xpdlElement=";
191:                //                  + node.getXPDLElement().toName() + ", Id="
192:                //                  + ((XMLComplexElement) node.getXPDLElement()).get("Id").toValue());
193:            }
194:
195:            public JaWEComponentView getView() {
196:                return panel;
197:            }
198:
199:            public JComponent getDisplay() {
200:                return panel.getDisplay();
201:            }
202:
203:            public String getType() {
204:                return type;
205:            }
206:
207:            public void setType(String type) {
208:                this .type = type;
209:            }
210:
211:            public String getName() {
212:                return "SimpleNavigatorComponent";
213:            }
214:
215:            public boolean adjustXPDL(Package pkg) {
216:                return false;
217:            }
218:
219:            public List checkValidity(XMLElement el, boolean fullCheck) {
220:                return null;
221:            }
222:
223:            public boolean canCreateElement(XMLCollection col) {
224:                return true;
225:            }
226:
227:            public boolean canInsertElement(XMLCollection col, XMLElement el) {
228:                return true;
229:            }
230:
231:            public boolean canModifyElement(XMLElement el) {
232:                return true;
233:            }
234:
235:            public boolean canRemoveElement(XMLCollection col, XMLElement el) {
236:                return true;
237:            }
238:
239:            public boolean canDuplicateElement(XMLCollection col, XMLElement el) {
240:                return true;
241:            }
242:
243:            public boolean canRepositionElement(XMLCollection col, XMLElement el) {
244:                return true;
245:            }
246:
247:            public void setUpdateInProgress(boolean inProgress) {
248:                updateInProgress = inProgress;
249:            }
250:
251:            public boolean isUpdateInProgress() {
252:                return updateInProgress;
253:            }
254:
255:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.