Search in sources :

Example 1 with EPartService

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

the class EntityLocationHyperlink method linkActivated.

public void linkActivated() {
    try {
        IEclipseContext context = (IEclipseContext) PlatformUI.getWorkbench().getService(IEclipseContext.class);
        EPartService partService = context.get(EPartService.class);
        Collection<MPart> parts = partService.getParts();
        for (MPart part : parts) {
            IEclipseContext partContext = part.getContext();
            if (partContext == null)
                continue;
            IModelInput modelInput = partContext.get(IModelInput.class);
            if (modelInput != null && ((IFilePersistenceProvider) modelInput.getPersistenceProvider()).getStore().equals(file)) {
                partService.activate(part, true);
                IEntityPartViewer viewer = partContext.get(IEntityPartViewer.class);
                IEntity entityContents = viewer.getEntityContents();
                final IEntity entity = EntityUtils.getEntity(entityContents, location);
                viewer.selectAndReveal(entity);
            }
        }
    } catch (Exception e) {
        E4CompatibilityPlugin.log(e);
    }
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) IModelInput(org.whole.lang.ui.input.IModelInput) IEntity(org.whole.lang.model.IEntity) EPartService(org.eclipse.e4.ui.workbench.modeling.EPartService) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IFilePersistenceProvider(org.whole.lang.codebase.IFilePersistenceProvider) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 2 with EPartService

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

the class RevertHandler method execute.

@Execute
public void execute(EPartService partService, IModelInput modelInput, @Named(IServiceConstants.ACTIVE_SELECTION) IBindingManager bm) {
    if (E4Utils.isLegacyApplication()) {
        IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
        viewer.setContents((IModelInput) bm.wGetValue("modelInput"), null);
    } else {
        AbstractE4Part part = (AbstractE4Part) partService.getActivePart().getObject();
        part.getViewer().setContents(modelInput, null);
    }
}
Also used : AbstractE4Part(org.whole.lang.e4.ui.parts.AbstractE4Part) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 3 with EPartService

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

the class QuitHandler method execute.

@Execute
public void execute(EPartService partService, IWorkbench workbench, Shell shell) {
    IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode("org.whole.product.e4.lw");
    boolean exitWithoutPrompt = preferences.getBoolean("exitWithoutPrompt", false);
    if (exitWithoutPrompt) {
        safeCloseWorkbench(partService, workbench);
        return;
    }
    MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(shell, "Confirm exit", "Exit Whole Platform?", "Always exit without prompt", exitWithoutPrompt, null, null);
    if (dialog.getReturnCode() == Window.OK) {
        preferences.putBoolean("exitWithoutPrompt", dialog.getToggleState());
        try {
            preferences.flush();
        } catch (BackingStoreException e) {
        }
        safeCloseWorkbench(partService, workbench);
    }
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) BackingStoreException(org.osgi.service.prefs.BackingStoreException) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 4 with EPartService

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

the class LifeCycleManager method removePortfolioPartsWithoutPersistedFile.

private void removePortfolioPartsWithoutPersistedFile(MApplication app, EPartService partService, EModelService modelService) {
    List<MPart> parts = modelService.findElements(app, MPart.class, EModelService.IN_ACTIVE_PERSPECTIVE, new Selector() {

        @Override
        public boolean select(MApplicationElement element) {
            if (// $NON-NLS-1$
            !"name.abuchen.portfolio.ui.part.portfolio".equals(element.getElementId()))
                return false;
            // $NON-NLS-1$
            return element.getPersistedState().get("file") == null;
        }
    });
    for (MPart part : parts) {
        MElementContainer<MUIElement> parent = part.getParent();
        if (parent.getSelectedElement().equals(part))
            parent.setSelectedElement(null);
        parent.getChildren().remove(part);
    }
}
Also used : MApplicationElement(org.eclipse.e4.ui.model.application.MApplicationElement) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) MUIElement(org.eclipse.e4.ui.model.application.ui.MUIElement) Selector(org.eclipse.e4.ui.workbench.Selector)

Example 5 with EPartService

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

the class NewFileHandler method execute.

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, // 
@Optional @Named(IServiceConstants.ACTIVE_PART) MPart activePart, MApplication app, EPartService partService, EModelService modelService) {
    NewClientWizard wizard = new NewClientWizard();
    WizardDialog dialog = new WizardDialog(shell, wizard);
    if (dialog.open() == Window.OK) {
        MPart part = partService.createPart(UIConstants.Part.PORTFOLIO);
        part.setLabel(Messages.LabelUnnamedXml);
        part.getTransientData().put(Client.class.getName(), wizard.getClient());
        if (activePart != null)
            activePart.getParent().getChildren().add(part);
        else
            ((MPartStack) modelService.find(UIConstants.PartStack.MAIN, app)).getChildren().add(part);
        part.setVisible(true);
        part.getParent().setVisible(true);
        partService.showPart(part, PartState.ACTIVATE);
    }
}
Also used : NewClientWizard(name.abuchen.portfolio.ui.wizards.client.NewClientWizard) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) MPartStack(org.eclipse.e4.ui.model.application.ui.basic.MPartStack) Client(name.abuchen.portfolio.model.Client) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Execute(org.eclipse.e4.core.di.annotations.Execute)

Aggregations

Execute (org.eclipse.e4.core.di.annotations.Execute)11 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)9 MPartStack (org.eclipse.e4.ui.model.application.ui.basic.MPartStack)5 File (java.io.File)3 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Client (name.abuchen.portfolio.model.Client)2 UpdateHelper (name.abuchen.portfolio.ui.update.UpdateHelper)2 CoreException (org.eclipse.core.runtime.CoreException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 EPartService (org.eclipse.e4.ui.workbench.modeling.EPartService)2 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)2 AbstractE4Part (org.whole.lang.e4.ui.parts.AbstractE4Part)2 IEntity (org.whole.lang.model.IEntity)2 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 Map (java.util.Map)1