From cfb4b6566d3561c34b875c8a0670dc8338b2f9ad Mon Sep 17 00:00:00 2001 From: Kevin Kassin <KK@Medion-PC> Date: Sat, 29 Jul 2017 12:48:32 +0200 Subject: [PATCH] #Commit 29.7 12:50 added javadoc for the code of the last commit, made changes to the visual style of constraints --- .../iorm/ui/literals/LayoutLiterals.java | 6 ++-- .../iorm/ui/palette/FeatureManager.java | 28 +++++++++++---- .../ui/palette/FeaturePaletteDescriptor.java | 14 ++++++++ .../iorm/ui/palette/PaletteCategory.java | 7 ++++ .../framed/iorm/ui/palette/PaletteView.java | 4 +++ .../iorm/ui/palette/ViewVisibility.java | 7 ++++ ...actInterRelationshipConstraintPattern.java | 4 +-- ...elationshipExclusionConstraintPattern.java | 4 +-- ...ationshipImplicationConstraintPattern.java | 2 +- ...actIntraRelationshipConstraintPattern.java | 5 ++- .../ui/providers/ToolBehaviorProvider.java | 35 +++++++++++++++---- 11 files changed, 94 insertions(+), 22 deletions(-) diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/LayoutLiterals.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/LayoutLiterals.java index 240398a7..42f96950 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/LayoutLiterals.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/literals/LayoutLiterals.java @@ -27,12 +27,14 @@ public class LayoutLiterals { * (1) the color of text or<br> * (2) the color of lines or<br> * (3) the color of backgrounds or<br> - * (4) the color of graphiti shapes shadows + * (4) the color of graphiti shapes shadows or<br> + * (5) the color of constraint texts and connections */ public static final IColorConstant COLOR_TEXT = IColorConstant.BLACK, COLOR_LINES = IColorConstant.BLACK, COLOR_BACKGROUND = IColorConstant.WHITE, - COLOR_SHADOW = IColorConstant.GRAY; + COLOR_SHADOW = IColorConstant.GRAY, + COLOR_CONSTRAINTS = IColorConstant.DARK_GRAY; /** * layout integer for wizards diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/FeatureManager.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/FeatureManager.java index 52062984..de08e5c2 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/FeatureManager.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/FeatureManager.java @@ -5,6 +5,11 @@ import java.util.Map; import org.framed.iorm.ui.literals.NameLiterals; +/** + * This static class is used to get information about when and where a feature with a specific name + * is shown in the palette. + * @author Kevin Kassin + */ public class FeatureManager { /** @@ -37,25 +42,36 @@ public class FeatureManager { RELATIONSHIP_IMPLICATION_FEATURE_NAME = NameLiterals.RELATIONSHIP_IMPLICATION_FEATURE_NAME, RELATIONSHIP_EXCLUSION_FEATURE_NAME = NameLiterals.RELATIONSHIP_EXCLUSION_FEATURE_NAME; - //TODO k�rzel + /** + * simple short forms of the palette categories to make code more readable + */ private static PaletteCategory entities = PaletteCategory.ENTITIES_CATEGORY, properties = PaletteCategory.PROPERTIES_CATEGORY, relations = PaletteCategory.RELATIONS_CATEGORY, constraints = PaletteCategory.CONSTRAINTS_CATEGORY, none = PaletteCategory.NONE; - + /** + * simple short forms of the view visibility to make code more readable + */ private static ViewVisibility all = ViewVisibility.ALL_VIEWS, top = ViewVisibility.TOPLEVEL_VIEW, compartment = ViewVisibility.COMPARTMENT_VIEW, no_view = ViewVisibility.NO_VIEW; - - //TODO + /** + * the map that saves when and where a feature with a specific name is shown in the palette + */ public static Map<String, FeaturePaletteDescriptor> features = createFeatureCategoryMap(); /** - * TODO - * Step 1 features in none of the categories + * creates the map that saves when and where a feature with a specific name is shown in the palette + * using the following steps: + * <p> + * Step 1: features shown in none of the categories<br> + * Step 2: features shown in the category "Entities"<br> + * Step 3: features shown in the category "Properties"<br> + * Step 4: features shown in the category "Relations"<br> + * Step 5: features shown in the category "Constraints"<br> * @return */ private static Map<String, FeaturePaletteDescriptor> createFeatureCategoryMap() { diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/FeaturePaletteDescriptor.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/FeaturePaletteDescriptor.java index f0ffdf21..3bb3fcef 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/FeaturePaletteDescriptor.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/FeaturePaletteDescriptor.java @@ -1,10 +1,24 @@ package org.framed.iorm.ui.palette; +/** + * An object of this class describes when and where to show a feature in the palette. + * @author Kevin Kassin + */ public class FeaturePaletteDescriptor { + /** + * in which category to show a feature in the palette + */ public PaletteCategory paletteCategory = PaletteCategory.NONE; + + /** + * depending on the current palette view when to show the feature in the palette + */ public ViewVisibility viewVisibility = ViewVisibility.NO_VIEW; + /** + * Class constructor + */ public FeaturePaletteDescriptor(PaletteCategory paletteCategory, ViewVisibility viewVisibility) { this.paletteCategory = paletteCategory; this.viewVisibility = viewVisibility; diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/PaletteCategory.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/PaletteCategory.java index 20f77640..2e8690f4 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/PaletteCategory.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/PaletteCategory.java @@ -1,5 +1,12 @@ package org.framed.iorm.ui.palette; +import org.framed.iorm.ui.providers.ToolBehaviorProvider; //*import for javadoc link + +/** + * This enum creates possible values to save in which category to show a feature in the palette. It is used in + * {@link FeatureManager} and the {@link ToolBehaviorProvider}. + * @author Kevin Kassin + */ public enum PaletteCategory { ENTITIES_CATEGORY, diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/PaletteView.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/PaletteView.java index fc74c8ca..79420462 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/PaletteView.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/PaletteView.java @@ -1,5 +1,9 @@ package org.framed.iorm.ui.palette; +/** + * This enumeration offers values for the palette views. + * @author Kevin Kassin + */ public enum PaletteView { TOPLEVEL_VIEW, diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/ViewVisibility.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/ViewVisibility.java index d91966e2..a201bedb 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/ViewVisibility.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/palette/ViewVisibility.java @@ -1,5 +1,12 @@ package org.framed.iorm.ui.palette; +import org.framed.iorm.ui.providers.ToolBehaviorProvider; //*import for javadoc link + +/** + * This enum creates possible values to save in which palette view to show a feature in the palette. It is used in + * {@link FeatureManager} and the {@link ToolBehaviorProvider}. + * @author Kevin Kassin + */ public enum ViewVisibility { ALL_VIEWS, diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/AbstractInterRelationshipConstraintPattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/AbstractInterRelationshipConstraintPattern.java index efe3878e..07b8cfd3 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/AbstractInterRelationshipConstraintPattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/AbstractInterRelationshipConstraintPattern.java @@ -43,7 +43,7 @@ public class AbstractInterRelationshipConstraintPattern extends FRaMEDConnection /** * the color values used for the polyline and the arrowhead gathered from {@link LayoutLiterals} */ - protected final IColorConstant COLOR_CONNECTIONS = LayoutLiterals.COLOR_CONNECTIONS, + protected final IColorConstant COLOR_CONSTRAINTS = LayoutLiterals.COLOR_CONSTRAINTS, COLOR_ARROWHEAD = LayoutLiterals.COLOR_ARROWHEAD; /** @@ -92,7 +92,7 @@ public class AbstractInterRelationshipConstraintPattern extends FRaMEDConnection connection.setStart(graphicalSourceAnchor); connection.setEnd(graphicalTargetAnchor); Polyline polyline = graphicAlgorithmService.createPolyline(connection); - polyline.setForeground(manageColor(COLOR_CONNECTIONS)); + polyline.setForeground(manageColor(COLOR_CONSTRAINTS)); polyline.setLineStyle(LineStyle.DASH); polyline.setLineWidth(2); return connection; diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/RelationshipExclusionConstraintPattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/RelationshipExclusionConstraintPattern.java index 846df58d..266944f0 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/RelationshipExclusionConstraintPattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/RelationshipExclusionConstraintPattern.java @@ -95,13 +95,13 @@ public class RelationshipExclusionConstraintPattern extends AbstractInterRelatio 0, -1*ARROWHEAD_HEIGHT };//P3 Polyline polylineTarget = graphicAlgorithmService.createPolyline(connectionDecoratorTarget, points); polylineTarget.setLineWidth(2); - polylineTarget.setForeground(manageColor(COLOR_CONNECTIONS)); + polylineTarget.setForeground(manageColor(COLOR_CONSTRAINTS)); PropertyUtil.setShape_IdValue(connectionDecoratorTarget, SHAPE_ID_INTER_REL_CON); ConnectionDecorator connectionDecoratorSource = pictogramElementCreateService.createConnectionDecorator(connection, false, 0, true); Polyline polylineSource = graphicAlgorithmService.createPolyline(connectionDecoratorSource, points); polylineSource.setLineWidth(2); - polylineSource.setForeground(manageColor(COLOR_CONNECTIONS)); + polylineSource.setForeground(manageColor(COLOR_CONSTRAINTS)); PropertyUtil.setShape_IdValue(connectionDecoratorSource, SHAPE_ID_INTER_REL_CON); //Step 4 link(connection, addedRoleImplication); diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/RelationshipImplicationConstraintPattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/RelationshipImplicationConstraintPattern.java index 7da329d1..20e5cb1c 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/RelationshipImplicationConstraintPattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/interrelationship/RelationshipImplicationConstraintPattern.java @@ -94,7 +94,7 @@ public class RelationshipImplicationConstraintPattern extends AbstractInterRelat 0, 0, //P2 -1*ARROWHEAD_LENGTH, -1*ARROWHEAD_HEIGHT }; //P3 Polygon arrowhead = graphicAlgorithmService.createPolygon(connectionDecorator, points); - arrowhead.setForeground(manageColor(COLOR_CONNECTIONS)); + arrowhead.setForeground(manageColor(COLOR_CONSTRAINTS)); arrowhead.setBackground(manageColor(COLOR_ARROWHEAD)); PropertyUtil.setShape_IdValue(connectionDecorator, SHAPE_ID_INTER_REL_CON); //Step 4 diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/intrarelationship/AbstractIntraRelationshipConstraintPattern.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/intrarelationship/AbstractIntraRelationshipConstraintPattern.java index f59089fe..b7355060 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/intrarelationship/AbstractIntraRelationshipConstraintPattern.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/pattern/connections/intrarelationship/AbstractIntraRelationshipConstraintPattern.java @@ -51,7 +51,7 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS * the color values gathered from {@link LayoutLiterals} */ protected static final IColorConstant COLOR_CONNECTIONS = LayoutLiterals.COLOR_CONNECTIONS, - COLOR_TEXT = LayoutLiterals.COLOR_TEXT; + COLOR_CONSTRAINTS = LayoutLiterals.COLOR_CONSTRAINTS; /** * layout integers gathered from {@link LayoutLiterals} @@ -141,8 +141,7 @@ public abstract class AbstractIntraRelationshipConstraintPattern extends FRaMEDS ConnectionDecorator constraintName = pictogramElementCreateService.createConnectionDecorator(targetConnection, true, 0.5, true); Text nameText = graphicAlgorithmService.createText(constraintName, type.getName().toLowerCase()); - nameText.setForeground(manageColor(COLOR_TEXT)); - nameText.setFont(manageFont("Arial", 10, false, true)); + nameText.setForeground(manageColor(COLOR_CONSTRAINTS)); PropertyUtil.setShape_IdValue(constraintName, SHAPE_ID_INTRA_REL_CON_NAME_DECORATOR); link(constraintName, addContext.getNewObject()); return constraintName; diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ToolBehaviorProvider.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ToolBehaviorProvider.java index 4a24b62c..2f6d5550 100644 --- a/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ToolBehaviorProvider.java +++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/providers/ToolBehaviorProvider.java @@ -86,11 +86,13 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ */ private PaletteView paletteView = PaletteView.TOPLEVEL_VIEW; - //TODO - PaletteCompartmentEntry entityCategory = new PaletteCompartmentEntry(ENTITIES_PALETTE_CATEGORY_NAME, null); - 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); + /** + * the categories of the palette + */ + PaletteCompartmentEntry entityCategory, + propertiesCategory, + relationsCategory, + constraintsCategory; /** * Class constructor @@ -199,7 +201,11 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ * builds the palette of the editor using the following steps * <p> * Step 1: It creates the different palette categories.<br> - * Step 2: It add create shape features to the correct categories according to the {@link FeatureManager} + * Step 2: It adds create shape features to the correct categories according to the {@link FeatureManager} + * using the operation {@link #addShapeFeature}.<br> + * Step 3: It adds create connection features to the correct categories according to the {@link FeatureManager} + * using the operation {@link #addConnectionFeature}.<br> + * Step 4: It adds the categories with the added features to the palette. */ @Override public IPaletteCompartmentEntry[] getPalette() { @@ -209,12 +215,15 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ propertiesCategory = new PaletteCompartmentEntry(PROPERTIES_PALETTE_CATEGORY_NAME, null); relationsCategory = new PaletteCompartmentEntry(RELATIONS_PALETTE_CATEGORY_NAME, null); constraintsCategory = new PaletteCompartmentEntry(CONSTRAINTS_PALETTE_CATEGORY_NAME, null); + //Step 2 for(ICreateFeature feature : getFeatureProvider().getCreateFeatures()) { addShapeFeature(feature); } + //Step 3 for(ICreateConnectionFeature feature : getFeatureProvider().getCreateConnectionFeatures()) { addConnectionFeature(feature); } + //Step 4 pallete.add(entityCategory); pallete.add(propertiesCategory); pallete.add(relationsCategory); @@ -222,6 +231,13 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ return pallete.toArray(new IPaletteCompartmentEntry[pallete.size()]); } + /** + * adds a shape feature to a palette category if wanted + * <p> + * It uses the {@link FeaturePaletteDescriptor} of the feature to calculate if and where to add the + * feature. + * @param feature the feature to probably add to the palette + */ private void addShapeFeature(ICreateFeature feature) { FeaturePaletteDescriptor fpd = FeatureManager.features.get(feature.getCreateName()); if(fpd == null) throw new FeatureHasNoPaletteDescriptorException(feature.getCreateName()); @@ -251,6 +267,13 @@ public class ToolBehaviorProvider extends DefaultToolBehaviorProvider{ break; } } } + /** + * adds a connection feature to a palette category if wanted + * <p> + * It uses the {@link FeaturePaletteDescriptor} of the feature to calculate if and where to add the + * feature. + * @param feature the feature to probably add to the palette + */ private void addConnectionFeature(ICreateConnectionFeature feature) { FeaturePaletteDescriptor fpd = FeatureManager.features.get(feature.getCreateName()); if(fpd == null) throw new FeatureHasNoPaletteDescriptorException(feature.getCreateName()); -- GitLab