use of org.eclipse.e4.ui.workbench.modeling.EModelService 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);
}
}
use of org.eclipse.e4.ui.workbench.modeling.EModelService 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);
}
}
Aggregations