How to change the target runtime and the color of events [message #1237347] |
Wed, 29 January 2014 08:22  |
Eclipse User |
|
|
|
Hi,
I have extended BPMN2Editor. By this extension I have an own palette and additionally changed the color of start and end event. In case the target runtime at the project properties has been set to 'None', then I want to open the editor with my runtime. I have hoped to solve this issue by:
---------------------------------------------------------------------------------
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
// set the runtime hard coded that the correct one is taken
// needs to be called before INIT that the palette is taken correctly
super.getPreferences().put("target.runtime", "my.runtime");
super.init(site, input);
// determine the correct target runtime
targetRuntime = super.getPreferences().getRuntime();
if (!"my.runtime".equals(targetRuntime.getId())) {
for (TargetRuntime rt : TargetRuntime.getAllRuntimes()) {
if ("my.runtime".equals(rt.getId())) {
targetRuntime = rt;
break;
}
}
}
if (targetRuntime == null) {
targetRuntime = TargetRuntime.getDefaultRuntime();
}
// change the color (currently not working)
// normally we should expect that replacing the runtime should also set the colors
// correctly, but this is not working
ShapeStyle shape;
for (Class key : targetRuntime.getShapeStyles().keySet()) {
if (key.getCanonicalName().equals("org.eclipse.bpmn2.StartEvent")) {
shape = targetRuntime.getShapeStyle(key);
shape.setShapeForeground(ShapeStyle.DEFAULT_COLOR.BLACK);
shape.setShapeBackground(ShapeStyle.DEFAULT_COLOR.BLACK);
shape.setDirty(true);
} else if (key.getCanonicalName().equals("org.eclipse.bpmn2.EndEvent")) {
shape = targetRuntime.getShapeStyle(key);
shape.setShapeForeground(ShapeStyle.DEFAULT_COLOR.BLUE);
shape.setShapeBackground(ShapeStyle.DEFAULT_COLOR.BLUE);
shape.setDirty(true);
}
}
// set the target runtime
TargetRuntime.setCurrentRuntime(targetRuntime);
super.getPreferences().setRuntime(targetRuntime);
}
---------------------------------------------------------------------------------
My issue is that 'my.runtime' is used (the correct palette is shown by the editor), but colors of the start and end events are not correct. The colors are always taken from "org.eclipse.bpmn2.modeler.runtime.none", which has been verified by changing the colors in the debugger.
Any idea how to solve this issue? Thanks
Peter
|
|
|
|
|
|
Re: How to change the target runtime and the color of events [message #1238038 is a reply to message #1238000] |
Fri, 31 January 2014 03:24  |
Eclipse User |
|
|
|
Hi Peter,
I've run across similar issues with the Preference cache and I'm starting to doubt my original design decision. Until I can resolve this and come up with a better idea, try using the getInstance(IProject) to load the cache and associate the preference instance with the project, then call dispose() and getInstance(IProject) again. I know it's a hack, but it might be a workaround for now.
[Updated on: Fri, 31 January 2014 03:25] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.06632 seconds