Source Code Cross Referenced for ProductProjectManager.java in  » IDE-Netbeans » uml » org » netbeans » modules » uml » integration » ide » 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 » IDE Netbeans » uml » org.netbeans.modules.uml.integration.ide 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        /*
043:         * File         : ProductProjectManager.java
044:         * Version      : 1.2
045:         * Description  : Tracks and manages open Describe projects
046:         * Author       : Ashish
047:         */
048:        package org.netbeans.modules.uml.integration.ide;
049:
050:        import java.io.File;
051:
052:        import javax.swing.JFileChooser;
053:        import javax.swing.filechooser.FileFilter;
054:
055:        import org.netbeans.modules.uml.core.IApplication;
056:        import org.netbeans.modules.uml.core.coreapplication.IPreferenceManager2;
057:        import org.netbeans.modules.uml.core.metamodel.core.foundation.INamespace;
058:        import org.netbeans.modules.uml.core.metamodel.diagrams.IDiagram;
059:        import org.netbeans.modules.uml.core.metamodel.diagrams.IDiagramKind;
060:        import org.netbeans.modules.uml.core.metamodel.structure.IProject;
061:        import org.netbeans.modules.uml.core.support.umlsupport.FileSysManip;
062:        import org.netbeans.modules.uml.core.workspacemanagement.IWSProject;
063:        import org.netbeans.modules.uml.core.workspacemanagement.IWorkspace;
064:        import org.netbeans.modules.uml.ui.controls.newdialog.INewDialog;
065:        import org.netbeans.modules.uml.ui.controls.newdialog.INewDialogDiagramDetails;
066:        import org.netbeans.modules.uml.ui.controls.newdialog.INewDialogProjectDetails;
067:        import org.netbeans.modules.uml.ui.controls.newdialog.INewDialogTabDetails;
068:        import org.netbeans.modules.uml.ui.controls.newdialog.NewDialog;
069:        import org.netbeans.modules.uml.ui.controls.newdialog.NewDialogDiagramDetails;
070:        import org.netbeans.modules.uml.ui.controls.newdialog.NewDialogProjectDetails;
071:        import org.netbeans.modules.uml.ui.controls.projecttree.IProjectTreeControl;
072:        import org.netbeans.modules.uml.ui.support.ProductHelper;
073:        import org.netbeans.modules.uml.ui.support.applicationmanager.IProductDiagramManager;
074:        import org.netbeans.modules.uml.ui.support.applicationmanager.IProductProjectManager;
075:        import org.netbeans.modules.uml.ui.support.projecttreesupport.ITreeItem;
076:        import org.netbeans.modules.uml.ui.swing.projecttree.DesignCenterSwingModel;
077:        import org.netbeans.modules.uml.ui.swing.projecttree.ISwingProjectTreeModel;
078:        import org.netbeans.modules.uml.ui.swing.projecttree.JProjectTree;
079:
080:        /**
081:         *  Tracks and manages open Describe projects.
082:         *
083:         * Revision History
084:         * No.  Date        Who         What
085:         * ---  ----        ---         ----
086:         *   1  2002-05-03  Sumitabh    Added new methods displayInsertProjectDialog()
087:         *                              and displayNewProjectDialog() introduced in
088:         *                              Wolverine build 64.
089:         * @author  Ashish
090:         * @version 1.0
091:         */
092:        public class ProductProjectManager implements  IProductProjectManager {
093:            public void setCurrentProject(IProject proj) {
094:                mCurrentProject = proj;
095:            }
096:
097:            public IProject getCurrentProject() {
098:                return mCurrentProject;
099:            }
100:
101:            /**
102:             * This method asks the user for new project details and create a new project.
103:             */
104:            public void displayNewProjectDialog() {
105:                INewDialogProjectDetails details = new NewDialogProjectDetails();
106:                details.setAllowFromRESelection(false);
107:                details.setMode("Analysis");
108:                displayNewProjectDialog(details);
109:            }
110:
111:            public void displayInsertProjectDialog(IWorkspace wks) {
112:                JFileChooser chooser = new JFileChooser();
113:
114:                chooser.setAcceptAllFileFilterUsed(false);
115:                chooser.setMultiSelectionEnabled(false);
116:                chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
117:                chooser.addChoosableFileFilter(new FileFilter() {
118:                    public boolean accept(File file) {
119:                        return file.isDirectory()
120:                                || file
121:                                        .toString()
122:                                        .toLowerCase()
123:                                        .endsWith(
124:                                                UMLSupport
125:                                                        .getString("Dialog.InsertProject.ProjectExtension"));
126:                    }
127:
128:                    public String getDescription() {
129:                        return UMLSupport
130:                                .getString("Dialog.InsertProject.FileFilter.Description");
131:                    }
132:                });
133:
134:                if (chooser.showOpenDialog(chooser) == JFileChooser.APPROVE_OPTION) {
135:                    File file = chooser.getSelectedFile();
136:                    if (file != null) {
137:                        IApplication pApp = UMLSupport.getUMLSupport()
138:                                .getApplication();
139:                        if (pApp != null) {
140:                            IProject proj = pApp.openProject(file
141:                                    .getAbsolutePath());
142:                            if (proj != null) {
143:                                insertProjectIntoWorkspace(wks, proj);
144:                            }
145:                        }
146:                    }
147:                }
148:            }
149:
150:            /**
151:             * Inserts the argument project into the passed in IWorkspace
152:             */
153:            private boolean insertProjectIntoWorkspace(IWorkspace pWorkspace,
154:                    IProject pProject) {
155:                boolean inserted = false;
156:                IApplication pApp = UMLSupport.getUMLSupport().getApplication();
157:                if (pApp != null) {
158:                    IWSProject appProj = pApp.importProject(pWorkspace,
159:                            pProject);
160:                    inserted = true;
161:
162:                    IProjectTreeControl control = ProductHelper
163:                            .getDesignCenterTree();
164:                    if (control != null && control instanceof  JProjectTree) {
165:                        JProjectTree tree = (JProjectTree) control;
166:                        ISwingProjectTreeModel model = tree.getProjectModel();
167:                        if (model != null) {
168:                            IWorkspace space = model.getWorkspace();
169:                            if (space != null && space.equals(pWorkspace)) {
170:                                //we need to refresh the design center project tree for the inserted project
171:                                //as the tree never gets notified for the added project
172:                                if (model instanceof  DesignCenterSwingModel) {
173:                                    ITreeItem parent = ((DesignCenterSwingModel) model)
174:                                            .getWorkspaceNode(pWorkspace, null);
175:                                    ((DesignCenterSwingModel) model)
176:                                            .addProject(pProject.getName(),
177:                                                    parent, pProject);
178:                                }
179:                            }
180:                        }
181:                    }
182:
183:                    pWorkspace.setIsDirty(true);
184:                }
185:                return inserted;
186:            }
187:
188:            private IProject mCurrentProject;
189:
190:            /**
191:             * Brings up the new project dialog
192:             */
193:            public void displayNewProjectDialog(
194:                    INewDialogProjectDetails pDetails) {
195:                IProject retProj = null;
196:                if (pDetails == null) {
197:                    pDetails = new NewDialogProjectDetails();
198:                    pDetails.setAllowFromRESelection(false);
199:                }
200:
201:                INewDialog pDialog = new NewDialog();
202:                if (pDialog != null) {
203:                    // Allow only the project tab
204:                    pDialog.addTab(NewDialogTabKind.NWIK_NEW_PROJECT);
205:                    if (pDetails != null) {
206:                        pDialog.specifyDefaults(pDetails);
207:                    }
208:
209:                    // Now display the dialog
210:                    INewDialogTabDetails pResults = pDialog.display(null);
211:
212:                    if (pResults != null
213:                            && pResults instanceof  INewDialogProjectDetails) {
214:                        // User hit ok, should be project results
215:                        INewDialogProjectDetails projDetails = (INewDialogProjectDetails) pResults;
216:
217:                        retProj = newProject(projDetails);
218:                        if (retProj != null) {
219:                            // This call will ask the user to create a diagram if a preference is set.
220:                            doPostNewProject(retProj, pDetails);
221:                        }
222:                    }
223:                }
224:            }
225:
226:            /**
227:             * Tells the IADApplication to create a new project.
228:             *
229:             * @param pFilename [in] The details about the new project
230:             * @param pOpenedProject [out] The new project that was created.
231:             */
232:            public IProject newProject(INewDialogProjectDetails pDetails) {
233:                IProject proj = null;
234:                if (pDetails != null) {
235:                    String location = pDetails.getLocation();
236:                    String name = pDetails.getName();
237:
238:                    String fullFilename = FileSysManip.createFullPath(location,
239:                            name, ".etd");
240:
241:                    //we do not need to do it here - as the new dialog display would have already created a project.
242:                    //INewDialogResultProcessor processor = new NewDialogResultProcessor();
243:                    //processor.handleResult(pDetails);
244:
245:                    IApplication pApp = UMLSupport.getUMLSupport()
246:                            .getApplication();
247:
248:                    if (pApp != null) {
249:                        proj = pApp.getProjectByFileName(fullFilename);
250:                    }
251:                }
252:                return proj;
253:            }
254:
255:            /**
256:             * After a project we need to question the user about creating a new diagram.  The 
257:             * INewDialogProjectDetails can specify that whether or not to question the user.
258:             *
259:             * @param pProject [in] The project that was just created.
260:             * @param pDetails [in] The new project details.
261:             */
262:            public void doPostNewProject(IProject pProject,
263:                    INewDialogProjectDetails pDetails) {
264:                if (pProject != null) {
265:                    boolean promptUser = true;
266:                    if (pDetails != null) {
267:                        promptUser = pDetails.getPromptToCreateDiagram();
268:                    }
269:
270:                    if (promptUser) {
271:
272:                        // Query the user for a new diagram
273:                        INamespace space = (INamespace) pProject;
274:                        queryUserForNewDiagram(space, IDiagramKind.DK_UNKNOWN,
275:                                IDiagramKind.DK_ALL);
276:
277:                    }
278:                }
279:            }
280:
281:            public IDiagram queryUserForNewDiagram(INamespace pNamespace,
282:                    int diaKind, int availableKinds) {
283:                IDiagram retDia = null;
284:                INewDialog diag = new NewDialog();
285:                diag.addTab(NewDialogTabKind.NWIK_NEW_DIAGRAM);
286:                INewDialogDiagramDetails details = new NewDialogDiagramDetails();
287:                details.setNamespace(pNamespace);
288:                details.setDiagramKind(diaKind);
289:                details.setAvailableDiagramKinds(availableKinds);
290:
291:                diag.specifyDefaults(details);
292:
293:                INewDialogTabDetails results = diag.display(null);
294:
295:                if (results != null
296:                        && results instanceof  INewDialogDiagramDetails) {
297:                    INewDialogDiagramDetails elementResults = (INewDialogDiagramDetails) results;
298:                    if (elementResults != null) {
299:                        INamespace space = elementResults.getNamespace();
300:                        String name = elementResults.getName();
301:                        int kind = elementResults.getDiagramKind();
302:                        if (name != null && name.length() > 0) {
303:                            retDia = newDiagram(space, kind, name);
304:                        }
305:                    }
306:                }
307:                return retDia;
308:            }
309:
310:            public IDiagram newDiagram(INamespace space, int diaKind,
311:                    String name) {
312:                IDiagram retDia = null;
313:                IProductDiagramManager diaMan = ProductHelper
314:                        .getProductDiagramManager();
315:                if (diaMan != null) {
316:                    if (retDia == null) {
317:                        if (space != null) {
318:                            retDia = diaMan.createDiagram(diaKind, space, name,
319:                                    null);
320:                        } else {
321:                            IProductProjectManager mgr = ProductHelper
322:                                    .getProductProjectManager();
323:                            if (mgr != null) {
324:                                IProject proj = mgr.getCurrentProject();
325:                                if (proj != null) {
326:                                    retDia = diaMan.createDiagram(diaKind,
327:                                            proj, name, null);
328:                                }
329:                            }
330:                        }
331:                    }
332:                }
333:                return retDia;
334:            }
335:
336:            public java.util.ArrayList<IProject> getOpenProjects() {
337:                return null;
338:            }
339:
340:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.