本文整理汇总了Java中org.eclipse.e4.ui.workbench.modeling.EModelService.createModelElement方法的典型用法代码示例。如果您正苦于以下问题:Java EModelService.createModelElement方法的具体用法?Java EModelService.createModelElement怎么用?Java EModelService.createModelElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.e4.ui.workbench.modeling.EModelService
的用法示例。
在下文中一共展示了EModelService.createModelElement方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
@Execute
public void execute(EModelService modelService, MApplication application) {
// create a new window and set its size
MWindow window = modelService.createModelElement(MWindow.class);
window.setX(1025);
window.setY(550);
window.setWidth(400);
window.setHeight(200);
// need the contributor URI so the translation service is able to retrieve
// the translations
window.setContributorURI("platform:/plugin/org.fipro.e4.translation");
window.setLabel("%application");
// add new Window to the application
application.getChildren().add(window);
}
示例2: createFastViewStack
import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
private static MPartStack createFastViewStack(MTrimmedWindow window, MPerspective mPerspective,
EModelService eModelService){
if (window != null && mPerspective != null) {
MPartStack mPartStack = eModelService.createModelElement(MPartStack.class);
mPartStack.setElementId(ELEXIS_FASTVIEW_STACK);
mPartStack.setToBeRendered(true);
mPartStack.getTags().add("Minimized");
mPartStack.setOnTop(false);
mPartStack.setVisible(false);
mPartStack.getTags().add("NoAutoCollapse");
mPartStack.getTags().add("active");
mPerspective.getChildren().add(0, mPartStack);
return mPartStack;
}
return null;
}
示例3: createFastViewToolControl
import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
private static MToolControl createFastViewToolControl(MTrimmedWindow window,
MPerspective mPerspective, EModelService eModelService, MTrimBar mTrimBar){
if (mTrimBar != null) {
MToolControl mToolControl = eModelService.createModelElement(MToolControl.class);
mToolControl.setElementId(getToolControlId(window, mPerspective));
mToolControl.setContributionURI(
"bundleclass://org.eclipse.e4.ui.workbench.addons.swt/org.eclipse.e4.ui.workbench.addons.minmax.TrimStack");
mToolControl.setToBeRendered(true);
mToolControl.setVisible(true);
mToolControl.getTags().add("TrimStack");
mToolControl.getPersistedState().put("YSize", "600");
mTrimBar.getChildren().add(0, mToolControl);
mTrimBar.setVisible(true);
mTrimBar.setToBeRendered(true);
return mToolControl;
}
return null;
}
示例4: createDynamicPart
import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
/**
* Allow to avoid using of EPartService, because it is not working in life
* cycle manager.
*
* @param modelService
* using for creating part descriptor and new empty part.
* @return MPart created on part descriptor. There are no menus, handlers
* and toolbar.
*/
@Inject
private MPart createDynamicPart(EModelService modelService) {
MPartDescriptor descriptor = modelService.getPartDescriptor(IdStorage.DYNAMIC_PART_DESCRIPTOR_ID);
if (descriptor == null) {
return null;
}
MPart part = modelService.createModelElement(MPart.class);
part.setElementId(descriptor.getElementId());
// part.getMenus().addAll(EcoreUtil.copyAll(descriptor.getMenus()));
// if (descriptor.getToolbar() != null) {
// part.setToolbar((MToolBar) EcoreUtil.copy((EObject)
// descriptor.getToolbar()));
// }
if (log.isDebugEnabled()) {
log.debug("ContributorURI: " + descriptor.getContributorURI()); //$NON-NLS-1$
}
part.setContributorURI(descriptor.getContributorURI());
part.setCloseable(descriptor.isCloseable());
if (log.isDebugEnabled()) {
log.debug("ContributionURI: " + descriptor.getContributionURI());
}
part.setContributionURI(descriptor.getContributionURI());
part.setLabel(descriptor.getLabel());
part.setIconURI(descriptor.getIconURI());
part.setTooltip(descriptor.getTooltip());
// part.getHandlers().addAll(EcoreUtil.copyAll(descriptor.getHandlers()));
part.getTags().addAll(descriptor.getTags());
// TODO set if property
part.getPersistedState().putAll(descriptor.getPersistedState());
part.getBindingContexts().addAll(descriptor.getBindingContexts());
return part;
}
示例5: addMandantSelectionItem
import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
private void addMandantSelectionItem(MApplication mApplication, EModelService eModelService){
MTrimBar trimbar =
(MTrimBar) eModelService.find("org.eclipse.ui.main.toolbar", mApplication);
if (trimbar != null) {
MTrimElement mTrimElement = null;
int position = 0;
int i = 0;
List<MTrimElement> childrens = trimbar.getChildren();
for (MTrimElement element : childrens) {
if ("ch.elexis.core.ui.toolcontrol.mandantselection"
.equals(element.getElementId())) {
mTrimElement = element;
}
if (position == 0 && ("ch.elexis.toolbar1".equals(element.getElementId())
|| "PerspectiveSpacer".equals(element.getElementId()))) {
position = i;
}
i++;
}
if (mTrimElement == null) {
MToolControl mToolControl = eModelService.createModelElement(MToolControl.class);
mToolControl.setElementId("ch.elexis.core.ui.toolcontrol.mandantselection");
mToolControl.setContributionURI(
"bundleclass://ch.elexis.core.ui/ch.elexis.core.ui.coolbar.MandantSelectionContributionItem");
mToolControl.setToBeRendered(true);
mToolControl.setVisible(true);
childrens.add(position, mToolControl);
}
}
}
示例6: 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);
}
}
}
}
示例7: execute
import org.eclipse.e4.ui.workbench.modeling.EModelService; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
try {
EModelService modelService = getService(EModelService.class);
FileDialog dialog = new FileDialog(UiDesk.getTopShell(), SWT.OPEN);
dialog.setFilterNames(new String[] {
"XMI", "XML (Legacy)"
});
dialog.setFilterExtensions(new String[] {
"*.xmi", "*.xml"
});
dialog.setFilterPath(CoreHub.getWritableUserDir().getAbsolutePath()); // Windows path
String path = dialog.open();
if (path != null) {
IPerspectiveDescriptor createdPd = null;
if (path.toLowerCase().endsWith("xml")) {
// legacy
MPerspective mPerspective = modelService.createModelElement(MPerspective.class);
// the workbench window must be on top - otherwise the exception 'Application does not have an active window' occurs
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().open();
List<String> fastViewIds =
perspectiveImportService.createPerspectiveFromLegacy(path, mPerspective);
createdPd = savePerspectiveToRegistryLegacy(mPerspective);
perspectiveImportService.openPerspective(createdPd);
switchToPerspectiveLegacy(mPerspective, fastViewIds);
IWorkbenchPage wp = (IWorkbenchPage) PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
wp.savePerspectiveAs(createdPd);
} else {
createdPd = perspectiveImportService.importPerspective(path, null, true);
}
if (createdPd != null) {
MessageDialog.openInformation(UiDesk.getDisplay().getActiveShell(), "Import",
"Die Perspektive '" + createdPd.getLabel()
+ "' wurde erfolgreich importiert.");
}
}
} catch (Exception e) {
MessageDialog.openError(UiDesk.getDisplay().getActiveShell(), "Import",
"Diese Perspektive kann nicht importiert werden.");
LoggerFactory.getLogger(PerspektiveExportHandler.class).error("import error", e);
}
return null;
}