Search in sources :

Example 1 with LazyConfirmationDialogReloader

use of org.whole.lang.ui.dialogs.LazyConfirmationDialogReloader 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);
        }
    });
}
Also used : LazyConfirmationDialogReloader(org.whole.lang.ui.dialogs.LazyConfirmationDialogReloader) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IPartFocusListener(org.whole.lang.ui.editparts.IPartFocusListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FillLayout(org.eclipse.swt.layout.FillLayout) CommandStackEventListener(org.eclipse.gef.commands.CommandStackEventListener) FocusEvent(org.eclipse.swt.events.FocusEvent) ActionRegistry(org.whole.lang.e4.ui.actions.ActionRegistry) E4KeyHandler(org.whole.lang.e4.ui.actions.E4KeyHandler) E4NavigationKeyHandler(org.whole.lang.e4.ui.actions.E4NavigationKeyHandler) CommandStackEvent(org.eclipse.gef.commands.CommandStackEvent) FocusListener(org.eclipse.swt.events.FocusListener) IPartFocusListener(org.whole.lang.ui.editparts.IPartFocusListener) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) IEntityPart(org.whole.lang.ui.editparts.IEntityPart) PostConstruct(javax.annotation.PostConstruct)

Aggregations

PostConstruct (javax.annotation.PostConstruct)1 CommandStackEvent (org.eclipse.gef.commands.CommandStackEvent)1 CommandStackEventListener (org.eclipse.gef.commands.CommandStackEventListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 FocusEvent (org.eclipse.swt.events.FocusEvent)1 FocusListener (org.eclipse.swt.events.FocusListener)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 ActionRegistry (org.whole.lang.e4.ui.actions.ActionRegistry)1 E4KeyHandler (org.whole.lang.e4.ui.actions.E4KeyHandler)1 E4NavigationKeyHandler (org.whole.lang.e4.ui.actions.E4NavigationKeyHandler)1 LazyConfirmationDialogReloader (org.whole.lang.ui.dialogs.LazyConfirmationDialogReloader)1 IEntityPart (org.whole.lang.ui.editparts.IEntityPart)1 IPartFocusListener (org.whole.lang.ui.editparts.IPartFocusListener)1 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)1