本文整理汇总了Java中org.eclipse.e4.ui.workbench.modeling.EPartService.switchPerspective方法的典型用法代码示例。如果您正苦于以下问题:Java EPartService.switchPerspective方法的具体用法?Java EPartService.switchPerspective怎么用?Java EPartService.switchPerspective使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.e4.ui.workbench.modeling.EPartService
的用法示例。
在下文中一共展示了EPartService.switchPerspective方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.eclipse.e4.ui.workbench.modeling.EPartService; //导入方法依赖的package包/类
@Execute
public void execute(MWindow window, EPartService partService,
EModelService modelService) {
// assumes you have only two perspectives
List<MPerspective> perspectives = modelService.findElements(window,
null, MPerspective.class, null);
if (perspectives.size() != 2) {
System.out.println("works only for exactly two perspectives");
}
MPerspective activePerspective = modelService
.getActivePerspective(window);
if (activePerspective.equals(perspectives.get(0))) {
partService.switchPerspective(perspectives.get(1));
} else {
partService.switchPerspective(perspectives.get(0));
}
}
示例2: openNewWindowPerspective
import org.eclipse.e4.ui.workbench.modeling.EPartService; //导入方法依赖的package包/类
/**
* Opens the specified perspective in a new window.
*
* @param perspectiveId
* The perspective to open; must not be <code>null</code>
* @throws ExecutionException
* If the perspective could not be opened.
*/
private void openNewWindowPerspective(IEclipseContext context, String perspectiveID) {
MApplication application = context.get(MApplication.class);
EPartService partService = context.get(EPartService.class);
EModelService modelService = context.get(EModelService.class);
List<MPerspective> perspectives = modelService.findElements(application, perspectiveID, MPerspective.class, null);
partService.switchPerspective(perspectives.get(0));
}
示例3: openPerspective
import org.eclipse.e4.ui.workbench.modeling.EPartService; //导入方法依赖的package包/类
/**
* Opens the perspective with the given identifier.
*
* @param perspectiveId
* The perspective to open; must not be <code>null</code>
* @throws ExecutionException
* If the perspective could not be opened.
*/
private final void openPerspective(IEclipseContext context, String perspectiveID) {
MApplication application = context.get(MApplication.class);
EPartService partService = context.get(EPartService.class);
EModelService modelService = context.get(EModelService.class);
List<MPerspective> perspectives = modelService.findElements(application, perspectiveID, MPerspective.class, null);
partService.switchPerspective(perspectives.get(0));
}
示例4: execute
import org.eclipse.e4.ui.workbench.modeling.EPartService; //导入方法依赖的package包/类
@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);
}
}
示例5: execute
import org.eclipse.e4.ui.workbench.modeling.EPartService; //导入方法依赖的package包/类
@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);
}
示例6: switchPerspective
import org.eclipse.e4.ui.workbench.modeling.EPartService; //导入方法依赖的package包/类
public void switchPerspective(MApplication application, final EPartService partService, final MPerspective element)
{
try
{
partService.switchPerspective(element);
} catch (Exception e)
{
// workaround: Application does not have an active window
// Exception....
List<MWindow> windows = application.getChildren();
final MWindow mWindow = windows.get(0);
Display.getDefault().syncExec(new Runnable()
{
@Override
public void run()
{
// get the main window and make it active
// somehow this solves the problem
mWindow.getContext().activate();
partService.switchPerspective(element);
}
});
}
CloudScaleBranding.initProjectExplorer();
}
示例7: execute
import org.eclipse.e4.ui.workbench.modeling.EPartService; //导入方法依赖的package包/类
@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);
}
示例8: execute
import org.eclipse.e4.ui.workbench.modeling.EPartService; //导入方法依赖的package包/类
@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);
}
示例9: execute
import org.eclipse.e4.ui.workbench.modeling.EPartService; //导入方法依赖的package包/类
@Execute
public void execute(MApplication app, EPartService partService, EModelService modelService) {
MPerspective element = (MPerspective) modelService.find(PART_ID, app);
partService.switchPerspective(element);
}
示例10: execute
import org.eclipse.e4.ui.workbench.modeling.EPartService; //导入方法依赖的package包/类
@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);
}
示例11: execute
import org.eclipse.e4.ui.workbench.modeling.EPartService; //导入方法依赖的package包/类
@Execute
public void execute(EPartService partService, EModelService modelService, MWindow window) throws IOException {
// create a resource, which is able to store e4 model elements
E4XMIResourceFactory e4xmiResourceFactory = new E4XMIResourceFactory();
Resource resource = e4xmiResourceFactory.createResource(null);
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream("/home/simon/simon.xmi");
// load the stored model element
resource.load(inputStream, null);
if (!resource.getContents().isEmpty()) {
// after the model element is loaded it can be obtained from the
// contents of the resource
MPerspective loadedPerspective = (MPerspective) resource.getContents().get(0);
// get the parent perspective stack, so that the loaded
// perspective can be added to it.
MPerspective activePerspective = modelService.getActivePerspective(window);
MElementContainer<MUIElement> perspectiveParent = activePerspective.getParent();
// remove the current perspective, which should be replaced by
// the loaded one
List<MPerspective> alreadyPresentPerspective = modelService.findElements(window,
loadedPerspective.getElementId(), MPerspective.class, null);
for (MPerspective perspective : alreadyPresentPerspective) {
modelService.removePerspectiveModel(perspective, window);
}
// add the loaded perspective and switch to it
perspectiveParent.getChildren().add(loadedPerspective);
partService.switchPerspective(loadedPerspective);
}
} finally {
if (inputStream != null) {
inputStream.close();
}
}
}
示例12: execute
import org.eclipse.e4.ui.workbench.modeling.EPartService; //导入方法依赖的package包/类
@Execute
public void execute(EPartService partService) {
partService.switchPerspective(advancedPerspective);
}
示例13: execute
import org.eclipse.e4.ui.workbench.modeling.EPartService; //导入方法依赖的package包/类
@Execute
public void execute(EPartService partService) {
partService.switchPerspective(basicPerspective);
}