Search in sources :

Example 6 with EPartService

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

the class OpenPartHandler method execute.

@Execute
public void execute(EPartService partService, @Named(UIConstants.Parameter.PART) String partname) {
    MPart part = partService.findPart(partname);
    part.setVisible(true);
    partService.activate(part, true);
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 7 with EPartService

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

the class OpenRecentFileHandler 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, @Named("name.abuchen.portfolio.ui.param.file") String file) {
    MPart part = partService.createPart(UIConstants.Part.PORTFOLIO);
    part.setLabel(new File(file).getName());
    part.setTooltip(file);
    part.getPersistedState().put(UIConstants.File.PERSISTED_STATE_KEY, file);
    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 : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) MPartStack(org.eclipse.e4.ui.model.application.ui.basic.MPartStack) File(java.io.File) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 8 with EPartService

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

the class OpenSampleHandler method execute.

@Execute
public void execute(// 
@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, // 
final MApplication app, final EPartService partService, final EModelService modelService, @Named(UIConstants.Parameter.SAMPLE_FILE) final String sampleFile) {
    try {
        IRunnableWithProgress loadResourceOperation = new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try (InputStream in = this.getClass().getResourceAsStream(sampleFile)) {
                    InputStream inputStream = new ProgressMonitorInputStream(in, monitor);
                    Reader replacingReader = new TokenReplacingReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8), buildResourcesTokenResolver());
                    final Client client = ClientFactory.load(replacingReader);
                    fixTaxonomyLabels(client);
                    sync.asyncExec(() -> {
                        MPart part = partService.createPart(UIConstants.Part.PORTFOLIO);
                        part.setLabel(sampleFile.substring(sampleFile.lastIndexOf('/') + 1));
                        part.getTransientData().put(Client.class.getName(), client);
                        MPartStack stack = (MPartStack) modelService.find(UIConstants.PartStack.MAIN, app);
                        stack.getChildren().add(part);
                        partService.showPart(part, PartState.ACTIVATE);
                    });
                } catch (IOException ignore) {
                    PortfolioPlugin.log(ignore);
                }
            }
        };
        new ProgressMonitorDialog(shell).run(true, true, loadResourceOperation);
    } catch (InvocationTargetException | InterruptedException e) {
        PortfolioPlugin.log(e);
    }
}
Also used : ProgressMonitorInputStream(name.abuchen.portfolio.util.ProgressMonitorInputStream) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) InputStreamReader(java.io.InputStreamReader) MPartStack(org.eclipse.e4.ui.model.application.ui.basic.MPartStack) ProgressMonitorInputStream(name.abuchen.portfolio.util.ProgressMonitorInputStream) InputStream(java.io.InputStream) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) TokenReplacingReader(name.abuchen.portfolio.util.TokenReplacingReader) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TokenReplacingReader(name.abuchen.portfolio.util.TokenReplacingReader) Client(name.abuchen.portfolio.model.Client) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 9 with EPartService

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

the class SaveHandler method execute.

@Execute
public void execute(IEclipseContext context, EPartService partService) {
    IEclipseContext saveContext = context.createChild();
    AbstractE4Part part = (AbstractE4Part) partService.getActivePart().getObject();
    ContextInjectionFactory.invoke(part, Persist.class, saveContext);
    saveContext.dispose();
}
Also used : AbstractE4Part(org.whole.lang.e4.ui.parts.AbstractE4Part) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) CanExecute(org.eclipse.e4.core.di.annotations.CanExecute) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 10 with EPartService

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

the class OpenDialogHandler method execute.

@Execute
public void execute(IEclipseContext context, EPartService partService) {
    E4Dialog dialog = ContextInjectionFactory.make(E4Dialog.class, context);
    dialog.create();
    if (dialog.open() == Window.OK) {
    // do nothing
    }
}
Also used : E4Dialog(org.whole.lang.e4.ui.dialogs.E4Dialog) 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