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

(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/resources/layer.xml (+1 lines)
Lines 238-243 Link Here
238
            <file name="templateTopComponent.form" url="../wizard/winsys/templateTopComponent.frmx"/>
238
            <file name="templateTopComponent.form" url="../wizard/winsys/templateTopComponent.frmx"/>
239
            <file name="templateTopComponent.java" url="../wizard/winsys/templateTopComponent.javx"/>
239
            <file name="templateTopComponent.java" url="../wizard/winsys/templateTopComponent.javx"/>
240
            <file name="templateTopComponentAnno.java" url="../wizard/winsys/templateTopComponentAnno.javx"/>
240
            <file name="templateTopComponentAnno.java" url="../wizard/winsys/templateTopComponentAnno.javx"/>
241
            <file name="templateTopComponent637.java" url="../wizard/winsys/templateTopComponent637.javx"/>
241
            <file name="templateWstcref.xml" url="../wizard/winsys/templateWstcref.xml"/>
242
            <file name="templateWstcref.xml" url="../wizard/winsys/templateWstcref.xml"/>
242
            <file name="instantiatingIterator.java" url="../wizard/wizard/instantiatingIterator.javx"/>
243
            <file name="instantiatingIterator.java" url="../wizard/wizard/instantiatingIterator.javx"/>
243
            <file name="sampleAction.java" url="../wizard/wizard/sampleAction.javx"/>
244
            <file name="sampleAction.java" url="../wizard/wizard/sampleAction.javx"/>
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/NewTCIterator.java (-9 / +19 lines)
Lines 225-236 Link Here
225
        final String mode = model.getMode();
225
        final String mode = model.getMode();
226
226
227
        boolean actionLessTC;
227
        boolean actionLessTC;
228
        boolean xmlLessTC;
228
        try {
229
        try {
229
            SpecificationVersion current = model.getModuleInfo().getDependencyVersion("org.openide.windows");
230
            SpecificationVersion current = model.getModuleInfo().getDependencyVersion("org.openide.windows");
230
            actionLessTC = current == null || current.compareTo(new SpecificationVersion("6.24")) >= 0; // NOI18N
231
            actionLessTC = current == null || current.compareTo(new SpecificationVersion("6.24")) >= 0; // NOI18N
232
            xmlLessTC = current == null || current.compareTo(new SpecificationVersion("6.37")) >= 0; // NOI18N
231
        } catch (IOException ex) {
233
        } catch (IOException ex) {
232
            Logger.getLogger(NewTCIterator.class.getName()).log(Level.INFO, null, ex);
234
            Logger.getLogger(NewTCIterator.class.getName()).log(Level.INFO, null, ex);
233
            actionLessTC = false;
235
            actionLessTC = false;
236
            xmlLessTC = false;
234
        }
237
        }
235
        boolean propertiesPersistence;
238
        boolean propertiesPersistence;
236
        try {
239
        try {
Lines 295-301 Link Here
295
        final String tcName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName,
298
        final String tcName = getRelativePath(moduleInfo.getSourceDirectoryPath(), packageName,
296
                name, "TopComponent.java"); //NOI18N
299
                name, "TopComponent.java"); //NOI18N
297
        FileObject template = CreatedModifiedFiles.getTemplate(
300
        FileObject template = CreatedModifiedFiles.getTemplate(
298
            propertiesPersistence ? "templateTopComponentAnno.java" : "templateTopComponent.java" //NOI18N
301
            xmlLessTC ? "templateTopComponent637.java" :    
302
            (propertiesPersistence ? "templateTopComponentAnno.java" : "templateTopComponent.java")
299
        );
303
        );
300
        fileChanges.add(fileChanges.createFileWithSubstitutions(tcName, template, replaceTokens));
304
        fileChanges.add(fileChanges.createFileWithSubstitutions(tcName, template, replaceTokens));
301
        // x. generate java classes
305
        // x. generate java classes
Lines 311-327 Link Here
311
            fileChanges.add(fileChanges.createFileWithSubstitutions(actionName, template, replaceTokens));
315
            fileChanges.add(fileChanges.createFileWithSubstitutions(actionName, template, replaceTokens));
312
        }
316
        }
313
        
317
        
314
        final String settingsName = name + "TopComponent.settings"; //NOI18N
318
        if (!xmlLessTC) {
315
        template = CreatedModifiedFiles.getTemplate("templateSettings.xml");//NOI18N
319
            final String settingsName = name + "TopComponent.settings"; //NOI18N
316
        fileChanges.add(fileChanges.createLayerEntry("Windows2/Components/" + settingsName, template, replaceTokens, null, null)); // NOI18N
320
            template = CreatedModifiedFiles.getTemplate("templateSettings.xml");//NOI18N
321
            fileChanges.add(fileChanges.createLayerEntry("Windows2/Components/" + settingsName, template, replaceTokens, null, null)); // NOI18N
322
        }
317
        
323
        
318
        final String wstcrefName = name + "TopComponent.wstcref"; //NOI18N
324
        if (!xmlLessTC) {
319
        template = CreatedModifiedFiles.getTemplate("templateWstcref.xml");//NOI18N
325
            final String wstcrefName = name + "TopComponent.wstcref"; //NOI18N
320
        fileChanges.add(fileChanges.createLayerEntry("Windows2/Modes/" + mode + "/" + wstcrefName, // NOI18N
326
            template = CreatedModifiedFiles.getTemplate("templateWstcref.xml");//NOI18N
321
                             template, replaceTokens, null, null));
327
            fileChanges.add(fileChanges.createLayerEntry("Windows2/Modes/" + mode + "/" + wstcrefName, // NOI18N
328
                                 template, replaceTokens, null, null));
329
        }
