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 206954
Collapse All | Expand All

(-)a/apisupport.refactoring/src/org/netbeans/modules/apisupport/hints/NavigatorHinter.java (+97 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.apisupport.hints;
44
45
import com.sun.source.tree.ModifiersTree;
46
import java.util.LinkedHashMap;
47
import java.util.Map;
48
import java.util.concurrent.Callable;
49
import javax.lang.model.element.Element;
50
import org.netbeans.api.java.source.GeneratorUtilities;
51
import org.netbeans.api.java.source.WorkingCopy;
52
import static org.netbeans.modules.apisupport.hints.Bundle.*;
53
import org.openide.DialogDisplayer;
54
import org.openide.NotifyDescriptor;
55
import org.openide.filesystems.FileObject;
56
import org.openide.util.NbBundle.Messages;
57
import org.openide.util.lookup.ServiceProvider;
58
59
@ServiceProvider(service=Hinter.class)
60
public class NavigatorHinter implements Hinter {
61
62
    private static final String PANELS_FOLDER = "Navigator/Panels/";
63
    private static final String REGISTRATION_BINARY = "org.netbeans.spi.navigator.NavigatorPanel$Registration";
64
65
    @Messages("NavigatorHinter.missing_dep=You must be using org.netbeans.spi.navigator 1.22+ before using this fix.")
66
    @Override public void process(final Context ctx) throws Exception {
67
        final FileObject file = ctx.file();
68
        if (!file.getPath().startsWith(PANELS_FOLDER)) {
69
            return;
70
        }
71
        final Object instanceCreate = ctx.instanceAttribute(file);
72
        if (instanceCreate != null) {
73
            ctx.addStandardAnnotationHint(new Callable<Void>() {
74
                public @Override Void call() throws Exception {
75
                    if (!ctx.canAccess(REGISTRATION_BINARY)) {
76
                        DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(NavigatorHinter_missing_dep(), NotifyDescriptor.WARNING_MESSAGE));
77
                        return null;
78
                    }
79
                    ctx.findAndModifyDeclaration(instanceCreate, new Context.ModifyDeclarationTask() {
80
                        @Override public void run(WorkingCopy wc, Element declaration, ModifiersTree modifiers) throws Exception {
81
                            Map<String,Object> params = new LinkedHashMap<String,Object>();
82
                            params.put("mimeType", file.getParent().getPath().substring(PANELS_FOLDER.length()));
83
                            params.put("position", file.getAttribute("position"));
84
                            params.put("displayName", "#TODO");
85
                            String canon = REGISTRATION_BINARY.replace('$', '.');
86
                            ModifiersTree nue = ctx.addAnnotation(wc, modifiers, canon, canon + "s", params);
87
                            ctx.delete(file);
88
                            wc.rewrite(modifiers, GeneratorUtilities.get(wc).importFQNs(nue));
89
                        }
90
                    });
91
                    return null;
92
                }
93
            });
94
        }
95
    }
96
97
}
(-)a/beans/nbproject/project.xml (-1 / +1 lines)
Lines 194-200 Link Here
194
                    <compile-dependency/>
194
                    <compile-dependency/>
195
                    <run-dependency>
195
                    <run-dependency>
196
                        <release-version>1</release-version>
196
                        <release-version>1</release-version>
197
                        <specification-version>1.5</specification-version>
197
                        <specification-version>1.22</specification-version>
198
                    </run-dependency>
198
                    </run-dependency>
199
                </dependency>
199
                </dependency>
200
                <dependency>
200
                <dependency>
(-)a/beans/src/org/netbeans/modules/beans/BeanPanel.java (+1 lines)
Lines 30-35 Link Here
30
 *
30
 *
31
 * @author Tomas Zezula
31
 * @author Tomas Zezula
32
 */
32
 */
