summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Wouters2014-03-25 10:14:26 (EDT)
committerLaurent Wouters2014-03-25 10:16:46 (EDT)
commit210fa20c99b8f172e936fc1e74ab1a5e30c0076b (patch)
tree3aba43550bea87d660f156ea6c305adcee8a289a
parent1ccfec07a10987a0a2f0b90bc20d69a0fe7c5aaf (diff)
downloadorg.eclipse.papyrus-210fa20c99b8f172e936fc1e74ab1a5e30c0076b.zip
org.eclipse.papyrus-210fa20c99b8f172e936fc1e74ab1a5e30c0076b.tar.gz
org.eclipse.papyrus-210fa20c99b8f172e936fc1e74ab1a5e30c0076b.tar.bz2
#430703: [Model Explorer] NPE throw when an invalid diagram is added to the model
Solved remaining issues with the new model wizard https://bugs.eclipse.org/bugs/show_bug.cgi?id=430703 Signed-off-by: Laurent Wouters <laurent.wouters@cea.fr>
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/builtin/default.configuration4
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototype.java28
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototypeContentProvider.java8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/kind/DiagramKindContentProvider.java21
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramCategoryPage.java3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramKindPage.java1
6 files changed, 44 insertions, 21 deletions
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/builtin/default.configuration b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/builtin/default.configuration
index 98e319f..638f82c 100755
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/builtin/default.configuration
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/builtin/default.configuration
@@ -347,7 +347,7 @@
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//NamedElement"/>
</owningRules>
</modelKinds>
- <modelKinds xsi:type="configuration:PapyrusSyncTable" name="Allocation Table" icon="platform:/plugin/org.eclipse.papyrus.sysml.nattable.allocation.config/icons/table_SysML_Allocation.png" implementationID="PapyrusSysMLAllocationTable" categories="//@categories.1">
+ <modelKinds xsi:type="configuration:PapyrusSyncTable" name="SysML Allocation Table" icon="platform:/plugin/org.eclipse.papyrus.sysml.nattable.allocation.config/icons/table_SysML_Allocation.png" implementationID="PapyrusSysMLAllocationTable" categories="//@categories.1">
<profiles href="http://www.eclipse.org/papyrus/0.7.0/SysML#//allocations"/>
<modelRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Package"/>
@@ -356,7 +356,7 @@
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Package"/>
</owningRules>
</modelKinds>
- <modelKinds xsi:type="configuration:PapyrusSyncTable" name="Requirement Table" icon="platform:/plugin/org.eclipse.papyrus.sysml.nattable.requirement.config/icons/table_SysML_Requirement.png" implementationID="PapyrusSysMLRequirementTable" categories="//@categories.1">
+ <modelKinds xsi:type="configuration:PapyrusSyncTable" name="SysML Requirement Table" icon="platform:/plugin/org.eclipse.papyrus.sysml.nattable.requirement.config/icons/table_SysML_Requirement.png" implementationID="PapyrusSysMLRequirementTable" categories="//@categories.1">
<profiles href="http://www.eclipse.org/papyrus/0.7.0/SysML#//requirements"/>
<modelRules>
<element href="http://www.eclipse.org/uml2/5.0.0/UML#//Package"/>
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototype.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototype.java
index 1d35e6f..5ba6e8c 100755
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototype.java
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototype.java
@@ -18,6 +18,8 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -430,11 +432,33 @@ public abstract class ViewPrototype {
* @author Laurent Wouters
*/
public static class Comp implements Comparator<ViewPrototype> {
+ private static final Map<Class<? extends PapyrusView>, Integer> priorities = new HashMap<Class<? extends PapyrusView>, Integer>();
+ {
+ priorities.put(PapyrusDiagram.class, 1);
+ priorities.put(PapyrusTable.class, 2);
+ priorities.put(PapyrusSyncTable.class, 3);
+ }
+
+ private static Integer getPriority(ViewPrototype proto) {
+ for (Map.Entry<Class<? extends PapyrusView>, Integer> entry : priorities.entrySet()) {
+ if (entry.getKey().isAssignableFrom(proto.configuration.getClass())) {
+ return entry.getValue();
+ }
+ }
+ return 0;
+ }
+
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
- public int compare(ViewPrototype arg0, ViewPrototype arg1) {
- return (arg0.getLabel().compareTo(arg1.getLabel()));
+ public int compare(ViewPrototype proto1, ViewPrototype proto2) {
+ Integer p1 = getPriority(proto1);
+ Integer p2 = getPriority(proto2);
+ if (p1 == p2) {
+ return (proto1.getLabel().compareTo(proto2.getLabel()));
+ } else {
+ return p1.compareTo(p2);
+ }
}
}
}
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototypeContentProvider.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototypeContentProvider.java
index a12c267..fd99c56 100755
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototypeContentProvider.java
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototypeContentProvider.java
@@ -16,6 +16,7 @@ package org.eclipse.papyrus.infra.viewpoints.policy;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -218,8 +219,11 @@ public class ViewPrototypeContentProvider implements ITreeContentProvider {
public Object[] getChildren(Object element) {
if (element == treeRoot)
return categories.toArray();
- if (element instanceof Category)
- return views.get((Category) element).toArray();
+ if (element instanceof Category) {
+ List<ViewPrototype> protos = new ArrayList<ViewPrototype>(views.get((Category) element));
+ Collections.sort(protos, new ViewPrototype.Comp());
+ return protos.toArray();
+ }
if (element instanceof ViewPrototype)
return getChildren((ViewPrototype) element);
return new Object[0];
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/kind/DiagramKindContentProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/kind/DiagramKindContentProvider.java
index 38d71b6..da9ffb5 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/kind/DiagramKindContentProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/kind/DiagramKindContentProvider.java
@@ -16,7 +16,6 @@ package org.eclipse.papyrus.uml.diagram.wizards.kind;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -98,12 +97,7 @@ public class DiagramKindContentProvider implements IStructuredContentProvider {
result.addAll(getPrototypes(diagramCategory));
}
}
- Collections.sort(result, new Comparator<ViewPrototype>() {
-
- public int compare(ViewPrototype o1, ViewPrototype o2) {
- return o1.getLabel().compareTo(o2.getLabel());
- }
- });
+ Collections.sort(result, new ViewPrototype.Comp());
return result.toArray(new Object[result.size()]);
}
if(inputElement instanceof String) {
@@ -122,12 +116,13 @@ public class DiagramKindContentProvider implements IStructuredContentProvider {
*/
protected List<ViewPrototype> getPrototypes(String diagramCategory) {
List<ViewPrototype> result = new ArrayList<ViewPrototype>();
- if (!prototypes.containsKey(diagramCategory))
- return result;
- EClass rootType = getExpectedRootType(diagramCategory);
- for(ViewPrototype proto : prototypes.get(diagramCategory))
- if (isAllowedOn(proto, rootType))
- result.add(proto);
+ // Add the category-specific views
+ if (prototypes.containsKey(diagramCategory)) {
+ EClass rootType = getExpectedRootType(diagramCategory);
+ for (ViewPrototype proto : prototypes.get(diagramCategory))
+ if (isAllowedOn(proto, rootType))
+ result.add(proto);
+ }
return result;
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramCategoryPage.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramCategoryPage.java
index 964b676..f584904 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramCategoryPage.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramCategoryPage.java
@@ -274,7 +274,8 @@ public class SelectDiagramCategoryPage extends WizardPage {
*/
protected void diagramCategorySelected(String category, boolean checked) {
if(checked) {
- mySelectedDiagramCategoryIds.add(category);
+ if (!mySelectedDiagramCategoryIds.contains(category))
+ mySelectedDiagramCategoryIds.add(category);
} else {
mySelectedDiagramCategoryIds.remove(category);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramKindPage.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramKindPage.java
index 5615125..82f4c04 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramKindPage.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramKindPage.java
@@ -473,7 +473,6 @@ public class SelectDiagramKindPage extends WizardPage {
*/
protected ViewPrototype[] getSelectedPrototypes() {
Object[] checked = diagramKindTableViewer.getCheckedElements();
- // as Object is not a subclass of String we cannot cast Object[] to String[]
ViewPrototype[] result = Arrays.asList(checked).toArray(new ViewPrototype[checked.length]);
return result;
}