Search in sources :

Example 6 with ESelectionService

use of org.eclipse.e4.ui.workbench.modeling.ESelectionService in project portfolio by buchen.

the class OpenBookmarksHandler method execute.

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell, ESelectionService selectionService) {
    Object object = selectionService.getSelection();
    if (!(object instanceof SecuritySelection))
        return;
    SecuritySelection selection = (SecuritySelection) object;
    if (selection.getClient().getSettings().getBookmarks().isEmpty())
        return;
    List<Bookmark> bookmarks = selection.getClient().getSettings().getBookmarks().stream().filter(b -> !b.isSeparator()).collect(Collectors.toList());
    BookmarkPopup<Bookmark> popup = new // 
    BookmarkPopup<>(// 
    shell, // 
    selection.getSecurity().getName(), // 
    bookmarks, // 
    Bookmark::getLabel, bm -> DesktopAPI.browse(bm.constructURL(selection.getClient(), selection.getSecurity())));
    popup.open();
}
Also used : IServiceConstants(org.eclipse.e4.ui.services.IServiceConstants) TableViewer(org.eclipse.jface.viewers.TableViewer) Execute(org.eclipse.e4.core.di.annotations.Execute) Function(java.util.function.Function) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) Composite(org.eclipse.swt.widgets.Composite) Named(javax.inject.Named) Shell(org.eclipse.swt.widgets.Shell) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) DesktopAPI(name.abuchen.portfolio.ui.util.DesktopAPI) Collectors(java.util.stream.Collectors) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) Consumer(java.util.function.Consumer) PopupDialog(org.eclipse.jface.dialogs.PopupDialog) List(java.util.List) Bookmark(name.abuchen.portfolio.model.Bookmark) SWT(org.eclipse.swt.SWT) SecuritySelection(name.abuchen.portfolio.ui.selection.SecuritySelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Control(org.eclipse.swt.widgets.Control) SelectionListener(org.eclipse.swt.events.SelectionListener) SecuritySelection(name.abuchen.portfolio.ui.selection.SecuritySelection) Bookmark(name.abuchen.portfolio.model.Bookmark) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 7 with ESelectionService

use of org.eclipse.e4.ui.workbench.modeling.ESelectionService in project whole by wholeplatform.

the class AbstractModelTextAction method run.

@Override
public void run() {
    ESelectionService selectionService = getContext().get(ESelectionService.class);
    IBindingManager bm = (IBindingManager) selectionService.getSelection();
    ISynchronizableRunnable runnable = new TextualFunctionRunnable(getContext(), bm, getText(), getBehaviorUri());
    runnable.syncExec(3000);
}
Also used : TextualFunctionRunnable(org.whole.lang.e4.ui.jobs.TextualFunctionRunnable) ISynchronizableRunnable(org.whole.lang.e4.ui.jobs.ISynchronizableRunnable) IBindingManager(org.whole.lang.bindings.IBindingManager) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService)

Example 8 with ESelectionService

use of org.eclipse.e4.ui.workbench.modeling.ESelectionService in project whole by wholeplatform.

the class AbstractModelTextAction method update.

@Override
public void update() {
    setEnabled(false);
    ESelectionService selectionService = getContext().get(ESelectionService.class);
    if (selectionService.getSelection() instanceof IBindingManager) {
        IBindingManager bm = (IBindingManager) selectionService.getSelection();
        setEnabled(calculateEnabled(bm));
    }
}
Also used : IBindingManager(org.whole.lang.bindings.IBindingManager) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService)

Example 9 with ESelectionService

use of org.eclipse.e4.ui.workbench.modeling.ESelectionService in project whole by wholeplatform.

the class DirectEditAction method update.

@Override
public void update() {
    setEnabled(false);
    ESelectionService selectionService = getContext().get(ESelectionService.class);
    if (selectionService.getSelection() instanceof IBindingManager) {
        IBindingManager bm = (IBindingManager) selectionService.getSelection();
        if (bm.wIsSet("viewer")) {
            IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
            IEntity focusEntity = bm.wGet("focusEntity");
            IEntityPart entityPart = viewer.getEditPartRegistry().get(focusEntity);
            setEnabled(entityPart.understandsRequest(request));
        }
    }
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 10 with ESelectionService

use of org.eclipse.e4.ui.workbench.modeling.ESelectionService in project whole by wholeplatform.

the class DirectEditAction method run.

@Override
public void run() {
    ESelectionService selectionService = getContext().get(ESelectionService.class);
    IBindingManager bm = (IBindingManager) selectionService.getSelection();
    IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
    IEntity focusEntity = bm.wGet("focusEntity");
    IEntityPart entityPart = viewer.getEditPartRegistry().get(focusEntity);
    try {
        entityPart.performRequest(request);
    } catch (Exception e) {
        e.getCause();
    }
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Aggregations

ESelectionService (org.eclipse.e4.ui.workbench.modeling.ESelectionService)14 IBindingManager (org.whole.lang.bindings.IBindingManager)13 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)7 IEntity (org.whole.lang.model.IEntity)6 Shell (org.eclipse.swt.widgets.Shell)4 CommandStack (org.eclipse.gef.commands.CommandStack)3 ModelTransactionCommand (org.whole.lang.ui.commands.ModelTransactionCommand)3 IEntityPart (org.whole.lang.ui.editparts.IEntityPart)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 List (java.util.List)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 Named (javax.inject.Named)1 Bookmark (name.abuchen.portfolio.model.Bookmark)1 SecuritySelection (name.abuchen.portfolio.ui.selection.SecuritySelection)1 DesktopAPI (name.abuchen.portfolio.ui.util.DesktopAPI)1 Execute (org.eclipse.e4.core.di.annotations.Execute)1 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)1 IServiceConstants (org.eclipse.e4.ui.services.IServiceConstants)1