--- a/openide.windows/apichanges.xml Wed Oct 12 12:15:11 2011 +0200
+++ a/openide.windows/apichanges.xml Wed Oct 12 16:10:29 2011 +0200
@@ -60,7 +60,8 @@
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.
--- a/openide.windows/manifest.mf Wed Oct 12 12:15:11 2011 +0200
+++ a/openide.windows/manifest.mf Wed Oct 12 16:10:29 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
--- a/openide.windows/src/org/netbeans/modules/openide/windows/TopComponentProcessor.java Wed Oct 12 12:15:11 2011 +0200
+++ a/openide.windows/src/org/netbeans/modules/openide/windows/TopComponentProcessor.java Wed Oct 12 16:10:29 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;
@@ -86,10 +88,16 @@
throw new LayerGenerationException("Cannot find TopComponent.Description for this element", e, processingEnv, reg);
}
String id = info.preferredID().replace('.', '-');
-
- String role = reg.role();
+ List uniqueRolesList = new ArrayList();
+ String[] roles = reg.roles();
+ for (String role : roles){
String rootFolder = role.isEmpty() ? "Windows2" : "Windows2/Roles/" + role;
-
+ if(!uniqueRolesList.contains(role)){
+ uniqueRolesList.add(role);
+ } else {
+ throw new LayerGenerationException("Duplicate role name found", e, processingEnv, reg);
+ }
+
File settingsFile = layer(e).
file(rootFolder+"/Components/" + id + ".settings").
contents(settingsFile(e));
@@ -101,6 +109,7 @@
contents(modeFile(info.preferredID(), reg.openAtStartup()));
modeFile.write();
}
+ }
for (Element e : roundEnv.getElementsAnnotatedWith(TopComponent.OpenActionRegistration.class)) {
TopComponent.OpenActionRegistration reg = e.getAnnotation(TopComponent.OpenActionRegistration.class);
--- a/openide.windows/src/org/openide/windows/TopComponent.java Wed Oct 12 12:15:11 2011 +0200
+++ a/openide.windows/src/org/openide/windows/TopComponent.java Wed Oct 12 16:10:29 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 an empty string for the default layout
* @see WindowManager#setRole(java.lang.String)
* @since 6.45
*/
- String role() default "";
+ String[] roles() default "";
}
/** Creates an action that can open the component.
--- a/openide.windows/test/unit/src/org/netbeans/modules/openide/windows/TopComponentProcessorTest.java Wed Oct 12 12:15:11 2011 +0200
+++ a/openide.windows/test/unit/src/org/netbeans/modules/openide/windows/TopComponentProcessorTest.java Wed Oct 12 16:10:29 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"