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.flow.common.editor.editpart.ElementEditPart;
20: import org.drools.eclipse.flow.common.editor.editpart.figure.ElementFigure;
21: import org.eclipse.draw2d.IFigure;
22: import org.eclipse.draw2d.RoundedRectangle;
23: import org.eclipse.draw2d.geometry.Dimension;
24: import org.eclipse.draw2d.geometry.Rectangle;
25: import org.eclipse.swt.graphics.Color;
26: import org.eclipse.swt.widgets.Display;
27:
28: /**
29: * EditPart for a RuleSet node.
30: *
31: * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris Verlaenen</a>
32: */
33: public class RuleSetNodeEditPart extends ElementEditPart {
34:
35: private static final Color color = new Color(Display.getCurrent(),
36: 255, 250, 205);
37:
38: protected IFigure createFigure() {
39: return new RuleSetNodeFigure();
40: }
41:
42: public class RuleSetNodeFigure extends ElementFigure {
43:
44: private RoundedRectangle rectangle;
45:
46: protected void customizeFigure() {
47: rectangle = new RoundedRectangle();
48: rectangle.setCornerDimensions(new Dimension(25, 25));
49: add(rectangle, 0);
50: rectangle.setBackgroundColor(color);
51: rectangle.setBounds(getBounds());
52: setSelected(false);
53: }
54:
55: public void setBounds(Rectangle rectangle) {
56: super .setBounds(rectangle);
57: this .rectangle.setBounds(rectangle);
58: }
59:
60: public void setSelected(boolean b) {
61: super .setSelected(b);
62: rectangle.setLineWidth(b ? 3 : 1);
63: repaint();
64: }
65: }
66: }
|