Source Code Cross Referenced for CompLibManagerPanel.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » complib » ui » 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 » visualweb.api.designer » org.netbeans.modules.visualweb.complib.ui 
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:         * CompLibManagerPanel.java
043:         *
044:         * Created on April 21, 2005, 8:35 AM
045:         */
046:
047:        package org.netbeans.modules.visualweb.complib.ui;
048:
049:        import java.awt.Component;
050:        import java.awt.Dialog;
051:        import java.awt.GridBagConstraints;
052:        import java.awt.GridBagLayout;
053:        import java.text.MessageFormat;
054:        import java.util.ArrayList;
055:        import java.util.MissingResourceException;
056:
057:        import javax.swing.ImageIcon;
058:        import javax.swing.JButton;
059:        import javax.swing.JScrollBar;
060:        import javax.swing.JTree;
061:        import javax.swing.tree.DefaultMutableTreeNode;
062:        import javax.swing.tree.DefaultTreeCellRenderer;
063:        import javax.swing.tree.DefaultTreeModel;
064:        import javax.swing.tree.TreeNode;
065:        import javax.swing.tree.TreePath;
066:        import javax.swing.tree.TreeSelectionModel;
067:
068:        import org.openide.DialogDescriptor;
069:        import org.openide.DialogDisplayer;
070:        import org.openide.NotifyDescriptor;
071:        import org.openide.util.HelpCtx;
072:        import org.openide.util.NbBundle;
073:
074:        import org.netbeans.modules.visualweb.complib.BuiltInComplib;
075:        import org.netbeans.modules.visualweb.complib.Complib;
076:        import org.netbeans.modules.visualweb.complib.ComplibServiceProvider;
077:        import org.netbeans.modules.visualweb.complib.ExtensionComplib;
078:        import org.netbeans.modules.visualweb.complib.IdeUtil;
079:
080:        /**
081:         *
082:         * @author jhoff
083:         * @author Edwin Goei
084:         */
085:        public class CompLibManagerPanel extends javax.swing.JPanel {
086:
087:            private static final ChildUserObject DESIGN_TIME_UO = new ChildUserObject(
088:                    "manager.designTimeNode");
089:
090:            private static final ChildUserObject RUNTIME_UO = new ChildUserObject(
091:                    "manager.runtimeNode");
092:
093:            private static final ChildUserObject JAVADOC_UO = new ChildUserObject(
094:                    "manager.javadocNode");
095:
096:            private static final ChildUserObject SOURCE_UO = new ChildUserObject(
097:                    "manager.sourceNode");
098:
099:            private static final ChildUserObject WEB_RESOURCES_UO = new ChildUserObject(
100:                    "manager.webResourcesNode");
101:
102:            private static final ChildUserObject HELP_UO = new ChildUserObject(
103:                    "manager.helpNode");
104:
105:            private static final ComplibServiceProvider csp = ComplibServiceProvider
106:                    .getInstance();
107:
108:            /**
109:             * User object for main complib node that returns a localized string
110:             *
111:             * @author Edwin Goei
112:             */
113:            private static class CompLibUserObject {
114:                private Complib compLib;
115:
116:                private CompLibUserObject(Complib compLib) {
117:                    this .compLib = compLib;
118:                }
119:
120:                public Complib getComponentLibrary() {
121:                    return compLib;
122:                }
123:
124:                public String toString() {
125:                    return compLib.getVersionedTitle();
126:                }
127:            }
128:
129:            /**
130:             * User object for child nodes that returns a localized string
131:             *
132:             * @author Edwin Goei
133:             */
134:            private static class ChildUserObject {
135:                private String key;
136:
137:                private ChildUserObject(String key) {
138:                    this .key = key;
139:                }
140:
141:                public String toString() {
142:                    try {
143:                        return NbBundle.getMessage(CompLibManagerPanel.class,
144:                                key);
145:                    } catch (MissingResourceException e) {
146:                        // Fail gracefully
147:                        IdeUtil.logWarning(e);
148:                        return key;
149:                    }
150:                }
151:            }
152:
153:            public static class TreeCellRenderer extends
154:                    DefaultTreeCellRenderer {
155:
156:                private static ImageIcon LIBRARY_ICON = new ImageIcon(
157:                        TreeCellRenderer.class
158:                                .getResource("images/libraries.png"));
159:
160:                private static ImageIcon HELP_ICON = new ImageIcon(
161:                        TreeCellRenderer.class.getResource("images/help.gif"));
162:
163:                private static ImageIcon JAVADOC_ICON = new ImageIcon(
164:                        TreeCellRenderer.class
165:                                .getResource("images/JavaDoc.gif"));
166:
167:                private static ImageIcon DESIGN_TIME_ICON = new ImageIcon(
168:                        TreeCellRenderer.class
169:                                .getResource("images/library.png"));
170:
171:                private static ImageIcon RUNTIME_ICON = new ImageIcon(
172:                        TreeCellRenderer.class
173:                                .getResource("images/library.png"));
174:
175:                private static ImageIcon JAR_ICON = new ImageIcon(
176:                        TreeCellRenderer.class.getResource("images/jar.gif"));
177:
178:                private static ImageIcon WEB_RESOURCES_ICON = new ImageIcon(
179:                        TreeCellRenderer.class
180:                                .getResource("images/library.gif"));
181:
182:                public Component getTreeCellRendererComponent(JTree tree,
183:                        Object value, boolean sel, boolean expanded,
184:                        boolean leaf, int row, boolean hasFocus) {
185:                    // Render selection
186:                    super .getTreeCellRendererComponent(tree, value, sel,
187:                            expanded, leaf, row, hasFocus);
188:
189:                    // By default assume that a top level complib node is selected
190:                    setIcon(LIBRARY_ICON);
191:
192:                    Object userObject = ((DefaultMutableTreeNode) value)
193:                            .getUserObject();
194:                    if (userObject instanceof  ChildUserObject) {
195:                        // Second level node is selected
196:                        if (userObject == DESIGN_TIME_UO) {
197:                            setIcon(DESIGN_TIME_ICON);
198:                        } else if (userObject == RUNTIME_UO) {
199:                            setIcon(RUNTIME_ICON);
200:                        } else if (userObject == JAVADOC_UO) {
201:                            setIcon(JAVADOC_ICON);
202:                        } else if (userObject == SOURCE_UO) {
203:                            setIcon(JAR_ICON);
204:                        } else if (userObject == WEB_RESOURCES_UO) {
205:                            setIcon(WEB_RESOURCES_ICON);
206:                        } else if (userObject == HELP_UO) {
207:                            setIcon(HELP_ICON);
208:                        }
209:                    }
210:
211:                    return this ;
212:                }
213:            }
214:
215:            /**
216:             * Creates a new CompLibManagerPanel form
217:             */
218:            public CompLibManagerPanel() {
219:                initComponents();
220:                compLibDetailPanel.setLayout(new GridBagLayout());
221:                clGBConstraints = new java.awt.GridBagConstraints();
222:                clGBConstraints.fill = GridBagConstraints.BOTH;
223:                clGBConstraints.weightx = 1.0;
224:                clGBConstraints.weighty = 1.0;
225:
226:                treeCompLib.setCellRenderer(new TreeCellRenderer());
227:                treeCompLib.getSelectionModel().setSelectionMode(
228:                        TreeSelectionModel.SINGLE_TREE_SELECTION);
229:
230:                initTreeModel(null);
231:
232:                // Scroll all the way to the left
233:                JScrollBar hBar = complibListScroll.getHorizontalScrollBar();
234:                hBar.setValue(hBar.getMinimum());
235:            }
236:
237:            /**
238:             * Initialize the tree model and also set a selected node if possible.
239:             * 
240:             * @param selectedComplib
241:             *            if not null, select the main complib node to select or if
242:             *            null, try the select the first node if one exists
243:             */
244:            private void initTreeModel(Complib selectedComplib) {
245:                // Create the TreeModel based on current complibs
246:                DefaultMutableTreeNode treeRoot = new DefaultMutableTreeNode(
247:                        "Component Libraries"); // NOI18N
248:                DefaultTreeModel compLibModel = new DefaultTreeModel(treeRoot);
249:                treeCompLib.setModel(compLibModel);
250:
251:                DefaultMutableTreeNode selectedComplibNode = null;
252:                ArrayList<Complib> complibs = csp.getInstalledComplibs();
253:                int i = 0;
254:                for (Complib complib : complibs) {
255:                    // If no selectedComplib specified then select the first one
256:                    if (selectedComplib == null && i == 0) {
257:                        selectedComplib = complib;
258:                    }
259:
260:                    CompLibUserObject cluo = new CompLibUserObject(complib);
261:                    DefaultMutableTreeNode complibNode = new DefaultMutableTreeNode(
262:                            cluo);
263:
264:                    // Children of the main complib node
265:                    DefaultMutableTreeNode designTimeNode = new DefaultMutableTreeNode(
266:                            DESIGN_TIME_UO, false);
267:                    DefaultMutableTreeNode runtimeNode = new DefaultMutableTreeNode(
268:                            RUNTIME_UO, false);
269:                    DefaultMutableTreeNode javadocNode = new DefaultMutableTreeNode(
270:                            JAVADOC_UO, false);
271:                    DefaultMutableTreeNode sourceNode = new DefaultMutableTreeNode(
272:                            SOURCE_UO, false);
273:                    DefaultMutableTreeNode webResourceNode = new DefaultMutableTreeNode(
274:                            WEB_RESOURCES_UO, false);
275:                    DefaultMutableTreeNode helpNode = new DefaultMutableTreeNode(
276:                            HELP_UO, false);
277:                    // TODO Check w/ JeffH for ordering
278:                    complibNode.add(designTimeNode);
279:                    complibNode.add(runtimeNode);
280:                    complibNode.add(javadocNode);
281:                    complibNode.add(sourceNode);
282:                    complibNode.add(webResourceNode);
283:                    complibNode.add(helpNode);
284:
285:                    // Add this complib node to the tree model
286:                    compLibModel.insertNodeInto(complibNode, treeRoot, i++);
287:
288:                    // Expand this node and make it viewable
289:                    TreeNode[] treeNodePath = runtimeNode.getPath();
290:                    treeCompLib.scrollPathToVisible(new TreePath(treeNodePath));
291:
292:                    // Remember the selected complib node
293:                    if (complib.equals(selectedComplib)) {
294:                        selectedComplibNode = complibNode;
295:                    }
296:                }
297:
298:                if (selectedComplibNode != null) {
299:                    treeCompLib.setSelectionPath((new TreePath(
300:                            selectedComplibNode.getPath())));
301:                }
302:            }
303:
304:            /**
305:             * This method is called from within the constructor to initialize the form.
306:             * WARNING: Do NOT modify this code. The content of this method is always
307:             * regenerated by the Form Editor.
308:             */
309:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
310:            private void initComponents() {
311:                java.awt.GridBagConstraints gridBagConstraints;
312:
313:                compLibSplit = new javax.swing.JSplitPane();
314:                compLibDetailPanel = new javax.swing.JPanel();
315:                compLibListPanel = new javax.swing.JPanel();
316:                compLibListLabel = new javax.swing.JLabel();
317:                complibListScroll = new javax.swing.JScrollPane();
318:                treeCompLib = new javax.swing.JTree();
319:                buttonPanel = new javax.swing.JPanel();
320:                btnImport = new javax.swing.JButton();
321:                btnRemove = new javax.swing.JButton();
322:
323:                setLayout(new java.awt.GridBagLayout());
324:
325:                setPreferredSize(new java.awt.Dimension(875, 525));
326:                compLibSplit.setDividerLocation(275);
327:                compLibDetailPanel.setLayout(new java.awt.GridBagLayout());
328:
329:                compLibSplit.setRightComponent(compLibDetailPanel);
330:
331:                compLibListPanel.setLayout(new java.awt.GridBagLayout());
332:
333:                compLibListLabel.setLabelFor(treeCompLib);
334:                org.openide.awt.Mnemonics.setLocalizedText(compLibListLabel,
335:                        org.openide.util.NbBundle.getMessage(
336:                                CompLibManagerPanel.class,
337:                                "manager.componentLibrariesLabel"));
338:                gridBagConstraints = new java.awt.GridBagConstraints();
339:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
340:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
341:                gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
342:                compLibListPanel.add(compLibListLabel, gridBagConstraints);
343:                compLibListLabel
344:                        .getAccessibleContext()
345:                        .setAccessibleDescription(
346:                                org.openide.util.NbBundle
347:                                        .getMessage(CompLibManagerPanel.class,
348:                                                "manager.componentLibrariesLabelA11yDescription"));
349:
350:                treeCompLib.setRootVisible(false);
351:                treeCompLib
352:                        .addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
353:                            public void valueChanged(
354:                                    javax.swing.event.TreeSelectionEvent evt) {
355:                                treeCompLibValueChanged(evt);
356:                            }
357:                        });
358:
359:                complibListScroll.setViewportView(treeCompLib);
360:
361:                gridBagConstraints = new java.awt.GridBagConstraints();
362:                gridBagConstraints.gridx = 0;
363:                gridBagConstraints.gridy = 1;
364:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
365:                gridBagConstraints.weightx = 1.0;
366:                gridBagConstraints.weighty = 1.0;
367:                gridBagConstraints.insets = new java.awt.Insets(0, 10, 10, 10);
368:                compLibListPanel.add(complibListScroll, gridBagConstraints);
369:
370:                buttonPanel.setLayout(new java.awt.GridLayout(1, 0, 5, 0));
371:
372:                org.openide.awt.Mnemonics.setLocalizedText(btnImport,
373:                        org.openide.util.NbBundle.getMessage(
374:                                CompLibManagerPanel.class,
375:                                "manager.ImportButton"));
376:                btnImport
377:                        .addActionListener(new java.awt.event.ActionListener() {
378:                            public void actionPerformed(
379:                                    java.awt.event.ActionEvent evt) {
380:                                btnImportActionPerformed(evt);
381:                            }
382:                        });
383:
384:                buttonPanel.add(btnImport);
385:                btnImport.getAccessibleContext().setAccessibleDescription(
386:                        org.openide.util.NbBundle.getMessage(
387:                                CompLibManagerPanel.class,
388:                                "manager.importButtonA11yDescription"));
389:
390:                org.openide.awt.Mnemonics.setLocalizedText(btnRemove,
391:                        org.openide.util.NbBundle.getMessage(
392:                                CompLibManagerPanel.class,
393:                                "manager.RemoveButton"));
394:                btnRemove
395:                        .addActionListener(new java.awt.event.ActionListener() {
396:                            public void actionPerformed(
397:                                    java.awt.event.ActionEvent evt) {
398:                                btnRemoveActionPerformed(evt);
399:                            }
400:                        });
401:
402:                buttonPanel.add(btnRemove);
403:                btnRemove.getAccessibleContext().setAccessibleDescription(
404:                        org.openide.util.NbBundle.getMessage(
405:                                CompLibManagerPanel.class,
406:                                "manager.RemoveButtonA11YDescription"));
407:
408:                gridBagConstraints = new java.awt.GridBagConstraints();
409:                gridBagConstraints.gridx = 0;
410:                gridBagConstraints.gridy = 2;
411:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
412:                gridBagConstraints.insets = new java.awt.Insets(0, 10, 10, 10);
413:                compLibListPanel.add(buttonPanel, gridBagConstraints);
414:
415:                compLibSplit.setLeftComponent(compLibListPanel);
416:
417:                gridBagConstraints = new java.awt.GridBagConstraints();
418:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
419:                gridBagConstraints.weightx = 1.0;
420:                gridBagConstraints.weighty = 1.0;
421:                add(compLibSplit, gridBagConstraints);
422:
423:            }// </editor-fold>//GEN-END:initComponents
424:
425:            private void btnImportActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnImportActionPerformed
426:                showImportCompLibDialog();
427:            }// GEN-LAST:event_btnImportActionPerformed
428:
429:            private void btnRemoveActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnRemoveActionPerformed
430:                // Find the currently selected complib
431:                Complib compLib;
432:                TreePath selectedPath = treeCompLib.getSelectionPath();
433:                if (selectedPath == null) {
434:                    return;
435:                }
436:                DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectedPath
437:                        .getPathComponent(1);
438:                compLib = getComponentLibraryForNode(node);
439:                if (!(compLib instanceof  ExtensionComplib)) {
440:                    return;
441:                }
442:                ExtensionComplib extCompLib = (ExtensionComplib) compLib;
443:
444:                String inUseProjectNames = csp.getInUseProjectNames(extCompLib);
445:                if (inUseProjectNames == null) {
446:                    // Confirmation dialog
447:                    String message = NbBundle.getMessage(
448:                            CompLibManagerPanel.class,
449:                            "manager.RemoveComplibConfirm");
450:                    NotifyDescriptor nd = new NotifyDescriptor.Confirmation(
451:                            message, NotifyDescriptor.OK_CANCEL_OPTION);
452:                    Object result = DialogDisplayer.getDefault().notify(nd);
453:                    if (NotifyDescriptor.OK_OPTION == result) {
454:                        // Delete the currently selected compLib
455:                        csp.remove(extCompLib);
456:
457:                        // Select the previous node in the tree
458:                        DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node
459:                                .getParent();
460:                        DefaultMutableTreeNode prevChild = (DefaultMutableTreeNode) parent
461:                                .getChildBefore(node);
462:                        if (prevChild == null) {
463:                            // No previous node in tree
464:                            initTreeModel(null);
465:                        } else {
466:                            initTreeModel(getComponentLibraryForNode(prevChild));
467:                        }
468:                    }
469:                } else {
470:                    String msg = NbBundle.getMessage(CompLibManagerPanel.class,
471:                            "manager.RemoveComplibInUse"); // NOI18N
472:                    msg = MessageFormat.format(msg, inUseProjectNames);
473:                    NotifyDescriptor nd = new NotifyDescriptor.Message(msg,
474:                            NotifyDescriptor.WARNING_MESSAGE);
475:                    DialogDisplayer.getDefault().notify(nd);
476:                }
477:            }// GEN-LAST:event_btnRemoveActionPerformed
478:
479:            private void treeCompLibValueChanged(
480:                    javax.swing.event.TreeSelectionEvent evt) {// GEN-FIRST:event_treeCompLibValueChanged
481:
482:                DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeCompLib
483:                        .getLastSelectedPathComponent();
484:
485:                if (node == null) {
486:                    // Nothing was selected, remove the current one
487:                    setDetailPanel(null);
488:                    return;
489:                }
490:
491:                Object userObject = node.getUserObject();
492:                if (userObject instanceof  CompLibUserObject) {
493:                    // Top level complib node is selected
494:                    CompLibUserObject cluo = (CompLibUserObject) userObject;
495:                    updateRemoveButtonState(cluo.getComponentLibrary());
496:                    setDetailPanel(new MainDetailPanel(cluo
497:                            .getComponentLibrary()));
498:                } else {
499:                    // Second level node is selected
500:                    DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node
501:                            .getParent();
502:                    CompLibUserObject cluo = (CompLibUserObject) parent
503:                            .getUserObject();
504:                    Complib compLib = cluo.getComponentLibrary();
505:                    updateRemoveButtonState(compLib);
506:
507:                    String labelKey;
508:                    String descriptionKey;
509:                    String mnemonicKey;
510:                    if (userObject == DESIGN_TIME_UO) {
511:                        labelKey = "manager.DesignTimeLabel";
512:                        descriptionKey = "manager.DesignTimeDescription";
513:                        mnemonicKey = "manager.DesignTimeMnemonic";
514:                        setDetailPanel(new PathDetailPanel(compLib
515:                                .getDesignTimePath(), labelKey, descriptionKey,
516:                                mnemonicKey));
517:                    } else if (userObject == RUNTIME_UO) {
518:                        labelKey = "manager.RuntimeLabel";
519:                        descriptionKey = "manager.RuntimeDescription";
520:                        mnemonicKey = "manager.RuntimeMnemonic";
521:                        setDetailPanel(new PathDetailPanel(compLib
522:                                .getRuntimePath(), labelKey, descriptionKey,
523:                                mnemonicKey));
524:                    } else if (userObject == JAVADOC_UO) {
525:                        labelKey = "manager.JavadocLabel";
526:                        descriptionKey = "manager.JavadocDescription";
527:                        mnemonicKey = "manager.JavadocMnemonic";
528:                        setDetailPanel(new PathDetailPanel(compLib
529:                                .getJavadocPath(), labelKey, descriptionKey,
530:                                mnemonicKey));
531:                    } else if (userObject == SOURCE_UO) {
532:                        labelKey = "manager.SourceLabel";
533:                        descriptionKey = "manager.SourceDescription";
534:                        mnemonicKey = "manager.SourceMnemonic";
535:                        setDetailPanel(new PathDetailPanel(compLib
536:                                .getSourcePath(), labelKey, descriptionKey,
537:                                mnemonicKey));
538:                    } else if (userObject == WEB_RESOURCES_UO) {
539:                        labelKey = "manager.WebResourceLabel";
540:                        descriptionKey = "manager.WebResourceDescription";
541:                        mnemonicKey = "manager.WebResourceMnemonic";
542:                        setDetailPanel(new PathDetailPanel(compLib
543:                                .getWebResourcePath(), labelKey,
544:                                descriptionKey, mnemonicKey));
545:                    } else if (userObject == HELP_UO) {
546:                        setDetailPanel(new HelpSourcesDetailPanel(compLib));
547:                    }
548:                }
549:            }// GEN-LAST:event_treeCompLibValueChanged
550:
551:            private Complib getComponentLibraryForNode(
552:                    DefaultMutableTreeNode node) {
553:                Object userObject = node.getUserObject();
554:                if (userObject instanceof  CompLibUserObject) {
555:                    // Top level complib node is selected
556:                    CompLibUserObject cluo = (CompLibUserObject) userObject;
557:                    return cluo.getComponentLibrary();
558:                } else {
559:                    assert userObject instanceof  ChildUserObject;
560:                    // Second level node is selected
561:                    DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node
562:                            .getParent();
563:                    CompLibUserObject cluo = (CompLibUserObject) parent
564:                            .getUserObject();
565:                    return cluo.getComponentLibrary();
566:                }
567:            }
568:
569:            private synchronized void showImportCompLibDialog() {
570:                new ImportComplibPanel().showDialog(this );
571:            }
572:
573:            synchronized void notifyImportComplete(Complib newCompLib) {
574:                initTreeModel(newCompLib);
575:            }
576:
577:            private void updateRemoveButtonState(Complib compLib) {
578:                btnRemove.setEnabled(!(compLib instanceof  BuiltInComplib));
579:            }
580:
581:            /**
582:             * @param panel
583:             *            null means don't use a panel and just remove the current one
584:             */
585:            private void setDetailPanel(Component panel) {
586:                // First remove all components
587:                compLibDetailPanel.removeAll();
588:                if (panel != null) {
589:                    // Add new panel
590:                    compLibDetailPanel.add(panel, clGBConstraints);
591:                }
592:
593:                /*
594:                 * I'm not sure why a call to repaint() does not work here or where this
595:                 * code came from.
596:                 */
597:                compLibDetailPanel.updateUI();
598:            }
599:
600:            // Variables declaration - do not modify//GEN-BEGIN:variables
601:            private javax.swing.JButton btnImport;
602:            private javax.swing.JButton btnRemove;
603:            private javax.swing.JPanel buttonPanel;
604:            private javax.swing.JPanel compLibDetailPanel;
605:            private javax.swing.JLabel compLibListLabel;
606:            private javax.swing.JPanel compLibListPanel;
607:            private javax.swing.JSplitPane compLibSplit;
608:            private javax.swing.JScrollPane complibListScroll;
609:            private javax.swing.JTree treeCompLib;
610:            // End of variables declaration//GEN-END:variables
611:            private GridBagConstraints clGBConstraints;
612:
613:            /**
614:             * This method is the main entry point for this dialog panel
615:             * 
616:             * @param currentCategoryName
617:             *            to be used in dialog
618:             */
619:            public void showDialog() {
620:                String title = NbBundle.getMessage(CompLibManagerPanel.class,
621:                        "manager.dialogTitle"); // NOI18N
622:                HelpCtx helpCtx = new HelpCtx(
623:                        "projrave_ui_elements_dialogs_component_library_manager"); // NOI18N
624:                JButton closeButton = new JButton();
625:                closeButton.setMnemonic(org.openide.util.NbBundle.getMessage(
626:                        CompLibManagerPanel.class,
627:                        "manager.closeButtonMnemonic").charAt(0));
628:                String msg = org.openide.util.NbBundle.getMessage(
629:                        CompLibManagerPanel.class, "manager.closeButtonLabel");
630:                closeButton.setText(msg);
631:                closeButton.getAccessibleContext()
632:                        .setAccessibleDescription(msg);
633:
634:                Object[] options = new Object[] { closeButton };
635:                DialogDescriptor descriptor = new DialogDescriptor(this , title,
636:                        true, options, closeButton,
637:                        DialogDescriptor.DEFAULT_ALIGN, helpCtx, null);
638:                Dialog dialog = DialogDisplayer.getDefault().createDialog(
639:                        descriptor);
640:                dialog.getAccessibleContext().setAccessibleName(
641:                        NbBundle.getMessage(CompLibManagerPanel.class,
642:                                "manager.dialogA11yName"));
643:                dialog.getAccessibleContext().setAccessibleDescription(
644:                        NbBundle.getMessage(CompLibManagerPanel.class,
645:                                "manager.dialogA11yDescription"));
646:                descriptor.setValid(true);
647:
648:                dialog.setVisible(true);
649:            }
650:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.