This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 70759
Collapse All | Expand All

(-)core/navigator/arch.xml (-1 / +1 lines)
Lines 125-131 Link Here
125
      <h4>Writing NavigatorPanel implementation</h4>
125
      <h4>Writing NavigatorPanel implementation</h4>
126
        <p>Implementing <a href="@TOP@/org/netbeans/spi/navigator/NavigatorPanel.html">NavigatorPanel</a>
126
        <p>Implementing <a href="@TOP@/org/netbeans/spi/navigator/NavigatorPanel.html">NavigatorPanel</a>
127
         interface is easy, you can copy from template basic implementation 
127
         interface is easy, you can copy from template basic implementation 
128
        <a href="@TOP@/org/netbeans/spi/navigator/doc-files/BasicNavPanelImpl.java">BasicNavPanelImpl.java</a>.</p>
128
        <a href="@TOP@/org/netbeans/spi/navigator/doc-files/BasicNavPanelImpl_java">BasicNavPanelImpl.java</a>.</p>
129
        
129
        
130
        Advices on important part of panel implementation:
130
        Advices on important part of panel implementation:
131
131
(-)core/navigator/src/org/netbeans/spi/navigator/doc-files/BasicNavPanelImpl.java (-104 lines)
Removed Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
import java.util.Collection;
15
import javax.swing.JComponent;
16
import javax.swing.JLabel;
17
import org.netbeans.spi.navigator.NavigatorPanel;
18
import org.openide.util.Lookup;
19
import org.openide.util.LookupEvent;
20
import org.openide.util.LookupListener;
21
22
/**
23
 * Basic dummy implementation of NavigatorPanel interface.
24
 */