33
@NavigatorPanel.Registration(mimeType="text/x-java", position=500, displayName="#LBL_BeanPatterns")
33
public class BeanPanel implements NavigatorPanel {
34
public class BeanPanel implements NavigatorPanel {
34
35
35
    private BeanPanelUI component;
36
    private BeanPanelUI component;
(-)a/beans/src/org/netbeans/modules/beans/resources/mf-layer.xml (-12 lines)
Lines 56-73 Link Here
56
            </file>
56
            </file>
57
        </folder>
57
        </folder>
58
    </folder>
58
    </folder>
59
  <folder name="Navigator">
60
        <folder name="Panels">
61
            <folder name="text">
62
                <folder name="x-java">
63
                    <file name="org-netbeans-modules-beans-BeanPanel.instance">
64
                        <attr name="position" intvalue="500"/>
65
                    </file>
66
                </folder>
67
            </folder>
68
        </folder>
69
    </folder>
70
  
71
59
72
    <folder name="org.netbeans.modules.java.codestyle">
60
    <folder name="org.netbeans.modules.java.codestyle">
73
        <file name="AddProperty.freemarker" url="templates/AddProperty.freemarker">
61
        <file name="AddProperty.freemarker" url="templates/AddProperty.freemarker">
(-)a/image/nbproject/project.xml (-9 / +9 lines)
Lines 59-64 Link Here
59
                    </run-dependency>
59
                    </run-dependency>
60
                </dependency>
60
                </dependency>
61
                <dependency>
61
                <dependency>
62
                    <code-name-base>org.netbeans.spi.navigator</code-name-base>
63
                    <build-prerequisite/>
64
                    <compile-dependency/>
65
                    <run-dependency>
66
                        <release-version>1</release-version>
67
                        <specification-version>1.22</specification-version>
68
                    </run-dependency>
69
                </dependency>
70
                <dependency>
62
                    <code-name-base>org.openide.actions</code-name-base>
71
                    <code-name-base>org.openide.actions</code-name-base>
63
                    <build-prerequisite/>
72
                    <build-prerequisite/>
64
                    <compile-dependency/>
73
                    <compile-dependency/>
Lines 138-152 Link Here
138
                        <specification-version>6.2</specification-version>
147
                        <specification-version>6.2</specification-version>
139
                    </run-dependency>
148
                    </run-dependency>
140
                </dependency>
149
                </dependency>
141
                 <dependency>
142
                    <code-name-base>org.netbeans.spi.navigator</code-name-base>
143
                    <build-prerequisite/>
144
                    <compile-dependency/>
145
                    <run-dependency>
146
                        <release-version>1</release-version>
147
                        <specification-version>1.19</specification-version>
148
                    </run-dependency>
149
                </dependency>
150
            </module-dependencies>
150
            </module-dependencies>
151
            <public-packages/>
151
            <public-packages/>
152
        </data>
152
        </data>
(-)a/image/src/org/netbeans/modules/image/Layer.xml (-26 lines)
Lines 161-190 Link Here
161
        </folder>
161
        </folder>
162
    </folder>
162
    </folder>
163
    
163
    
164
    <folder name="Navigator">
165
        <folder name="Panels">
166
            <folder name="image">
167
                <folder name="png">
168
                     <file name="org-netbeans-modules-image-navigation-ImageNavigatorPanel.instance">
169
                        <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.image.navigation.Bundle"/>
170
                    </file>
171
                </folder>
172
                <folder name="jpeg">
173
                     <file name="org-netbeans-modules-image-navigation-ImageNavigatorPanel.instance">
174
                        <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.image.navigation.Bundle"/>
175
                    </file>
176
                </folder>
177
                <folder name="bmp">
178
                     <file name="org-netbeans-modules-image-navigation-ImageNavigatorPanel.instance">
179
                        <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.image.navigation.Bundle"/>
180
                    </file>
181
                </folder>
182
                <folder name="gif">
183
                     <file name="org-netbeans-modules-image-navigation-ImageNavigatorPanel.instance">
184
                        <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.image.navigation.Bundle"/>
185
                    </file>
186
                </folder>
187
            </folder>
188
        </folder>
189
    </folder>
190
</filesystem>
164
</filesystem>
(-)a/image/src/org/netbeans/modules/image/navigation/ImageNavigatorPanel.java (+6 lines)
Lines 60-65 Link Here
60
 *
60
 *
61
 * @author jpeska
61
 * @author jpeska
62
 */
62
 */
63
@NavigatorPanel.Registrations({
64
    @NavigatorPanel.Registration(mimeType="image/png", displayName="#Navigator_DisplayName"),
65
    @NavigatorPanel.Registration(mimeType="image/jpeg", displayName="#Navigator_DisplayName"),
66
    @NavigatorPanel.Registration(mimeType="image/bmp", displayName="#Navigator_DisplayName"),
67
    @NavigatorPanel.Registration(mimeType="image/gif", displayName="#Navigator_DisplayName")
68
})
63
public class ImageNavigatorPanel implements NavigatorPanel {
69
public class ImageNavigatorPanel implements NavigatorPanel {
64
70
65
    /**
71
    /**
(-)a/java.navigation/nbproject/project.xml (+1 lines)
Lines 205-210 Link Here
205
                    <compile-dependency/>
205
                    <compile-dependency/>
206
                    <run-dependency>
206
                    <run-dependency>
207
                        <release-version>1</release-version>
207
                        <release-version>1</release-version>
208
                        <specification-version>1.22</specification-version>
208
                    </run-dependency>
209
                    </run-dependency>
209
                </dependency>
210
                </dependency>
210
                <dependency>
211
                <dependency>
(-)a/java.navigation/src/org/netbeans/modules/java/navigation/ClassMemberPanel.java (+4 lines)
Lines 56-61 Link Here
56
 *
56
 *
57
 * @author Tomas Zezula
57
 * @author Tomas Zezula
58
 */
58
 */
59
@NavigatorPanel.Registrations({
60
    @NavigatorPanel.Registration(mimeType="text/x-java", position=100, displayName="#LBL_members"),
61
    @NavigatorPanel.Registration(mimeType="application/x-class-file", displayName="#LBL_members")
62
})
59
public class ClassMemberPanel implements NavigatorPanel {
63
public class ClassMemberPanel implements NavigatorPanel {
60
64
61
    private ClassMemberPanelUI component;
65
    private ClassMemberPanelUI component;
(-)a/java.navigation/src/org/netbeans/modules/java/navigation/resources/layer.xml (-19 lines)
Lines 46-70 Link Here
46
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
46
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
47
<filesystem>
47
<filesystem>
48
48
49
    <folder name="Navigator">
50
        <folder name="Panels">
51
            <folder name="text">
52
                <folder name="x-java">
53
                    <file name="org-netbeans-modules-java-navigation-ClassMemberPanel.instance">
54
                        <attr name="position" intvalue="100"/>
55
                    </file>
56
                    <!-- file name="org-netbeans-modules-java-navigation-InheritanceTreePanel.instance"/ -->
57
                </folder>
58
            </folder>
59
            <folder name="application">
60
                <folder name="x-class-file">
61
                    <file name="org-netbeans-modules-java-navigation-ClassMemberPanel.instance"/>
62
                    <!-- file name="org-netbeans-modules-java-navigation-InheritanceTreePanel.instance"/ -->
63
                </folder>
64
            </folder>
65
        </folder>
66
    </folder>
67
    
68
    <folder name="Loaders">
49
    <folder name="Loaders">
69
        <folder name="text">
50
        <folder name="text">
70
            <folder name="x-java">
51
            <folder name="x-java">
(-)a/maven.grammar/nbproject/project.xml (-1 / +1 lines)
Lines 207-213 Link Here
207
                    <compile-dependency/>
207
                    <compile-dependency/>
208
                    <run-dependency>
208
                    <run-dependency>
209
                        <release-version>1</release-version>
209
                        <release-version>1</release-version>
210
                        <specification-version>1.7</specification-version>
210
                        <specification-version>1.22</specification-version>
211
                    </run-dependency>
211
                    </run-dependency>
212
                </dependency>
212
                </dependency>
213
                <dependency>
213
                <dependency>
(-)a/maven.grammar/src/org/netbeans/modules/maven/grammar/layer.xml (-6 lines)
Lines 131-142 Link Here
131
        <folder name="Panels">
131
        <folder name="Panels">
132
            <folder name="text">
132
            <folder name="text">
133
                <folder name="x-maven-pom+xml">
133
                <folder name="x-maven-pom+xml">
134
                    <file name="org-netbeans-modules-maven-navigator-POMModelNavigator.instance">
135
                        <attr name="position" intvalue="100"/>
136
                    </file>
137
                    <file name="org-netbeans-modules-maven-navigator-POMInheritanceNavigator.instance">
138
                        <attr name="position" intvalue="200"/>
139
                    </file>
140
                    <file name="org-netbeans-modules-xml-text-navigator-XMLNavigatorPanel.instance">
134
                    <file name="org-netbeans-modules-xml-text-navigator-XMLNavigatorPanel.instance">
141
                        <attr name="position" intvalue="300"/>
135
                        <attr name="position" intvalue="300"/>
142
                    </file>
136
                    </file>
(-)a/maven.grammar/src/org/netbeans/modules/maven/navigator/POMInheritanceNavigator.java (+2 lines)
Lines 44-49 Link Here
44
44
45
import java.util.Collection;
45
import java.util.Collection;
46
import javax.swing.JComponent;
46
import javax.swing.JComponent;
47
import org.netbeans.modules.maven.api.Constants;
47
import org.netbeans.spi.navigator.NavigatorPanel;
48
import org.netbeans.spi.navigator.NavigatorPanel;
48
import org.openide.loaders.DataObject;
49
import org.openide.loaders.DataObject;
49
import org.openide.util.Lookup;
50
import org.openide.util.Lookup;
Lines 54-59 Link Here
54
 *
55
 *
55
 * @author mkleint
56
 * @author mkleint
56
 */
57
 */
58
@NavigatorPanel.Registration(mimeType=Constants.POM_MIME_TYPE, position=200, displayName="#POM_NAME")
57
public class POMInheritanceNavigator implements NavigatorPanel {
59
public class POMInheritanceNavigator implements NavigatorPanel {
58
    private POMInheritancePanel component;
60
    private POMInheritancePanel component;
59
    
61
    
(-)a/maven.grammar/src/org/netbeans/modules/maven/navigator/POMModelNavigator.java (+2 lines)
Lines 44-49 Link Here
44
44
45
import java.util.Collection;
45
import java.util.Collection;
46
import javax.swing.JComponent;
46
import javax.swing.JComponent;
47
import org.netbeans.modules.maven.api.Constants;
47
import org.netbeans.spi.navigator.NavigatorPanel;
48
import org.netbeans.spi.navigator.NavigatorPanel;
48
import org.openide.loaders.DataObject;
49
import org.openide.loaders.DataObject;
49
import org.openide.util.Lookup;
50
import org.openide.util.Lookup;
Lines 55-60 Link Here
55
 *
56
 *
56
 * @author mkleint
57
 * @author mkleint
57
 */
58
 */
59
@NavigatorPanel.Registration(mimeType=Constants.POM_MIME_TYPE, position=100, displayName="#POM_MODEL_NAME")
58
public class POMModelNavigator implements NavigatorPanel {
60
public class POMModelNavigator implements NavigatorPanel {
59
    private POMModelPanel component;
61
    private POMModelPanel component;
60
    
62
    
(-)a/o.apache.tools.ant.module/nbproject/project.xml (-1 / +1 lines)
Lines 109-115 Link Here
109
                    <compile-dependency/>
109
                    <compile-dependency/>
110
                    <run-dependency>
110
                    <run-dependency>
111
                        <release-version>1</release-version>
111
                        <release-version>1</release-version>
112
                        <specification-version>1.0</specification-version>
112
                        <specification-version>1.22</specification-version>
113
                    </run-dependency>
113
                    </run-dependency>
114
                </dependency>
114
                </dependency>
115
                <dependency>
115
                <dependency>
(-)a/o.apache.tools.ant.module/src/org/apache/tools/ant/module/nodes/AntNavigatorPanel.java (+2 lines)
Lines 50-55 Link Here
50
import javax.swing.JComponent;
50
import javax.swing.JComponent;
51
import javax.swing.JPanel;
51
import javax.swing.JPanel;
52
import javax.swing.ListSelectionModel;
52
import javax.swing.ListSelectionModel;
53
import org.apache.tools.ant.module.loader.AntProjectDataObject;
53
import org.netbeans.spi.navigator.NavigatorPanel;
54
import org.netbeans.spi.navigator.NavigatorPanel;
54
import org.openide.explorer.ExplorerManager;
55
import org.openide.explorer.ExplorerManager;
55
import org.openide.explorer.ExplorerUtils;
56
import org.openide.explorer.ExplorerUtils;
Lines 66-71 Link Here
66
 * Displays Ant targets in the Navigator.
67
 * Displays Ant targets in the Navigator.
67
 * @author Jesse Glick
68
 * @author Jesse Glick
68
 */
69
 */
70
@NavigatorPanel.Registration(mimeType=AntProjectDataObject.MIME_TYPE, displayName="#ANP_label")
69
public final class AntNavigatorPanel implements NavigatorPanel {
71
public final class AntNavigatorPanel implements NavigatorPanel {
70
    
72
    
71
    private Lookup.Result<DataObject> selection;
73
    private Lookup.Result<DataObject> selection;
(-)a/o.apache.tools.ant.module/src/org/apache/tools/ant/module/resources/AntModuleLayer.xml (-10 lines)
Lines 185-200 Link Here
185
            </folder>
185
            </folder>
186
        </folder>
186
        </folder>
187
    </folder>
187
    </folder>
188
    
189
    <folder name="Navigator">
190
        <folder name="Panels">
191
            <folder name="text">
192
                <folder name="x-ant+xml">
193
                    <file name="org-apache-tools-ant-module-nodes-AntNavigatorPanel.instance"/>
194
                </folder>
195
            </folder>
196
        </folder>
197
    </folder>
198
188
199
    <folder name="org-apache-tools-ant-module">
189
    <folder name="org-apache-tools-ant-module">
200
        <folder name="target-actions">
190
        <folder name="target-actions">
(-)a/spi.navigator/apichanges.xml (-1 / +19 lines)
Lines 108-114 Link Here
108
    <!-- ACTUAL CHANGES BEGIN HERE: -->
108
    <!-- ACTUAL CHANGES BEGIN HERE: -->
109
109
110
  <changes>
110
  <changes>
111
111
    <change id="NavigatorPanel.Registration">
112
        <api name="navigator_api"/>
113
        <summary>Added <code>@NavigatorPanel.Registration</code></summary>
114
        <version major="1" minor="22"/>
115
        <date year="2012" month="1" day="12"/>
116
        <author login="glick"/>
117
        <compatibility binary="compatible" source="compatible" deprecation="no" deletion="no" addition="yes">
118
            <p>
119
                Upgrade manual layer registrations.
120
            </p>
121
        </compatibility>
122
        <description>
123
            <p>
124
                Added <code>@NavigatorPanel.Registration</code> for ease of use and lazy loading.
125
            </p>
126
        </description>
127
        <class package="org.netbeans.spi.navigator" name="NavigatorPanel"/>
128
        <issue number="206954"/>
129
    </change>
112
    <change id="NavigatorDisplayer">
130
    <change id="NavigatorDisplayer">
113
        <api name="navigator_api"/>
131
        <api name="navigator_api"/>
114
        <summary>Added SPI interface NavigatorDisplayer</summary>
132
        <summary>Added SPI interface NavigatorDisplayer</summary>
(-)a/spi.navigator/arch.xml (-36 / +6 lines)
Lines 78-85 Link Here
78
   <p>
78
   <p>
79
   API allows its clients to plug in their Swing based views easily, which 
79
   API allows its clients to plug in their Swing based views easily, which 
80
   then will be automatically shown in specialized Navigator UI.</p>
80
   then will be automatically shown in specialized Navigator UI.</p>
81
   <p>
82
   Client's views are registered through declarative xml layers approach.</p>
83
   
81
   
84
   <api group="java" name="org.netbeans.spi.navigator.NavigatorPanel" category="stable" type="export" />
82
   <api group="java" name="org.netbeans.spi.navigator.NavigatorPanel" category="stable" type="export" />
85
   <api group="java" name="org.netbeans.spi.navigator.NavigatorHandler" category="devel" type="export" />
83
   <api group="java" name="org.netbeans.spi.navigator.NavigatorHandler" category="devel" type="export" />
Lines 146-158 Link Here
146
    
144
    
147
   <usecase id="basicUsage" name="Basic Usage Steps" >
145
   <usecase id="basicUsage" name="Basic Usage Steps" >
148
      In order to plug in a view into Navigator UI for certain document (data) type,
146
      In order to plug in a view into Navigator UI for certain document (data) type,
149
      module writers need to complete following steps:
147
      module writers need to write a <a href="@TOP@/org/netbeans/spi/navigator/NavigatorPanel.html">NavigatorPanel</a>
150
148
      implementation marked with <code>@Registration</code>.
151
      <ul>
152
        <li><b>Write <a href="@TOP@/org/netbeans/spi/navigator/NavigatorPanel.html">NavigatorPanel</a>
153
         implementation</b></li>
154
        <li><b>Register implementation class in xml layer</b></li>
155
      </ul>
156
149
157
      <h4>Writing NavigatorPanel implementation</h4>
150
      <h4>Writing NavigatorPanel implementation</h4>
158
        <p>Implementing <a href="@TOP@/org/netbeans/spi/navigator/NavigatorPanel.html">NavigatorPanel</a>
151
        <p>Implementing <a href="@TOP@/org/netbeans/spi/navigator/NavigatorPanel.html">NavigatorPanel</a>
Lines 163-172 Link Here
163
156
164
        <ul>
157
        <ul>
165
            <li><b>Instantiation:</b> Your implementation of NavigatorPanel
158
            <li><b>Instantiation:</b> Your implementation of NavigatorPanel
166
            is instantied automatically by the system if you register it in a layer
159
            is instantied automatically by the system if you register it using <code>@Registration</code>.</li>
167
            (described in next step). See detailed 
168
            <a href="@org-openide-util@/org/openide/util/doc-files/api.html#instances">Instantiation rules</a>
169
            to understand which kind of instantiation possibilities are on the plate.<p></p></li>
170
160
171
            <li><b>getComponent</b> method: Simply create and return your UI
161
            <li><b>getComponent</b> method: Simply create and return your UI
172
            representation of your data in Swing's JComponent envelope. Just be sure
162
            representation of your data in Swing's JComponent envelope. Just be sure
Lines 209-215 Link Here
209
            should show some please wait message.<p></p></li>
199
            should show some please wait message.<p></p></li>
210
        </ul>
200
        </ul>
211
201
212
      <h4>Registering NavigatorPanel impl in a layer</h4>
202
      <h4>Registering NavigatorPanel impl</h4>
213
       <p>Declarative registration of your NavigatorPanel impl connects this
203
       <p>Declarative registration of your NavigatorPanel impl connects this
214
        implementation with specific content type, which is type of 
204
        implementation with specific content type, which is type of 
215
        the document, expressed in mime-type syntax, for example 'text/x-java'
205
        the document, expressed in mime-type syntax, for example 'text/x-java'
Lines 217-242 Link Here
217
        your NavigatorPanel impl in UI, when <b>currently activated Node
207
        your NavigatorPanel impl in UI, when <b>currently activated Node
218
        is backed by primary FileObject whose 
208
        is backed by primary FileObject whose 
219
        <a href="@org-openide-filesystems@/org/openide/filesystems/FileObject.html#getMIMEType()">FileObject.getMimeType()</a>
209
        <a href="@org-openide-filesystems@/org/openide/filesystems/FileObject.html#getMIMEType()">FileObject.getMimeType()</a>
220
        equals to content type specified in your layer.</b></p>
210
        equals to content type specified in your registering annotation</b> (see more options below).</p>
221
        <p>  
222
        Writing layer registration itself is easy, you can again copy from template layer
223
         <a href="@TOP@/org/netbeans/spi/navigator/doc-files/basicNavLayer.xml">
224
        Basic Navigator Registration Layer</a>.</p>
225
226
        Additional important info:
227
228
        <ul>
229
            <li>System looks up for navigator providers only in
230
            <b>Navigator/Panels</b> folder, nowhere else.<p></p></li>
231
232
            <li>Content type is specified as cascade of subdirectories under
233
                Navigator/Panels directory. Mime-type syntax is recommended and
234
                handy for specifying content type.<br></br>
235
                It is not compulsory though, so if you need to make up a name
236
                for your content type, just go for it. (more below)<p></p></li>
237
 
238
        </ul>
239
        
240
   </usecase> 
211
   </usecase> 
241
212
242
   <usecase id="lookupHint" name="Advanced Content Registration - Linking to Node's Lookup" >
213
   <usecase id="lookupHint" name="Advanced Content Registration - Linking to Node's Lookup" >
Lines 1372-1379 Link Here
1372
 <answer id="resources-read">
1343
 <answer id="resources-read">
1373
  <p>
1344
  <p>
1374
   Yes Navigator module reads registered view providers from specific folder
1345
   Yes Navigator module reads registered view providers from specific folder
1375
   /navigator/panels.
1346
   Navigator/Panels.
1376
   
1377
  </p>
1347
  </p>
1378
 </answer>
1348
 </answer>
1379
1349
(-)a/spi.navigator/manifest.mf (-1 / +1 lines)
Lines 2-5 Link Here
2
OpenIDE-Module: org.netbeans.spi.navigator/1
2
OpenIDE-Module: org.netbeans.spi.navigator/1
3
OpenIDE-Module-Layer: org/netbeans/modules/navigator/resources/layer.xml
3
OpenIDE-Module-Layer: org/netbeans/modules/navigator/resources/layer.xml
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/navigator/resources/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/navigator/resources/Bundle.properties
5
OpenIDE-Module-Specification-Version: 1.21
5
OpenIDE-Module-Specification-Version: 1.22
(-)a/spi.navigator/src/org/netbeans/modules/navigator/LazyPanel.java (+115 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.navigator;
44
45
import java.util.Map;
46
import javax.swing.JComponent;
47
import org.netbeans.spi.navigator.NavigatorPanel;
48
import org.netbeans.spi.navigator.NavigatorPanelWithUndo;
49
import org.openide.awt.UndoRedo;
50
import org.openide.util.Lookup;
51
52
/**
53
 * Delegating panel for use from {@link NavigatorPanel.Registration}.
54
 */
55
public class LazyPanel implements NavigatorPanelWithUndo {
56
57
    /**
58
     * Referenced from generated layer.
59
     */
60
    public static NavigatorPanel create(Map<String,?> attrs) {
61
        return new LazyPanel(attrs);
62
    }
63
64
    private final Map<String,?> attrs;
65
    private NavigatorPanel delegate;
66
67
    private LazyPanel(Map<String,?> attrs) {
68
        this.attrs = attrs;
69
    }
70
71
    private synchronized NavigatorPanel initialize() {
72
        if (delegate == null) {
73
            delegate = (NavigatorPanel) attrs.get("delegate");
74
        }
75
        return delegate;
76
    }
77
78
    @Override public String getDisplayName() {
79
        if (delegate != null) {
80
            return delegate.getDisplayName();
81
        } else {
82
            return (String) attrs.get("displayName");
83
        }
84
    }
85
86
    @Override public String getDisplayHint() {
87
        if (delegate != null) {
88
            return delegate.getDisplayHint();
89
        } else { // unused currently, so no separate attr
90
            return (String) attrs.get("displayName");
91
        }
92
    }
93
94
    @Override public JComponent getComponent() {
95
        return initialize().getComponent();
96
    }
97
98
    @Override public void panelActivated(Lookup context) {
99
        initialize().panelActivated(context);
100
    }
101
102
    @Override public void panelDeactivated() {
103
        initialize().panelDeactivated();
104
    }
105
106
    @Override public Lookup getLookup() {
107
        return initialize().getLookup();
108
    }
109
110
    @Override public UndoRedo getUndoRedo() {
111
        NavigatorPanel p = initialize();
112
        return p instanceof NavigatorPanelWithUndo ? ((NavigatorPanelWithUndo) p).getUndoRedo() : UndoRedo.NONE;
113
    }
114
115
}
(-)a/spi.navigator/src/org/netbeans/modules/navigator/NavigatorPanelRegistrationProcessor.java (+100 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.navigator;
44
45
import java.util.Arrays;
46
import java.util.HashSet;
47
import java.util.Set;
48
import javax.annotation.processing.Processor;
49
import javax.annotation.processing.RoundEnvironment;
50
import javax.annotation.processing.SupportedSourceVersion;
51
import javax.lang.model.SourceVersion;
52
import javax.lang.model.element.Element;
53
import javax.lang.model.element.TypeElement;
54
import org.netbeans.spi.navigator.NavigatorPanel;
55
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
56
import org.openide.filesystems.annotations.LayerGenerationException;
57
import org.openide.util.lookup.ServiceProvider;
58
59
@ServiceProvider(service=Processor.class)
60
@SupportedSourceVersion(SourceVersion.RELEASE_6)
61
public class NavigatorPanelRegistrationProcessor extends LayerGeneratingProcessor {
62
63
    @Override public Set<String> getSupportedAnnotationTypes() {
64
        return new HashSet<String>(Arrays.asList(NavigatorPanel.Registration.class.getCanonicalName(), NavigatorPanel.Registrations.class.getCanonicalName()));
65
    }
66
67
    @Override protected boolean handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws LayerGenerationException {
68
        if (roundEnv.processingOver()) {
69
            return false;
70
        }
71
        for (Element e : roundEnv.getElementsAnnotatedWith(NavigatorPanel.Registration.class)) {
72
            NavigatorPanel.Registration r = e.getAnnotation(NavigatorPanel.Registration.class);
73
            if (r == null) {
74
                continue;
75
            }
76
            register(e, r);
77
        }
78
        for (Element e : roundEnv.getElementsAnnotatedWith(NavigatorPanel.Registrations.class)) {
79
            NavigatorPanel.Registrations rr = e.getAnnotation(NavigatorPanel.Registrations.class);
80
            if (rr == null) {
81
                continue;
82
            }
83
            for (NavigatorPanel.Registration r : rr.value()) {
84
                register(e, r);
85
            }
86
        }
87
        return true;
88
    }
89
90
    private void register(Element e, NavigatorPanel.Registration r) throws LayerGenerationException {
91
        String suffix = layer(e).instanceFile("dummy", null, null, r, null).getPath().substring("dummy".length()); // e.g. /my-Panel.instance
92
        layer(e).file(ProviderRegistry.PANELS_FOLDER + r.mimeType() + suffix).
93
                methodvalue("instanceCreate", LazyPanel.class.getName(), "create").
94
                instanceAttribute("delegate", NavigatorPanel.class, r, null).
95
                position(r.position()).
96
                bundlevalue("displayName", r.displayName()).
97
                write();
98
    }
99
100
}
(-)a/spi.navigator/src/org/netbeans/modules/navigator/ProviderRegistry.java (-1 / +1 lines)
Lines 60-66 Link Here
60
class ProviderRegistry {
60
class ProviderRegistry {
61
    
61
    
62
    /** folder in layer file system where navigator panels are searched for */
62
    /** folder in layer file system where navigator panels are searched for */
63
    private static final String PANELS_FOLDER = "/Navigator/Panels/"; //NOI18N
63
    static final String PANELS_FOLDER = "Navigator/Panels/"; //NOI18N
64
    /** template for finding all NavigatorPanel instances in lookup */
64
    /** template for finding all NavigatorPanel instances in lookup */
65
    private static final Lookup.Template<NavigatorPanel> NAV_PANEL_TEMPLATE = 
65
    private static final Lookup.Template<NavigatorPanel> NAV_PANEL_TEMPLATE = 
66
            new Lookup.Template<NavigatorPanel>(NavigatorPanel.class);
66
            new Lookup.Template<NavigatorPanel>(NavigatorPanel.class);
(-)a/spi.navigator/src/org/netbeans/spi/navigator/NavigatorPanel.java (-5 / +46 lines)
Lines 44-57 Link Here
44
44
45
package org.netbeans.spi.navigator;
45
package org.netbeans.spi.navigator;
46
46
47
import java.lang.annotation.ElementType;
48
import java.lang.annotation.Retention;
49
import java.lang.annotation.RetentionPolicy;
50
import java.lang.annotation.Target;
47
import javax.swing.JComponent;
51
import javax.swing.JComponent;
48
import org.openide.util.Lookup;
52
import org.openide.util.Lookup;
49
53
50
/** Navigation related view description.
54
/** Navigation related view description.
51
 *
55
 *
52
 * Implementors of this interface, also registered in layer,
56
 * Implementors of this interface will be plugged into Navigator UI.
53
 * will be plugged into Navigator UI.
57
 * @see Registration
54
 *
55
 * @author Dafe Simonek
58
 * @author Dafe Simonek
56
 */
59
 */
57
public interface NavigatorPanel {
60
public interface NavigatorPanel {
Lines 63-69 Link Here
63
    public String getDisplayName ();
66
    public String getDisplayName ();
64
67
65
    /** Description of the view, explaining main purpose of the view.
68
    /** Description of the view, explaining main purpose of the view.
66
     * Will be shown in Navigator UI.
69
     * <em>Currently unused.</em>
67
     * 
70
     * 
68
     * @return String description of the view.
71
     * @return String description of the view.
69
     */
72
     */
Lines 120-125 Link Here
120
     * @return Lookup instance or null
123
     * @return Lookup instance or null
121
     */
124
     */
122
    public Lookup getLookup ();
125
    public Lookup getLookup ();
126
127
    /**
128
     * Registers a navigator panel.
129
     * @since 1.22
130
     */
131
    @Target({ElementType.TYPE, ElementType.METHOD})
132
    @Retention(RetentionPolicy.SOURCE)
133
    @interface Registration {
134
135
        /**
136
         * MIME type to register under.
137
         * For example: {@code text/javascript}
138
         */
139
        String mimeType();
140
141
        /**
142
         * Optional position for this panel among others of the same type.
143
         */
144
        int position() default Integer.MAX_VALUE;
145
146
        /**
147
         * Label for this view to be used in a switcher UI.
148
         * Will be replaced with {@link NavigatorPanel#getDisplayName}
149
         * if and when the panel is actually shown.
150
         * May use {@code pkg.Bundle#key} or {@code #key} syntax.
151
         */
152
        String displayName();
153
154
    }
123
    
155
    
124
    
156
    /**
157
     * Used in case multiple registrations are needed in one place.
158
     * @since 1.22
159
     */
160
    @Target({ElementType.TYPE, ElementType.METHOD})
161
    @Retention(RetentionPolicy.SOURCE)
162
    @interface Registrations {
163
        Registration[] value();
164
    }
165
125
}
166
}
(-)a/spi.navigator/src/org/netbeans/spi/navigator/NavigatorPanelWithUndo.java (-2 / +2 lines)
Lines 52-59 Link Here
52
 * Clients will implement this interface when they need undo and redo support
52
 * Clients will implement this interface when they need undo and redo support
53
 * enabled for their Navigator view/panel.
53
 * enabled for their Navigator view/panel.
54
 *
54
 *
55
 * Implementors of this interface, also registered in layer,
55
 * Implementors of this interface will be plugged into Navigator UI.
56
 * will be plugged into Navigator UI.
56
 * @see NavigatorPanel.Registration
57
 * 
57
 * 
58
 * @since 1.5
58
 * @since 1.5
59
 *
59
 *
(-)a/spi.navigator/src/org/netbeans/spi/navigator/doc-files/BasicNavPanelImpl_java (+1 lines)
Lines 53-58 Link Here
53
/**
53
/**
54
 * Basic dummy implementation of NavigatorPanel interface.
54
 * Basic dummy implementation of NavigatorPanel interface.
55
 */
55
 */
56
@NavigatorPanel.Registration(mimeType="text/plain", displayName="Dummy View")
56
public class BasicNavPanelImpl implements NavigatorPanel {
57
public class BasicNavPanelImpl implements NavigatorPanel {
57
58
58
    /** holds UI of this panel */
59
    /** holds UI of this panel */
(-)a/spi.navigator/src/org/netbeans/spi/navigator/doc-files/basicNavLayer.xml (-62 lines)
Lines 1-62 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
5
Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
6
7
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
8
Other names may be trademarks of their respective owners.
9
10
11
The contents of this file are subject to the terms of either the GNU
12
General Public License Version 2 only ("GPL") or the Common
13
Development and Distribution License("CDDL") (collectively, the
14
"License"). You may not use this file except in compliance with the
15
License. You can obtain a copy of the License at
16
http://www.netbeans.org/cddl-gplv2.html
17
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
18
specific language governing permissions and limitations under the
19
License.  When distributing the software, include this License Header
20
Notice in each file and include the License file at
21
nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
22
particular file as subject to the "Classpath" exception as provided
23
by Oracle in the GPL Version 2 section of the License file that
24
accompanied this code. If applicable, add the following below the
25
License Header, with the fields enclosed by brackets [] replaced by
26
your own identifying information:
27
"Portions Copyrighted [year] [name of copyright owner]"
28
29
Contributor(s):
30
31
The Original Software is NetBeans. The Initial Developer of the Original
32
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
33
Microsystems, Inc. All Rights Reserved.
34
35
If you wish your version of this file to be governed by only the CDDL
36
or only the GPL Version 2, indicate your decision by adding
37
"[Contributor] elects to include this software in this distribution
38
under the [CDDL or GPL Version 2] license." If you do not indicate a
39
single choice of license, a recipient has the option to distribute
40
your version of this file under either the CDDL, the GPL Version 2 or
41
to extend the choice of license to its licensees as provided above.
42
However, if you add GPL Version 2 code and therefore, elected the GPL
43
Version 2 license, then the option applies only if the new code is
44
made subject to such option by the copyright holder.
45
-->
46
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.0//EN" "http://www.netbeans.org/dtds/filesystem-1_0.dtd">
47
48
<filesystem>
49
    <folder name="Navigator">
50
        <folder name="Panels">
51
            <!-- Sudirectory structure below represents content type in mime type syntax.
52
                 Replace with content type your navigator view will show  -->
53
            <folder name="text">
54
                <folder name="plain">
55
                    <!-- NavigatorPanel implementation, replace with your own -->
56
                    <file name="org-netbeans-modules-some_module-SomeTextPlainProvider.instance"/>
57
                </folder>
58
            </folder>
59
        </folder>
60
    </folder>
61
</filesystem>
62

Return to bug 206954