use of org.eclipse.gef.tools.DirectEditManager in project yamcs-studio by yamcs.
the class PVWidgetSelectionHandle method createDragTracker.
@Override
protected DragTracker createDragTracker() {
DragEditPartsTracker tracker = new DragEditPartsTracker(getOwner()) {
@Override
protected boolean handleButtonDown(int button) {
if ((button == 1 || button == 3) && widgetModel instanceof IPVWidgetModel) {
DirectEditManager directEditManager = new PVNameDirectEditManager(getOwner(), new CellEditorLocator() {
@Override
public void relocate(CellEditor celleditor) {
Rectangle rect;
int width = 120;
if (!pvName.isEmpty() && getTextExtent().width > 120)
width = getTextExtent().width + 4;
rect = new Rectangle(PVWidgetSelectionHandle.this.getLocation(), new Dimension(width, getTextExtent().height));
translateToAbsolute(rect);
Text control = (Text) celleditor.getControl();
org.eclipse.swt.graphics.Rectangle trim = control.computeTrim(0, 0, 0, 0);
rect.translate(trim.x, trim.y);
rect.width += trim.width;
rect.height += trim.height;
control.setBounds(rect.x, rect.y, rect.width, rect.height);
}
});
directEditManager.show();
}
return true;
}
};
tracker.setDefaultCursor(getCursor());
return tracker;
}
use of org.eclipse.gef.tools.DirectEditManager in project statecharts by Yakindu.
the class ExternalXtextLabelEditPart method performDirectEditRequest.
@Override
protected void performDirectEditRequest(final Request request) {
final DirectEditManager manager = createDirectEditManager();
final Request theRequest = request;
try {
getEditingDomain().runExclusive(new Runnable() {
public void run() {
if (isActive()) {
if (theRequest.getExtendedData().get(REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
final Character initialChar = (Character) theRequest.getExtendedData().get(REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
if (manager instanceof XtextDirectEditManager) {
XtextDirectEditManager xtextDirectEditManager = (XtextDirectEditManager) manager;
xtextDirectEditManager.show(initialChar);
} else if (manager instanceof TextDirectEditManager) {
((TextDirectEditManager) manager).show(initialChar);
}
} else {
manager.show();
}
if (manager instanceof XtextDirectEditManager) {
XtextDirectEditManager xtextDirectEditManager = (XtextDirectEditManager) manager;
XtextStyledTextCellEditor cellEditor = (XtextStyledTextCellEditor) xtextDirectEditManager.getCellEditor();
setContext(cellEditor.getXtextAdapter().getFakeResourceContext().getFakeResource());
}
}
}
});
} catch (final InterruptedException e) {
e.printStackTrace();
}
}
use of org.eclipse.gef.tools.DirectEditManager in project statecharts by Yakindu.
the class XtextLabelEditPart method performDirectEditRequest.
@Override
public void performDirectEditRequest(final Request request) {
final DirectEditManager manager = createDirectEditManager();
final Request theRequest = request;
try {
getEditingDomain().runExclusive(new Runnable() {
public void run() {
if (isActive()) {
if (theRequest.getExtendedData().get(REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
final Character initialChar = (Character) theRequest.getExtendedData().get(REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
if (manager instanceof XtextDirectEditManager) {
XtextDirectEditManager xtextDirectEditManager = (XtextDirectEditManager) manager;
xtextDirectEditManager.show(initialChar);
} else if (manager instanceof TextDirectEditManager) {
((TextDirectEditManager) manager).show(initialChar);
}
} else {
manager.show();
}
if (manager instanceof XtextDirectEditManager) {
XtextDirectEditManager xtextDirectEditManager = (XtextDirectEditManager) manager;
XtextStyledTextCellEditor cellEditor = (XtextStyledTextCellEditor) xtextDirectEditManager.getCellEditor();
setContext(cellEditor.getXtextAdapter().getFakeResourceContext().getFakeResource());
}
}
}
});
} catch (final InterruptedException e) {
e.printStackTrace();
}
}
use of org.eclipse.gef.tools.DirectEditManager in project dbeaver by serge-rider.
the class AttributePart method performDirectEdit.
protected void performDirectEdit() {
ERDGraphicalViewer viewer = (ERDGraphicalViewer) getViewer();
ValidationMessageHandler handler = viewer.getValidationHandler();
Label l = getFigure().getLabel();
ColumnNameTypeCellEditorValidator columnNameTypeCellEditorValidator = new ColumnNameTypeCellEditorValidator(handler);
DirectEditManager manager = new ExtendedDirectEditManager(this, TextCellEditor.class, new LabelCellEditorLocator(l), l, columnNameTypeCellEditorValidator);
manager.show();
}
Aggregations