01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08: *
09: * When distributing Covered Code, include this CDDL Header Notice in each file
10: * and include the License file at http://www.netbeans.org/cddl.txt.
11: * If applicable, add the following below the CDDL Header, with the fields
12: * enclosed by brackets [] replaced by your own identifying information:
13: * "Portions Copyrighted [year] [name of copyright owner]"
14: *
15: * The Original Software is NetBeans. The Initial Developer of the Original
16: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17: * Microsystems, Inc. All Rights Reserved.
18: */
19:
20: package org.netbeans.modules.beans;
21:
22: import javax.lang.model.element.Element;
23: import javax.swing.JComponent;
24: import org.netbeans.api.java.source.ElementHandle;
25: import org.netbeans.spi.navigator.NavigatorPanel;
26: import org.openide.util.Lookup;
27: import org.openide.util.NbBundle;
28:
29: /**
30: *
31: * @author Tomas Zezula
32: */
33: public class BeanPanel implements NavigatorPanel {
34:
35: private BeanPanelUI component;
36:
37: private static BeanPanel INSTANCE;
38:
39: public BeanPanel() {
40: this .INSTANCE = this ;
41: }
42:
43: public void panelActivated(Lookup context) {
44: assert context != null;
45: // System.out.println("Panel Activated");
46: BeanNavigatorJavaSourceFactory.getInstance().setLookup(context,
47: getBeanPanelUI());
48: getBeanPanelUI().showWaitNode();
49: }
50:
51: public void panelDeactivated() {
52: getBeanPanelUI().showWaitNode(); // To clear the ui
53: BeanNavigatorJavaSourceFactory.getInstance().setLookup(
54: Lookup.EMPTY, null);
55: }
56:
57: public Lookup getLookup() {
58: return this .getBeanPanelUI().getLookup();
59: }
60:
61: public String getDisplayName() {
62: return NbBundle.getMessage(BeanPanel.class, "LBL_BeanPatterns");
63: }
64:
65: public String getDisplayHint() {
66: return NbBundle
67: .getMessage(BeanPanel.class, "HINT_BeanPatterns");
68: }
69:
70: public JComponent getComponent() {
71: return getBeanPanelUI();
72: }
73:
74: public void selectElement(ElementHandle<Element> eh) {
75: getBeanPanelUI().selectElementNode(eh);
76: }
77:
78: private synchronized BeanPanelUI getBeanPanelUI() {
79: if (this .component == null) {
80: this .component = new BeanPanelUI();
81: }
82: return this .component;
83: }
84:
85: public static BeanPanel getInstance() {
86: return INSTANCE;
87: }
88:
89: }
|