| /******************************************************************************* |
| * Copyright (c) 2006, 2010 Soyatec (http://www.soyatec.com) and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Soyatec - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.xwt.tools.ui.designer.parts.direct; |
| |
| import org.eclipse.draw2d.IFigure; |
| 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.graphics.Point; |
| import org.eclipse.swt.widgets.Text; |
| |
| public class ElementCellEditLocator implements CellEditorLocator { |
| private IFigure figure; |
| |
| public ElementCellEditLocator(IFigure figure) { |
| this.figure = figure; |
| } |
| |
| public void relocate(CellEditor celleditor) { |
| Text text = (Text) celleditor.getControl(); |
| Point pref = text.computeSize(SWT.DEFAULT, SWT.DEFAULT); |
| Rectangle rect = this.figure.getBounds(); |
| text.setBounds(rect.x - 1, rect.y - 1, pref.x + 1, pref.y + 1); |
| |
| } |
| |
| } |