use of org.whole.lang.e4.ui.actions.E4NavigationKeyHandler in project whole by wholeplatform.
the class ModelMergeViewer method createMergeArea.
protected Control createMergeArea(Composite parent) {
IImportAsModelDialogFactory factory = ContextInjectionFactory.make(ImportAsModelDialogFactory.class, getContext());
IEclipseContext params = EclipseContextFactory.create();
params.set("parent", parent);
params.set(IImportAsModelDialogFactory.class, factory);
viewer = ContextInjectionFactory.make(E4GraphicalViewer.class, getContext(), params);
viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
updateSelection(E4Utils.createSelectionBindings(event, getContext()));
}
});
viewer.getControl().addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent event) {
}
@SuppressWarnings("unchecked")
@Override
public void focusGained(FocusEvent event) {
getContext().set(IEntityPartViewer.class, viewer);
getContext().set(ActionRegistry.class, actionRegistry);
updateSelection(E4Utils.createSelectionBindings(viewer.getSelectedEditParts(), viewer, getContext()));
}
});
viewer.addPartFocusListener(new IPartFocusListener() {
@SuppressWarnings("unchecked")
public void focusChanged(IEntityPart oldPart, IEntityPart newPart) {
updateSelection(E4Utils.createSelectionBindings(viewer.getSelectedEditParts(), viewer, getContext()));
}
});
E4KeyHandler keyHandler = new E4KeyHandler(getContext());
keyHandler.setParent(new E4NavigationKeyHandler(getContext()));
viewer.setKeyHandler(keyHandler);
viewer.setEntityContents(createDefaultContents());
getContext().set(IEntityPartViewer.class, viewer);
actionRegistry = ContextInjectionFactory.make(ActionRegistry.class, getContext());
actionRegistry.registerWorkbenchActions();
getContext().set(ActionRegistry.class, actionRegistry);
JFaceMenuBuilder uiBuilder = ContextInjectionFactory.make(JFaceMenuBuilder.class, getContext());
contextMenuProvider = new PopupMenuProvider<IContributionItem, IMenuManager>(uiBuilder);
viewer.setContextMenu(new ContextMenuProvider(viewer) {
@Override
public void buildContextMenu(IMenuManager menuManager) {
contextMenuProvider.populate(menuManager);
}
});
return parent;
}
use of org.whole.lang.e4.ui.actions.E4NavigationKeyHandler in project whole by wholeplatform.
the class E4Dialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
if (E4Utils.isLegacyApplication())
HandlersBehavior.registerHandlers(handlerService);
IEclipseContext params = EclipseContextFactory.create();
params.set("parent", parent);
viewer = ContextInjectionFactory.make(E4GraphicalViewer.class, context, params);
viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
updateSelection(E4Utils.createSelectionBindings(event, context));
}
});
viewer.getControl().addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent event) {
}
@SuppressWarnings("unchecked")
@Override
public void focusGained(FocusEvent event) {
context.set(IEntityPartViewer.class, viewer);
context.set(ActionRegistry.class, actionRegistry);
updateSelection(E4Utils.createSelectionBindings(viewer.getSelectedEditParts(), viewer, context));
}
});
viewer.addPartFocusListener(new IPartFocusListener() {
@SuppressWarnings("unchecked")
public void focusChanged(IEntityPart oldPart, IEntityPart newPart) {
updateSelection(E4Utils.createSelectionBindings(viewer.getSelectedEditParts(), viewer, context));
context.activateBranch();
}
});
E4KeyHandler keyHandler = new E4KeyHandler(context);
keyHandler.setParent(new E4NavigationKeyHandler(context));
context.set(IEntityPartViewer.class, viewer);
viewer.setKeyHandler(keyHandler);
viewer.setEntityContents(createDefaultContents());
actionRegistry = ContextInjectionFactory.make(ActionRegistry.class, context);
actionRegistry.registerWorkbenchActions();
context.set(ActionRegistry.class, actionRegistry);
JFaceMenuBuilder uiBuilder = ContextInjectionFactory.make(JFaceMenuBuilder.class, context);
contextMenuProvider = new PopupMenuProvider<IContributionItem, IMenuManager>(uiBuilder);
viewer.setContextMenu(new ContextMenuProvider(viewer) {
@Override
public void buildContextMenu(IMenuManager menuManager) {
contextMenuProvider.populate(menuManager);
}
});
return parent;
}
use of org.whole.lang.e4.ui.actions.E4NavigationKeyHandler in project whole by wholeplatform.
the class E4FindReplaceDialog method createReplaceArea.
protected Control createReplaceArea(Composite parent) {
IEclipseContext params = EclipseContextFactory.create();
params.set("parent", parent);
replaceViewer = ContextInjectionFactory.make(E4GraphicalViewer.class, context, params);
replaceViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
replaceViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
updateSelection(E4Utils.createSelectionBindings(event, context));
}
});
replaceViewer.getControl().addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
}
@SuppressWarnings("unchecked")
@Override
public void focusGained(FocusEvent e) {
context.set(IEntityPartViewer.class, replaceViewer);
context.set(ActionRegistry.class, replaceActionRegistry);
updateSelection(E4Utils.createSelectionBindings(replaceViewer.getSelectedEditParts(), replaceViewer, context));
}
});
replaceViewer.addPartFocusListener(new IPartFocusListener() {
@SuppressWarnings("unchecked")
public void focusChanged(IEntityPart oldPart, IEntityPart newPart) {
updateSelection(E4Utils.createSelectionBindings(replaceViewer.getSelectedEditParts(), replaceViewer, context));
}
});
E4KeyHandler keyHandler = new E4KeyHandler(context);
keyHandler.setParent(new E4NavigationKeyHandler(context));
replaceViewer.setKeyHandler(keyHandler);
replaceViewer.setEntityContents(createDefaultContents());
context.set(IEntityPartViewer.class, replaceViewer);
replaceActionRegistry = ContextInjectionFactory.make(ActionRegistry.class, context);
replaceActionRegistry.registerWorkbenchActions();
context.set(ActionRegistry.class, replaceActionRegistry);
replaceViewer.setContextMenu(new ContextMenuProvider(replaceViewer) {
@Override
public void buildContextMenu(IMenuManager menuManager) {
contextMenuProvider.populate(menuManager);
}
});
return parent;
}
use of org.whole.lang.e4.ui.actions.E4NavigationKeyHandler in project whole by wholeplatform.
the class AbstractE4Part method createPartControl.
@PostConstruct
public void createPartControl(Composite parent) {
restoreState();
registerHandlers();
parent.setLayout(new FillLayout());
viewer = createEntityViewer(parent);
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
updateSelection(E4Utils.createSelectionBindings(event, context));
}
});
viewer.getControl().addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent event) {
}
@Override
@SuppressWarnings("unchecked")
public void focusGained(FocusEvent event) {
context.set(IEntityPartViewer.class, viewer);
context.set(ActionRegistry.class, actionRegistry);
updateSelection(E4Utils.createSelectionBindings(viewer.getSelectedEditParts(), viewer, context));
}
});
viewer.addPartFocusListener(new IPartFocusListener() {
@SuppressWarnings("unchecked")
public void focusChanged(IEntityPart oldPart, IEntityPart newPart) {
updateSelection(E4Utils.createSelectionBindings(viewer.getSelectedEditParts(), viewer, context));
}
});
E4KeyHandler keyHandler = new E4KeyHandler(context);
keyHandler.setParent(new E4NavigationKeyHandler(context));
context.set(IEntityPartViewer.class, viewer);
viewer.setKeyHandler(keyHandler);
viewer.setContents(modelInput, createDefaultContents());
actionRegistry = ContextInjectionFactory.make(ActionRegistry.class, context);
actionRegistry.registerKeyActions(viewer.getKeyHandler());
context.set(ActionRegistry.class, actionRegistry);
configureContextMenu();
if (!E4Utils.isLegacyApplication())
viewer.getCommandStack().addCommandStackEventListener(new CommandStackEventListener() {
@Override
public void stackChanged(CommandStackEvent event) {
if ((event.getDetail() & CommandStack.POST_MASK) != 0)
part.setDirty(viewer.isDirty());
}
});
reloader = new LazyConfirmationDialogReloader(viewer.getControl(), new Runnable() {
@Override
public void run() {
viewer.setContents(modelInput, null);
}
});
}
Aggregations