本文整理汇总了Java中org.eclipse.e4.ui.workbench.modeling.EModelService.getActivePerspective方法的典型用法代码示例。如果您正苦于以下问题:Java EModelService.getActivePerspective方法的具体用法?Java EModelService.getActivePerspective怎么用?Java EModelService.getActivePerspective使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.e4.ui.workbench.modeling.EModelService
的用法示例。
在下文中一共展示了EModelService.getActivePerspective方法的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));
}
}
示例2: execute
import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
@Execute
public void execute(EModelService modelService, MWindow window) {
// clone the currently active perspective
MPerspective activePerspective = modelService
.getActivePerspective(window);
modelService.cloneElement(activePerspective, window);
}
示例3: execute
import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的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);
}
示例4: execute
import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的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);
}
示例5: canExecute
import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
@CanExecute
public boolean canExecute(EModelService modelService, MWindow window) {
// check whether a snippet for the active perspective exists
MPerspective activePerspective = modelService.getActivePerspective(window);
return modelService.findSnippet(window, activePerspective.getElementId()) != null;
}
示例6: execute
import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
@Execute
public void execute(EModelService modelService, MWindow window) {
// store model of the active perspective
MPerspective activePerspective = modelService.getActivePerspective(window);
// create a resource, which is able to store e4 model elements
E4XMIResourceFactory e4xmiResourceFactory = new E4XMIResourceFactory();
Resource resource = e4xmiResourceFactory.createResource(null);
// You must clone the perspective as snippet, otherwise the running
// application would break, because the saving process of the resource
// removes the element from the running application model
MUIElement clonedPerspective = modelService.cloneElement(activePerspective, window);
// add the cloned model element to the resource so that it may be stored
resource.getContents().add((EObject) clonedPerspective);
FileOutputStream outputStream = null;
try {
// Use a stream to save the model element
outputStream = new FileOutputStream("/home/simon/simon.xmi");
resource.save(outputStream, null);
} catch (IOException ex) {
ex.printStackTrace();
} finally {
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
示例7: canExecute
import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
@CanExecute
public boolean canExecute(MApplication app, EModelService modelService){
MPerspective activePerspective = modelService.getActivePerspective(
app.getSelectedElement());
return advancedPerspective != activePerspective;
}
示例8: canExecute
import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
@CanExecute
public boolean canExecute(MApplication application, EModelService modelService){
MPerspective activePerspective = modelService.getActivePerspective(
application.getSelectedElement());
return activePerspective.getElementId().equals(PERSPECTIVE_ID);
}
示例9: canExecute
import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
@CanExecute
public boolean canExecute(MApplication app, EModelService modelService){
MPerspective activePerspective = modelService.getActivePerspective(
app.getSelectedElement());
return basicPerspective != activePerspective;
}
示例10: getActivePerspective
import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
public static MPerspective getActivePerspective(){
EModelService modelService = getService(EModelService.class);
MTrimmedWindow mWindow = getActiveWindow();
if (mWindow != null) {
return modelService.getActivePerspective(mWindow);
}
return null;
}
示例11: getActivePerspective
import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
private MPerspective getActivePerspective(){
EModelService modelService = getService(EModelService.class);
MTrimmedWindow mWindow = getActiveWindow();
if (mWindow != null) {
return modelService.getActivePerspective(mWindow);
}
return null;
}
示例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();
}
}
}
示例13: changeFastViewBarFromLeftToBottom
import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
/**
* Changes the fastviews position from left trimbar to bottom trimbar
*/
public static void changeFastViewBarFromLeftToBottom(){
EModelService eModelService = getService(EModelService.class);
MApplication mApplication = getService(MApplication.class);
MTrimmedWindow mWindow = getCurrentWindow(eModelService, mApplication);
if (mWindow != null) {
MPerspective mPerspective = eModelService.getActivePerspective(mWindow);
if (mPerspective != null) {
String perspectiveId = mPerspective.getElementId();
MToolControl mToolControl =
findFastViewToolControl(eModelService, mWindow, perspectiveId,
SideValue.BOTTOM);
if (mToolControl == null) {
mToolControl = findFastViewToolControl(eModelService, mWindow, perspectiveId,
SideValue.LEFT);
if (mToolControl != null) {
MTrimBar trimBarBottom =
findTrimBar(eModelService, mWindow, SideValue.BOTTOM);
if (trimBarBottom != null) {
MToolControl copyToolcontrol =
eModelService.createModelElement(MToolControl.class);
copyToolcontrol.setElementId(mToolControl.getElementId());
copyToolcontrol.setContributionURI(
"bundleclass://org.eclipse.e4.ui.workbench.addons.swt/org.eclipse.e4.ui.workbench.addons.minmax.TrimStack");
copyToolcontrol.setToBeRendered(true);
copyToolcontrol.setVisible(true);
copyToolcontrol.getTags().add("TrimStack");
copyToolcontrol.getPersistedState().put("YSize", "600");
trimBarBottom.getChildren().add(0, copyToolcontrol);
mToolControl.setToBeRendered(false);
mToolControl.setVisible(false);
mToolControl.getParent().getChildren().remove(mToolControl);
mToolControl.setParent(null);
trimBarBottom.setVisible(true);
trimBarBottom.setToBeRendered(true);
}
}
}
else {
mToolControl.setToBeRendered(true);
}
}
}
}