Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.tooling.runtime/src/org/eclipse/papyrus/infra/gmfdiag/tooling/runtime/draw2d/labels/VerticalLabelCellEditorLocator.java')
-rwxr-xr-xplugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.tooling.runtime/src/org/eclipse/papyrus/infra/gmfdiag/tooling/runtime/draw2d/labels/VerticalLabelCellEditorLocator.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.tooling.runtime/src/org/eclipse/papyrus/infra/gmfdiag/tooling/runtime/draw2d/labels/VerticalLabelCellEditorLocator.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.tooling.runtime/src/org/eclipse/papyrus/infra/gmfdiag/tooling/runtime/draw2d/labels/VerticalLabelCellEditorLocator.java
new file mode 100755
index 00000000000..ee5c97e2fbc
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.tooling.runtime/src/org/eclipse/papyrus/infra/gmfdiag/tooling/runtime/draw2d/labels/VerticalLabelCellEditorLocator.java
@@ -0,0 +1,36 @@
+package org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.draw2d.labels;
+
+import org.eclipse.draw2d.FigureUtilities;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.tools.CellEditorLocator;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * A cell editor locator for rotated images.
+ */
+public class VerticalLabelCellEditorLocator implements CellEditorLocator {
+
+ private final VerticalLabel myVerticalLabel;
+
+ public VerticalLabelCellEditorLocator(final VerticalLabel verticalLabel) {
+ myVerticalLabel = verticalLabel;
+ }
+
+ /** {@inheritDoc} */
+ public void relocate(final CellEditor celleditor) {
+ Text text = (Text) celleditor.getControl();
+ Rectangle rect = myVerticalLabel.getBounds().getCopy();
+ myVerticalLabel.translateToAbsolute(rect);
+ int avr = FigureUtilities.getFontMetrics(text.getFont()).getAverageCharWidth();
+ Dimension textSize = new Dimension(text.computeSize(SWT.DEFAULT, SWT.DEFAULT)).expand(avr * 2, 0);
+ rect.x = rect.x + 3;
+ rect.y = rect.y + rect.height / 2 - textSize.height / 2;
+ rect.setSize(textSize);
+ if (!rect.equals(new Rectangle(text.getBounds()))) {
+ text.setBounds(rect.x, rect.y, rect.width, rect.height);
+ }
+ }
+} \ No newline at end of file

Back to the top