Source Code Cross Referenced for PerspectiveUtil.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » ui » util » 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 » ESB » cbesb 1.2 » com.bostechcorp.cbesb.ui.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ChainBuilder ESB
003:         *          Visual Enterprise Integration
004:         * 
005:         * Copyright (C) 2006 Bostech Corporation
006:         * 
007:         * This program is free software; you can redistribute it and/or modify it 
008:         * under the terms of the GNU General Public License as published by the 
009:         * Free Software Foundation; either version 2 of the License, or (at your option) 
010:         * any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful, 
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
014:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
015:         * for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License along with 
018:         * this program; if not, write to the Free Software Foundation, Inc., 
019:         * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020:         *
021:         *
022:         * $Id$
023:         */
024:        package com.bostechcorp.cbesb.ui.util;
025:
026:        import java.util.Collection;
027:        import java.util.HashMap;
028:        import java.util.Vector;
029:
030:        import org.eclipse.ui.IPerspectiveDescriptor;
031:        import org.eclipse.ui.IPerspectiveRegistry;
032:        import org.eclipse.ui.IWorkbenchPage;
033:        import org.eclipse.ui.IWorkbenchWindow;
034:        import org.eclipse.ui.PlatformUI;
035:        import org.eclipse.ui.part.EditorPart;
036:
037:        public class PerspectiveUtil {
038:
039:            public static Vector editor_vector = new Vector();
040:            public static final String PERSPECTIVE_ID_COMPONENTFLOWEDIT = "com.bostechcorp.cbesb.ui.ide.componentFlowEditorPerspective";
041:            public static final String PERSPECTIVE_ID_FORMATMESSAGEEDIT = "com.bostechcorp.cbesb.ui.ide.messageformatperspective";
042:            public static final String PERSPECTIVE_ID_TRANSFORMEREDIT = "com.bostechcorp.cbesb.ui.ide.transformerperspective";
043:
044:            public static final String PERSPECTIVE_ID_X12EDIT = "com.bostechcorp.cbesb.ui.ide.x12variantperspective";
045:            public static final String PERSPECTIVE_ID_HL7EDIT = "com.bostechcorp.cbesb.ui.ide.hl7variantperspective";
046:            public static final String PERSPECTIVE_ID_MAPTESTEDIT = "com.bostechcorp.cbesb.ui.ide.perspective.maptestingperspective";
047:            public static final String PERSPECTIVE_ID_DATASOURCEMAPPER = "com.bostechcorp.cbesb.ui.ide.datasourcemapperperpective";
048:
049:            public static Vector getVector() {
050:                if (editor_vector == null) {
051:                    editor_vector = new Vector();
052:                }
053:                return editor_vector;
054:            }
055:
056:            public static void addEditor(EditorPart editor) {
057:
058:                int size = editor_vector.size();
059:                String ID = null;
060:                for (int i = 0; i < size; i++) {
061:                    HashMap map = (HashMap) editor_vector.get(i);
062:                    if (map.containsKey(editor)) {
063:                        ID = (String) map.get(editor);
064:                        break;
065:                    }
066:                }
067:                EditorPart editor_added = (EditorPart) editor;
068:                HashMap map = new HashMap();
069:                map.put(editor_added, ID);
070:                if (editor_vector.contains(map)) {
071:                    editor_vector.remove(map);
072:
073:                }
074:
075:                editor_vector.add(map);
076:                goToPer(editor_vector, map, editor_added);
077:            }
078:
079:            public static void addEditor(EditorPart editor, String ID) {
080:
081:                if (editor_vector == null) {
082:                    editor_vector = new Vector();
083:                }
084:                EditorPart editor_added = (EditorPart) editor;
085:                HashMap map = new HashMap();
086:                map.put(editor_added, ID);
087:                if (editor_vector.contains(map)) {
088:                    editor_vector.remove(map);
089:
090:                }
091:
092:                editor_vector.add(map);
093:                goToPer(editor_vector, map, editor_added);
094:            }
095:
096:            public static void removeEditor(EditorPart editor, String ID) {
097:                boolean left = false;
098:                EditorPart editor_removed = (EditorPart) editor;
099:                HashMap map = new HashMap();
100:                map.put(editor_removed, ID);
101:                if (editor_vector.contains(map)) {
102:                    editor_vector.remove(map);
103:
104:                }
105:
106:                for (int i = 0; i < editor_vector.size(); i++) {
107:                    HashMap map1 = (HashMap) editor_vector.get(i);
108:                    if (map1.containsValue(ID)) {
109:                        left = true;
110:                        break;
111:                    }
112:                }
113:
114:                if (!left) {
115:                    try {
116:                        IPerspectiveRegistry registry = PlatformUI
117:                                .getWorkbench().getPerspectiveRegistry();
118:                        IPerspectiveDescriptor perspectiveDesc = registry
119:                                .findPerspectiveWithId(ID);
120:                        IWorkbenchWindow workbench = PlatformUI.getWorkbench()
121:                                .getActiveWorkbenchWindow();
122:                        if (workbench != null && perspectiveDesc != null
123:                                && null != workbench.getActivePage())
124:                            workbench.getActivePage().closePerspective(
125:                                    perspectiveDesc, false, false);
126:                    } catch (Exception e) {
127:                        e.printStackTrace();
128:                    }
129:                }
130:
131:                goToPer(editor_vector, map, editor_removed);
132:            }
133:
134:            public static void goToPer(Vector vector, HashMap last,
135:                    EditorPart part) {
136:                int index = vector.size();
137:                if (index != 0) {
138:                    HashMap editorPart_last = (HashMap) vector.get(index - 1);
139:                    Collection list = editorPart_last.values();
140:                    Object[] objects = list.toArray();
141:                    String ID = objects[0].toString();
142:
143:                    showPer(ID);
144:                } else {
145:                    try {
146:                        IPerspectiveRegistry registry = PlatformUI
147:                                .getWorkbench().getPerspectiveRegistry();
148:                        IPerspectiveDescriptor perspectiveDesc = registry
149:                                .findPerspectiveWithId(registry
150:                                        .getDefaultPerspective());
151:                        IWorkbenchWindow workbench = PlatformUI.getWorkbench()
152:                                .getActiveWorkbenchWindow();
153:                        if (workbench != null && perspectiveDesc != null
154:                                && null != workbench.getActivePage())
155:                            workbench.getActivePage().setPerspective(
156:                                    perspectiveDesc);
157:                    } catch (Exception e) {
158:                        e.printStackTrace();
159:                    }
160:                }
161:
162:            }
163:
164:            public static void showPer(String part) {
165:                activePerspective(part);
166:            }
167:
168:            public static void activeFlowEditPerspective() {
169:                activePerspective(PERSPECTIVE_ID_COMPONENTFLOWEDIT);
170:            }
171:
172:            public static void activeFormatEditPerspective() {
173:                activePerspective(PERSPECTIVE_ID_FORMATMESSAGEEDIT);
174:            }
175:
176:            public static void activeTransformerEditPerspective() {
177:                activePerspective(PERSPECTIVE_ID_TRANSFORMEREDIT);
178:            }
179:
180:            public static void activeX12EditorPerspective() {
181:                activePerspective(PERSPECTIVE_ID_X12EDIT);
182:            }
183:
184:            public static void activeMapTestingEditorPerspective() {
185:                activePerspective(PERSPECTIVE_ID_MAPTESTEDIT);
186:            }
187:
188:            public static void activeHL7EditorPerspective() {
189:                activePerspective(PERSPECTIVE_ID_HL7EDIT);
190:            }
191:
192:            public static void activeDataSourceMapperEditorPerspective() {
193:                activePerspective(PERSPECTIVE_ID_DATASOURCEMAPPER);
194:            }
195:
196:            public static void activeEditorPerspective(String perspectiveID) {
197:                activePerspective(perspectiveID);
198:            }
199:
200:            private static void activePerspective(String perspectiveID) {
201:                IWorkbenchWindow workbench = PlatformUI.getWorkbench()
202:                        .getActiveWorkbenchWindow();
203:
204:                IPerspectiveRegistry registry = PlatformUI.getWorkbench()
205:                        .getPerspectiveRegistry();
206:
207:                IPerspectiveDescriptor perspectiveDesc = registry
208:                        .findPerspectiveWithId(perspectiveID);
209:
210:                if (workbench != null) {
211:                    IWorkbenchPage activePage = workbench.getActivePage();
212:                    if (activePage != null) {
213:                        IPerspectiveDescriptor currentPerspective = activePage
214:                                .getPerspective();
215:
216:                        if (currentPerspective != null
217:                                && (currentPerspective.getId()
218:                                        .equals(perspectiveID)))
219:                            return;
220:                        try {
221:                            activePage.setPerspective(perspectiveDesc);
222:                        } catch (Exception e) {
223:                            e.printStackTrace();
224:                        }
225:
226:                    }
227:                    //  if (!confirmPerspectiveSwitch(workbench, perspectiveDesc)) {
228:                    //      return;
229:                    //  }
230:                }
231:                //replaceCurrentPerspective(perspectiveDesc);	
232:            }
233:
234:            /*	private static void replaceCurrentPerspective(IPerspectiveDescriptor persp) {
235:             IWorkbenchWindow window = PlatformUI.getWorkbench()
236:             .getActiveWorkbenchWindow();
237:             if (window == null) {
238:             return;
239:             }
240:             IWorkbenchPage page = window.getActivePage();
241:             if (page == null) {
242:             return;
243:             }
244:             page.setPerspective(persp);
245:             }
246:            
247:             private static boolean confirmPerspectiveSwitch(IWorkbenchWindow window,
248:             IPerspectiveDescriptor finalPersp) {
249:             IPreferenceStore store = ComponentFlowEditorDiagramEditorPlugin.getInstance()
250:             .getPreferenceStore();
251:            
252:             String desc = finalPersp.getDescription();
253:             final String message = "Drawing a component flow diagram is typically associated with the Component Flow Editor perspective.  Do you want to open this perspective now?";
254:            
255:             boolean result = MessageDialog
256:             .openQuestion(window.getShell(),
257:             "Open Associated Perspective?", message);
258:             return result;
259:             }*/
260:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.