Skip to content

Commit

Permalink
Temp working
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillipus committed Nov 7, 2024
1 parent 7c58186 commit d0cd284
Show file tree
Hide file tree
Showing 13 changed files with 108 additions and 101 deletions.
4 changes: 0 additions & 4 deletions com.archimatetool.editor/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1339,10 +1339,6 @@
class="com.archimatetool.editor.model.compatibility.handlers.Archimate32Handler"
id="com.archimatetool.editor.compatibility.archimate32converter">
</compatibilityHandler>
<compatibilityHandler
class="com.archimatetool.editor.model.compatibility.handlers.LineStyleHandler"
id="com.archimatetool.editor.compatibility.lineStyle">
</compatibilityHandler>
</extension>
<extension
point="com.archimatetool.editor.imageExportProvider">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ public static IDiagramModelArchimateObject createDiagramModelArchimateObject(IAr
// Gradient
dmo.setGradient(ArchiPlugin.PREFERENCES.getInt(IPreferenceConstants.DEFAULT_GRADIENT));

// Line Style for Grouping
if(element instanceof Grouping) {
dmo.setLineStyle(IDiagramModelObject.LINE_STYLE_DASHED);
}

return dmo;
}

Expand All @@ -86,8 +81,6 @@ public static IDiagramModelArchimateConnection createDiagramModelArchimateConnec
connection.setArchimateRelationship(relation);

IGraphicalObjectUIProvider provider = (IGraphicalObjectUIProvider)ObjectUIFactory.INSTANCE.getProvider(connection);

// Text alignment
connection.setTextAlignment(provider.getDefaultTextAlignment());

// Set user default colors as set in prefs
Expand Down Expand Up @@ -123,58 +116,63 @@ public Object getNewObject() {
return null;
}

boolean isSpecialization = fProfile != null && fProfile.getArchimateModel() != null;
boolean isSpecialization = fProfile != null && fProfile.getArchimateModel() != null;

EObject object = IArchimateFactory.eINSTANCE.create(fTemplate);

// Add Profile to Concept if set
if(object instanceof IArchimateConcept concept && isSpecialization) {
concept.getProfiles().add(fProfile);
if(object instanceof IArchimateConcept && isSpecialization) {
((IArchimateConcept)object).getProfiles().add(fProfile);
}

// Archimate Connection created from Relationship Template
if(object instanceof IArchimateRelationship relationship) {
return createDiagramModelArchimateConnection(relationship);
// Connection created from Relationship Template
if(object instanceof IArchimateRelationship) {
return createDiagramModelArchimateConnection((IArchimateRelationship)object);
}

// Archimate Diagram Object created from Archimate Element Template
else if(object instanceof IArchimateElement element) {
else if(object instanceof IArchimateElement) {
IArchimateElement element = (IArchimateElement)object;
element.setName(isSpecialization ? fProfile.getName() : ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
return createDiagramModelArchimateObject(element);
}

// Group
else if(object instanceof IDiagramModelGroup group) {
else if(object instanceof IDiagramModelGroup) {
IDiagramModelGroup group = (IDiagramModelGroup)object;
group.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
ColorFactory.setDefaultColors(group);
// Gradient
group.setGradient(ArchiPlugin.PREFERENCES.getInt(IPreferenceConstants.DEFAULT_GRADIENT));
}

// Note
else if(object instanceof IDiagramModelNote note) {
else if(object instanceof IDiagramModelNote) {
IDiagramModelNote note = (IDiagramModelNote)object;
ColorFactory.setDefaultColors(note);
// Gradient
note.setGradient(ArchiPlugin.PREFERENCES.getInt(IPreferenceConstants.DEFAULT_GRADIENT));
}

// Connection
else if(object instanceof IDiagramModelConnection connection) {
ColorFactory.setDefaultColors(connection);
else if(object instanceof IDiagramModelConnection) {
ColorFactory.setDefaultColors((IDiagramModelConnection)object);
}

IGraphicalObjectUIProvider provider = (IGraphicalObjectUIProvider)ObjectUIFactory.INSTANCE.getProvider(object);

if(object instanceof ITextAlignment textAlignment) {
textAlignment.setTextAlignment(provider.getDefaultTextAlignment());
if(object instanceof ITextAlignment) {
((ITextAlignment)object).setTextAlignment(provider.getDefaultTextAlignment());
}

if(object instanceof ITextPosition textPosition) {
textPosition.setTextPosition(provider.getDefaultTextPosition());
if(object instanceof ITextPosition) {
((ITextPosition)object).setTextPosition(provider.getDefaultTextPosition());
}

// Add new bounds with a default user size
if(object instanceof IDiagramModelObject dmo) {
if(object instanceof IDiagramModelObject) {
Dimension size = provider.getDefaultSize();
dmo.setBounds(0, 0, size.width, size.height);
((IDiagramModelObject)object).setBounds(0, 0, size.width, size.height);
}

return object;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
*/
public class DiagramModelObjectLineStyleCommand extends FeatureCommand {

public DiagramModelObjectLineStyleCommand(IDiagramModelObject object, int style) {
super("Change Line Style", object,
IDiagramModelObject.FEATURE_LINE_STYLE, style, IDiagramModelObject.FEATURE_LINE_STYLE_DEFAULT);
public DiagramModelObjectLineStyleCommand(IDiagramModelObject object, int style, int defaultValue) {
super("Change Line Style", object, IDiagramModelObject.FEATURE_LINE_STYLE, style, defaultValue);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.archimatetool.editor.ui.FontFactory;
import com.archimatetool.editor.ui.ImageFactory;
import com.archimatetool.editor.ui.factory.IGraphicalObjectUIProvider;
import com.archimatetool.editor.ui.factory.IObjectUIProvider;
import com.archimatetool.editor.ui.factory.ObjectUIFactory;
import com.archimatetool.editor.utils.StringUtils;
import com.archimatetool.model.IArchimateElement;
Expand Down Expand Up @@ -269,7 +270,8 @@ protected int getLineWidth() {
}

protected int getLineStyle() {
return fDiagramModelObject.getLineStyle();
IObjectUIProvider provider = ObjectUIFactory.INSTANCE.getProvider(getDiagramModelObject());
return provider != null && provider.getFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE) instanceof Integer val ? val : IDiagramModelObject.LINE_STYLE_SOLID;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.archimatetool.editor.diagram.commands.ConnectionLineTypeCommand;
import com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand;
import com.archimatetool.editor.diagram.commands.DiagramModelObjectAlphaCommand;
import com.archimatetool.editor.diagram.commands.DiagramModelObjectLineStyleCommand;
import com.archimatetool.editor.diagram.commands.DiagramModelObjectOutlineAlphaCommand;
import com.archimatetool.editor.diagram.commands.FillColorCommand;
import com.archimatetool.editor.diagram.commands.FontColorCommand;
Expand Down Expand Up @@ -112,6 +113,8 @@ CompoundCommand createCommand(IDiagramModelComponent targetComponent) {
CompoundCommand result = new CompoundCommand(Messages.FormatPainterTool_0);

IDiagramModelComponent sourceComponent = FormatPainterInfo.INSTANCE.getSourceComponent();

IObjectUIProvider sourceUIProvider = ObjectUIFactory.INSTANCE.getProvider(sourceComponent);
IObjectUIProvider targetUIProvider = ObjectUIFactory.INSTANCE.getProvider(targetComponent);

// IFontAttribute
Expand Down Expand Up @@ -213,8 +216,9 @@ CompoundCommand createCommand(IDiagramModelComponent targetComponent) {
}

// Line Style
if(targetUIProvider != null && targetUIProvider.shouldExposeFeature(IDiagramModelObject.FEATURE_LINE_STYLE)) {
cmd = new FeatureCommand("", target, IDiagramModelObject.FEATURE_LINE_STYLE, source.getLineStyle(), IDiagramModelObject.FEATURE_LINE_STYLE_DEFAULT); //$NON-NLS-1$
if(targetUIProvider != null && sourceUIProvider != null && targetUIProvider.shouldExposeFeature(IDiagramModelObject.FEATURE_LINE_STYLE)) {
cmd = new DiagramModelObjectLineStyleCommand(target, (int)sourceUIProvider.getFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE),
(int)targetUIProvider.getDefaultFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE));
if(cmd.canExecute()) {
result.add(cmd);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

import com.archimatetool.editor.diagram.commands.DiagramModelObjectLineStyleCommand;
import com.archimatetool.editor.ui.IArchiImages;
import com.archimatetool.editor.ui.factory.IObjectUIProvider;
import com.archimatetool.editor.ui.factory.ObjectUIFactory;
import com.archimatetool.model.IDiagramModelObject;


Expand Down Expand Up @@ -78,7 +80,8 @@ public void run() {

for(EObject object : section.getEObjects()) {
if(isValidObject(object)) {
Command cmd = new DiagramModelObjectLineStyleCommand((IDiagramModelObject)object, value);
IDiagramModelObject dmo = (IDiagramModelObject)object;
Command cmd = new DiagramModelObjectLineStyleCommand(dmo, value, getDefaultLineStyle(dmo));
if(cmd.canExecute()) {
result.add(cmd);
}
Expand All @@ -94,7 +97,8 @@ public ImageDescriptor getImageDescriptor() {
}
};

action.setChecked(((IDiagramModelObject)section.getFirstSelectedObject()).getLineStyle() == value);
int lineStyle = getActualLineStyle((IDiagramModelObject)section.getFirstSelectedObject());
action.setChecked(lineStyle == value);

return action;
}
Expand All @@ -107,9 +111,19 @@ private boolean isValidObject(EObject eObject) {
section.getFilter().shouldExposeFeature(eObject, IDiagramModelObject.FEATURE_LINE_STYLE);
}

private int getActualLineStyle(IDiagramModelObject dmo) {
IObjectUIProvider provider = ObjectUIFactory.INSTANCE.getProvider(dmo);
return provider != null && provider.getFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE) instanceof Integer val ? val : IDiagramModelObject.LINE_STYLE_SOLID;
}

private int getDefaultLineStyle(IDiagramModelObject dmo) {
IObjectUIProvider provider = ObjectUIFactory.INSTANCE.getProvider(dmo);
return provider != null && provider.getDefaultFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE) instanceof Integer val ? val : IDiagramModelObject.LINE_STYLE_SOLID;
}

void updateControl() {
IDiagramModelObject dmo = (IDiagramModelObject)section.getFirstSelectedObject();
int lineStyle = dmo.getLineStyle();
int lineStyle = getActualLineStyle(dmo);

switch(lineStyle) {
case IDiagramModelObject.LINE_STYLE_SOLID:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.swt.graphics.Color;

import com.archimatetool.model.IDiagramModelObject;
import com.archimatetool.model.ITextAlignment;
import com.archimatetool.model.ITextPosition;

Expand Down Expand Up @@ -62,4 +63,23 @@ public int getDefaultTextPosition() {
public boolean hasIcon() {
return false;
}

@Override
public Object getDefaultFeatureValue(String featureName) {
if(IDiagramModelObject.FEATURE_LINE_STYLE.equals(featureName)) {
return IDiagramModelObject.LINE_STYLE_SOLID;
}

return super.getDefaultFeatureValue(featureName);
}

@Override
public Object getFeatureValue(String featureName) {
if(IDiagramModelObject.FEATURE_LINE_STYLE.equals(featureName) && instance instanceof IDiagramModelObject dmo) {
int value = dmo.getLineStyle();
return (value == IDiagramModelObject.LINE_STYLE_DEFAULT) ? getDefaultFeatureValue(featureName) : value;
}

return super.getFeatureValue(featureName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,24 @@ public interface IObjectUIProvider {
boolean shouldExposeFeature(EAttribute feature);

/**
* @param feature The feature in question
* @param featureName The feature in question
* @return True if this object should expose a feature in the UI
*/
boolean shouldExposeFeature(String featureName);

/**
* @param featureName The feature in question
* @return a default value for a given feature. Default is null
*/
default Object getDefaultFeatureValue(String featureName) {
return null;
}

/**
* @param featureName The feature in question
* @return a value for a given feature. Default is null
*/
default Object getFeatureValue(String featureName) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.archimatetool.editor.diagram.figures.elements.GroupingFigure;
import com.archimatetool.editor.ui.IArchiImages;
import com.archimatetool.model.IArchimatePackage;
import com.archimatetool.model.IDiagramModelObject;
import com.archimatetool.model.ITextAlignment;
import com.archimatetool.model.ITextPosition;

Expand Down Expand Up @@ -74,4 +75,13 @@ public int getDefaultTextAlignment() {
public int getDefaultTextPosition() {
return ITextPosition.TEXT_POSITION_TOP;
}

@Override
public Object getDefaultFeatureValue(String featureName) {
if(IDiagramModelObject.FEATURE_LINE_STYLE.equals(featureName)) {
return IDiagramModelObject.LINE_STYLE_DASHED;
}

return super.getDefaultFeatureValue(featureName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ public interface IDiagramModelObject extends IConnectable, IFontAttribute, ILine
boolean FEATURE_DERIVE_ELEMENT_LINE_COLOR_DEFAULT = true;

String FEATURE_LINE_STYLE = "lineStyle";
int FEATURE_LINE_STYLE_DEFAULT = 0;
int LINE_STYLE_DEFAULT = -1;
int LINE_STYLE_SOLID = 0;
int LINE_STYLE_DASHED = 1;
int LINE_STYLE_DOTTED = 2;
int FEATURE_LINE_STYLE_DEFAULT = LINE_STYLE_DEFAULT;

/**
* @return the value of FEATURE_LINE_ALPHA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
* Use this to determine when loading a different version model if it will bring the whole
* show down. Example, folders were introduced in version 1.3 of Archi but won't open in Archi 1.2.<p>
*
* PLEASE NOTE - THIS IS THE VERSION OF THE INTERNAL MODEL, NOT ARCHI.
* PLEASE NOTE - THIS IS THE VERSION OF THE MODEL, NOT ARCHI.
* As from Archi version 2.6.0 I will try to keep the model version number the same as Archi's version number when the model version is incremented.
* Only need to change the model version number if there are changes that affect backwards compatibility.<p>
* <pre>
* History:
*
* 1.0.0 - Archi versions 0.7 - 1.2.0 the version number was not saved to the XMI file
* History:<br>
*
* 1.0.0 - Archi versions 0.7 - 1.2.0 the version number was not saved to the XMI file<br>
* 1.1.0 - Archi version 1.3.0 introduced sub-folders which are not backwards-compatible
* 1.1.1 - Archi version 1.4.0 added sub-folders in the Views folder which are not backwards-compatible
* 1.2.0 - Archi version 1.5.0 added the Sketch View which is not backwards-compatible, and text alignment attribute
Expand Down Expand Up @@ -50,11 +51,9 @@
* - Add images to IDiagramModelArchimateObject
* - Refactor IDiagramModelImageProvider, IIconic and more...
* 5.0.0 - ArchiMate 3.2
* 5.0.1 - Line styles on diagram objects. Grouping figure has to be set to dashed lines.
*
* </pre>
* @author Phillip Beauvoir
*/
public interface ModelVersion {
String VERSION = "5.0.1"; //$NON-NLS-1$
String VERSION = "5.0.0"; //$NON-NLS-1$
}
Loading

0 comments on commit d0cd284

Please sign in to comment.