Commit 03e135bb authored by Nico Mack's avatar Nico Mack

Fixed an issue in CoronaFactory

parent 54362a4a
......@@ -91,6 +91,7 @@ STROKE_WIDTH_NODE=strokeWidth
FILL_COLOUR_ELEMENT=fillColour
TEXT_COLOUR_ELEMENT=textColour
STROKE_COLOUR_ELEMENT=strokeColour
LABEL_COLOUR_ELEMENT=labelColour
SELECTED_ELEMENT=selected
DESELECTED_ELEMENT=deselected
RGB_COLOUR_NODE=rgb
......@@ -120,9 +121,11 @@ CORNER_RADIUS_NODE=cornerRadius
CIRCLE_SIZE_NODE=circleSize
SQUARE_SIZE_NODE=squareSize
TRIANGLE_SIZE_NODE=triangleSize
LABEL_SHAPE_NODE=labelShape
NAME_ATTRIBUTE=name
REPEAT_ATTRIBUTE=repeat
INDEX_ATTRIBUTE=index
COUNT_ATTRIBUTE=count
SHADE_ATTRIBUTE=shade
SHADE_DARKER_VALUE=darker
SHADE_BRIGHTER_VALUE=brighter
NUMBER_OF_LAYERS_PROPERTY=NumberOfLayers
LAYER_NAME_PROPERTY=LayerName
HANDLE_ID_PROPERTY=HandleId
LAYER_ID_PROPERTY=LayerId
PERSISTENT_PROPERTY=Persistent
PRESELECT_ID_PROPERTY=PreselectId
NUMBER_OF_VARIABLES_PROPERTY=NumberOfVariables
VARIABLE_ID_PROPERTY=VariableId
VARIABLE_NAME_PROPERTY=VariableName
VARIABLE_UNIT_PROPERTY=VariableUnit;
VARIABLE_MINVALUE_PROPERTY=VariableMinValue;
VARIABLE_MAXVALUE_PROPERTY=VariableMaxValue;
VARIABLE_SCALE_PROPERTY=VariableScale;
VARIABLE_COLOUR_PROPERTY=VariableColour
......@@ -37,4 +37,12 @@ public interface BootstrapCallback {
* @return
*/
public BootstrapContext postInstantiation(Element node, BootstrapContext context);
/**
*
* @param context
* @return
*/
public BootstrapContext next(BootstrapContext context);
}
......@@ -587,10 +587,18 @@ public class BootstrappingUtils {
Element rgbNode = colourNode.getChild(Externalization.RGB_COLOUR_NODE);
if (rgbNode != null) {
int rgb = getContentAsInteger(colourNode, Externalization.RGB_COLOUR_NODE, BootstrappingUtils.MANDATORY, null, context);
String shade = getAttributeAsString(rgbNode, Externalization.SHADE_ATTRIBUTE, BootstrappingUtils.OPTIONAL, Externalization.EMPTY_STRING);
int alpha = getContentAsInteger(colourNode, Externalization.ALPHA_NODE, BootstrappingUtils.OPTIONAL, 255, context);
rgb += alpha << 24;
colour = new Color(rgb, true); // With Alpha Channel
if (Externalization.SHADE_DARKER_VALUE.equals(shade)) {
colour = colour.darker();
} else if (Externalization.SHADE_BRIGHTER_VALUE.equals(shade)) {
colour = colour.brighter();
}
} else {
String colourString = getContent(colourNode, Externalization.EMPTY_STRING, null);
if ((colourString != null) && (colourString.length() > 0)) {
......
......@@ -85,11 +85,11 @@ public class CoronaFactory<C extends Corona> implements Iterator<C> {
C next = null;
try {
if ((callback != null) && (repeating))
if (callback != null)
this.context = callback.preInstantiation(this.coronaNode, this.context);
C instance = (C) CoronaBootstrapper.buildCoronaFromElement(this.coronaNode, this.context, this.callback);
next = instance;
if ((callback != null) && (repeating))
if (callback != null)
this.context = callback.postInstantiation(this.coronaNode, this.context);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException | BuildException exception) {
logger.error("Failed to instantiate a corona from template!", exception); //$NON-NLS-1$
......@@ -97,6 +97,8 @@ public class CoronaFactory<C extends Corona> implements Iterator<C> {
this.index++;
if (this.repeating) {
context.setProperty(this.indexVariable, this.index);
if (callback != null)
this.context = callback.next(context);
}
return next;
......
......@@ -132,9 +132,13 @@ public class Externalization extends NLS {
public static String FILL_COLOUR_ELEMENT;
public static String TEXT_COLOUR_ELEMENT;
public static String STROKE_COLOUR_ELEMENT;
public static String LABEL_COLOUR_ELEMENT;
public static String SELECTED_ELEMENT;
public static String DESELECTED_ELEMENT;
public static String RGB_COLOUR_NODE;
public static String SHADE_ATTRIBUTE;
public static String SHADE_DARKER_VALUE;
public static String SHADE_BRIGHTER_VALUE;
public static String TRIGGER_CONDITION_NODE;
......@@ -159,6 +163,7 @@ public class Externalization extends NLS {
public static String TEMPLATES_NODE;
public static String TEMPLATE_NODE;
public static String LABEL_SHAPE_NODE;
public static String ASSIGNABLE_NODE;
public static String ZOOM_LEVEL_NODE;
public static String SYNCHRONOUS_ZOOM_NODE;
......
package lu.list.itis.dkd.tui.utility;
import org.eclipse.osgi.util.NLS;
public class Templating extends NLS {
private static final String BUNDLE_NAME = "templating"; //$NON-NLS-1$
public static String HANDLE_ID_PROPERTY;
public static String NUMBER_OF_LAYERS_PROPERTY;
public static String LAYER_NAME_PROPERTY;
public static String LAYER_ID_PROPERTY;
public static String PERSISTENT_PROPERTY;
public static String PRESELECT_ID_PROPERTY;
public static String NUMBER_OF_VARIABLES_PROPERTY;
public static String VARIABLE_ID_PROPERTY;
public static String VARIABLE_NAME_PROPERTY;
public static String VARIABLE_UNIT_PROPERTY;
public static String VARIABLE_MINVALUE_PROPERTY;
public static String VARIABLE_MAXVALUE_PROPERTY;
public static String VARIABLE_SCALE_PROPERTY;
public static String VARIABLE_COLOUR_PROPERTY;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Templating.class);
}
private Templating() {}
}
......@@ -105,4 +105,11 @@ public class TemplateBootstrapperTest implements BootstrapCallback {
return context;
}
/** {@inheritDoc} */
@Override
public BootstrapContext next(BootstrapContext context) {
// TODO Auto-generated method stub
return null;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment