use of org.knime.workbench.editor2.directannotationedit.StyledTextEditorLocator in project knime-core by knime.
the class AnnotationEditPolicy method getDirectEditCommand.
/**
* {@inheritDoc}
*/
@Override
protected Command getDirectEditCommand(final DirectEditRequest edit) {
StyledTextEditor ste = (StyledTextEditor) edit.getCellEditor();
AnnotationData newAnnoData = (AnnotationData) ste.getValue();
AnnotationEditPart annoPart = (AnnotationEditPart) getHost();
Annotation oldAnno = annoPart.getModel();
Rectangle oldFigBounds = annoPart.getFigure().getBounds().getCopy();
// y-coordinate is the only dimension that doesn't change
newAnnoData.setY(oldFigBounds.y);
// trim was never really verified (was always 0 on my platform),
// see also StyledTextEditorLocator#relocate
Composite compositeEditor = (Composite) ste.getControl();
org.eclipse.swt.graphics.Rectangle trim = compositeEditor.computeTrim(0, 0, 0, 0);
if (annoPart instanceof NodeAnnotationEditPart) {
// the width and height grow with the text entered
newAnnoData.setX(compositeEditor.getBounds().x);
newAnnoData.setHeight(compositeEditor.getBounds().height - trim.height);
newAnnoData.setWidth(compositeEditor.getBounds().width - trim.width);
} else {
// with workflow annotations only the height grows with the text
newAnnoData.setX(oldFigBounds.x);
newAnnoData.setHeight(compositeEditor.getBounds().height - trim.height);
newAnnoData.setWidth(oldFigBounds.width - trim.width);
}
if (hasAnnotationDataChanged(oldAnno, newAnnoData)) {
return new AnnotationEditCommand(annoPart, oldAnno, newAnnoData);
}
return null;
}
use of org.knime.workbench.editor2.directannotationedit.StyledTextEditorLocator in project knime-core by knime.
the class AnnotationEditPart method performEdit.
/**
* Opens the editor to directoy edit the annotation in place.
*/
public void performEdit() {
final EditPart parent = getParent();
if (parent instanceof WorkflowRootEditPart) {
WorkflowRootEditPart wkfRootEdit = (WorkflowRootEditPart) parent;
if (wkfRootEdit.getWorkflowManager().isWriteProtected()) {
return;
}
}
if (m_directEditManager == null) {
m_directEditManager = new AnnotationEditManager(this, new StyledTextEditorLocator((NodeAnnotationFigure) getFigure()));
}
m_directEditManager.show();
}
Aggregations