下面列出了org.eclipse.ui.internal.registry.PerspectiveDescriptor#org.eclipse.e4.ui.workbench.modeling.EPartService 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Cursor enablement for E4
*/
private void forceActivate() {
EPartService partService = (EPartService)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class);
partService.activate(null);
partService.activate(partService.getActivePart(),true);
// E4 activation seems slightly hosed - add this in
EmacsPlusUtils.asyncUiRun(new Runnable() {
public void run() {
try {
// this will finish activating
EmacsPlusUtils.executeCommand("org.eclipse.ui.window.activateEditor", null); //$NON-NLS-1$
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Register to selection service to update button enablement
* Register the Automatic Perspective switch part listener
*/
@Override
public void postWindowOpen() {
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
configurer.addEditorAreaTransfer(EditorInputTransfer.getInstance());
configurer.addEditorAreaTransfer(ResourceTransfer.getInstance());
configurer.addEditorAreaTransfer(FileTransfer.getInstance());
configurer.addEditorAreaTransfer(MarkerTransfer.getInstance());
configurer.configureEditorAreaDropListener(new EditorAreaDropAdapter(
configurer.getWindow()));
final MWindow model = ((WorkbenchPage) window.getActivePage()).getWindowModel();
model.getContext().get(EPartService.class).addPartListener(new AutomaticSwitchPerspectivePartListener());
final Object widget = model.getWidget();
if (widget instanceof Shell) {
((Widget) widget).setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_MAIN_SHELL);
}
// Replace ObjectActionContributorManager with filtered actions
CustomObjectActionContributorManager.getManager();
}
@Execute
public void execute(MApplication app, EPartService partService,
EModelService modelService) {
MPerspective element = (MPerspective) modelService.find(PART_ID, app);
if (element != null) {
partService.switchPerspective(element);
logger.trace("Switch to " + PART_ID);
}
}
@Execute
public void execute(MApplication app, EPartService partService,
EModelService modelService) {
MPerspective element = (MPerspective) modelService.find(PART_ID, app);
partService.switchPerspective(element);
logger.trace("Switch to " + PART_ID);
}
@CanExecute
public boolean canExecute(EPartService partService) {
if (partService != null) {
return !partService.getDirtyParts().isEmpty();
}
return false;
}
@CanExecute
public boolean canExecute(EPartService partService) {
if (partService != null) {
return !partService.getDirtyParts().isEmpty();
}
return false;
}
@CanExecute
public boolean canExecute(EPartService partService) {
if (partService != null) {
return !partService.getDirtyParts().isEmpty();
}
return false;
}
@Execute
public void execute(EModelService modelService, EPartService partService,
MWindow window,
@Named("com.vogella.rcp.jface.translation.commandparameter.perspectiveid") String id) {
MPerspective activePerspective = modelService
.getActivePerspective(window);
MUIElement find = modelService.find(id, window);
if (find == null || activePerspective.equals(find)) {
return;
}
partService.switchPerspective((MPerspective) find);
}
@Execute
public void execute(EModelService modelService, MWindow window, EPartService partService) {
// get active perpective and find stored snippet of this perspective
MPerspective activePerspective = modelService.getActivePerspective(window);
MUIElement perspectiveSnippet = modelService.cloneSnippet(window, activePerspective.getElementId(), window);
// remove existing active perspective
MElementContainer<MUIElement> parent = activePerspective.getParent();
modelService.removePerspectiveModel(activePerspective, window);
// add stored perspective snippet and switch to it
parent.getChildren().add(perspectiveSnippet);
partService.switchPerspective((MPerspective) perspectiveSnippet);
}
@CanExecute
public boolean canExecute(EPartService partService) {
if (partService != null) {
return !partService.getDirtyParts().isEmpty();
}
return false;
}
@CanExecute
public boolean canExecute(EPartService partService) {
if (partService != null) {
return !partService.getDirtyParts().isEmpty();
}
return false;
}
@CanExecute
public boolean canExecute(EPartService partService) {
if (partService != null) {
return !partService.getDirtyParts().isEmpty();
}
return false;
}
@CanExecute
public boolean canExecute(EPartService partService) {
if (partService != null) {
return !partService.getDirtyParts().isEmpty();
}
return false;
}
@CanExecute
public boolean canExecute(EPartService partService) {
if (partService != null) {
return !partService.getDirtyParts().isEmpty();
}
return false;
}
@CanExecute
public boolean canExecute(EPartService partService) {
if (partService != null) {
return !partService.getDirtyParts().isEmpty();
}
return false;
}
void closePart(MPart part) {
// based on org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.closePart()
IEclipseContext context = part.getContext();
if (context != null && part.isCloseable()) {
EPartService partService = context.get(EPartService.class);
partService.hidePart(part,true);
}
}
public void registerHandlers(final IEclipseContext context, final IWorkbenchPage page) {
EPartService partService = context.get(EPartService.class);
ESelectionService selectionService = context.get(ESelectionService.class);
if (!isRegistered && partService != null && selectionService != null) {
partService.addPartListener(CoolbarToolControl.this);
selectionService.addSelectionListener(CoolbarToolControl.this);
isRegistered = true;
}
}
private void switchToPerspectiveLegacy(MPerspective loadedPerspective,
List<String> preLoadedFastViewIds){
EModelService modelService = getService(EModelService.class);
EPartService partService = getService(EPartService.class);
MApplication mApplication = getService(MApplication.class);
MTrimmedWindow mWindow = (MTrimmedWindow) modelService.find("IDEWindow", mApplication);
if (mWindow == null) {
List<MWindow> windows = mApplication.getChildren();
if (!windows.isEmpty() && windows.get(0) instanceof MTrimmedWindow) {
mWindow = (MTrimmedWindow) windows.get(0);
}
}
MPerspective activePerspective = modelService.getActivePerspective(mWindow);
MElementContainer<MUIElement> perspectiveParent = activePerspective.getParent();
List<String> fastViewIds = preLoadedFastViewIds;
// add the loaded perspective and switch to it
String id = loadedPerspective.getElementId();
Iterator<MUIElement> it = perspectiveParent.getChildren().iterator();
while (it.hasNext()) {
MUIElement element = it.next();
if (id.equals(element.getElementId()) || element.getElementId().startsWith(id + ".<")) {
it.remove();
}
}
perspectiveParent.getChildren().add(loadedPerspective);
// add fast view
for (String fastViewId : fastViewIds) {
ElexisFastViewUtil.addToFastView(loadedPerspective.getElementId(), fastViewId);
}
// the workbench window must be on top - otherwise the exception 'Application does not have an active window' occurs
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().open();
partService.switchPerspective(loadedPerspective);
}
private static EPartService getPartService() {
return WorkbenchHelper.getService(EPartService.class);
}
@Execute
public void execute(MApplication app, EPartService partService, EModelService modelService) {
MPerspective element = (MPerspective) modelService.find(PART_ID, app);
partService.switchPerspective(element);
}
@Execute
public void execute(MApplication app, EPartService partService, EModelService modelService) {
MPerspective element = (MPerspective) modelService.find(PART_ID, app);
partService.switchPerspective(element);
logger.trace("Switch to " + PART_ID);
}
@Execute
public void execute(EPartService partService) {
partService.saveAll(false);
}
@Execute
public void execute(EPartService partService) {
partService.saveAll(false);
}
@Execute
public void execute(EPartService partService) {
partService.saveAll(false);
}
@Execute
public void execute(EPartService partService) {
partService.saveAll(false);
}
@Execute
public void execute(EPartService partService) {
partService.saveAll(false);
}
@Execute
public void execute(EPartService partService) {
partService.saveAll(false);
}
@Execute
public void execute(EPartService partService) {
partService.saveAll(false);
}
@Execute
public void execute(EPartService partService) {
partService.saveAll(false);
}
@Execute
public void execute(EPartService partService) {
partService.saveAll(false);
}