322
330
323
        String bundlePath = getRelativePath(moduleInfo.getResourceDirectoryPath(false), packageName, "", "Bundle.properties"); //NOI18N
331
        String bundlePath = getRelativePath(moduleInfo.getResourceDirectoryPath(false), packageName, "", "Bundle.properties"); //NOI18N
324
        if (actionLessTC) {
332
        if (xmlLessTC) {
333
            // nothing in layer
334
        } else if (actionLessTC) {
325
            String path = "Actions/Window/" + packageName.replace('.','-') + "-" + name + "Action.instance"; // NOI18N
335
            String path = "Actions/Window/" + packageName.replace('.','-') + "-" + name + "Action.instance"; // NOI18N
326
            {
336
            {
327
                Map<String,Object> attrs = new HashMap<String,Object>();
337
                Map<String,Object> attrs = new HashMap<String,Object>();
(-)ad1b676ecc7a (+127 lines)
Added Link Here
1
<#assign licenseFirst = "/*">
2
<#assign licensePrefix = " * ">
3
<#assign licenseLast = " */">
4
<#include "../Licenses/license-${project.license}.txt">
5
6
package ${PACKAGENAME};
7
8
import org.openide.util.NbBundle;
9
import org.openide.windows.TopComponent;
10
import org.openide.windows.WindowManager;
11
import org.netbeans.api.settings.ConvertAsProperties;
12
import org.openide.awt.ActionID;
13
import org.openide.awt.ActionReference;
14
15
<#assign PREFFERED_ID="${TEMPLATENAME}TopComponent"/>
16
17
/**
18
 * Top component which displays something.
19
 */
20
@ConvertAsProperties(
21
    dtd="-//${PACKAGENAME}//${TEMPLATENAME}//EN",
22
    autostore=false
23
)
24
@TopComponent.Description(
25
    preferredID="${PREFFERED_ID}", 
26
    ${COMMENTICON}iconBase="${ICONPATH}", 
27
    persistenceType=TopComponent.PERSISTENCE_ALWAYS
28
)
29
public final class ${TEMPLATENAME}TopComponent extends TopComponent {
30
31
    private static ${TEMPLATENAME}TopComponent instance;
32
33
    public ${TEMPLATENAME}TopComponent() {
34
        initComponents();
35
        setName(NbBundle.getMessage(${TEMPLATENAME}TopComponent.class, "CTL_${TEMPLATENAME}TopComponent"));
36
        setToolTipText(NbBundle.getMessage(${TEMPLATENAME}TopComponent.class, "HINT_${TEMPLATENAME}TopComponent"));
37
${WINSYSBEHAVIOR}
38
    }
39
40
    /** This method is called from within the constructor to
41
     * initialize the form.
42
     * WARNING: Do NOT modify this code. The content of this method is
43
     * always regenerated by the Form Editor.
44
     */
45
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
46
    private void initComponents() {
47
48
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
49
        this.setLayout(layout);
50
        layout.setHorizontalGroup(
51
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
52
            .addGap(0, 400, Short.MAX_VALUE)
53
        );
54
        layout.setVerticalGroup(
55
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
56
            .addGap(0, 300, Short.MAX_VALUE)
57
        );
58
    }// </editor-fold>//GEN-END:initComponents
59
60
61
    // Variables declaration - do not modify//GEN-BEGIN:variables
62
    // End of variables declaration//GEN-END:variables
63
64
    @TopComponent.Registration(mode = "${MODE}", openAtStartup = ${OPENED})
65
    @ActionID(category = "Windows", id = "${PACKAGENAME}.${TEMPLATENAME}TopComponent")
66
    @ActionReference(path = "Menu/Window"
67
        //, position = 333
68
    )
69
    @TopComponent.OpenActionRegistration(
70
        displayName = "#CTL_${TEMPLATENAME}Action",
71
        preferredID="${PREFFERED_ID}"
72
    )
73
    private static synchronized ${TEMPLATENAME}TopComponent create() {
74
        if (instance == null) {
75
            instance = new ${TEMPLATENAME}TopComponent();
76
        }
77
        return instance;
78
    }
79
80
    /** Search logic for the ${TEMPLATENAME}TopComponent instance. 
81
    public static synchronized ${TEMPLATENAME}TopComponent findInstance() {
82
        final String PREFERRED_ID = ${TEMPLATENAME}TopComponent.class.getAnnotation(TopComponent.Description.class).preferredID();
83
        TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
84
        if (win == null) {
85
            Logger.getLogger(${TEMPLATENAME}TopComponent.class.getName()).warning(
86
                    "Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system.");
87
            return create();
88
        }
89
        if (win instanceof ${TEMPLATENAME}TopComponent) {
90
            return (${TEMPLATENAME}TopComponent)win;
91
        }
92
        Logger.getLogger(${TEMPLATENAME}TopComponent.class.getName()).warning(
93
                "There seem to be multiple components with the '" + PREFERRED_ID +
94
                "' ID. That is a potential source of errors and unexpected behavior.");
95
        return create();
96
    }
97
    */
98
99
    @Override
100
    public void componentOpened() {
101
        // TODO add custom code on component opening
102
    }
103
104
    @Override
105
    public void componentClosed() {
106
        // TODO add custom code on component closing
107
    }
108
109
    void writeProperties(java.util.Properties p) {
110
        // better to version settings since initial version as advocated at
111
        // http://wiki.apidesign.org/wiki/PropertyFiles
112
        p.setProperty("version", "1.0");
113
        // TODO store your settings
114
    }
115
    Object readProperties(java.util.Properties p) {
116
        if (instance == null) {
117
            instance = this;
118
        }
119
        instance.readPropertiesImpl(p);
120
        return instance;
121
    }
122
123
    private void readPropertiesImpl(java.util.Properties p) {
124
        String version = p.getProperty("version");
125
        // TODO read your settings according to their version
126
    }
127
}
(-)a/openide.awt/src/org/netbeans/modules/openide/awt/ActionProcessor.java (-1 / +7 lines)
Lines 277-283 Link Here
277
            if (e.getAnnotation(ActionRegistration.class) != null) {
277
            if (e.getAnnotation(ActionRegistration.class) != null) {
278
                continue;
278
                continue;
279
            }
279
            }
280
            throw new LayerGenerationException("Don't use @ActionReference without @ActionRegistration", e);
280
            ActionID id = e.getAnnotation(ActionID.class);
281
            if (id != null) {
282
                ActionReference ref = e.getAnnotation(ActionReference.class);
283
                processReferences(e, ref, id);
284
                continue;
285
            }
286
            throw new LayerGenerationException("Don't use @ActionReference without @ActionID", e);
281
        }
287
        }
282
        for (Element e : roundEnv.getElementsAnnotatedWith(ActionReferences.class)) {
288
        for (Element e : roundEnv.getElementsAnnotatedWith(ActionReferences.class)) {
283
            if (e.getAnnotation(ActionRegistration.class) != null) {
289
            if (e.getAnnotation(ActionRegistration.class) != null) {
(-)a/openide.windows/apichanges.xml (+18 lines)
Lines 50-55 Link Here
50
<apidef name="winsys">Window System API</apidef>
50
<apidef name="winsys">Window System API</apidef>
51
</apidefs>
51
</apidefs>
52
<changes>
52
<changes>
53
<change id="topcomponent.registration">
54
    <api name="winsys"/>
55
    <summary>Register default TopComponent location via annotations</summary>
56
    <version major="6" minor="37"/>
57
    <date day="30" month="11" year="2010"/>
58
    <author login="jtulach"/>
59
    <compatibility addition="no" binary="compatible" source="compatible" semantic="compatible" deprecation="no" deletion="no" modification="no"/>
60
    <description>
61
        Use <a href="@TOP@/org/openide/windows/TopComponent.Registration.html">TopComponent.Registration</a>,
62
        <a href="@TOP@/org/openide/windows/TopComponent.Description.html">TopComponent.Description</a> and
63
        <a href="@TOP@/org/openide/windows/TopComponent.OpenActionRegistration.html">TopComponent.OpenActionRegistration</a>
64
        to register default location of a 
65
        <a href="@TOP@/org/openide/windows/TopComponent.html">TopComponent</a>,
66
        some of its properties and action to open it.
67
    </description>
68
    <class package="org.openide.windows" name="TopComponent"/>
69
    <issue number="191407"/>
70
</change>
53
<change id="reuse.existing.frame.as.the.main.window">
71
<change id="reuse.existing.frame.as.the.main.window">
54
    <api name="winsys"/>
72
    <api name="winsys"/>
55
    <summary>Reuse existing JFrame instance (if any) as IDE's main window.</summary>
73
    <summary>Reuse existing JFrame instance (if any) as IDE's main window.</summary>
(-)a/openide.windows/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.windows
2
OpenIDE-Module: org.openide.windows
3
OpenIDE-Module-Specification-Version: 6.36
3
OpenIDE-Module-Specification-Version: 6.37
4
OpenIDE-Module-Localizing-Bundle: org/openide/windows/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/openide/windows/Bundle.properties
5
AutoUpdate-Essential-Module: true
5
AutoUpdate-Essential-Module: true
6
6
(-)a/openide.windows/nbproject/project.xml (+5 lines)
Lines 58-63 Link Here
58
                    </run-dependency>
58
                    </run-dependency>
59
                </dependency>
59
                </dependency>
60
                <dependency>
60
                <dependency>
61
                    <code-name-base>org.openide.filesystems</code-name-base>
62
                    <build-prerequisite/>
63
                    <compile-dependency/>
64
                </dependency>
65
                <dependency>
61
                    <code-name-base>org.openide.nodes</code-name-base>
66
                    <code-name-base>org.openide.nodes</code-name-base>
62
                    <build-prerequisite/>
67
                    <build-prerequisite/>
63
                    <compile-dependency/>
68
                    <compile-dependency/>
(-)ad1b676ecc7a (+165 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 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 2010 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.openide.windows;
44
45
import java.util.HashSet;
46
import java.util.Set;
47
import javax.annotation.processing.Processor;
48
import javax.annotation.processing.RoundEnvironment;
49
import javax.annotation.processing.SupportedSourceVersion;
50
import javax.lang.model.SourceVersion;
51
import javax.lang.model.element.Element;
52
import javax.lang.model.element.TypeElement;
53
import javax.lang.model.type.DeclaredType;
54
import javax.lang.model.type.ExecutableType;
55
import org.openide.awt.ActionID;
56
import org.openide.filesystems.annotations.LayerBuilder.File;
57
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
58
import org.openide.filesystems.annotations.LayerGenerationException;
59
import org.openide.util.lookup.ServiceProvider;
60
import org.openide.windows.TopComponent;
61
import org.openide.windows.TopComponent.Description;
62
63
@SupportedSourceVersion(SourceVersion.RELEASE_6)
64
@ServiceProvider(service=Processor.class)
65
public final class TopComponentProcessor extends LayerGeneratingProcessor {
66
    public TopComponentProcessor() {
67
    }
68
69
    @Override
70
    public Set<String> getSupportedAnnotationTypes() {
71
        Set<String> hash = new HashSet<String>();
72
        hash.add(TopComponent.Registration.class.getCanonicalName());
73
        hash.add(TopComponent.OpenActionRegistration.class.getCanonicalName());
74
        hash.add(TopComponent.Description.class.getCanonicalName());
75
        return hash;
76
    }
77
    
78
    @Override
79
    protected boolean handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws LayerGenerationException {
80
        for (Element e : roundEnv.getElementsAnnotatedWith(TopComponent.Registration.class)) {
81
            TopComponent.Registration reg = e.getAnnotation(TopComponent.Registration.class);
82
            assert reg != null;
83
            
84
            Description info = findInfo(e);
85
            String id = info.preferredID().replace('.', '-');
86
            
87
            File settingsFile = layer(e).
88
                file("Windows2/Components/" + id + ".settings").
89
                contents(settingsFile(e));
90
            settingsFile.write();
91
            
92
            File modeFile = layer(e).
93
                file("Windows2/Modes/" + reg.mode() + "/" + id + ".wstcref").
94
                contents(modeFile(info.preferredID(), reg.openAtStartup()));
95
            modeFile.write();
96
        }
97
        
98
        for (Element e : roundEnv.getElementsAnnotatedWith(TopComponent.OpenActionRegistration.class)) {
99
            TopComponent.OpenActionRegistration reg = e.getAnnotation(TopComponent.OpenActionRegistration.class);
100
            assert reg != null;
101
            Description info = findInfo(e);
102
            
103
            ActionID aid = e.getAnnotation(ActionID.class);
104
            if (aid != null) {
105
                File actionFile = layer(e).
106
                    file("Actions/" + aid.category() + "/" + aid.id().replace('.', '-') + ".instance").
107
                    methodvalue("instanceCreate", "org.openide.windows.TopComponent", "openAction");
108
                actionFile.instanceAttribute("component", TopComponent.class);
109
                if (reg.preferredID().length() > 0) {
110
                    actionFile.stringvalue("preferredID", reg.preferredID());
111
                }
112
                actionFile.bundlevalue("displayName", reg.displayName());
113
                if (info != null && info.iconBase().length() > 0) {
114
                    actionFile.stringvalue("iconBase", info.iconBase());
115
                }
116
                actionFile.write();
117
            }
118
        }
119
        return true;
120
    }
121
122
    private Description findInfo(Element e) throws LayerGenerationException {
123
        Element type;
124
        switch (e.asType().getKind()) {
125
            case DECLARED: type = e; break;
126
            case EXECUTABLE: type = ((DeclaredType)((ExecutableType)e.asType()).getReturnType()).asElement(); break;
127
            default: throw new LayerGenerationException("" + e.asType().getKind(), e);    
128
        }
129
        TopComponent.Description info = type.getAnnotation(TopComponent.Description.class);
130
        return info;
131
    }
132
133
    private static String settingsFile(Element e) throws LayerGenerationException {
134
        String clazz, method;
135
        switch (e.getKind()) {
136
            case CLASS: clazz = e.toString(); method = null; break;
137
            case METHOD: clazz = e.getEnclosingElement().toString(); method = e.getSimpleName().toString(); break;
138
            default:
139
                throw new LayerGenerationException("Cannot work on given element", e);
140
        }
141
        StringBuilder sb = new StringBuilder();
142
        sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
143
        sb.append("<!DOCTYPE settings PUBLIC \"-//NetBeans//DTD Session settings 1.0//EN\" \"http://www.netbeans.org/dtds/sessionsettings-1_0.dtd\">\n");
144
        sb.append("<settings version=\"1.0\">\n");
145
        sb.append("  <instance class=\"").append(clazz).append("\"");
146
        if (method != null) {
147
            sb.append(" method=\"").append(method).append("\"");
148
        }
149
        sb.append("/>\n");
150
        sb.append("</settings>\n");
151
        return sb.toString();
152
    }
153
    
154
    private static String modeFile(String id, boolean openAtStart) 
155
    throws LayerGenerationException {
156
        StringBuilder sb = new StringBuilder();
157
        sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
158
        sb.append("<!DOCTYPE tc-ref PUBLIC \"-//NetBeans//DTD Top Component in Mode Properties 2.0//EN\" \"http://www.netbeans.org/dtds/tc-ref2_0.dtd\">\n");
159
        sb.append("<tc-ref version=\"2.0\">\n");
160
        sb.append("  <tc-id id=\"").append(id).append("\"/>\n");
161
        sb.append("  <state opened=\"").append(openAtStart).append("\"/>\n");
162
        sb.append("</tc-ref>\n");
163
        return sb.toString();
164
    }
165
}
(-)a/openide.windows/src/org/openide/windows/OpenComponentAction.java (-4 / +12 lines)
Lines 43-49 Link Here
43
package org.openide.windows;
43
package org.openide.windows;
44
44
45
import java.awt.EventQueue;
45
import java.awt.EventQueue;
46
import java.awt.Image;
47
import java.awt.event.ActionEvent;
46
import java.awt.event.ActionEvent;
48
import java.awt.event.ActionListener;
47
import java.awt.event.ActionListener;
49
import java.util.Map;
48
import java.util.Map;
Lines 71-79 Link Here
71
        if (component != null) {
70
        if (component != null) {
72
            return component;
71
            return component;
73
        }
72
        }
74
        component = (TopComponent)map.get("component"); // NOI18N
73
        TopComponent c = null;
75
        assert component != null : "Component cannot be created for " + map;
74
        Object id = map.get("preferredID"); // NOI18N
76
        return component;
75
        if (id instanceof String) {
76
            c = WindowManager.getDefault().findTopComponent((String)id);
77
        }
78
        if (c == null) {
79
            c = (TopComponent)map.get("component");
80
        }
81
        if (id != null) {
82
            component = c;
83
        }
84
        return c;
77
    }
85
    }
78
86
79
    public void actionPerformed(ActionEvent e) {
87
    public void actionPerformed(ActionEvent e) {
(-)a/openide.windows/src/org/openide/windows/TopComponent.java (-2 / +94 lines)
Lines 60-65 Link Here
60
import java.io.ObjectOutputStream;
60
import java.io.ObjectOutputStream;
61
import java.io.ObjectStreamException;
61
import java.io.ObjectStreamException;
62
import java.io.Serializable;
62
import java.io.Serializable;
63
import java.lang.annotation.ElementType;
64
import java.lang.annotation.Retention;
65
import java.lang.annotation.RetentionPolicy;
66
import java.lang.annotation.Target;
63
import java.lang.ref.Reference;
67
import java.lang.ref.Reference;
64
import java.lang.ref.WeakReference;
68
import java.lang.ref.WeakReference;
65
import java.lang.reflect.InvocationTargetException;
69
import java.lang.reflect.InvocationTargetException;
Lines 85-90 Link Here
85
import javax.swing.Timer;
89
import javax.swing.Timer;
86
import javax.swing.plaf.basic.BasicHTML;
90
import javax.swing.plaf.basic.BasicHTML;
87
import javax.swing.text.Keymap;
91
import javax.swing.text.Keymap;
92
import org.openide.awt.ActionID;
88
import org.openide.awt.Actions;
93
import org.openide.awt.Actions;
89
import org.openide.awt.UndoRedo;
94
import org.openide.awt.UndoRedo;
90
import org.openide.nodes.Node;
95
import org.openide.nodes.Node;
Lines 92-97 Link Here
92
import org.openide.nodes.NodeListener;
97
import org.openide.nodes.NodeListener;
93
import org.openide.util.ContextAwareAction;
98
import org.openide.util.ContextAwareAction;
94
import org.openide.util.HelpCtx;
99
import org.openide.util.HelpCtx;
100
import org.openide.util.ImageUtilities;
95
import org.openide.util.Lookup;
101
import org.openide.util.Lookup;
96
import org.openide.util.NbBundle;
102
import org.openide.util.NbBundle;
97
import org.openide.util.NbPreferences;
103
import org.openide.util.NbPreferences;
Lines 422-427 Link Here
422
    }
428
    }
423
429
424
    /**
430
    /**
431
     * Rather than overriding this method, consider using {@link Description}.
425
     * Overwrite when you want to change default persistence type. Default
432
     * Overwrite when you want to change default persistence type. Default
426
     * persistence type is PERSISTENCE_ALWAYS.
433
     * persistence type is PERSISTENCE_ALWAYS.
427
     * Return value should be constant over a given TC's lifetime.
434
     * Return value should be constant over a given TC's lifetime.
Lines 429-434 Link Here
429
     * @since 4.20
436
     * @since 4.20
430
     */
437
     */
431
    public int getPersistenceType() {
438
    public int getPersistenceType() {
439
        Description info = getClass().getAnnotation(Description.class); 
440
        if (info != null) {
441
            return info.persistenceType();
442
        }
443
        
432
        //First check for 'PersistenceType' client property for compatibility.
444
        //First check for 'PersistenceType' client property for compatibility.
433
        if (warnedClasses.add(getClass()) && !TopComponent.class.equals(getClass())) {
445
        if (warnedClasses.add(getClass()) && !TopComponent.class.equals(getClass())) {
434
            Logger.getAnonymousLogger().warning(
446
            Logger.getAnonymousLogger().warning(
Lines 652-664 Link Here
652
     *   &lt;attr name="displayName" bundlevalue="your.pkg.Bundle#key"/&gt;
664
     *   &lt;attr name="displayName" bundlevalue="your.pkg.Bundle#key"/&gt;
653
     *   &lt;attr name="iconBase" stringvalue="your/pkg/YourComponent.png"/&gt;
665
     *   &lt;attr name="iconBase" stringvalue="your/pkg/YourComponent.png"/&gt;
654
     *   &lt;!-- if desired: &lt;attr name="noIconInMenu" boolvalue="false"/&gt; --&gt;
666
     *   &lt;!-- if desired: &lt;attr name="noIconInMenu" boolvalue="false"/&gt; --&gt;
667
     *   &lt;!-- if desired: &lt;attr name="preferredID" stringvalue="id.of.your.tc"/&gt; --&gt;
655
     * &lt;/file&gt;
668
     * &lt;/file&gt;
656
     * </pre>
669
     * </pre>
670
     * The <code>preferredID</code> attribute is supported since version
671
     * 6.37. If specified the action first seeks for existing <code>preferredID</code>
672
     * component and if found, it opens and activates it.
673
     * <p>
674
     * Rather than doing all this in XML, consider using {@link OpenActionRegistration}.
675
     * 
657
     * 
676
     * 
658
     * @param component the component to open
677
     * @param component the component to open
659
     * @param displayName the display name of the action
678
     * @param displayName the display name of the action
660
     * @param image the image to associated with the action
679
     * @param image the image to associated with the action
661
     * @param noIconInMenu true if this icon shall not have an item in menu
680
     * @param noIconInMenu true if this icon shall not have an item in menu
681
     * @see OpenActionRegistration
662
     * 
682
     * 
663
     * @since 6.24
683
     * @since 6.24
664
     */
684
     */
Lines 704-709 Link Here
704
    }
724
    }
705
725
706
    /**
726
    /**
727
     * Rather than overriding this method, consider using {@link Description}.
707
     * Subclasses are encouraged to override this method to provide preferred value
728
     * Subclasses are encouraged to override this method to provide preferred value
708
     * for unique TopComponent ID returned by {@link org.openide.windows.WindowManager#findTopComponentID}.
729
     * for unique TopComponent ID returned by {@link org.openide.windows.WindowManager#findTopComponentID}.
709
     *
730
     *
Lines 716-722 Link Here
716
     * @since 4.13
737
     * @since 4.13
717
     */
738
     */
718
    protected String preferredID() {
739
    protected String preferredID() {
719
        Class clazz = getClass();
740
        Class<?> clazz = getClass();
741
        Description id = clazz.getAnnotation(Description.class);
742
        if (id != null) {
743
            return id.preferredID();
744
        }
720
745
721
        if (getPersistenceType() != PERSISTENCE_NEVER && warnedTCPIClasses.add(clazz)) {
746
        if (getPersistenceType() != PERSISTENCE_NEVER && warnedTCPIClasses.add(clazz)) {
722
            Logger.getAnonymousLogger().warning(
747
            Logger.getAnonymousLogger().warning(
Lines 1027-1034 Link Here
1027
        firePropertyChange("icon", old, icon); // NOI18N
1052
        firePropertyChange("icon", old, icon); // NOI18N
1028
    }
1053
    }
1029
1054
1030
    /** @return The icon of the top component */
1055
    /** 
1056
     * Rather than overriding this method, consider using {@link Description}.
1057
     * @return The icon of the top component 
1058
     */
1031
    public Image getIcon() {
1059
    public Image getIcon() {
1060
        Description id;
1061
        if (icon == null && (id = getClass().getAnnotation(Description.class)) != null) {
1062
            icon = ImageUtilities.loadImage(id.iconBase(), true);
1063
        }
1032
        return icon;
1064
        return icon;
1033
    }
1065
    }
1034
1066
Lines 1357-1362 Link Here
1357
        */
1389
        */
1358
        public TopComponent cloneComponent();
1390
        public TopComponent cloneComponent();
1359
    }
1391
    }
1392
    
1393
    /** Provides basic information about the persistence of a {@link TopComponent}.
1394
     * Using this annotation is preferred to overriding {@link #preferredID()}
1395
     * or calling {@link #setIcon(java.awt.Image)}.
1396
     * @since 6.37
1397
     */
1398
    @Retention(RetentionPolicy.RUNTIME)
1399
    @Target(ElementType.TYPE)
1400
    public static @interface Description {
1401
        /** The default value for {@link TopComponent#preferredID()}.
1402
         */
1403
        public String preferredID();
1404
        /** The icon to load for {@link TopComponent#getIcon()}.
1405
         */
1406
        public String iconBase() default "";
1407
        /** Default value for {@link TopComponent#getPersistenceType()}. 
1408
         * 
1409
         * @return one of {@link TopComponent#PERSISTENCE_ALWAYS}, 
1410
         * {@link TopComponent#PERSISTENCE_NEVER}, 
1411
         * {@link TopComponent#PERSISTENCE_ONLY_OPENED}
1412
         * 
1413
         */
1414
        public int persistenceType() default PERSISTENCE_ALWAYS;
1415
    }
1416
    
1417
    /** Registers {@link TopComponent} into specified location among
1418
     * existing {@link Mode window system modes}. The mode itself needs 
1419
     * to be created by other means, this just adds reference to the
1420
     * component to it.
1421
     * 
1422
     * @since 6.37
1423
     */
1424
    @Retention(RetentionPolicy.SOURCE)
1425
    @Target({ ElementType.TYPE, ElementType.METHOD })
1426
    public static @interface Registration {
1427
        /** Name of the mode the component shall be opened in */
1428
        String mode();
1429
        /** Shall the component be opened at start */
1430
        boolean openAtStartup();
1431
    }
1432
    
1433
    /** Creates an action that can open the component.
1434
     * The action is generated only
1435
     * if {@link ActionID} annotation is used on the same element, otherwise
1436
     * a compilation error is raised. Also the {@link Description} shall be
1437
     * present.
1438
     * @since 6.37
1439
     */
1440
    @Retention(RetentionPolicy.SOURCE)
1441
    @Target({ ElementType.TYPE, ElementType.METHOD })
1442
    public static @interface OpenActionRegistration {
1443
        /** Display name of the action, usually can refer to value from a
1444
         * <code>Bundle.properties</code> using <code>#KEY</code>.
1445
         */
1446
        String displayName();
1447
        
1448
        /** The identification of an existing component to seek for.
1449
         */
1450
        String preferredID() default "";
1451
    }
1360
1452
1361
    /** Registry of all top components.
1453
    /** Registry of all top components.
1362
    * There is one instance that can be obtained via {@link TopComponent#getRegistry}
1454
    * There is one instance that can be obtained via {@link TopComponent#getRegistry}
(-)ad1b676ecc7a (+44 lines)
Added Link Here
1
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
#
3
# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
4
#
5
# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
6
# Other names may be trademarks of their respective owners.
7
#
8
# The contents of this file are subject to the terms of either the GNU
9
# General Public License Version 2 only ("GPL") or the Common
10
# Development and Distribution License("CDDL") (collectively, the
11
# "License"). You may not use this file except in compliance with the
12
# License. You can obtain a copy of the License at
13
# http://www.netbeans.org/cddl-gplv2.html
14
# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
15
# specific language governing permissions and limitations under the
16
# License.  When distributing the software, include this License Header
17
# Notice in each file and include the License file at
18
# nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
19
# particular file as subject to the "Classpath" exception as provided
20
# by Oracle in the GPL Version 2 section of the License file that
21
# accompanied this code. If applicable, add the following below the
22
# License Header, with the fields enclosed by brackets [] replaced by
23
# your own identifying information:
24
# "Portions Copyrighted [year] [name of copyright owner]"
25
#
26
# Contributor(s):
27
#
28
# The Original Software is NetBeans. The Initial Developer of the Original
29
# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
30
# Microsystems, Inc. All Rights Reserved.
31
#
32
# If you wish your version of this file to be governed by only the CDDL
33
# or only the GPL Version 2, indicate your decision by adding
34
# "[Contributor] elects to include this software in this distribution
35
# under the [CDDL or GPL Version 2] license." If you do not indicate a
36
# single choice of license, a recipient has the option to distribute
37
# your version of this file under either the CDDL, the GPL Version 2 or
38
# to extend the choice of license to its licensees as provided above.
39
# However, if you add GPL Version 2 code and therefore, elected the GPL
40
# Version 2 license, then the option applies only if the new code is
41
# made subject to such option by the copyright holder.
42
43
44
TEST_ACTION=Hello TC!
(-)ad1b676ecc7a (+155 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 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 2010 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.openide.windows;
44
45
import java.awt.EventQueue;
46
import java.awt.event.ActionEvent;
47
import java.io.ByteArrayInputStream;
48
import java.util.Arrays;
49
import javax.swing.Action;
50
import javax.xml.parsers.DocumentBuilder;
51
import javax.xml.parsers.DocumentBuilderFactory;
52
import org.netbeans.junit.NbTestCase;
53
import org.openide.awt.ActionID;
54
import org.openide.awt.ActionReference;
55
import org.openide.filesystems.FileObject;
56
import org.openide.filesystems.FileUtil;
57
import org.openide.windows.TopComponent;
58
import org.w3c.dom.Document;
59
60
public class TopComponentProcessorTest extends  NbTestCase {
61
62
    public TopComponentProcessorTest(String n) {
63
        super(n);
64
    }
65
66
    @Override
67
    protected boolean runInEQ() {
68
        return getName().contains("InEQ");
69
    }
70
71
    public void testTCRegisteredFine() throws Exception {
72
        FileObject set = FileUtil.getConfigFile("Windows2/Components/my-tc.settings");
73
        assertNotNull("Settings file found", set);
74
        assertValidate(set.asText());
75
    }
76
77
    public void testModeIsOK() throws Exception {
78
        FileObject set = FileUtil.getConfigFile("Windows2/Modes/output/my-tc.wstcref");
79
        assertNotNull("Mode file found", set);
80
        final String t = set.asText();
81
        assertValidate(t);
82
        assertEquals("not opened, no true in there", -1, t.indexOf("true"));
83
    }
84
    
85
    public void testFactoryRegisteredFine() throws Exception {
86
        FileObject set = FileUtil.getConfigFile("Windows2/Components/factory-tc.settings");
87
        assertNotNull("Settings file found", set);
88
        assertValidate(set.asText());
89
    }
90
91
    public void testFactoryModeIsOK() throws Exception {
92
        FileObject set = FileUtil.getConfigFile("Windows2/Modes/explorer/factory-tc.wstcref");
93
        assertNotNull("Mode file found", set);
94
        final String t = set.asText();
95
        assertValidate(t);
96
        assertTrue("opened, no true in there", t.indexOf("true") > 0);
97
    }
98
99
    public void testFactoryActionIsOKInEQ() throws Exception {
100
        assertTrue("This one needs to run in EQT", EventQueue.isDispatchThread());
101
        FileObject fo = FileUtil.getConfigFile("Actions/Windows/open-factory-tc.instance");
102
        assertNotNull("Action generated", fo);
103
        Action a = (Action)fo.getAttribute("instanceCreate");
104
        assertNotNull("Action found", a);
105
        assertEquals("Not created yet", 0, TC.cnt);
106
        a.actionPerformed(new ActionEvent(this, 0, ""));
107
        assertEquals("Created", 1, TC.cnt);
108
        assertEquals("Hello TC!", a.getValue(Action.NAME));
109
        assertEquals("any/iconbase.png", a.getValue("iconBase"));
110
        assertEquals("preferredID found", "factory.tc", fo.getAttribute("preferredID"));
111
        
112
        FileObject dir = FileUtil.getConfigFile("Kuk/Huk");
113
        assertNotNull("Kuk/Huk found", dir);
114
        FileObject ref = dir.getFileObject("open-factory-tc.shadow");
115
        assertNotNull("Reference found: " + Arrays.toString(dir.getChildren()), ref);
116
        assertEquals(fo.getPath(), ref.getAttribute("originalFile"));
117
    }
118
    
119
    private static void assertValidate(String xml) throws Exception {
120
        DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
121
        f.setValidating(true);
122
        DocumentBuilder b = f.newDocumentBuilder();
123
        Document res = b.parse(new ByteArrayInputStream(xml.getBytes("UTF-8")));
124
        assertNotNull("Parsed OK", res);
125
    }
126
    
127
    @TopComponent.Registration(
128
        mode="output",
129
        openAtStartup=false
130
    )
131
    @TopComponent.Description(
132
        preferredID="my-tc", iconBase="org/openide/windows/Icon.png"
133
    )
134
    public static class TC1 extends TopComponent {
135
    }
136
    
137
    @TopComponent.Registration(
138
        mode="explorer",
139
        openAtStartup=true
140
    )
141
    @TopComponent.Description(
142
        preferredID="factory.tc", iconBase="any/iconbase.png"
143
    )
144
    public static class TC extends TopComponent {
145
        static int cnt;
146
        
147
        @ActionID(category="Windows", id="open.factory.tc")
148
        @TopComponent.OpenActionRegistration(displayName="#TEST_ACTION",preferredID="factory.tc")
149
        @ActionReference(path="Kuk/Huk")
150
        public static TC create() {
151
            cnt++;
152
            return new TC();
153
        }
154
    }
155
}
(-)a/openide.windows/test/unit/src/org/openide/windows/TopComponentTest.java (+18 lines)
Lines 44-49 Link Here
44
44
45
package org.openide.windows;
45
package org.openide.windows;
46
46
47
import java.awt.Image;
47
import java.awt.event.ActionEvent;
48
import java.awt.event.ActionEvent;
48
import java.awt.event.KeyEvent;
49
import java.awt.event.KeyEvent;
49
import java.beans.PropertyChangeEvent;
50
import java.beans.PropertyChangeEvent;
Lines 66-71 Link Here
66
import org.openide.nodes.Node;
67
import org.openide.nodes.Node;
67
import org.openide.util.ContextAwareAction;
68
import org.openide.util.ContextAwareAction;
68
import org.openide.util.HelpCtx;
69
import org.openide.util.HelpCtx;
70
import org.openide.util.ImageUtilities;
69
import org.openide.util.Lookup;
71
import org.openide.util.Lookup;
70
import org.openide.util.actions.CookieAction;
72
import org.openide.util.actions.CookieAction;
71
import org.openide.util.io.NbMarshalledObject;
73
import org.openide.util.io.NbMarshalledObject;
Lines 83-88 Link Here
83
    public TopComponentTest(String testName) {
85
    public TopComponentTest(String testName) {
84
        super(testName);
86
        super(testName);
85
    }
87
    }
88
    
89
    public void testPreferredIDAndIconTakenFromAnnotation() {
90
        @TopComponent.Description(
91
            preferredID="my.id", iconBase="org/openide/windows/icon.png",
92
            persistenceType=TopComponent.PERSISTENCE_ONLY_OPENED    
93
        )
94
        class MyTC extends TopComponent {
95
        }
96
        TopComponent tc = new MyTC();
97
        
98
        assertEquals("ID is OK", "my.id", tc.preferredID());
99
        Image image = ImageUtilities.loadImage("org/openide/windows/icon.png");
100
        assertEquals("Image is OK", image, tc.getIcon());
101
        
102
        assertEquals("Only opened", TopComponent.PERSISTENCE_ONLY_OPENED, tc.getPersistenceType());
103
    }
86
104
87
    public void testCanTCGarbageCollectWhenActionInMap() {
105
    public void testCanTCGarbageCollectWhenActionInMap() {
88
        TopComponent tc = new TopComponent();
106
        TopComponent tc = new TopComponent();
(-)a/settings/apichanges.xml (+14 lines)
Lines 108-113 Link Here
108
108
109
<!-- ACTUAL CHANGES BEGIN HERE: -->
109
<!-- ACTUAL CHANGES BEGIN HERE: -->
110
  <changes>
110
  <changes>
111
    <change id="private.factories">
112
        <api name="settings_spi"/>
113
        <summary>Factory methods can be private</summary>
114
        <version major="1" minor="29"/>
115
        <date day="30" month="11" year="2010"/>
116
        <author login="jtulach"/>
117
        <compatibility addition="yes" binary="compatible" deletion="no" deprecation="no" modification="yes" semantic="compatible" source="compatible"/>
118
        <description>
119
            To be consistent with behavior of methodvalue attribute of
120
            <a href="@org-openide-filesystems@/org/openide/filesystems/XMLFileSystem.html">XMLFileSystem</a>,
121
            now the factory methods referenced from settings files can be <code> private static</code>
122
            as well.
123
        </description>
124
    </change>
111
    <change id="readResolveBehaviour">
125
    <change id="readResolveBehaviour">
112
        <api name="settings_spi"/>
126
        <api name="settings_spi"/>
113
        <summary>readProperties can designate its replace</summary>
127
        <summary>readProperties can designate its replace</summary>
(-)a/settings/manifest.mf (-1 / +1 lines)
Lines 3-7 Link Here
3
OpenIDE-Module-Layer: org/netbeans/modules/settings/resources/mf-layer.xml
3
OpenIDE-Module-Layer: org/netbeans/modules/settings/resources/mf-layer.xml
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/settings/resources/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/settings/resources/Bundle.properties
5
AutoUpdate-Essential-Module: true
5
AutoUpdate-Essential-Module: true
6
OpenIDE-Module-Specification-Version: 1.28
6
OpenIDE-Module-Specification-Version: 1.29
7
7
(-)a/settings/src/org/netbeans/modules/settings/convertors/XMLSettingsSupport.java (-2 / +2 lines)
Lines 665-675 Link Here
665
            try {
665
            try {
666
                Object instance;
666
                Object instance;
667
                try {
667
                try {
668
                    Method method = clazz.getMethod(targetMethod, new Class[]{FileObject.class});
668
                    Method method = clazz.getDeclaredMethod(targetMethod, new Class[]{FileObject.class});
669
                    method.setAccessible(true);
669
                    method.setAccessible(true);
670
                    instance = method.invoke(null, source);
670
                    instance = method.invoke(null, source);
671
                } catch (NoSuchMethodException ex) {
671
                } catch (NoSuchMethodException ex) {
672
                    Method method = clazz.getMethod(targetMethod);
672
                    Method method = clazz.getDeclaredMethod(targetMethod);
673
                    method.setAccessible(true);
673
                    method.setAccessible(true);
674
                    instance = method.invoke(null, new Object[0]);
674
                    instance = method.invoke(null, new Object[0]);
675
                }
675
                }

Return to bug 191407