01: package org.drools.eclipse.flow.ruleflow.editor.editpart;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import org.drools.eclipse.DroolsEclipsePlugin;
20: import org.drools.eclipse.flow.common.editor.editpart.ElementEditPart;
21: import org.drools.eclipse.flow.common.editor.editpart.figure.ElementFigure;
22: import org.eclipse.draw2d.IFigure;
23: import org.eclipse.draw2d.RoundedRectangle;
24: import org.eclipse.draw2d.geometry.Dimension;
25: import org.eclipse.draw2d.geometry.Rectangle;
26: import org.eclipse.jface.resource.ImageDescriptor;
27: import org.eclipse.swt.graphics.Color;
28: import org.eclipse.swt.graphics.Image;
29: import org.eclipse.swt.widgets.Display;
30:
31: /**
32: * EditPart for an action node.
33: *
34: * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris Verlaenen</a>
35: */
36: public class ActionEditPart extends ElementEditPart {
37:
38: private static final Color color = new Color(Display.getCurrent(),
39: 255, 250, 205);
40:
41: protected IFigure createFigure() {
42: return new RuleSetNodeFigure();
43: }
44:
45: public static class RuleSetNodeFigure extends ElementFigure {
46:
47: private static final Image ICON = ImageDescriptor
48: .createFromURL(
49: DroolsEclipsePlugin.getDefault().getBundle()
50: .getEntry("icons/action.gif"))
51: .createImage();
52:
53: private RoundedRectangle rectangle;
54:
55: protected void customizeFigure() {
56: rectangle = new RoundedRectangle();
57: rectangle.setCornerDimensions(new Dimension(25, 25));
58: add(rectangle, 0);
59: rectangle.setBackgroundColor(color);
60: rectangle.setBounds(getBounds());
61: setSelected(false);
62: setIcon(ICON);
63: }
64:
65: public void setBounds(Rectangle rectangle) {
66: super .setBounds(rectangle);
67: this .rectangle.setBounds(rectangle);
68: }
69:
70: public void setSelected(boolean b) {
71: super .setSelected(b);
72: rectangle.setLineWidth(b ? 3 : 1);
73: repaint();
74: }
75: }
76: }
|