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