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

(-)a/openide.windows/apichanges.xml (-2 / +3 lines)
Lines 54-66 Link Here
54
    <api name="winsys"/>
54
    <api name="winsys"/>
55
    <summary>Added optional <code>role</code> parameter to <code>TopComponent</code> <code>Registration</code> annotation.</summary>
55
    <summary>Added optional <code>role</code> parameter to <code>TopComponent</code> <code>Registration</code> annotation.</summary>
56
    <version major="6" minor="45"/>
56
    <version major="6" minor="45"/>
57
    <date day="22" month="6" year="2011"/>
57
    <date day="19" month="10" year="2011"/>
58
    <author login="saubrecht"/>
58
    <author login="saubrecht"/>
59
    <compatibility addition="yes" source="compatible" semantic="compatible" deprecation="no" deletion="no" modification="no"/>
59
    <compatibility addition="yes" source="compatible" semantic="compatible" deprecation="no" deletion="no" modification="no"/>
60
    <description>
60
    <description>
61
        Since the window system now supports multiple window layouts - roles -
61
        Since the window system now supports multiple window layouts - roles -
62
        the annotation for TopComponent registration needs an optional parameter
62
        the annotation for TopComponent registration needs an optional parameter
63
        to specify the role the window should belong to.
63
        to specify one or more roles the window should belong to. If no roles
64
        are specified, the TopComponent is registered in the default layout.
64
    </description>
65
    </description>
65
    <class package="org.openide.windows" name="TopComponent"/>
66
    <class package="org.openide.windows" name="TopComponent"/>
66
    <issue number="199452"/>
67
    <issue number="199452"/>
(-)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.46
3
OpenIDE-Module-Specification-Version: 6.47
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/src/org/netbeans/modules/openide/windows/TopComponentProcessor.java (-13 / +34 lines)
Lines 42-48 Link Here
42
42
43
package org.netbeans.modules.openide.windows;
43
package org.netbeans.modules.openide.windows;
44
44
45
import java.util.ArrayList;
45
import java.util.HashSet;
46
import java.util.HashSet;
47
import java.util.List;
46
import java.util.Set;
48
import java.util.Set;
47
import javax.annotation.processing.Processor;
49
import javax.annotation.processing.Processor;
48
import javax.annotation.processing.RoundEnvironment;
50
import javax.annotation.processing.RoundEnvironment;
Lines 59-64 Link Here
59
import org.openide.util.lookup.ServiceProvider;
61
import org.openide.util.lookup.ServiceProvider;
60
import org.openide.windows.TopComponent;
62
import org.openide.windows.TopComponent;
61
import org.openide.windows.TopComponent.Description;
63
import org.openide.windows.TopComponent.Description;
64
import org.openide.windows.TopComponent.Registration;
62
65
63
@SupportedSourceVersion(SourceVersion.RELEASE_6)
66
@SupportedSourceVersion(SourceVersion.RELEASE_6)
64
@ServiceProvider(service=Processor.class)
67
@ServiceProvider(service=Processor.class)
Lines 86-105 Link Here
86
                throw new LayerGenerationException("Cannot find TopComponent.Description for this element", e, processingEnv, reg);
89
                throw new LayerGenerationException("Cannot find TopComponent.Description for this element", e, processingEnv, reg);
87
            }
90
            }
88
            String id = info.preferredID().replace('.', '-');
91
            String id = info.preferredID().replace('.', '-');
89
            
90
            String role = reg.role();
91
            String rootFolder = role.isEmpty() ? "Windows2" : "Windows2/Roles/" + role;
92
92
93
            File settingsFile = layer(e).
93
            String rootFolder;
94
                file(rootFolder+"/Components/" + id + ".settings").
94
            String[] roles = reg.roles();
95
                contents(settingsFile(e));
95
            if (roles.length == 0) {
96
            settingsFile.write();
96
                rootFolder = "Windows2";
97
            
97
                generateSettingsAndWstcref(e, rootFolder, id, reg, info);
98
            File modeFile = layer(e).
98
            } else {
99
                file(rootFolder+"/Modes/" + reg.mode() + "/" + id + ".wstcref").
99
                Set<String> uniqueRoles = new HashSet<String>();
100
                position(reg.position()).
100
                for (String role : roles) {
101
                contents(modeFile(info.preferredID(), reg.openAtStartup()));
101
                    if (!uniqueRoles.add(role)) {
102
            modeFile.write();
102
                        throw new LayerGenerationException("Duplicate role name found", e, processingEnv, reg);
103
                    }
104
                    if (role.isEmpty()) {
105
                        throw new LayerGenerationException("Unnamed role found", e, processingEnv, reg);
106
                    }
107
                    rootFolder = "Windows2/Roles/" + role;
108
                    generateSettingsAndWstcref(e, rootFolder, id, reg, info);
109
                }
110
            }
