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);
}
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);
}
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);
}
}
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();
}
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
}
}
Aggregations