summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Drossel2009-01-20 11:17:56 (EST)
committerCarsten Drossel2009-01-20 11:17:56 (EST)
commit80d27d93b6fa71d61e6dbb4a8d45d1a55d244771 (patch)
tree402aae549f1b7a0e1a881740ab36c25f1b941fd1
parentb0e77141f9db0b0d17d590aecd5aad06478ae438 (diff)
downloadorg.eclipse.riena-80d27d93b6fa71d61e6dbb4a8d45d1a55d244771.zip
org.eclipse.riena-80d27d93b6fa71d61e6dbb4a8d45d1a55d244771.tar.gz
org.eclipse.riena-80d27d93b6fa71d61e6dbb4a8d45d1a55d244771.tar.bz2
consistent checking for inconsistent workarea definitions in all workarea definiton registries
-rw-r--r--org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/internal/navigation/ui/swt/workarea/SwtExtensionWorkareaDefinitionRegistry.java44
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/internal/navigation/ui/swt/workarea/SwtExtensionWorkareaDefinitionRegistryTest.java28
-rw-r--r--org.eclipse.riena.ui.workarea/src/org/eclipse/riena/internal/ui/workarea/registry/ExplicitWorkareaDefinitionRegistry.java20
-rw-r--r--org.eclipse.riena.ui.workarea/src/org/eclipse/riena/internal/ui/workarea/registry/WorkareaDefinitionRegistryFacade.java9
-rw-r--r--org.eclipse.riena.ui.workarea/src/org/eclipse/riena/ui/workarea/WorkareaManager.java2
-rw-r--r--org.eclipse.riena.ui.workarea/src/org/eclipse/riena/ui/workarea/spi/AbstractWorkareaDefinitionRegistry.java58
-rw-r--r--org.eclipse.riena.ui.workarea/src/org/eclipse/riena/ui/workarea/spi/IWorkareaDefinitionRegistry.java12
7 files changed, 94 insertions, 79 deletions
diff --git a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/internal/navigation/ui/swt/workarea/SwtExtensionWorkareaDefinitionRegistry.java b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/internal/navigation/ui/swt/workarea/SwtExtensionWorkareaDefinitionRegistry.java
index 6c6b13c..a12f438 100644
--- a/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/internal/navigation/ui/swt/workarea/SwtExtensionWorkareaDefinitionRegistry.java
+++ b/org.eclipse.riena.navigation.ui.swt/src/org/eclipse/riena/internal/navigation/ui/swt/workarea/SwtExtensionWorkareaDefinitionRegistry.java
@@ -10,56 +10,16 @@
*******************************************************************************/
package org.eclipse.riena.internal.navigation.ui.swt.workarea;
-import java.util.HashMap;
-import java.util.Map;
-
import org.eclipse.riena.navigation.IModuleGroupNodeExtension;
import org.eclipse.riena.navigation.IModuleNodeExtension;
import org.eclipse.riena.navigation.INavigationAssemblyExtension;
import org.eclipse.riena.navigation.ISubApplicationNodeExtension;
import org.eclipse.riena.navigation.ISubModuleNodeExtension;
-import org.eclipse.riena.navigation.model.ExtensionPointFailure;
import org.eclipse.riena.ui.workarea.IWorkareaDefinition;
import org.eclipse.riena.ui.workarea.WorkareaDefinition;
-import org.eclipse.riena.ui.workarea.spi.IWorkareaDefinitionRegistry;
-
-public class SwtExtensionWorkareaDefinitionRegistry implements IWorkareaDefinitionRegistry {
-
- private Map<Object, IWorkareaDefinition> workareas = new HashMap<Object, IWorkareaDefinition>();
-
- public SwtExtensionWorkareaDefinitionRegistry() {
- }
-
- public IWorkareaDefinition getDefinition(Object id) {
-
- return workareas.get(id);
- }
-
- public IWorkareaDefinition register(Object id, IWorkareaDefinition definition) {
+import org.eclipse.riena.ui.workarea.spi.AbstractWorkareaDefinitionRegistry;
- if (getDefinition(id) != null) {
- IWorkareaDefinition existingDefinition = getDefinition(id);
- if (!existingDefinition.getControllerClass().equals(definition.getControllerClass())) {
- throw new ExtensionPointFailure(
- "Inconsistent workarea definition: a definition for submodules with typeId=\"" + id //$NON-NLS-1$
- + "\" already exists and it has a different controller (class " //$NON-NLS-1$
- + existingDefinition.getControllerClass().getSimpleName() + " instead of " //$NON-NLS-1$
- + definition.getControllerClass().getSimpleName() + ")."); //$NON-NLS-1$
- }
- if (!existingDefinition.getViewId().equals(definition.getViewId())) {
- throw new ExtensionPointFailure(
- "Inconsistent workarea definition: a definition for submodules with typeId=\"" + id //$NON-NLS-1$
- + "\" already exists and it has a different view (" + existingDefinition.getViewId() //$NON-NLS-1$
- + " instead of " + definition.getViewId() + ")."); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (existingDefinition.isViewShared() != definition.isViewShared()) {
- throw new ExtensionPointFailure(
- "Inconsistent workarea definition: a definition for submodules with typeId=\"" + id //$NON-NLS-1$
- + "\" already exists and it has a different shared value."); //$NON-NLS-1$
- }
- }
- return workareas.put(id, definition);
- }
+public class SwtExtensionWorkareaDefinitionRegistry extends AbstractWorkareaDefinitionRegistry {
public void update(INavigationAssemblyExtension[] data) {
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/navigation/ui/swt/workarea/SwtExtensionWorkareaDefinitionRegistryTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/navigation/ui/swt/workarea/SwtExtensionWorkareaDefinitionRegistryTest.java
index e2e6e55..f55ab25 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/navigation/ui/swt/workarea/SwtExtensionWorkareaDefinitionRegistryTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/navigation/ui/swt/workarea/SwtExtensionWorkareaDefinitionRegistryTest.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.riena.internal.navigation.ui.swt.workarea;
-import org.eclipse.riena.navigation.model.ExtensionPointFailure;
+import org.eclipse.riena.navigation.ApplicationModelFailure;
import org.eclipse.riena.navigation.ui.controllers.SubModuleController;
import org.eclipse.riena.tests.RienaTestCase;
import org.eclipse.riena.tests.collect.NonUITestCase;
@@ -43,7 +43,6 @@ public class SwtExtensionWorkareaDefinitionRegistryTest extends RienaTestCase {
workareaDefinition = new WorkareaDefinition(TestSubModuleController.class, TEST_VIEW_ID, TEST_IS_VIEW_SHARED);
}
- @SuppressWarnings("restriction")
public void testRegisterDefinition() throws Exception {
workareaDefinitionRegistry.register(TEST_TYPE_ID, workareaDefinition);
@@ -51,7 +50,6 @@ public class SwtExtensionWorkareaDefinitionRegistryTest extends RienaTestCase {
assertSame(workareaDefinition, workareaDefinitionRegistry.getDefinition(TEST_TYPE_ID));
}
- @SuppressWarnings("restriction")
public void testRegisterSameDefinitionDifferentTypeId() throws Exception {
workareaDefinitionRegistry.register(TEST_TYPE_ID, workareaDefinition);
@@ -64,7 +62,6 @@ public class SwtExtensionWorkareaDefinitionRegistryTest extends RienaTestCase {
assertSame(otherWorkareaDefinition, workareaDefinitionRegistry.getDefinition(OTHER_TEST_TYPE_ID));
}
- @SuppressWarnings("restriction")
public void testRegisterSameDefinitionSameTypeId() throws Exception {
workareaDefinitionRegistry.register(TEST_TYPE_ID, workareaDefinition);
@@ -73,11 +70,10 @@ public class SwtExtensionWorkareaDefinitionRegistryTest extends RienaTestCase {
TEST_VIEW_ID, TEST_IS_VIEW_SHARED);
workareaDefinitionRegistry.register(TEST_TYPE_ID, otherWorkareaDefinition);
- assertSame(otherWorkareaDefinition, workareaDefinitionRegistry.getDefinition(TEST_TYPE_ID));
- assertNotSame(workareaDefinition, workareaDefinitionRegistry.getDefinition(TEST_TYPE_ID));
+ assertSame(workareaDefinition, workareaDefinitionRegistry.getDefinition(TEST_TYPE_ID));
+ assertNotSame(otherWorkareaDefinition, workareaDefinitionRegistry.getDefinition(TEST_TYPE_ID));
}
- @SuppressWarnings("restriction")
public void testRegisterDifferentDefinitionSameTypeId() throws Exception {
workareaDefinitionRegistry.register(TEST_TYPE_ID, workareaDefinition);
@@ -87,27 +83,27 @@ public class SwtExtensionWorkareaDefinitionRegistryTest extends RienaTestCase {
otherWorkareaDefinition = new WorkareaDefinition(OtherTestSubModuleController.class, TEST_VIEW_ID,
TEST_IS_VIEW_SHARED);
workareaDefinitionRegistry.register(TEST_TYPE_ID, otherWorkareaDefinition);
- fail("ExtensionPointFailure expected");
- } catch (ExtensionPointFailure expected) {
- ok("ExtensionPointFailure expected");
+ fail("ApplicationModelFailure expected");
+ } catch (ApplicationModelFailure expected) {
+ ok("ApplicationModelFailure expected");
}
try {
otherWorkareaDefinition = new WorkareaDefinition(TestSubModuleController.class, OTHER_TEST_VIEW_ID,
TEST_IS_VIEW_SHARED);
workareaDefinitionRegistry.register(TEST_TYPE_ID, otherWorkareaDefinition);
- fail("ExtensionPointFailure expected");
- } catch (ExtensionPointFailure expected) {
- ok("ExtensionPointFailure expected");
+ fail("ApplicationModelFailure expected");
+ } catch (ApplicationModelFailure expected) {
+ ok("ApplicationModelFailure expected");
}
try {
otherWorkareaDefinition = new WorkareaDefinition(TestSubModuleController.class, TEST_VIEW_ID,
OTHER_TEST_IS_VIEW_SHARED);
workareaDefinitionRegistry.register(TEST_TYPE_ID, otherWorkareaDefinition);
- fail("ExtensionPointFailure expected");
- } catch (ExtensionPointFailure expected) {
- ok("ExtensionPointFailure expected");
+ fail("ApplicationModelFailure expected");
+ } catch (ApplicationModelFailure expected) {
+ ok("ApplicationModelFailure expected");
}
}
diff --git a/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/internal/ui/workarea/registry/ExplicitWorkareaDefinitionRegistry.java b/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/internal/ui/workarea/registry/ExplicitWorkareaDefinitionRegistry.java
index 436dc4d..94ff710 100644
--- a/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/internal/ui/workarea/registry/ExplicitWorkareaDefinitionRegistry.java
+++ b/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/internal/ui/workarea/registry/ExplicitWorkareaDefinitionRegistry.java
@@ -10,37 +10,27 @@
*******************************************************************************/
package org.eclipse.riena.internal.ui.workarea.registry;
-import java.util.HashMap;
-import java.util.Map;
-
import org.eclipse.riena.navigation.INavigationNode;
import org.eclipse.riena.ui.workarea.IWorkareaDefinition;
-import org.eclipse.riena.ui.workarea.spi.IWorkareaDefinitionRegistry;
-
-class ExplicitWorkareaDefinitionRegistry implements IWorkareaDefinitionRegistry {
+import org.eclipse.riena.ui.workarea.spi.AbstractWorkareaDefinitionRegistry;
- private static final ExplicitWorkareaDefinitionRegistry instance = new ExplicitWorkareaDefinitionRegistry();
+final class ExplicitWorkareaDefinitionRegistry extends AbstractWorkareaDefinitionRegistry {
- private Map<Object, IWorkareaDefinition> workareas = new HashMap<Object, IWorkareaDefinition>();
+ private static final ExplicitWorkareaDefinitionRegistry INSTANCE = new ExplicitWorkareaDefinitionRegistry();
static ExplicitWorkareaDefinitionRegistry getInstance() {
- return instance;
+ return INSTANCE;
}
private ExplicitWorkareaDefinitionRegistry() {
}
- public IWorkareaDefinition getDefinition(Object id) {
-
- return workareas.get(id);
- }
-
public IWorkareaDefinition register(Object id, IWorkareaDefinition definition) {
if (id instanceof INavigationNode) {
return registerDefinition((INavigationNode<?>) id, definition);
} else {
- return workareas.put(id, definition);
+ return super.register(id, definition);
}
}
diff --git a/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/internal/ui/workarea/registry/WorkareaDefinitionRegistryFacade.java b/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/internal/ui/workarea/registry/WorkareaDefinitionRegistryFacade.java
index acc91f5..9c329ee 100644
--- a/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/internal/ui/workarea/registry/WorkareaDefinitionRegistryFacade.java
+++ b/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/internal/ui/workarea/registry/WorkareaDefinitionRegistryFacade.java
@@ -25,14 +25,14 @@ import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTrackerCustomizer;
-public class WorkareaDefinitionRegistryFacade implements IWorkareaDefinitionRegistry, ServiceTrackerCustomizer {
+public final class WorkareaDefinitionRegistryFacade implements IWorkareaDefinitionRegistry, ServiceTrackerCustomizer {
- private static final WorkareaDefinitionRegistryFacade instance = new WorkareaDefinitionRegistryFacade();
+ private static final WorkareaDefinitionRegistryFacade INSTANCE = new WorkareaDefinitionRegistryFacade();
private SortedSet<WorkareaDefinitionRegistryWithRank> contributedRegistries;
public static WorkareaDefinitionRegistryFacade getInstance() {
- return instance;
+ return INSTANCE;
}
private WorkareaDefinitionRegistryFacade() {
@@ -197,8 +197,9 @@ public class WorkareaDefinitionRegistryFacade implements IWorkareaDefinitionRegi
*/
public int compareTo(WorkareaDefinitionRegistryWithRank other) {
- if (this.getRanking() != other.getRanking())
+ if (this.getRanking() != other.getRanking()) {
return this.getRanking() > other.getRanking() ? -1 : 1;
+ }
return 0;
}
diff --git a/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/ui/workarea/WorkareaManager.java b/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/ui/workarea/WorkareaManager.java
index c0fb439..22af7af 100644
--- a/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/ui/workarea/WorkareaManager.java
+++ b/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/ui/workarea/WorkareaManager.java
@@ -14,7 +14,7 @@ import org.eclipse.riena.internal.ui.workarea.registry.WorkareaDefinitionRegistr
import org.eclipse.riena.navigation.INavigationNode;
import org.eclipse.riena.ui.ridgets.controller.IController;
-public class WorkareaManager {
+public final class WorkareaManager {
static private WorkareaManager instance = new WorkareaManager();
diff --git a/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/ui/workarea/spi/AbstractWorkareaDefinitionRegistry.java b/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/ui/workarea/spi/AbstractWorkareaDefinitionRegistry.java
new file mode 100644
index 0000000..f956217
--- /dev/null
+++ b/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/ui/workarea/spi/AbstractWorkareaDefinitionRegistry.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.ui.workarea.spi;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.riena.navigation.ApplicationModelFailure;
+import org.eclipse.riena.ui.workarea.IWorkareaDefinition;
+
+public abstract class AbstractWorkareaDefinitionRegistry implements IWorkareaDefinitionRegistry {
+
+ protected Map<Object, IWorkareaDefinition> workareas = new HashMap<Object, IWorkareaDefinition>();
+
+ public IWorkareaDefinition getDefinition(Object id) {
+ return workareas.get(id);
+ }
+
+ public IWorkareaDefinition register(Object id, IWorkareaDefinition definition) {
+ if (getDefinition(id) != null) {
+ IWorkareaDefinition existingDefinition = getDefinition(id);
+ if ((existingDefinition.getControllerClass() == null && definition.getControllerClass() != null)
+ || (existingDefinition.getControllerClass() != null && !existingDefinition.getControllerClass()
+ .equals(definition.getControllerClass()))) {
+ throw new ApplicationModelFailure(
+ "Inconsistent workarea definition: a definition for submodules with typeId=\"" + id //$NON-NLS-1$
+ + "\" already exists and it has a different controller (class " //$NON-NLS-1$
+ + existingDefinition.getControllerClass() + " instead of " //$NON-NLS-1$
+ + definition.getControllerClass() + ")."); //$NON-NLS-1$
+ }
+ if ((existingDefinition.getViewId() == null && definition.getViewId() != null)
+ || (existingDefinition.getViewId() != null && !existingDefinition.getViewId().equals(
+ definition.getViewId()))) {
+ throw new ApplicationModelFailure(
+ "Inconsistent workarea definition: a definition for submodules with typeId=\"" + id //$NON-NLS-1$
+ + "\" already exists and it has a different view (" + existingDefinition.getViewId() //$NON-NLS-1$
+ + " instead of " + definition.getViewId() + ")."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ if (existingDefinition.isViewShared() != definition.isViewShared()) {
+ throw new ApplicationModelFailure(
+ "Inconsistent workarea definition: a definition for submodules with typeId=\"" + id //$NON-NLS-1$
+ + "\" already exists and it has a different shared value."); //$NON-NLS-1$
+ }
+ return existingDefinition;
+ }
+ workareas.put(id, definition);
+ return definition;
+ }
+
+}
diff --git a/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/ui/workarea/spi/IWorkareaDefinitionRegistry.java b/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/ui/workarea/spi/IWorkareaDefinitionRegistry.java
index b99b876..037a707 100644
--- a/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/ui/workarea/spi/IWorkareaDefinitionRegistry.java
+++ b/org.eclipse.riena.ui.workarea/src/org/eclipse/riena/ui/workarea/spi/IWorkareaDefinitionRegistry.java
@@ -15,6 +15,16 @@ import org.eclipse.riena.ui.workarea.IWorkareaDefinition;
public interface IWorkareaDefinitionRegistry {
IWorkareaDefinition getDefinition(Object id);
-
+
+ /**
+ * Registers the specified workarea definition with the specified typeId.
+ *
+ * @param id
+ * The typeId.
+ * @param definition
+ * A workarea definition.
+ * @return The registered workarea definition or null, if the workarea
+ * definition could not be registered by this registry.
+ */
IWorkareaDefinition register(Object id, IWorkareaDefinition definition);
}