Search in sources :

Example 16 with IEntityPartViewer

use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.

the class AbstractE4DerivedGraphicalPart method createEntityViewer.

@Override
protected IEntityPartViewer createEntityViewer(Composite parent) {
    IEntityPartViewer viewer = super.createEntityViewer(parent);
    setSelectionLinkable(createSelectionLinkable(viewer));
    return viewer;
}
Also used : IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 17 with IEntityPartViewer

use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.

the class HandlersBehavior method canCopyAsImage.

public static boolean canCopyAsImage(IBindingManager bm) {
    if (!isValidFocusEntityPart(bm))
        return false;
    IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
    IEntity focusEntity = bm.wGet("focusEntity");
    return viewer.getEditPartRegistry().get(focusEntity) instanceof IGraphicalEntityPart;
}
Also used : IEntity(org.whole.lang.model.IEntity) IGraphicalEntityPart(org.whole.lang.ui.editparts.IGraphicalEntityPart) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 18 with IEntityPartViewer

use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.

the class HandlersBehavior method canSelectAll.

public static boolean canSelectAll(IBindingManager bm) {
    IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
    IEntity entityContents = viewer.getEntityContents();
    IGraphicalEntityPart contents = (IGraphicalEntityPart) viewer.getEditPartRegistry().get(entityContents);
    return ((IEntityFigure) contents.getFigure()).isInteractiveEdit();
}
Also used : IEntityFigure(org.whole.lang.ui.figures.IEntityFigure) IEntity(org.whole.lang.model.IEntity) IGraphicalEntityPart(org.whole.lang.ui.editparts.IGraphicalEntityPart) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 19 with IEntityPartViewer

use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.

the class OperationHandler method canExecute.

@CanExecute
public boolean canExecute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) IBindingManager bm) throws Exception {
    ITransactionScope ts = BindingManagerFactory.instance.createTransactionScope();
    try {
        bm.wEnterScope(ts);
        IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
        return !viewer.getEditDomain().isDisabled() && isEnabled(bm);
    } catch (Exception e) {
        return false;
    } finally {
        ts.rollback();
        bm.wExitScope();
    }
}
Also used : ITransactionScope(org.whole.lang.bindings.ITransactionScope) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) CanExecute(org.eclipse.e4.core.di.annotations.CanExecute)

Example 20 with IEntityPartViewer

use of org.whole.lang.ui.viewers.IEntityPartViewer in project whole by wholeplatform.

the class PasteHandler method execute.

@Override
@Execute
public void execute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) IBindingManager bm) {
    if (bm.wIsSet("viewer") && Clipboard.instance().getInternalOrNativeEntityContents() == null) {
        IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
        if (ClipboardUtils.hasTextFocus(viewer) || ClipboardUtils.hasTextSeletion(viewer)) {
            IEntity focusEntity = bm.wGet("focusEntity");
            ITextualEntityPart focusPart = (ITextualEntityPart) viewer.getEditPartRegistry().get(focusEntity);
            String textContents = Clipboard.instance().getTextContents();
            Command command = focusPart.getCommand(TextualRequest.createInsertRequest(textContents));
            CommandStack commandStack = viewer.getEditDomain().getCommandStack();
            if (command instanceof ITextCommand) {
                TextTransactionCommand transactionCommand = new TextTransactionCommand();
                transactionCommand.setModel(focusEntity);
                transactionCommand.merge((ITextCommand) command);
                transactionCommand.setLabel(getLabel(bm));
                commandStack.execute(transactionCommand);
            } else {
                command.setLabel(getLabel(bm) + " text");
                commandStack.execute(command);
            }
            return;
        }
    }
    super.execute(bm);
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) ITextCommand(org.whole.lang.ui.commands.ITextCommand) ITextualEntityPart(org.whole.lang.ui.editparts.ITextualEntityPart) IEntity(org.whole.lang.model.IEntity) ITextCommand(org.whole.lang.ui.commands.ITextCommand) TextTransactionCommand(org.whole.lang.ui.commands.TextTransactionCommand) Command(org.eclipse.gef.commands.Command) TextTransactionCommand(org.whole.lang.ui.commands.TextTransactionCommand) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) CanExecute(org.eclipse.e4.core.di.annotations.CanExecute) Execute(org.eclipse.e4.core.di.annotations.Execute)

Aggregations

IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)55 IEntity (org.whole.lang.model.IEntity)29 IBindingManager (org.whole.lang.bindings.IBindingManager)13 CommandStack (org.eclipse.gef.commands.CommandStack)12 ModelTransactionCommand (org.whole.lang.ui.commands.ModelTransactionCommand)11 OperationCanceledException (org.whole.lang.operations.OperationCanceledException)8 IEntityPart (org.whole.lang.ui.editparts.IEntityPart)8 ESelectionService (org.eclipse.e4.ui.workbench.modeling.ESelectionService)7 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)6 CanExecute (org.eclipse.e4.core.di.annotations.CanExecute)6 Execute (org.eclipse.e4.core.di.annotations.Execute)6 Shell (org.eclipse.swt.widgets.Shell)5 ITextualEntityPart (org.whole.lang.ui.editparts.ITextualEntityPart)5 ITransactionScope (org.whole.lang.bindings.ITransactionScope)3 IEventBroker (org.eclipse.e4.core.services.events.IEventBroker)2 UISynchronize (org.eclipse.e4.ui.di.UISynchronize)2 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)2 Command (org.eclipse.gef.commands.Command)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 Control (org.eclipse.swt.widgets.Control)2