use of com.archimatetool.editor.ui.components.GlobalActionDisablementHandler in project archi by archimatetool.
the class AbstractDiagramEditorActionBarContributor method contributeToToolBar.
@Override
public void contributeToToolBar(IToolBarManager toolBarManager) {
// Add the Zoom Manager Combo
fZoomCombo = new ZoomComboContributionItem(getPage()) {
// Hook into the Combo so we can disable global edit action handlers when it gets the focus
private GlobalActionDisablementHandler globalActionHandler;
@Override
protected Control createControl(Composite parent) {
Combo combo = (Combo) super.createControl(parent);
combo.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
globalActionHandler = new GlobalActionDisablementHandler(getActionBars());
globalActionHandler.clearGlobalActions();
}
@Override
public void focusLost(FocusEvent e) {
if (globalActionHandler != null) {
globalActionHandler.restoreGlobalActions();
}
}
});
return combo;
}
@Override
protected int computeWidth(Control control) {
// On Linux GTK this can get too wide
return Math.min(super.computeWidth(control), 100);
}
};
toolBarManager.add(fZoomCombo);
toolBarManager.add(new Separator());
toolBarManager.add(getAction(GEFActionConstants.ALIGN_LEFT));
toolBarManager.add(getAction(GEFActionConstants.ALIGN_CENTER));
toolBarManager.add(getAction(GEFActionConstants.ALIGN_RIGHT));
toolBarManager.add(new Separator());
toolBarManager.add(getAction(GEFActionConstants.ALIGN_TOP));
toolBarManager.add(getAction(GEFActionConstants.ALIGN_MIDDLE));
toolBarManager.add(getAction(GEFActionConstants.ALIGN_BOTTOM));
toolBarManager.add(new Separator());
toolBarManager.add(getAction(GEFActionConstants.MATCH_WIDTH));
toolBarManager.add(getAction(GEFActionConstants.MATCH_HEIGHT));
toolBarManager.add(getAction(GEFActionConstants.MATCH_SIZE));
toolBarManager.add(new Separator());
toolBarManager.add(getAction(DefaultEditPartSizeAction.ID));
toolBarManager.add(getAction(ResetAspectRatioAction.ID));
toolBarManager.add(new GroupMarker(GROUP_TOOLBAR_END));
}
use of com.archimatetool.editor.ui.components.GlobalActionDisablementHandler in project archi by archimatetool.
the class AbstractDirectEditManager method initCellEditor.
@Override
protected void initCellEditor() {
// Hook into the global Action Handlers and null them
fGlobalActionHandler = new GlobalActionDisablementHandler();
fGlobalActionHandler.clearGlobalActions();
// Filter out any illegal xml characters
UIUtils.applyInvalidCharacterFilter(getTextControl());
}
use of com.archimatetool.editor.ui.components.GlobalActionDisablementHandler in project archi by archimatetool.
the class UserPropertiesSection method hookCellEditorGlobalActionHandler.
/**
* Set some editing global Action Handlers to null when the cell editor is activated
* And restore them when the cell editor is deactivated.
*/
private void hookCellEditorGlobalActionHandler(CellEditor cellEditor) {
Listener listener = new Listener() {
// We have to disable the action handlers of the the active Editor/View site *and* the Properties View Site
GlobalActionDisablementHandler propertiesViewGlobalActionHandler, globalActionHandler;
@Override
public void handleEvent(Event event) {
switch(event.type) {
case SWT.Activate:
// The Properties View site action bars
IActionBars actionBars = fPage.getSite().getActionBars();
propertiesViewGlobalActionHandler = new GlobalActionDisablementHandler(actionBars);
propertiesViewGlobalActionHandler.clearGlobalActions();
// The active View or Editor site's action bars also have to be updated
globalActionHandler = new GlobalActionDisablementHandler();
globalActionHandler.update();
break;
case SWT.Deactivate:
if (propertiesViewGlobalActionHandler != null) {
propertiesViewGlobalActionHandler.restoreGlobalActions();
globalActionHandler.update();
}
break;
default:
break;
}
}
};
cellEditor.getControl().addListener(SWT.Activate, listener);
cellEditor.getControl().addListener(SWT.Deactivate, listener);
}
Aggregations