Skip to content
Snippets Groups Projects
Commit 3e07751c authored by Kevin Kassin's avatar Kevin Kassin
Browse files

#Commit 27.7

implemented Feature Manager that saves when and where to show
paletteentries,
changed way the palette is calculated 
parent 7745386c
Branches
No related tags found
No related merge requests found
Showing
with 296 additions and 132 deletions
package org.framed.iorm.ui.exceptions;
import org.framed.iorm.ui.literals.TextLiterals;
import org.framed.iorm.ui.palette.FeaturePaletteDescriptor;
import org.framed.iorm.ui.providers.ToolBehaviorProvider;
/**
* This exception is thrown when a feature has no {@link FeaturePaletteDescriptor} when the
* {@link ToolBehaviorProvider} builds the palette.
* @author Kevin Kassin
*/
public class FeatureHasNoPaletteDescriptorException extends RuntimeException {
/**
* serial
*/
private static final long serialVersionUID = -1153983811660560751L;
/**
* the exceptions message gathered from {@link TextLiterals}
*/
private static final String FEATURE_HAS_NO_DESCRIPTOR_MESSAGE = TextLiterals.FEATURE_HAS_NO_DESCRIPTOR_MESSAGE;
/**
* Class constructor
*/
public FeatureHasNoPaletteDescriptorException(String featureName) {
super(FEATURE_HAS_NO_DESCRIPTOR_MESSAGE + featureName);
}
}
...@@ -261,14 +261,4 @@ public class IdentifierLiterals { ...@@ -261,14 +261,4 @@ public class IdentifierLiterals {
DIAGRAM_KIND_MAIN_DIAGRAM = "main_diagram", DIAGRAM_KIND_MAIN_DIAGRAM = "main_diagram",
DIAGRAM_KIND_GROUP_DIAGRAM = "group_diagram", DIAGRAM_KIND_GROUP_DIAGRAM = "group_diagram",
DIAGRAM_KIND_COMPARTMENTTYPE_DIAGRAM = "compartment_diagram"; DIAGRAM_KIND_COMPARTMENTTYPE_DIAGRAM = "compartment_diagram";
/**
* identifiers to differ between the editor palettes
* <p>
* can be:<br>
* (1) the palette type used outside a stepped in compartment type or<br>
* (2) the pallete type used in a editor of a diagram of a compartment type
*/
public static final String PALETTE_TYPE_TOPLEVELVIEW = "palette_type_toplevel",
PALETTE_TYPE_COMPARTMENTVIEW = "palette_type_compartment";
} }
...@@ -31,6 +31,20 @@ public class NameLiterals { ...@@ -31,6 +31,20 @@ public class NameLiterals {
STANDARD_DIAGRAM_NAME = "newDiagram", STANDARD_DIAGRAM_NAME = "newDiagram",
CONTAINER_DIAGRAM_NAME = "Container"; CONTAINER_DIAGRAM_NAME = "Container";
/**
* name literals used for the palette categories
* <p>
* can be:<br>
* (1) the name of the palette category of entities (classes and roles)<br>
* (2) the name of the palette category of properties (attributes and operations)<br>
* (3) the name of the palette category of relations (inheritances and relationships)<br>
* (4) the name of the palette category of constraints (role, intra and inter relationship constraints)
*/
public static final String ENTITIES_PALETTE_CATEGORY_NAME = "Entities",
PROPERTIES_PALETTE_CATEGORY_NAME = "Properties",
RELATIONS_PALETTE_CATEGORY_NAME = "Relations",
CONSTRAINTS_PALETTE_CATEGORY_NAME = "Constraints";
/** /**
* standard values for graphiti shape names and cardinalities * standard values for graphiti shape names and cardinalities
* <p> * <p>
......
package org.framed.iorm.ui.literals; package org.framed.iorm.ui.literals;
import org.framed.iorm.ui.exceptions.FeatureModelNotReadableException; //*import for javadoc link import org.framed.iorm.ui.exceptions.*; //*import for javadoc link
import org.framed.iorm.ui.exceptions.NoDiagramFoundException; //*import for javadoc link
import org.framed.iorm.ui.exceptions.NoModelFoundException; //*import for javadoc link
import org.framed.iorm.ui.wizards.RoleModelWizardPage; //*import for javadoc link import org.framed.iorm.ui.wizards.RoleModelWizardPage; //*import for javadoc link
import org.framed.iorm.ui.wizards.RoleModelWizard; //*import for javadoc link import org.framed.iorm.ui.wizards.RoleModelWizard; //*import for javadoc link
import org.eclipse.ui.PartInitException; //*import for javadoc link import org.eclipse.ui.PartInitException; //*import for javadoc link
...@@ -79,6 +77,11 @@ public class TextLiterals { ...@@ -79,6 +77,11 @@ public class TextLiterals {
*/ */
public static final String ERROR_NO_MODEL_FOUND = "A model could not be found!"; public static final String ERROR_NO_MODEL_FOUND = "A model could not be found!";
/**
* the message for the {@link FeatureHasNoPaletteDescriptorException}
*/
public static final String FEATURE_HAS_NO_DESCRIPTOR_MESSAGE = "A Feature has no palette descriptor: ";
/** /**
* messages used in the Eclipse wizards * messages used in the Eclipse wizards
* <p> * <p>
......
...@@ -29,6 +29,7 @@ import org.framed.iorm.ui.exceptions.InvalidTypeOfEditorInputException; ...@@ -29,6 +29,7 @@ import org.framed.iorm.ui.exceptions.InvalidTypeOfEditorInputException;
import org.framed.iorm.ui.literals.IdentifierLiterals; import org.framed.iorm.ui.literals.IdentifierLiterals;
import org.framed.iorm.ui.literals.NameLiterals; import org.framed.iorm.ui.literals.NameLiterals;
import org.framed.iorm.ui.literals.TextLiterals; import org.framed.iorm.ui.literals.TextLiterals;
import org.framed.iorm.ui.palette.PaletteView;
import org.framed.iorm.ui.subeditors.FRaMEDDiagramEditor; import org.framed.iorm.ui.subeditors.FRaMEDDiagramEditor;
import org.framed.iorm.ui.subeditors.FRaMEDFeatureEditor; import org.framed.iorm.ui.subeditors.FRaMEDFeatureEditor;
import org.framed.iorm.ui.subeditors.FRaMEDTextViewer; import org.framed.iorm.ui.subeditors.FRaMEDTextViewer;
...@@ -56,11 +57,6 @@ public class MultipageEditor extends FormEditor implements ISelectionListener, I ...@@ -56,11 +57,6 @@ public class MultipageEditor extends FormEditor implements ISelectionListener, I
*/ */
private final String DIAGRAM_PROVIDER_ID = IdentifierLiterals.DIAGRAM_PROVIDER_ID; private final String DIAGRAM_PROVIDER_ID = IdentifierLiterals.DIAGRAM_PROVIDER_ID;
/**
* the palette type for a editor showing a compartments diagram gathered from {@link IdentifierLiterals}
*/
private final String PALETTE_TYPE_COMPARTMENTVIEW = IdentifierLiterals.PALETTE_TYPE_COMPARTMENTVIEW;
/** /**
* the value for the property diagram kind of compartment types diagram gathered from {@link IdentifierLiterals} * the value for the property diagram kind of compartment types diagram gathered from {@link IdentifierLiterals}
*/ */
...@@ -242,7 +238,7 @@ public class MultipageEditor extends FormEditor implements ISelectionListener, I ...@@ -242,7 +238,7 @@ public class MultipageEditor extends FormEditor implements ISelectionListener, I
if(PropertyUtil.isDiagram_KindValue(diagram, DIAGRAM_KIND_COMPARTMENTTYPE_DIAGRAM)) { if(PropertyUtil.isDiagram_KindValue(diagram, DIAGRAM_KIND_COMPARTMENTTYPE_DIAGRAM)) {
ToolBehaviorProvider toolBehaviorProvider = ToolBehaviorProvider toolBehaviorProvider =
(ToolBehaviorProvider) editorDiagram.getDiagramTypeProvider().getCurrentToolBehaviorProvider(); (ToolBehaviorProvider) editorDiagram.getDiagramTypeProvider().getCurrentToolBehaviorProvider();
toolBehaviorProvider.setPaletteType(PALETTE_TYPE_COMPARTMENTVIEW); toolBehaviorProvider.setPaletteType(PaletteView.COMPARTMENT_VIEW);
editorDiagram.getDiagramBehavior().refreshPalette(); editorDiagram.getDiagramBehavior().refreshPalette();
} }
} }
......
package org.framed.iorm.ui.palette;
import java.util.HashMap;
import java.util.Map;
import org.framed.iorm.ui.literals.NameLiterals;
public class FeatureManager {
/**
* the name literals for shape create features gathered from {@link NameLiterals}
*/
private static final String ATTRIBUTE_OPERATION_COMMON_FEATURE_NAME = NameLiterals.ATTRIBUTE_OPERATION_COMMON_FEATURE_NAME,
MODEL_FEATURE_NAME = NameLiterals.MODEL_FEATURE_NAME,
GROUP_OR_COMPARTMENT_TYPE_ELEMENT_FEATURE_NAME = NameLiterals.GROUP_OR_COMPARTMENT_TYPE_ELEMENT_FEATURE_NAME,
COMPARTMENTTYPE_FEATURE_NAME = NameLiterals.COMPARTMENTTYPE_FEATURE_NAME,
NATURALTYPE_FEATURE_NAME = NameLiterals.NATURALTYPE_FEATURE_NAME,
DATATYPE_FEATURE_NAME = NameLiterals.DATATYPE_FEATURE_NAME,
GROUP_FEATURE_NAME = NameLiterals.GROUP_FEATURE_NAME,
ROLETYPE_FEATURE_NAME = NameLiterals.ROLETYPE_FEATURE_NAME,
ATTRIBUTE_FEATURE_NAME = NameLiterals.ATTRIBUTE_FEATURE_NAME,
OPERATION_FEATURE_NAME = NameLiterals.OPERATION_FEATURE_NAME;
/**
* the name literals for connection create features gathered from {@link NameLiterals}
*/
private static final String RELATIONSHIP_FEATURE_NAME = NameLiterals.RELATIONSHIP_FEATURE_NAME,
INHERITANCE_FEATURE_NAME = NameLiterals.INHERITANCE_FEATURE_NAME,
ROLEIMPLICATION_FEATURE_NAME = NameLiterals.ROLEIMPLICATION_FEATURE_NAME,
ROLEEQUIVALENCE_FEATURE_NAME = NameLiterals.ROLEEQUIVALENCE_FEATURE_NAME,
ROLEPROHIBITION_FEATURE_NAME = NameLiterals.ROLEPROHIBITION_FEATURE_NAME,
ACYCLIC_FEATURE_NAME = NameLiterals.ACYCLIC_FEATURE_NAME,
CYCLIC_FEATURE_NAME = NameLiterals.CYCLIC_FEATURE_NAME,
IRREFLEXIVE_FEATURE_NAME = NameLiterals.IRREFLEXIVE_FEATURE_NAME,
REFLEXIVE_FEATURE_NAME = NameLiterals.REFLEXIVE_FEATURE_NAME,
TOTAL_FEATURE_NAME = NameLiterals.TOTAL_FEATURE_NAME,
RELATIONSHIP_IMPLICATION_FEATURE_NAME = NameLiterals.RELATIONSHIP_IMPLICATION_FEATURE_NAME,
RELATIONSHIP_EXCLUSION_FEATURE_NAME = NameLiterals.RELATIONSHIP_EXCLUSION_FEATURE_NAME;
//TODO krzel
private static PaletteCategory entities = PaletteCategory.ENTITIES_CATEGORY,
properties = PaletteCategory.PROPERTIES_CATEGORY,
relations = PaletteCategory.RELATIONS_CATEGORY,
constraints = PaletteCategory.CONSTRAINTS_CATEGORY,
none = PaletteCategory.NONE;
private static ViewVisibility all = ViewVisibility.ALL_VIEWS,
top = ViewVisibility.TOPLEVEL_VIEW,
compartment = ViewVisibility.COMPARTMENT_VIEW,
no_view = ViewVisibility.NO_VIEW;
//TODO
public static Map<String, FeaturePaletteDescriptor> features = createFeatureCategoryMap();
/**
* TODO
* Step 1 features in none of the categories
* @return
*/
private static Map<String, FeaturePaletteDescriptor> createFeatureCategoryMap() {
features = new HashMap<String, FeaturePaletteDescriptor>();
//Step 1
features.put(ATTRIBUTE_OPERATION_COMMON_FEATURE_NAME, new FeaturePaletteDescriptor(none, no_view));
features.put(MODEL_FEATURE_NAME, new FeaturePaletteDescriptor(none, no_view));
features.put(GROUP_OR_COMPARTMENT_TYPE_ELEMENT_FEATURE_NAME, new FeaturePaletteDescriptor(none, no_view));
//Step 2
features.put(COMPARTMENTTYPE_FEATURE_NAME, new FeaturePaletteDescriptor(entities, all));
features.put(NATURALTYPE_FEATURE_NAME, new FeaturePaletteDescriptor(entities, top));
features.put(DATATYPE_FEATURE_NAME, new FeaturePaletteDescriptor(entities, top));
features.put(GROUP_FEATURE_NAME, new FeaturePaletteDescriptor(entities, top));
features.put(ROLETYPE_FEATURE_NAME, new FeaturePaletteDescriptor(entities, compartment));
//Step 3
features.put(ATTRIBUTE_FEATURE_NAME, new FeaturePaletteDescriptor(properties, all));
features.put(OPERATION_FEATURE_NAME, new FeaturePaletteDescriptor(properties, all));
//Step 4
features.put(INHERITANCE_FEATURE_NAME, new FeaturePaletteDescriptor(relations, all));
features.put(RELATIONSHIP_FEATURE_NAME, new FeaturePaletteDescriptor(relations, compartment));
//Step 5
features.put(ROLEIMPLICATION_FEATURE_NAME, new FeaturePaletteDescriptor(constraints, compartment));
features.put(ROLEEQUIVALENCE_FEATURE_NAME, new FeaturePaletteDescriptor(constraints, compartment));
features.put(ROLEPROHIBITION_FEATURE_NAME, new FeaturePaletteDescriptor(constraints, compartment));
features.put(ACYCLIC_FEATURE_NAME, new FeaturePaletteDescriptor(constraints, compartment));
features.put(CYCLIC_FEATURE_NAME, new FeaturePaletteDescriptor(constraints, compartment));
features.put(IRREFLEXIVE_FEATURE_NAME, new FeaturePaletteDescriptor(constraints, compartment));
features.put(REFLEXIVE_FEATURE_NAME, new FeaturePaletteDescriptor(constraints, compartment));
features.put(TOTAL_FEATURE_NAME, new FeaturePaletteDescriptor(constraints, compartment));
features.put(RELATIONSHIP_IMPLICATION_FEATURE_NAME, new FeaturePaletteDescriptor(constraints, compartment));
features.put(RELATIONSHIP_EXCLUSION_FEATURE_NAME, new FeaturePaletteDescriptor(constraints, compartment));
return features;
}
}
package org.framed.iorm.ui.palette;
public class FeaturePaletteDescriptor {
public PaletteCategory paletteCategory = PaletteCategory.NONE;
public ViewVisibility viewVisibility = ViewVisibility.NO_VIEW;
public FeaturePaletteDescriptor(PaletteCategory paletteCategory, ViewVisibility viewVisibility) {
this.paletteCategory = paletteCategory;
this.viewVisibility = viewVisibility;
}
}
package org.framed.iorm.ui.palette;
public enum PaletteCategory {
ENTITIES_CATEGORY,
PROPERTIES_CATEGORY,
RELATIONS_CATEGORY,
CONSTRAINTS_CATEGORY,
NONE;
}
package org.framed.iorm.ui.palette;
public enum PaletteView {
TOPLEVEL_VIEW,
COMPARTMENT_VIEW;
}
package org.framed.iorm.ui.palette;
public enum ViewVisibility {
ALL_VIEWS,
TOPLEVEL_VIEW,
COMPARTMENT_VIEW,
NO_VIEW;
}
...@@ -5,6 +5,8 @@ import java.util.List; ...@@ -5,6 +5,8 @@ import java.util.List;
import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
import org.eclipse.graphiti.dt.IDiagramTypeProvider; import org.eclipse.graphiti.dt.IDiagramTypeProvider;
import org.eclipse.graphiti.features.ICreateConnectionFeature;
import org.eclipse.graphiti.features.ICreateFeature;
import org.eclipse.graphiti.features.context.ICustomContext; import org.eclipse.graphiti.features.context.ICustomContext;
import org.eclipse.graphiti.features.context.IPictogramElementContext; import org.eclipse.graphiti.features.context.IPictogramElementContext;
import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator; import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
...@@ -13,18 +15,24 @@ import org.eclipse.graphiti.mm.pictograms.FreeFormConnection; ...@@ -13,18 +15,24 @@ import org.eclipse.graphiti.mm.pictograms.FreeFormConnection;
import org.eclipse.graphiti.mm.pictograms.PictogramElement; import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape; import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.palette.IPaletteCompartmentEntry; import org.eclipse.graphiti.palette.IPaletteCompartmentEntry;
import org.eclipse.graphiti.palette.IToolEntry; import org.eclipse.graphiti.palette.impl.ConnectionCreationToolEntry;
import org.eclipse.graphiti.palette.impl.ObjectCreationToolEntry;
import org.eclipse.graphiti.palette.impl.PaletteCompartmentEntry;
import org.eclipse.graphiti.tb.DefaultToolBehaviorProvider; import org.eclipse.graphiti.tb.DefaultToolBehaviorProvider;
import org.eclipse.graphiti.tb.IContextButtonPadData; import org.eclipse.graphiti.tb.IContextButtonPadData;
import org.eclipse.graphiti.tb.IContextMenuEntry; import org.eclipse.graphiti.tb.IContextMenuEntry;
import org.framed.iorm.ui.literals.IdentifierLiterals; import org.framed.iorm.ui.literals.IdentifierLiterals;
import org.framed.iorm.ui.literals.NameLiterals; import org.framed.iorm.ui.literals.NameLiterals;
import org.framed.iorm.ui.palette.FeatureManager;
import org.framed.iorm.ui.palette.FeaturePaletteDescriptor;
import org.framed.iorm.ui.palette.PaletteView;
import org.framed.iorm.ui.palette.ViewVisibility;
import org.framed.iorm.ui.util.DiagramUtil; import org.framed.iorm.ui.util.DiagramUtil;
import org.framed.iorm.ui.util.GeneralUtil;
import org.framed.iorm.ui.util.PropertyUtil; import org.framed.iorm.ui.util.PropertyUtil;
import org.framed.iorm.ui.providers.FeatureProvider; //*import for javadoc link import org.framed.iorm.ui.providers.FeatureProvider; //*import for javadoc link
import org.framed.iorm.model.Relation; import org.framed.iorm.model.Relation;
import org.framed.iorm.model.Type; import org.framed.iorm.model.Type;
import org.framed.iorm.ui.exceptions.FeatureHasNoPaletteDescriptorException;
import org.framed.iorm.ui.graphitifeatures.StepInFeature; //*import for javadoc link import org.framed.iorm.ui.graphitifeatures.StepInFeature; //*import for javadoc link
import org.framed.iorm.ui.graphitifeatures.StepInNewTabFeature; //*import for javadoc link import org.framed.iorm.ui.graphitifeatures.StepInNewTabFeature; //*import for javadoc link
import org.framed.iorm.ui.graphitifeatures.StepOutFeature; //*import for javadoc link import org.framed.iorm.ui.graphitifeatures.StepOutFeature; //*import for javadoc link
...@@ -36,33 +44,13 @@ import org.framed.iorm.ui.graphitifeatures.StepOutFeature; //*import for javadoc ...@@ -36,33 +44,13 @@ import org.framed.iorm.ui.graphitifeatures.StepOutFeature; //*import for javadoc
public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{
/** /**
* the name literals for shape create features to remove from the editor palette for the diagram type * names for the palette categories gathered from {@link NameLiterals}
* gathered from {@link NameLiterals}
*/ */
private final String ATTRIBUTE_OPERATION_COMMON_FEATURE_NAME = NameLiterals.ATTRIBUTE_OPERATION_COMMON_FEATURE_NAME, private final String ENTITIES_PALETTE_CATEGORY_NAME = NameLiterals.ENTITIES_PALETTE_CATEGORY_NAME,
MODEL_FEATURE_NAME = NameLiterals.MODEL_FEATURE_NAME, PROPERTIES_PALETTE_CATEGORY_NAME = NameLiterals.PROPERTIES_PALETTE_CATEGORY_NAME,
GROUP_OR_COMPARTMENT_TYPE_ELEMENT_FEATURE_NAME = NameLiterals.GROUP_OR_COMPARTMENT_TYPE_ELEMENT_FEATURE_NAME, RELATIONS_PALETTE_CATEGORY_NAME = NameLiterals.RELATIONS_PALETTE_CATEGORY_NAME,
NATURALTYPE_FEATURE_NAME = NameLiterals.NATURALTYPE_FEATURE_NAME, CONSTRAINTS_PALETTE_CATEGORY_NAME = NameLiterals.CONSTRAINTS_PALETTE_CATEGORY_NAME;
DATATYPE_FEATURE_NAME = NameLiterals.DATATYPE_FEATURE_NAME,
GROUP_FEATURE_NAME = NameLiterals.GROUP_FEATURE_NAME,
ROLETYPE_FEATURE_NAME = NameLiterals.ROLETYPE_FEATURE_NAME;
/**
* the name literals for connection create features to remove from the editor palette for the diagram type
* gathered from {@link NameLiterals}
*/
private final String ROLEIMPLICATION_FEATURE_NAME = NameLiterals.ROLEIMPLICATION_FEATURE_NAME,
ROLEEQUIVALENCE_FEATURE_NAME = NameLiterals.ROLEEQUIVALENCE_FEATURE_NAME,
ROLEPROHIBITION_FEATURE_NAME = NameLiterals.ROLEPROHIBITION_FEATURE_NAME,
RELATIONSHIP_FEATURE_NAME = NameLiterals.RELATIONSHIP_FEATURE_NAME,
RELATIONSHIP_DECORATOR_FEATURE_NAME = NameLiterals.RELATIONSHIP_DECORATOR_FEATURE_NAME,
ACYCLIC_FEATURE_NAME = NameLiterals.ACYCLIC_FEATURE_NAME,
CYCLIC_FEATURE_NAME = NameLiterals.CYCLIC_FEATURE_NAME,
IRREFLEXIVE_FEATURE_NAME = NameLiterals.IRREFLEXIVE_FEATURE_NAME,
REFLEXIVE_FEATURE_NAME = NameLiterals.REFLEXIVE_FEATURE_NAME,
TOTAL_FEATURE_NAME = NameLiterals.TOTAL_FEATURE_NAME,
RELATIONSHIP_IMPLICATION_FEATURE_NAME = NameLiterals.RELATIONSHIP_IMPLICATION_FEATURE_NAME,
RELATIONSHIP_EXCLUSION_FEATURE_NAME = NameLiterals.RELATIONSHIP_EXCLUSION_FEATURE_NAME;
/** /**
* the value for the property diagram kind to identify diagrams belonging to a group or compartment type gathered * the value for the property diagram kind to identify diagrams belonging to a group or compartment type gathered
* from {@link IdentiferLiterals} * from {@link IdentiferLiterals}
...@@ -90,62 +78,34 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ ...@@ -90,62 +78,34 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{
private final String SHAPE_ID_GROUP_TYPEBODY = IdentifierLiterals.SHAPE_ID_GROUP_TYPEBODY, private final String SHAPE_ID_GROUP_TYPEBODY = IdentifierLiterals.SHAPE_ID_GROUP_TYPEBODY,
SHAPE_ID_COMPARTMENTTYPE_TYPEBODY = IdentifierLiterals.SHAPE_ID_COMPARTMENTTYPE_TYPEBODY; SHAPE_ID_COMPARTMENTTYPE_TYPEBODY = IdentifierLiterals.SHAPE_ID_COMPARTMENTTYPE_TYPEBODY;
/**
* identifiers used to differ the types of palettes gathered from {@link IdentifierLiterals}
*/
private final String PALETTE_TYPE_TOPLEVELVIEW = IdentifierLiterals.PALETTE_TYPE_TOPLEVELVIEW,
PALETTE_TYPE_COMPARTMENTVIEW = IdentifierLiterals.PALETTE_TYPE_COMPARTMENTVIEW;
/** /**
* the current type of the palette of the editor * the current type of the palette of the editor
* <p> * <p>
* This attribute is set by the {@link StepInFeature}, {@link StepInNewTabFeature} and {@link StepOutFeature}. * This attribute is set by the {@link StepInFeature}, {@link StepInNewTabFeature} and {@link StepOutFeature}.
* It is used to calculate the palette element to display depending on the type of diagram the editor is showing. * It is used to calculate the palette element to display depending on the type of diagram the editor is showing.
*/ */
private String paletteType = PALETTE_TYPE_TOPLEVELVIEW; private PaletteView paletteView = PaletteView.TOPLEVEL_VIEW;
private List<String> createFeaturesToHideInEveryView = new ArrayList<String>(), //TODO
createFeaturesToHideInTopLevelView = new ArrayList<String>(), PaletteCompartmentEntry entityCategory = new PaletteCompartmentEntry(ENTITIES_PALETTE_CATEGORY_NAME, null);
createFeaturesToHideInCompartmentView = new ArrayList<String>(); PaletteCompartmentEntry propertiesCategory = new PaletteCompartmentEntry(PROPERTIES_PALETTE_CATEGORY_NAME, null);
PaletteCompartmentEntry relationsCategory = new PaletteCompartmentEntry(RELATIONS_PALETTE_CATEGORY_NAME, null);
PaletteCompartmentEntry constraintsCategory = new PaletteCompartmentEntry(CONSTRAINTS_PALETTE_CATEGORY_NAME, null);
/** /**
* Class constructor * Class constructor
* <p>
* fills the list of features to hide
* @param diagramTypeProvider the provider of the edited diagram type * @param diagramTypeProvider the provider of the edited diagram type
*/ */
public ToolBehaviorProvider(IDiagramTypeProvider diagramTypeProvider) { public ToolBehaviorProvider(IDiagramTypeProvider diagramTypeProvider) {
super(diagramTypeProvider); super(diagramTypeProvider);
//features to hide in every view
createFeaturesToHideInEveryView.add(ATTRIBUTE_OPERATION_COMMON_FEATURE_NAME);
createFeaturesToHideInEveryView.add(MODEL_FEATURE_NAME);
createFeaturesToHideInEveryView.add(GROUP_OR_COMPARTMENT_TYPE_ELEMENT_FEATURE_NAME);
createFeaturesToHideInEveryView.add(RELATIONSHIP_DECORATOR_FEATURE_NAME);
//features to hide in the top level view
createFeaturesToHideInTopLevelView.add(ROLEIMPLICATION_FEATURE_NAME);
createFeaturesToHideInTopLevelView.add(ROLEEQUIVALENCE_FEATURE_NAME);
createFeaturesToHideInTopLevelView.add(ROLEPROHIBITION_FEATURE_NAME);
createFeaturesToHideInTopLevelView.add(RELATIONSHIP_FEATURE_NAME);
createFeaturesToHideInTopLevelView.add(ROLETYPE_FEATURE_NAME);
createFeaturesToHideInTopLevelView.add(ACYCLIC_FEATURE_NAME);
createFeaturesToHideInTopLevelView.add(CYCLIC_FEATURE_NAME);
createFeaturesToHideInTopLevelView.add(IRREFLEXIVE_FEATURE_NAME);
createFeaturesToHideInTopLevelView.add(REFLEXIVE_FEATURE_NAME);
createFeaturesToHideInTopLevelView.add(TOTAL_FEATURE_NAME);
createFeaturesToHideInTopLevelView.add(RELATIONSHIP_IMPLICATION_FEATURE_NAME);
createFeaturesToHideInTopLevelView.add(RELATIONSHIP_EXCLUSION_FEATURE_NAME);
//feature to hide in the compartment view
createFeaturesToHideInCompartmentView.add(NATURALTYPE_FEATURE_NAME);
createFeaturesToHideInCompartmentView.add(DATATYPE_FEATURE_NAME);
createFeaturesToHideInCompartmentView.add(GROUP_FEATURE_NAME);
} }
/** /**
* sets the value of the palette type to be shown * sets the value of the palette view to be shown
* @param paletteType the new palette to be set * @param paletteType the new palette view to be set
*/ */
public void setPaletteType(String paletteType) { public void setPaletteType(PaletteView paletteView) {
this.paletteType = paletteType; this.paletteView = paletteView;
} }
/** /**
...@@ -236,53 +196,89 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ ...@@ -236,53 +196,89 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{
} }
/** /**
* removes create features implemented by the pattern from the palette using the following steps: * builds the palette of the editor using the following steps
* <p> * <p>
* Step 1: It hides patterns that dont have a create features or whichs create features should not be used by the user * Step 1: It creates the different palette categories.<br>
* manually. * Step 2: It add create shape features to the correct categories according to the {@link FeatureManager}
* Step 2: It hides patterns that should not be shown if the palette type of the provider is set to class palette.<br>
* Step 3: It hides patterns that should not be shown if the palette type of the provider is set to role palette.
*/ */
@Override @Override
public IPaletteCompartmentEntry[] getPalette() { public IPaletteCompartmentEntry[] getPalette() {
List<IPaletteCompartmentEntry> paletteCompartmentEntry = new ArrayList<IPaletteCompartmentEntry>(); List<IPaletteCompartmentEntry> pallete = new ArrayList<IPaletteCompartmentEntry>();
List<IToolEntry> toolEntriesShapesToDelete = new ArrayList<IToolEntry>();
List<IToolEntry> toolEntriesConnectionToDelete = new ArrayList<IToolEntry>();
IPaletteCompartmentEntry[] superCompartments = super.getPalette();
//Step 1 //Step 1
for(int i = 0; i < superCompartments[1].getToolEntries().size(); i++) { entityCategory = new PaletteCompartmentEntry(ENTITIES_PALETTE_CATEGORY_NAME, null);
IToolEntry toolEntry = superCompartments[1].getToolEntries().get(i); propertiesCategory = new PaletteCompartmentEntry(PROPERTIES_PALETTE_CATEGORY_NAME, null);
if(GeneralUtil.containsEqual(createFeaturesToHideInEveryView, toolEntry.getLabel())) relationsCategory = new PaletteCompartmentEntry(RELATIONS_PALETTE_CATEGORY_NAME, null);
toolEntriesShapesToDelete.add(toolEntry); constraintsCategory = new PaletteCompartmentEntry(CONSTRAINTS_PALETTE_CATEGORY_NAME, null);
} for(ICreateFeature feature : getFeatureProvider().getCreateFeatures()) {
//Step 2 addShapeFeature(feature);
if(paletteType.equals(PALETTE_TYPE_TOPLEVELVIEW)) {
for(int i = 0; i < superCompartments[0].getToolEntries().size(); i++) {
IToolEntry toolEntry = superCompartments[0].getToolEntries().get(i);
if(GeneralUtil.containsEqual(createFeaturesToHideInTopLevelView, toolEntry.getLabel()))
toolEntriesConnectionToDelete.add(toolEntry);
} }
for(int i = 0; i < superCompartments[1].getToolEntries().size(); i++) { for(ICreateConnectionFeature feature : getFeatureProvider().getCreateConnectionFeatures()) {
IToolEntry toolEntry = superCompartments[1].getToolEntries().get(i); addConnectionFeature(feature);
if(GeneralUtil.containsEqual(createFeaturesToHideInTopLevelView, toolEntry.getLabel()))
toolEntriesShapesToDelete.add(toolEntry);
} }
//Step 3
if(paletteType.equals(PALETTE_TYPE_COMPARTMENTVIEW)) {
for(int i = 0; i < superCompartments[1].getToolEntries().size(); i++) {
IToolEntry toolEntry = superCompartments[1].getToolEntries().get(i);
if(GeneralUtil.containsEqual(createFeaturesToHideInCompartmentView, toolEntry.getLabel()))
toolEntriesShapesToDelete.add(toolEntry);
} }
for(IToolEntry toolEntryConnectionToDelete : toolEntriesConnectionToDelete) {
superCompartments[0].getToolEntries().remove(toolEntryConnectionToDelete);
} }
for(IToolEntry toolEntryShapeToDelete : toolEntriesShapesToDelete) { pallete.add(entityCategory);
superCompartments[1].getToolEntries().remove(toolEntryShapeToDelete); pallete.add(propertiesCategory);
} pallete.add(relationsCategory);
for (int j = 0; j < superCompartments.length; j++) { pallete.add(constraintsCategory);
paletteCompartmentEntry.add(superCompartments[j]); return pallete.toArray(new IPaletteCompartmentEntry[pallete.size()]);
}
return paletteCompartmentEntry.toArray(new IPaletteCompartmentEntry[paletteCompartmentEntry.size()]);
} }
private void addShapeFeature(ICreateFeature feature) {
FeaturePaletteDescriptor fpd = FeatureManager.features.get(feature.getCreateName());
if(fpd == null) throw new FeatureHasNoPaletteDescriptorException(feature.getCreateName());
if((fpd.viewVisibility == ViewVisibility.ALL_VIEWS) ||
(paletteView == PaletteView.TOPLEVEL_VIEW &&
fpd.viewVisibility == ViewVisibility.TOPLEVEL_VIEW) ||
(paletteView == PaletteView.COMPARTMENT_VIEW &&
fpd.viewVisibility == ViewVisibility.COMPARTMENT_VIEW)) {
ObjectCreationToolEntry objectCreationToolEntry =
new ObjectCreationToolEntry( feature.getCreateName(),
feature.getCreateDescription(), feature.getCreateImageId(),
feature.getCreateLargeImageId(), feature);
switch(fpd.paletteCategory) {
case ENTITIES_CATEGORY:
entityCategory.addToolEntry(objectCreationToolEntry);
break;
case PROPERTIES_CATEGORY:
propertiesCategory.addToolEntry(objectCreationToolEntry);
break;
case RELATIONS_CATEGORY:
relationsCategory.addToolEntry(objectCreationToolEntry);
break;
case CONSTRAINTS_CATEGORY:
constraintsCategory.addToolEntry(objectCreationToolEntry);
break;
default:
break;
} } }
private void addConnectionFeature(ICreateConnectionFeature feature) {
FeaturePaletteDescriptor fpd = FeatureManager.features.get(feature.getCreateName());
if(fpd == null) throw new FeatureHasNoPaletteDescriptorException(feature.getCreateName());
if((fpd.viewVisibility == ViewVisibility.ALL_VIEWS) ||
(paletteView == PaletteView.TOPLEVEL_VIEW &&
fpd.viewVisibility == ViewVisibility.TOPLEVEL_VIEW) ||
(paletteView == PaletteView.COMPARTMENT_VIEW &&
fpd.viewVisibility == ViewVisibility.COMPARTMENT_VIEW)) {
ConnectionCreationToolEntry connectionCreationToolEntry =
new ConnectionCreationToolEntry(feature.getCreateName(),
feature.getCreateDescription(), feature.getCreateImageId(),
feature.getCreateLargeImageId());
connectionCreationToolEntry.addCreateConnectionFeature(feature);
switch(fpd.paletteCategory) {
case ENTITIES_CATEGORY:
entityCategory.addToolEntry(connectionCreationToolEntry);
break;
case PROPERTIES_CATEGORY:
propertiesCategory.addToolEntry(connectionCreationToolEntry);
break;
case RELATIONS_CATEGORY:
relationsCategory.addToolEntry(connectionCreationToolEntry);
break;
case CONSTRAINTS_CATEGORY:
constraintsCategory.addToolEntry(connectionCreationToolEntry);
break;
default:
break;
} } }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment