Search in sources :

Example 11 with EPartService

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

the class E4ResourceBindingsContributor method addResourceBindings.

public void addResourceBindings(final IBindingManager bm) {
    if (bm.wIsSet("debug#breakpointsEnabled") && bm.wIsSet("eclipse#eclipseContext")) {
        try {
            EPartService partService = ((IEclipseContext) bm.wGetValue("eclipse#eclipseContext")).get(EPartService.class);
            final MPart debugPart = partService.findPart(IE4UIConstants.DEBUG_PART_ID);
            if (debugPart == null)
                return;
            IEntity breakpointsEnabled = BindingManagerFactory.instance.createValue(true);
            breakpointsEnabled.wAddRequestEventHandler(new IdentityRequestEventHandler() {

                public boolean notifyRequested(IEntity source, FeatureDescriptor feature, boolean value) {
                    Map<String, String> persistedState = debugPart.getPersistedState();
                    return Boolean.valueOf(persistedState.get("debug#breakpointsEnabled"));
                }
            });
            bm.wSet("debug#breakpointsEnabled", breakpointsEnabled);
        } catch (Exception e) {
        }
    }
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) IEntity(org.whole.lang.model.IEntity) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) EPartService(org.eclipse.e4.ui.workbench.modeling.EPartService) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) Map(java.util.Map) IdentityRequestEventHandler(org.whole.lang.events.IdentityRequestEventHandler)

Example 12 with EPartService

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

the class StartupAddon method checkForUpdates.

@Inject
@Optional
public // NOSONAR
void checkForUpdates(// NOSONAR
@UIEventTopic(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE) Event event, final IWorkbench workbench, final EPartService partService, @Preference(value = UIConstants.Preferences.AUTO_UPDATE) boolean autoUpdate) {
    if (autoUpdate) {
        Job job = new Job(Messages.JobMsgCheckingForUpdates) {

            @Override
            protected IStatus run(IProgressMonitor monitor) {
                try {
                    monitor.beginTask(Messages.JobMsgCheckingForUpdates, 200);
                    UpdateHelper updateHelper = new UpdateHelper(workbench, partService);
                    updateHelper.runUpdate(monitor, true);
                } catch (// NOSONAR
                CoreException e) {
                    PortfolioPlugin.log(e.getStatus());
                }
                return Status.OK_STATUS;
            }
        };
        job.setSystem(true);
        job.schedule(500);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) UpdateHelper(name.abuchen.portfolio.ui.update.UpdateHelper) CoreException(org.eclipse.core.runtime.CoreException) Job(org.eclipse.core.runtime.jobs.Job) Inject(javax.inject.Inject) Optional(org.eclipse.e4.core.di.annotations.Optional)

Example 13 with EPartService

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

the class OpenErrorLogFileHandler method execute.

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, // 
@Named(E4Workbench.INSTANCE_LOCATION) Location instanceLocation, MApplication app, EPartService partService, EModelService modelService) {
    // $NON-NLS-1$
    File logfile = new File(instanceLocation.getURL().getFile(), ".metadata/.log");
    if (!logfile.exists()) {
        MessageDialog.openError(shell, Messages.LabelError, MessageFormat.format(Messages.MsgErrorOpeningFile, logfile.getAbsoluteFile()));
    } else {
        MPart part = partService.createPart(UIConstants.Part.TEXT_VIEWER);
        part.getPersistedState().put(UIConstants.File.PERSISTED_STATE_KEY, logfile.getAbsolutePath());
        MPartStack stack = (MPartStack) modelService.find(UIConstants.PartStack.MAIN, app);
        stack.getChildren().add(part);
        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 14 with EPartService

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

the class UpdateHandler method execute.

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, final IWorkbench workbench, final EPartService partService) {
    try {
        new ProgressMonitorDialog(shell).run(true, true, monitor -> {
            try // NOSONAR
            {
                UpdateHelper updateHelper = new UpdateHelper(workbench, partService);
                updateHelper.runUpdate(monitor, false);
            } catch (CoreException e) {
                PortfolioPlugin.log(e);
                Display.getDefault().asyncExec(() -> ErrorDialog.openError(Display.getDefault().getActiveShell(), Messages.LabelError, Messages.MsgErrorUpdating, e.getStatus()));
            }
        });
    } catch (InvocationTargetException | InterruptedException e) {
        PortfolioPlugin.log(e);
    }
}
Also used : UpdateHelper(name.abuchen.portfolio.ui.update.UpdateHelper) CoreException(org.eclipse.core.runtime.CoreException) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 15 with EPartService

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

the class OpenFileHandler 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) {
    FileDialog dialog = new FileDialog(shell, SWT.OPEN);
    // $NON-NLS-1$ //$NON-NLS-2$
    dialog.setFilterExtensions(new String[] { "*.xml;*.zip;*.portfolio", "*.*" });
    dialog.setFilterNames(new String[] { Messages.LabelPortfolioPerformanceFile, Messages.LabelAllFiles });
    String fileSelected = dialog.open();
    if (fileSelected != null) {
        MPart part = partService.createPart(UIConstants.Part.PORTFOLIO);
        part.setLabel(new File(fileSelected).getName());
        part.setTooltip(fileSelected);
        part.getPersistedState().put(UIConstants.File.PERSISTED_STATE_KEY, fileSelected);
        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) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) 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