use of org.eclipse.ui.part.CellEditorActionHandler in project statecharts by Yakindu.
the class XtextDirectEditManager method initCellEditor.
protected void initCellEditor() {
committed = false;
// Get the Text Compartments Edit Part
setEditText(getEditPart().getEditText());
IFigure label = getEditPart().getFigure();
Assert.isNotNull(label);
StyledText text = (StyledText) getCellEditor().getControl();
// scale the font accordingly to the zoom level
text.setFont(getScaledFont(label));
// Hook the cell editor's copy/paste actions to the actionBars so that
// they can
// be invoked via keyboard shortcuts.
actionBars = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorSite().getActionBars();
saveCurrentActions(actionBars);
actionHandler = new CellEditorActionHandler(actionBars);
actionHandler.addCellEditor(getCellEditor());
actionBars.updateActionBars();
}
use of org.eclipse.ui.part.CellEditorActionHandler in project webtools.sourceediting by eclipse.
the class LabelEditManager method initCellEditor.
protected void initCellEditor() {
Text text = (Text) getCellEditor().getControl();
Label label = ((INamedEditPart) getEditPart()).getNameLabelFigure();
if (label != null) {
scaledFont = label.getFont();
Color color = label.getBackgroundColor();
text.setBackground(color);
String initialLabelText = label.getText();
getCellEditor().setValue(initialLabelText);
} else {
scaledFont = label.getParent().getFont();
text.setBackground(label.getParent().getBackgroundColor());
}
FontData data = scaledFont.getFontData()[0];
Dimension fontSize = new Dimension(0, data.getHeight());
label.getParent().translateToAbsolute(fontSize);
data.setHeight(fontSize.height);
scaledFont = new Font(null, data);
text.setFont(scaledFont);
// text.selectAll();
// Hook the cell editor's copy/paste actions to the actionBars so that they can
// be invoked via keyboard shortcuts.
actionBars = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorSite().getActionBars();
saveCurrentActions(actionBars);
actionHandler = new CellEditorActionHandler(actionBars);
actionHandler.addCellEditor(getCellEditor());
actionBars.updateActionBars();
}
use of org.eclipse.ui.part.CellEditorActionHandler in project webtools.sourceediting by eclipse.
the class TopLevelNameDirectEditManager method initCellEditor.
protected void initCellEditor() {
Text text = (Text) getCellEditor().getControl();
Label label = ((INamedEditPart) getEditPart()).getNameLabelFigure();
if (label != null) {
scaledFont = label.getFont();
Color color = label.getBackgroundColor();
text.setBackground(color);
String initialLabelText = component.getName();
getCellEditor().setValue(initialLabelText);
} else {
scaledFont = label.getParent().getFont();
text.setBackground(label.getParent().getBackgroundColor());
}
FontData data = scaledFont.getFontData()[0];
Dimension fontSize = new Dimension(0, data.getHeight());
label.getParent().translateToAbsolute(fontSize);
data.setHeight(fontSize.height);
scaledFont = new Font(null, data);
text.setFont(scaledFont);
// text.selectAll();
// Hook the cell editor's copy/paste actions to the actionBars so that they
// can
// be invoked via keyboard shortcuts.
actionBars = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorSite().getActionBars();
saveCurrentActions(actionBars);
actionHandler = new CellEditorActionHandler(actionBars);
actionHandler.addCellEditor(getCellEditor());
actionBars.updateActionBars();
}
use of org.eclipse.ui.part.CellEditorActionHandler in project yamcs-studio by yamcs.
the class TextEditManager method initCellEditor.
@Override
protected void initCellEditor() {
// update text
var textFigure = getEditPart().getAdapter(ITextFigure.class);
// var labelModel = (AbstractWidgetModel) getEditPart().getModel();
getCellEditor().setValue(textFigure.getText());
if (textFigure.isOpaque() || textFigure.getBorder() instanceof AbstractBackground) {
getCellEditor().getControl().setBackground(textFigure.getBackgroundColor());
} else {
getCellEditor().getControl().setBackground(textFigure.getParent().getBackgroundColor());
}
getCellEditor().getControl().setForeground(textFigure.getForegroundColor());
// update font
var zoomMgr = (ZoomManager) getEditPart().getViewer().getProperty(ZoomManager.class.toString());
if (zoomMgr != null) {
// this will force the font to be set
cachedZoom = -1.0;
updateScaledFont(zoomMgr.getZoom());
zoomMgr.addZoomListener(zoomListener);
} else {
getCellEditor().getControl().setFont(textFigure.getFont());
}
// Hook the cell editor's copy/paste actions to the actionBars so that they can
// be invoked via keyboard shortcuts.
var activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (activeEditor != null) {
actionBars = activeEditor.getEditorSite().getActionBars();
saveCurrentActions(actionBars);
actionHandler = new CellEditorActionHandler(actionBars);
actionHandler.addCellEditor(getCellEditor());
actionBars.updateActionBars();
}
}
use of org.eclipse.ui.part.CellEditorActionHandler in project eclipse.platform.text by eclipse.
the class SearchResultView method createPartControl.
/**
* Creates the search list inner viewer.
* @param parent the parent
*/
@Override
public void createPartControl(Composite parent) {
Assert.isTrue(fViewer == null);
fViewer = new SearchResultViewer(this, parent);
if (fMemento != null)
fViewer.restoreState(fMemento);
fMemento = null;
SearchManager.getDefault().addSearchChangeListener(fViewer);
fViewer.init();
// Add selectAll action handlers.
fCellEditorActionHandler = new CellEditorActionHandler(getViewSite().getActionBars());
fSelectAllAction = new SelectAllAction();
fSelectAllAction.setViewer(fViewer);
fCellEditorActionHandler.setSelectAllAction(fSelectAllAction);
fillActionBars(getViewSite().getActionBars());
fPropertyChangeListener = event -> {
if (SearchPreferencePage.POTENTIAL_MATCH_FG_COLOR.equals(event.getProperty()) || SearchPreferencePage.EMPHASIZE_POTENTIAL_MATCHES.equals(event.getProperty()))
if (fViewer != null)
fViewer.updatedPotentialMatchFgColor();
};
SearchPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
PlatformUI.getWorkbench().getHelpSystem().setHelp(fViewer.getControl(), SearchPlugin.getDefault().getSearchViewHelpContextId());
}
Aggregations