Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
View | Details | Raw Unified | Return to bug 206954 | Differences between
and this patch

Collapse All | Expand All

(-)a/apisupport.refactoring/src/org/netbeans/modules/apisupport/hints/NavigatorHinter.java (+96 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
                            String canon = REGISTRATION_BINARY.replace('$', '.');
85
                            ModifiersTree nue = ctx.addAnnotation(wc, modifiers, canon, canon + "s", params);
86
                            ctx.delete(file);
87
                            wc.rewrite(modifiers, GeneratorUtilities.get(wc).importFQNs(nue));
88
                        }
89
                    });
90
                    return null;
91
                }
92
            });
93
        }
94
    }
95
96
}
(-)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 (+8 lines)
 Lines 48-53    Link Here 
48
import javax.swing.SwingUtilities;
48
import javax.swing.SwingUtilities;
49
import org.netbeans.modules.image.ImageDataObject;
49
import org.netbeans.modules.image.ImageDataObject;
50
import org.netbeans.spi.navigator.NavigatorPanel;
50
import org.netbeans.spi.navigator.NavigatorPanel;
51
import org.netbeans.spi.navigator.NavigatorPanel.Registration;
52
import org.netbeans.spi.navigator.NavigatorPanel.Registrations;
51
import org.openide.filesystems.FileChangeAdapter;
53
import org.openide.filesystems.FileChangeAdapter;
52
import org.openide.filesystems.FileChangeListener;
54
import org.openide.filesystems.FileChangeListener;
53
import org.openide.filesystems.FileEvent;
55
import org.openide.filesystems.FileEvent;
 Lines 60-65    Link Here 
60
 *
62
 *
61
 * @author jpeska
63
 * @author jpeska
62
 */
64
 */
65
@Registrations({
66
    @Registration(mimeType="image/png"),
67
    @Registration(mimeType="image/jpeg"),
68
    @Registration(mimeType="image/bmp"),
69
    @Registration(mimeType="image/gif")
70
})
63
public class ImageNavigatorPanel implements NavigatorPanel {
71
public class ImageNavigatorPanel implements NavigatorPanel {
64
72
65
    /**
73
    /**
(-)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)
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)
58
public class POMModelNavigator implements NavigatorPanel {
60
public class POMModelNavigator implements NavigatorPanel {
59
    private POMModelPanel component;
61
    private POMModelPanel component;
60
    
62
    
(-)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.
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/NavigatorPanelRegistrationProcessor.java (+94 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
        layer(e).instanceFile(ProviderRegistry.PANELS_FOLDER + r.mimeType(), null, NavigatorPanel.class, r, null).position(r.position()).write();
92
    }
93
94
}
(-)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 (-4 / +37 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 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
    }
123
    
147
    
124
    
148
    /**
149
     * Used in case multiple registrations are needed in one place.
150
     * @since 1.22
151
     */
152
    @Target({ElementType.TYPE, ElementType.METHOD})
153
    @Retention(RetentionPolicy.SOURCE)
154
    @interface Registrations {
155
        Registration[] value();
156
    }
157
125
}
158
}
(-)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")
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
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo