Skip to content

Commit

Permalink
Temp 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillipus committed Nov 7, 2024
1 parent 1a42c0d commit ae85bd7
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,16 +270,8 @@ protected int getLineWidth() {
}

protected int getLineStyle() {
int value = fDiagramModelObject.getLineStyle();

if(value == IDiagramModelObject.LINE_STYLE_DEFAULT) {
IObjectUIProvider provider = ObjectUIFactory.INSTANCE.getProvider(getDiagramModelObject());
if(provider != null && provider.getDefaultFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE) instanceof Integer val) {
value = val;
}
}

return value;
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 @@ -111,16 +111,8 @@ private boolean isValidObject(EObject eObject) {
}

private int getLineStyle(IDiagramModelObject dmo) {
int value = dmo.getLineStyle();

if(value == IDiagramModelObject.LINE_STYLE_DEFAULT) {
IObjectUIProvider provider = ObjectUIFactory.INSTANCE.getProvider(dmo);
if(provider != null && provider.getDefaultFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE) instanceof Integer val) {
value = val;
}
}

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

void updateControl() {
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,26 @@ 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();
if(value == IDiagramModelObject.LINE_STYLE_DEFAULT) {
return getDefaultFeatureValue(featureName);
}
return value;
}

return super.getFeatureValue(featureName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,4 @@ public boolean shouldExposeFeature(EAttribute feature) {
public boolean shouldExposeFeature(String featureName) {
return true;
}

@Override
public Object getDefaultFeatureValue(String featureName) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,15 @@ public interface IObjectUIProvider {
* @param featureName The feature in question
* @return a default value for a given feature. Default is null
*/
Object getDefaultFeatureValue(String featureName);
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 @@ -76,11 +76,13 @@ 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);
}
}

0 comments on commit ae85bd7

Please sign in to comment.