diff -r 13c497c2e4c9 openide.windows/apichanges.xml --- a/openide.windows/apichanges.xml Wed Oct 12 12:15:11 2011 +0200 +++ b/openide.windows/apichanges.xml Mon Oct 17 08:59:14 2011 +0200 @@ -54,13 +54,14 @@ Added optional role parameter to TopComponent Registration annotation. - + Since the window system now supports multiple window layouts - roles - the annotation for TopComponent registration needs an optional parameter - to specify the role the window should belong to. + to specify one or more roles the window should belong to. If no roles + are specified, the TopComponent is registered in the default layout. diff -r 13c497c2e4c9 openide.windows/manifest.mf --- a/openide.windows/manifest.mf Wed Oct 12 12:15:11 2011 +0200 +++ b/openide.windows/manifest.mf Mon Oct 17 08:59:14 2011 +0200 @@ -1,6 +1,6 @@ Manifest-Version: 1.0 OpenIDE-Module: org.openide.windows -OpenIDE-Module-Specification-Version: 6.46 +OpenIDE-Module-Specification-Version: 6.47 OpenIDE-Module-Localizing-Bundle: org/openide/windows/Bundle.properties AutoUpdate-Essential-Module: true diff -r 13c497c2e4c9 openide.windows/src/org/netbeans/modules/openide/windows/TopComponentProcessor.java --- a/openide.windows/src/org/netbeans/modules/openide/windows/TopComponentProcessor.java Wed Oct 12 12:15:11 2011 +0200 +++ b/openide.windows/src/org/netbeans/modules/openide/windows/TopComponentProcessor.java Mon Oct 17 08:59:14 2011 +0200 @@ -42,7 +42,9 @@ package org.netbeans.modules.openide.windows; +import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.Set; import javax.annotation.processing.Processor; import javax.annotation.processing.RoundEnvironment; @@ -59,6 +61,7 @@ import org.openide.util.lookup.ServiceProvider; import org.openide.windows.TopComponent; import org.openide.windows.TopComponent.Description; +import org.openide.windows.TopComponent.Registration; @SupportedSourceVersion(SourceVersion.RELEASE_6) @ServiceProvider(service=Processor.class) @@ -86,20 +89,25 @@ throw new LayerGenerationException("Cannot find TopComponent.Description for this element", e, processingEnv, reg); } String id = info.preferredID().replace('.', '-'); - - String role = reg.role(); - String rootFolder = role.isEmpty() ? "Windows2" : "Windows2/Roles/" + role; - File settingsFile = layer(e). - file(rootFolder+"/Components/" + id + ".settings"). - contents(settingsFile(e)); - settingsFile.write(); - - File modeFile = layer(e). - file(rootFolder+"/Modes/" + reg.mode() + "/" + id + ".wstcref"). - position(reg.position()). - contents(modeFile(info.preferredID(), reg.openAtStartup())); - modeFile.write(); + String rootFolder; + String[] roles = reg.roles(); + if (roles.length == 0) { + rootFolder = "Windows2"; + generateSettingsAndWstcref(e, rootFolder, id, reg, info); + } else { + Set uniqueRoles = new HashSet(); + for (String role : roles) { + if (!uniqueRoles.add(role)) { + throw new LayerGenerationException("Duplicate role name found", e, processingEnv, reg); + } + if (role.isEmpty()) { + throw new LayerGenerationException("Unnamed role found", e, processingEnv, reg); + } + rootFolder = "Windows2/Roles/" + role; + generateSettingsAndWstcref(e, rootFolder, id, reg, info); + } + } } for (Element e : roundEnv.getElementsAnnotatedWith(TopComponent.OpenActionRegistration.class)) { @@ -126,6 +134,19 @@ return true; } + private void generateSettingsAndWstcref(Element e, String rootFolder, String id, Registration reg, Description info) throws LayerGenerationException { + File settingsFile = layer(e). + file(rootFolder + "/Components/" + id + ".settings"). + contents(settingsFile(e)); + settingsFile.write(); + + File modeFile = layer(e). + file(rootFolder + "/Modes/" + reg.mode() + "/" + id + ".wstcref"). + position(reg.position()). + contents(modeFile(info.preferredID(), reg.openAtStartup())); + modeFile.write(); + } + private Description findInfo(Element e) throws LayerGenerationException { Element type; switch (e.asType().getKind()) { diff -r 13c497c2e4c9 openide.windows/src/org/openide/windows/TopComponent.java --- a/openide.windows/src/org/openide/windows/TopComponent.java Wed Oct 12 12:15:11 2011 +0200 +++ b/openide.windows/src/org/openide/windows/TopComponent.java Mon Oct 17 08:59:14 2011 +0200 @@ -1428,11 +1428,11 @@ /** Shall the component be opened at start */ boolean openAtStartup(); /** - * Window layout role or an empty string for the default layout + * Window layout roles or no roles for the default layout * @see WindowManager#setRole(java.lang.String) - * @since 6.45 + * @since 6.47 */ - String role() default ""; + String[] roles() default {}; } /** Creates an action that can open the component. diff -r 13c497c2e4c9 openide.windows/test/unit/src/org/netbeans/modules/openide/windows/TopComponentProcessorTest.java --- a/openide.windows/test/unit/src/org/netbeans/modules/openide/windows/TopComponentProcessorTest.java Wed Oct 12 12:15:11 2011 +0200 +++ b/openide.windows/test/unit/src/org/netbeans/modules/openide/windows/TopComponentProcessorTest.java Mon Oct 17 08:59:14 2011 +0200 @@ -72,11 +72,13 @@ } public void testTCRegisteredInRoleFine() throws Exception { - FileObject set = FileUtil.getConfigFile("Windows2/Roles/UnitTestRole/Components/my-tc2.settings"); - assertNotNull("Settings file found", set); - assertValidate(set.asText()); + FileObject set1 = FileUtil.getConfigFile("Windows2/Roles/UnitTestRole1/Components/my-tc2.settings"); + assertNotNull("Settings file found", set1); + assertValidate(set1.asText()); + FileObject set2 = FileUtil.getConfigFile("Windows2/Roles/UnitTestRole2/Components/my-tc2.settings"); + assertNotNull("Settings file found", set2); } - + public void testTCRegisteredFine() throws Exception { FileObject set = FileUtil.getConfigFile("Windows2/Components/my-tc.settings"); assertNotNull("Settings file found", set); @@ -169,7 +171,7 @@ @TopComponent.Registration( mode="output", openAtStartup=false, - role="UnitTestRole" + roles={"UnitTestRole1", "UnitTestRole2"} ) @TopComponent.Description( preferredID="my-tc2", iconBase="org/openide/windows/Icon.png"