25
public class BasicNavPanelImpl implements NavigatorPanel {
26
27
    /** holds UI of this panel */
28
    private JComponent panelUI;
29
    /** template for finding data in given context.
30
     * Object used as example, replace with your own data source, for example JavaDataObject etc */
31
    private static final Lookup.Template MY_DATA = new Lookup.Template(Object.class);
32
    /** current context to work on */
33
    private Lookup.Result curContext;
34
    /** listener to context changes */
35
    private LookupListener contextL;
36
    
37
    /** public no arg constructor needed for system to instantiate provider well */
38
    public BasicNavPanelImpl() {
39
    }
40
41
    public String getDisplayHint() {
42
        return "Basic dummy implementation of NavigatorPanel interface";
43
    }
44
45
    public String getDisplayName() {
46
        return "Dummy View";
47
    }
48
49
    public JComponent getComponent() {
50
        if (panelUI == null) {
51
            panelUI = new JLabel("Dummy label");
52
            // You can override requestFocusInWindow() on the component if desired.
53
        }
54
        return panelUI;
55
    }
56
57
    public void panelActivated(Lookup context) {
58
        // lookup context and listen to result to get notified about context changes
59
        curContext = context.lookup(MY_DATA);
60
        curContext.addLookupListener(getContextListener());
61
        // get actual data and recompute content
62
        Collection data = curContext.allInstances();
63
        setNewContent(data);
64
    }
65
66
    public void panelDeactivated() {
67
        curContext.removeLookupListener(getContextListener());
68
        curContext = null;
69
    }
70
    
71
    public Lookup getLookup () {
72
        // go with default activated Node strategy
73
        return null;
74
    }
75
    
76
    /************* non - public part ************/
77
    
78
    private void setNewContent (Collection newData) {
79
        // put your code here that grabs information you need from given
80
        // collection of data, recompute UI of your panel and show it.
81
        // Note - be sure to compute the content OUTSIDE event dispatch thread,
82
        // just final repainting of UI should be done in event dispatch thread.
83
        // Please use RequestProcessor and Swing.invokeLater to achieve this.
84
    }
85
    
86
    /** Accessor for listener to context */
87
    private LookupListener getContextListener () {
88
        if (contextL == null) {
89
            contextL = new ContextListener();
90
        }
91
        return contextL;
92
    }
93
    
94
    /** Listens to changes of context and triggers proper action */
95
    private class ContextListener implements LookupListener {
96
        
97
        public void resultChanged(LookupEvent ev) {
98
            Collection data = ((Lookup.Result)ev.getSource()).allInstances();
99
            setNewContent(data);
100
        }
101
        
102
    } // end of ContextListener
103
    
104
}
(-)core/navigator/src/org/netbeans/spi/navigator/doc-files/BasicNavPanelImpl_java (+104 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
import java.util.Collection;
15
import javax.swing.JComponent;
16
import javax.swing.JLabel;
17
import org.netbeans.spi.navigator.NavigatorPanel;
18
import org.openide.util.Lookup;
19
import org.openide.util.LookupEvent;
20
import org.openide.util.LookupListener;
21
22
/**
23
 * Basic dummy implementation of NavigatorPanel interface.
24
 */
25
public class BasicNavPanelImpl implements NavigatorPanel {
26
27
    /** holds UI of this panel */
28
    private JComponent panelUI;
29
    /** template for finding data in given context.
30
     * Object used as example, replace with your own data source, for example JavaDataObject etc */
31
    private static final Lookup.Template MY_DATA = new Lookup.Template(Object.class);
32
    /** current context to work on */
33
    private Lookup.Result curContext;
34
    /** listener to context changes */
35
    private LookupListener contextL;
36
    
37
    /** public no arg constructor needed for system to instantiate provider well */
38
    public BasicNavPanelImpl() {
39
    }
40
41
    public String getDisplayHint() {
42
        return "Basic dummy implementation of NavigatorPanel interface";
43
    }
44
45
    public String getDisplayName() {
46
        return "Dummy View";
47
    }
48
49
    public JComponent getComponent() {
50
        if (panelUI == null) {
51
            panelUI = new JLabel("Dummy label");
52
            // You can override requestFocusInWindow() on the component if desired.
53
        }
54
        return panelUI;
55
    }
56
57
    public void panelActivated(Lookup context) {
58
        // lookup context and listen to result to get notified about context changes
59
        curContext = context.lookup(MY_DATA);
60
        curContext.addLookupListener(getContextListener());
61
        // get actual data and recompute content
62
        Collection data = curContext.allInstances();
63
        setNewContent(data);
64
    }
65
66
    public void panelDeactivated() {
67
        curContext.removeLookupListener(getContextListener());
68
        curContext = null;
69
    }
70
    
71
    public Lookup getLookup () {
72
        // go with default activated Node strategy
73
        return null;
74
    }
75
    
76
    /************* non - public part ************/
77
    
78
    private void setNewContent (Collection newData) {
79
        // put your code here that grabs information you need from given
80
        // collection of data, recompute UI of your panel and show it.
81
        // Note - be sure to compute the content OUTSIDE event dispatch thread,
82
        // just final repainting of UI should be done in event dispatch thread.
83
        // Please use RequestProcessor and Swing.invokeLater to achieve this.
84
    }
85
    
86
    /** Accessor for listener to context */
87
    private LookupListener getContextListener () {
88
        if (contextL == null) {
89
            contextL = new ContextListener();
90
        }
91
        return contextL;
92
    }
93
    
94
    /** Listens to changes of context and triggers proper action */
95
    private class ContextListener implements LookupListener {
96
        
97
        public void resultChanged(LookupEvent ev) {
98
            Collection data = ((Lookup.Result)ev.getSource()).allInstances();
99
            setNewContent(data);
100
        }
101
        
102
    } // end of ContextListener
103
    
104
}
(-)core/startup/src/org/netbeans/core/startup/NbInstaller.java (-2 / +3 lines)
Lines 1426-1433 Link Here
1426
                            String clazz = name.substring(0, name.length() - 6).replace('/', '.'); // NOI18N
1426
                            String clazz = name.substring(0, name.length() - 6).replace('/', '.'); // NOI18N
1427
                            try {
1427
                            try {
1428
                                Class.forName(clazz, false, m.getClassLoader());
1428
                                Class.forName(clazz, false, m.getClassLoader());
1429
                            } catch (ClassNotFoundException cnfe) {
1429
                            } catch (ClassNotFoundException cnfe) { // e.g. "Will not load classes from default package" from ProxyClassLoader
1430
                                Util.err.notify(cnfe); // huh?
1430
                                Util.err.annotate(cnfe, ErrorManager.UNKNOWN, "From " + clazz + " in " + m.getCodeNameBase() + " with effective classpath " + getEffectiveClasspath(m), null, null, null); // NOI18N
1431
                                Util.err.notify(ErrorManager.INFORMATIONAL, cnfe);
1431
                            } catch (LinkageError le) {
1432
                            } catch (LinkageError le) {
1432
                                Util.err.annotate(le, ErrorManager.UNKNOWN, "From " + clazz + " in " + m.getCodeNameBase() + " with effective classpath " + getEffectiveClasspath(m), null, null, null); // NOI18N
1433
                                Util.err.annotate(le, ErrorManager.UNKNOWN, "From " + clazz + " in " + m.getCodeNameBase() + " with effective classpath " + getEffectiveClasspath(m), null, null, null); // NOI18N
1433
                                Util.err.notify(ErrorManager.INFORMATIONAL, le);
1434
                                Util.err.notify(ErrorManager.INFORMATIONAL, le);

Return to bug 70759