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


Java EModelService.findElements方法代码示例

本文整理汇总了Java中org.eclipse.e4.ui.workbench.modeling.EModelService.findElements方法的典型用法代码示例。如果您正苦于以下问题:Java EModelService.findElements方法的具体用法?Java EModelService.findElements怎么用?Java EModelService.findElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.e4.ui.workbench.modeling.EModelService的用法示例。


在下文中一共展示了EModelService.findElements方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的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: getPerspectiveStack

import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
private MPerspectiveStack getPerspectiveStack(){
	EModelService modelService = getService(EModelService.class);
	MWindow window = getActiveWindow();
	List<MPerspectiveStack> theStack =
		modelService.findElements(window, null, MPerspectiveStack.class, null);
	if (theStack.size() > 0) {
		return theStack.get(0);
	}
	
	for (MWindowElement child : window.getChildren()) {
		if (child instanceof MPerspectiveStack) {
			return (MPerspectiveStack) child;
		}
	}
	return null;
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:17,代码来源:PerspectiveImportService.java

示例3: openNewWindowPerspective

import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的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

示例4: openPerspective

import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的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

示例5: findPlaceholder

import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
/** Find the MPlaceholder corresponding to this MPart in the MPerspective.  This
 *  may have persisted information relevant to loading this view.
 *  @return corresponding placeholder or <code>null</code>
 */
private MPlaceholder findPlaceholder()
{
    final IEclipseContext localContext = getViewSite().getService(IEclipseContext.class);
    final MPart part = localContext.get(MPart.class);
    final EModelService service = PlatformUI.getWorkbench().getService(EModelService.class);
    final IEclipseContext globalContext = PlatformUI.getWorkbench().getService(IEclipseContext.class);
    final MApplication app = globalContext.get(MApplication.class);
    final List<MPlaceholder> phs = service.findElements(app, null, MPlaceholder.class, null);
    for (MPlaceholder ph : phs)
        if (ph.getRef() == part)
            return ph;
    return null;
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:18,代码来源:RuntimeViewPart.java

示例6: findPartsById

import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
public static void findPartsById(MApplication application, EModelService service) {
    List<MPart> findElements = service.findElements(application, "mypart", //$NON-NLS-1$
            MPart.class, null);
    if (log.isInfoEnabled()) {
        log.info("Found part(s) : " + findElements.size()); //$NON-NLS-1$
    }
}
 
开发者ID:e4c,项目名称:EclipseCommander,代码行数:8,代码来源:PartUtils.java

示例7: findObjectsByTag

import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
public static void findObjectsByTag(MApplication application, EModelService service) {
    List<String> tags = new ArrayList<String>();
    tags.add("justatag"); //$NON-NLS-1$
    List<MUIElement> elementsWithTags = service.findElements(application, null, null, tags);
    if (log.isInfoEnabled()) {
        log.info("Found parts(s) : " + elementsWithTags.size()); //$NON-NLS-1$
    }
}
 
开发者ID:e4c,项目名称:EclipseCommander,代码行数:9,代码来源:PartUtils.java

示例8: execute

import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
@Execute
public void execute(@Named("PerspectiveId") String perspectiveId, EModelService service, final MApplication application,
		final EPartService partService)
{

	// Finding main perspective by ID fails for Main perspectives. Eclipse add '.<main_perspective>' to the ID
	// WORKAROUND: Get all perspectives and find element which ID starts with passed perspectiveId
	MPerspective element = null;
	List<MPerspective> elements = service.findElements(application, null, MPerspective.class, null);
	for (MPerspective p : elements)
	{
		if (p.getElementId().startsWith(perspectiveId))
		{
			element = p;
			break;
		}
	}

	// Switch perspective
	if (element != null)
	{

		final MPerspective fElement = element;
		BusyIndicator.showWhile(Display.getDefault(), new Runnable()
		{
			@Override
			public void run()
			{
				switchPerspective(application, partService, fElement);
			}
		});
	} else
	{
		throw new IllegalArgumentException("Perspective with perspectiveId: " + perspectiveId + " does not exist!");
	}

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

示例9: preSave

import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
/**
 * Called before the application model is saved when the application is
 * closing.
 * 
 * @param application	The application.
 * @param modelService	
 * @param partService	
 */
@PreSave
public void preSave(MApplication application, EModelService modelService,
		EPartService partService){
	
	LinkedList<String> tags = new LinkedList<String>();
	tags.add(REMOVE_ON_EXIT_TAG);
	
	//Remove all Parts from the model which have the REMOVE_ON_EXIT_TAG
	for(MPart part: modelService.findElements(application, null,
			MPart.class, tags)){
		part.getParent().getChildren().remove(part);
	}
}
 
开发者ID:Pro-Nouns,项目名称:LinGUIne,代码行数:22,代码来源:LifeCycleManager.java

示例10: clonePerspectiveWithWorkaround

import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
/**
 * Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=481996 Set the references of the
 * placeholder to the corresponding parts again in the copy.
 */
private static MPerspective clonePerspectiveWithWorkaround(EModelService modelService,
	MPerspective original){
	MPerspective clone = (MPerspective) modelService.cloneElement(original, null);
	clone.setElementId(original.getElementId());
	
	List<MPlaceholder> placeholderClones = modelService.findElements(clone, null,
		MPlaceholder.class, null, EModelService.IN_ANY_PERSPECTIVE);
	// For each placeholder in the new perspective, set the reference value to the one from the old perspective
	for (MPlaceholder placeholderClone : placeholderClones) {
		// Search for the corresponding placeholder in the "old" perspective
		List<MPlaceholder> placeholderOriginal =
			modelService.findElements(original, placeholderClone.getElementId(),
				MPlaceholder.class, null, EModelService.IN_ANY_PERSPECTIVE);
		if (placeholderOriginal.size() == 1) {
			// We found only one corresponding placeholder element. Set reference of old element to the new element
			placeholderClone.setRef((placeholderOriginal.get(0).getRef()));
		} else if (placeholderOriginal.isEmpty()) {
			System.out.println("NO PLACEHOLDER");
		} else {
			System.out.println("MORE THEN ONE PLACEHOLDER" + " " //$NON-NLS-1$
				+ placeholderOriginal.toString());
			placeholderClone.setRef((placeholderOriginal.get(0).getRef()));
		}
	}
	
	return clone;
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:32,代码来源:PerspectiveExportService.java

示例11: findParts

import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
public static void findParts(MApplication application, EModelService service) {
    List<MPart> parts = service.findElements(application, null, MPart.class, null);
    if (log.isInfoEnabled()) {
        log.info("Found parts(s) : " + parts.size()); //$NON-NLS-1$
    }
}
 
开发者ID:e4c,项目名称:EclipseCommander,代码行数:7,代码来源:PartUtils.java

示例12: execute

import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的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

示例13: savePerspectiveAs

import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
@SuppressWarnings("restriction")
@Override
public void savePerspectiveAs(String perspectiveId, String newName){
	EModelService modelService = getService(EModelService.class);
	MApplication mApplication = getService(MApplication.class);
	PerspectiveRegistry perspectiveRegistry =
		(PerspectiveRegistry) PlatformUI.getWorkbench().getPerspectiveRegistry();
	PerspectiveDescriptor existingPerspectiveDescriptor =
		(PerspectiveDescriptor) perspectiveRegistry.findPerspectiveWithId(perspectiveId);
	if (existingPerspectiveDescriptor != null) {
		
		int idx = isPerspectiveInsideStack(existingPerspectiveDescriptor);
		
		// loads the mapplication from the orginal descriptor
		openPerspective(existingPerspectiveDescriptor);
		
		// the model must be loaded
		List<MPerspective> modelPerspective = modelService.findElements(mApplication,
			existingPerspectiveDescriptor.getId(), MPerspective.class, null);
		
		// check if the model is loaded
		if (!modelPerspective.isEmpty()) {
			// create a new pd
			PerspectiveDescriptor newPd =
				perspectiveRegistry.createPerspective(newName, existingPerspectiveDescriptor);
			
			// saves an opens the new perspective
			PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
				.savePerspectiveAs(newPd);
			
			// close the new created one
			closePerspective(newPd);
			
			if (idx > -1) {
				// opens the original descriptor if it was already opened
				openPerspective(existingPerspectiveDescriptor);
			}
		}
		
	}
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:42,代码来源:PerspectiveImportService.java


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