当前位置: 首页>>代码示例>>Java>>正文


Java EPartService.switchPerspective方法代码示例

本文整理汇总了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));
	}
}
 
开发者ID:scela,项目名称:EclipseCon2014,代码行数:19,代码来源:SwitchPerspectiveHandler.java

示例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));
}
 
开发者ID:cplutte,项目名称:bts,代码行数:17,代码来源:ShowPerspectiveHandler.java

示例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));
}
 
开发者ID:cplutte,项目名称:bts,代码行数:17,代码来源:ShowPerspectiveHandler.java

示例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);
  }
}
 
开发者ID:incentivetoken,项目名称:offspring,代码行数:10,代码来源:ShowNXTPerspectiveHandler.java

示例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);
}
 
开发者ID:incentivetoken,项目名称:offspring,代码行数:8,代码来源:ShowTraderPerspectiveHandler.java

示例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();

}
 
开发者ID:CloudScale-Project,项目名称:Environment,代码行数:31,代码来源:OpenPerspectiveHandler.java

示例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);
}
 
开发者ID:vogellacompany,项目名称:codeexamples-eclipse,代码行数:16,代码来源:SwitchPerspectiveHandler.java

示例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);
}
 
开发者ID:vogellacompany,项目名称:codeexamples-eclipse,代码行数:16,代码来源:RestorePerspectiveHandler.java

示例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);
}
 
开发者ID:incentivetoken,项目名称:offspring,代码行数:6,代码来源:ShowHomePerspectiveHandler.java

示例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);
}
 
开发者ID:incentivetoken,项目名称:offspring,代码行数:7,代码来源:ShowAccountPerspectiveHandler.java

示例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();
		}
	}
}
 
开发者ID:vogellacompany,项目名称:codeexamples-eclipse,代码行数:46,代码来源:LoadHandler.java

示例12: execute

import org.eclipse.e4.ui.workbench.modeling.EPartService; //导入方法依赖的package包/类
@Execute
public void execute(EPartService partService) {
	partService.switchPerspective(advancedPerspective);
}
 
开发者ID:Pro-Nouns,项目名称:LinGUIne,代码行数:5,代码来源:SwitchToAdvancedPerspectiveHandler.java

示例13: execute

import org.eclipse.e4.ui.workbench.modeling.EPartService; //导入方法依赖的package包/类
@Execute
public void execute(EPartService partService) {
	partService.switchPerspective(basicPerspective);
}
 
开发者ID:Pro-Nouns,项目名称:LinGUIne,代码行数:5,代码来源:SwitchToBasicPerspectiveHandler.java


注:本文中的org.eclipse.e4.ui.workbench.modeling.EPartService.switchPerspective方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。