103
        }
111
        }
104
        
112
        
105
        for (Element e : roundEnv.getElementsAnnotatedWith(TopComponent.OpenActionRegistration.class)) {
113
        for (Element e : roundEnv.getElementsAnnotatedWith(TopComponent.OpenActionRegistration.class)) {
Lines 126-131 Link Here
126
        return true;
134
        return true;
127
    }
135
    }
128
136
137
    private void generateSettingsAndWstcref(Element e, String rootFolder, String id, Registration reg, Description info) throws LayerGenerationException {
138
        File settingsFile = layer(e).
139
                file(rootFolder + "/Components/" + id + ".settings").
140
                contents(settingsFile(e));
141
        settingsFile.write();
142
143
        File modeFile = layer(e).
144
                file(rootFolder + "/Modes/" + reg.mode() + "/" + id + ".wstcref").
145
                position(reg.position()).
146
                contents(modeFile(info.preferredID(), reg.openAtStartup()));
147
        modeFile.write();
148
    }
149
129
    private Description findInfo(Element e) throws LayerGenerationException {
150
    private Description findInfo(Element e) throws LayerGenerationException {
130
        Element type;
151
        Element type;
131
        switch (e.asType().getKind()) {
152
        switch (e.asType().getKind()) {
(-)a/openide.windows/src/org/openide/windows/TopComponent.java (-3 / +3 lines)
Lines 1428-1438 Link Here
1428
        /** Shall the component be opened at start */
1428
        /** Shall the component be opened at start */
1429
        boolean openAtStartup();
1429
        boolean openAtStartup();
1430
        /** 
1430
        /** 
1431
         * Window layout role or an empty string for the default layout 
1431
         * Window layout roles or no roles for the default layout
1432
         * @see WindowManager#setRole(java.lang.String) 
1432
         * @see WindowManager#setRole(java.lang.String) 
1433
         * @since 6.45
1433
         * @since 6.47
1434
         */
1434
         */
1435
        String role() default "";
1435
        String[] roles() default {};
1436
    }
1436
    }
1437
    
1437
    
1438
    /** Creates an action that can open the component.
1438
    /** Creates an action that can open the component.
(-)a/openide.windows/test/unit/src/org/netbeans/modules/openide/windows/TopComponentProcessorTest.java (-5 / +7 lines)
Lines 72-82 Link Here
72
    }
72
    }
73
73
74
    public void testTCRegisteredInRoleFine() throws Exception {
74
    public void testTCRegisteredInRoleFine() throws Exception {
75
        FileObject set = FileUtil.getConfigFile("Windows2/Roles/UnitTestRole/Components/my-tc2.settings");
75
        FileObject set1 = FileUtil.getConfigFile("Windows2/Roles/UnitTestRole1/Components/my-tc2.settings");
76
        assertNotNull("Settings file found", set);
76
        assertNotNull("Settings file found", set1);
77
        assertValidate(set.asText());
77
        assertValidate(set1.asText());
78
        FileObject set2 = FileUtil.getConfigFile("Windows2/Roles/UnitTestRole2/Components/my-tc2.settings");
79
        assertNotNull("Settings file found", set2);
78
    }
80
    }
79
81
    
80
    public void testTCRegisteredFine() throws Exception {
82
    public void testTCRegisteredFine() throws Exception {
81
        FileObject set = FileUtil.getConfigFile("Windows2/Components/my-tc.settings");
83
        FileObject set = FileUtil.getConfigFile("Windows2/Components/my-tc.settings");
82
        assertNotNull("Settings file found", set);
84
        assertNotNull("Settings file found", set);
Lines 169-175 Link Here
169
    @TopComponent.Registration(
171
    @TopComponent.Registration(
170
        mode="output",
172
        mode="output",
171
        openAtStartup=false,
173
        openAtStartup=false,
172
        role="UnitTestRole"
174
        roles={"UnitTestRole1", "UnitTestRole2"}
173
    )
175
    )
174
    @TopComponent.Description(
176
    @TopComponent.Description(
175
        preferredID="my-tc2", iconBase="org/openide/windows/Icon.png"
177
        preferredID="my-tc2", iconBase="org/openide/windows/Icon.png"

Return to bug 203553