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 (-1 / +2 lines)
Lines 60-66 Link Here
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 (-3 / +12 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 86-95 Link Here
86
                throw new LayerGenerationException("Cannot find TopComponent.Description for this element", e, processingEnv, reg);
88
                throw new LayerGenerationException("Cannot find TopComponent.Description for this element", e, processingEnv, reg);
87
            }
89
            }
88
            String id = info.preferredID().replace('.', '-');
90
            String id = info.preferredID().replace('.', '-');
89
            
91
            List<String> uniqueRolesList = new ArrayList<String>();
90
            String role = reg.role();
92
            String[] roles = reg.roles();
93
            for (String role : roles){
91
            String rootFolder = role.isEmpty() ? "Windows2" : "Windows2/Roles/" + role;
94
            String rootFolder = role.isEmpty() ? "Windows2" : "Windows2/Roles/" + role;
92
95
            if(!uniqueRolesList.contains(role)){
96
                uniqueRolesList.add(role);
97
            } else {
98
                throw new LayerGenerationException("Duplicate role name found", e, processingEnv, reg);
99
            }
100
           
93
            File settingsFile = layer(e).
101
            File settingsFile = layer(e).
94
                file(rootFolder+"/Components/" + id + ".settings").
102
                file(rootFolder+"/Components/" + id + ".settings").
95
                contents(settingsFile(e));
103
                contents(settingsFile(e));
Lines 101-106 Link Here
101
                contents(modeFile(info.preferredID(), reg.openAtStartup()));
109
                contents(modeFile(info.preferredID(), reg.openAtStartup()));
102
            modeFile.write();
110
            modeFile.write();
103
        }
111
        }
112
        }
104
        
113
        
105
        for (Element e : roundEnv.getElementsAnnotatedWith(TopComponent.OpenActionRegistration.class)) {
114
        for (Element e : roundEnv.getElementsAnnotatedWith(TopComponent.OpenActionRegistration.class)) {
106
            TopComponent.OpenActionRegistration reg = e.getAnnotation(TopComponent.OpenActionRegistration.class);
115
            TopComponent.OpenActionRegistration reg = e.getAnnotation(TopComponent.OpenActionRegistration.class);
(-)a/openide.windows/src/org/openide/windows/TopComponent.java (-2 / +2 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 an empty string 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.45
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