Skip to content
Snippets Groups Projects
Commit 26886f99 authored by Alberto Debiasi's avatar Alberto Debiasi
Browse files

Add checker to allow only createion of supported diagrams.

Change-Id: I03e7404283ea6c10f43baec9bd578295767626e7
parent 6a1a896f
No related branches found
No related tags found
No related merge requests found
......@@ -17,4 +17,7 @@ public class PreferenceProperties {
/** The palettes in view. */
public static String PALETTES_IN_VIEW="PaletteInView";
/** Supported Diagrams. */
public static String SUPPORTED_DIAGRAM="SupportedDiagram";
}
......@@ -43,6 +43,7 @@ public class ConstraintPreferenceInitializer extends AbstractPreferenceInitializ
store.setDefault(PreferenceProperties.DIAGRAM_IN_VIEW, true);
store.setDefault(PreferenceProperties.PALETTES_IN_VIEW, true);
store.setDefault(PreferenceProperties.SUPPORTED_DIAGRAM, true);
}
}
......@@ -80,6 +80,10 @@ public class ConstraintPreferencePage extends FieldEditorPreferencePage implemen
"Hide Diagram Palettes according to the current CHESS views", BooleanFieldEditor.SEPARATE_LABEL,
getFieldEditorParent());
addField(b2);
BooleanFieldEditor b3 = new BooleanFieldEditor(PreferenceProperties.SUPPORTED_DIAGRAM,
"Allow the creation of supported-only diagrams", BooleanFieldEditor.SEPARATE_LABEL,
getFieldEditorParent());
addField(b3);
}
/*
......
......@@ -16,6 +16,9 @@
package org.polarsys.chess.validator.managers;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.transaction.RollbackException;
......@@ -36,6 +39,8 @@ import org.polarsys.chess.validator.messages.Messages;
*/
public class DiagramChecker {
Set<String> supportedDiagrams = new HashSet<String>(Arrays.asList("BlockDefinition","RequirementDiagram","InternalBlock","StateMachine"));
/** The class diagram kind. */
public static String classDiagramKind = "PapyrusUMLClassDiagram";
......@@ -70,9 +75,23 @@ public class DiagramChecker {
public void check(Diagram diagram, StringBuffer s, DesignView currentView, TransactionalEditingDomain domain)
throws RollbackException {
Boolean checkDiagramType = org.polarsys.chess.core.Activator.getDefault().getPreferenceStore()
.getBoolean(PreferenceProperties.SUPPORTED_DIAGRAM);
if(checkDiagramType){
if (!hasSupportedType(diagram)) {
s.append(Messages.error_diagramSupportType);
throw new RollbackException(
new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.error_diagramSupportType));
}
}
Boolean checkDiagramInView = org.polarsys.chess.core.Activator.getDefault().getPreferenceStore()
.getBoolean(PreferenceProperties.DIAGRAM_IN_VIEW);
System.out.println("diagram: "+diagram);
if (checkDiagramInView) {
/*
* @dynamicConstraint D_1 if the diagram is created in the root of
......@@ -98,4 +117,9 @@ public class DiagramChecker {
}
private boolean hasSupportedType(Diagram diagram) {
String diagramType = diagram.getType();
return supportedDiagrams.contains(diagramType);
}
};
\ No newline at end of file
......@@ -33,6 +33,8 @@ public class Messages extends NLS {
/** The error_diagram current view. */
public static String error_diagramCurrentView;
public static String error_diagramSupportType;
/** The Null view msg. */
public static String NullViewMsg;
......
......@@ -7,6 +7,7 @@
#-------------------------------------------------------------------------------
error_diagramInView=Diagrams must be created inside the views
error_diagramCurrentView=This diagram is not allowed in the current view
error_diagramSupportType=This diagram is not supported
NullViewMsg=Can't modify the model outside the views
ModelManager_1=Deleting a view is forbidden.
ViewDeletionMsg=Can't delete view from the model\!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment