01: /*******************************************************************************
02: * Copyright (c) 2000, 2004 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Common Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/cpl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.openwfe.gpe.parts;
11:
12: import org.eclipse.swt.graphics.Point;
13: import org.eclipse.swt.widgets.Text;
14:
15: import org.eclipse.jface.viewers.CellEditor;
16:
17: import org.eclipse.draw2d.Label;
18: import org.eclipse.draw2d.geometry.Rectangle;
19:
20: import org.eclipse.gef.tools.CellEditorLocator;
21:
22: /**
23: * CellEditorLocator for Activities.
24: * @author Daniel Lee
25: */
26: public class FlowElementCellEditorLocator implements CellEditorLocator {
27: private Label label;
28:
29: /**
30: * Creates a new FlowElementCellEditorLocator for the given Label
31: * @param label the Label
32: */
33: public FlowElementCellEditorLocator(Label label) {
34: setLabel(label);
35: }
36:
37: /**
38: * @see CellEditorLocator#relocate(org.eclipse.jface.viewers.CellEditor)
39: */
40: public void relocate(CellEditor celleditor) {
41: Text text = (Text) celleditor.getControl();
42: Point pref = text.computeSize(-1, -1);
43: Rectangle rect = label.getTextBounds().getCopy();
44: label.translateToAbsolute(rect);
45: text.setBounds(rect.x - 1, rect.y - 1, pref.x + 1, pref.y + 1);
46: }
47:
48: /**
49: * Returns the Label figure.
50: * @return the Label
51: */
52: protected Label getLabel() {
53: return label;
54: }
55:
56: /**
57: * Sets the label.
58: * @param label The label to set
59: */
60: protected void setLabel(Label label) {
61: this.label = label;
62: }
63:
64: }
|