Skip to content

Commit

Permalink
Add new methods to UIProviders to support default value and value for…
Browse files Browse the repository at this point in the history
… features

- This will be needed for line styles where the default value will be different for the Grouping figure

- Add getDefaultFeatureValue(String featureName) to return a default value for a feature

- Add getFeatureValue(String featureName) to return a value for a feature which might be the feature value or the default feature value

- Move some methods up into IObjectUIProvider as default implementations

- Remove deprecated methods
  • Loading branch information
Phillipus committed Nov 21, 2024
1 parent 5025d77 commit b412db3
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ public Dimension getDefaultSize() {
return new Dimension(-1, -1);
}

/**
* @deprecated Use {@link #getDefaultSize()}
*/
@Override
public Dimension getUserDefaultSize() {
return getDefaultSize();
}

@Override
public int getDefaultTextAlignment() {
return ITextAlignment.TEXT_ALIGNMENT_CENTER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
*/
package com.archimatetool.editor.ui.factory;

import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPart;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;



Expand All @@ -36,34 +32,4 @@ void setInstance(EObject instance) {
this.instance = instance;
}

@Override
public String getDefaultName() {
return ""; //$NON-NLS-1$
}

@Override
public EditPart createEditPart() {
return null;
}

@Override
public Image getImage() {
return null;
}

@Override
public ImageDescriptor getImageDescriptor() {
return null;
}

@Override
@Deprecated
public boolean shouldExposeFeature(EAttribute feature) {
return shouldExposeFeature(feature.getName());
}

@Override
public boolean shouldExposeFeature(String featureName) {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ static Dimension defaultSize() {
*/
Dimension getDefaultSize();

/**
* @deprecated Use {@link #getDefaultSize()}
* @return The default size as set by the user for this object
*/
Dimension getUserDefaultSize();

/**
* @return The default text alignment
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
package com.archimatetool.editor.ui.factory;

import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.gef.EditPart;
import org.eclipse.jface.resource.ImageDescriptor;
Expand All @@ -29,33 +28,52 @@ public interface IObjectUIProvider {
/**
* @return A new GEF EditPart for this type of class
*/
EditPart createEditPart();
default EditPart createEditPart() {
return null;
}

/**
* @return The default name for this type of object
*/
String getDefaultName();
default String getDefaultName() {
return ""; //$NON-NLS-1$
}

/**
* @return The iconic image to use for this object
*/
Image getImage();
default Image getImage() {
return null;
}

/**
* @return The iconic image descriptor to use for this object
*/
ImageDescriptor getImageDescriptor();
default ImageDescriptor getImageDescriptor() {
return null;
}

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

default boolean shouldExposeFeature(String featureName) {
return true;
}

/**
* @param feature The feature in question
* @return True if this object should expose a feature in the UI
* @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
*/
boolean shouldExposeFeature(String featureName);
default Object getFeatureValue(String featureName) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.eclipse.emf.ecore.EClass;
Expand Down Expand Up @@ -82,7 +83,16 @@ public void testShouldExposeFeature(IObjectUIProvider provider) {
assertTrue(provider.shouldExposeFeature((String)null));
}

@ParamsTest
public void testGetDefaultFeatureValue(IObjectUIProvider provider) {
assertNull(provider.getDefaultFeatureValue((String)null));
}

@ParamsTest
public void testGetFeatureValue(IObjectUIProvider provider) {
assertNull(provider.getFeatureValue((String)null));
}

protected EObject createInstanceForExpectedClass(EClass expectedClass) {
return expectedClass.getEPackage().getEFactoryInstance().create(expectedClass);
}
Expand Down

0 comments on commit b412db3

Please sign in to comment.