aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Elder2013-03-11 14:15:18 (EDT)
committerPaul Webster2013-03-11 21:13:28 (EDT)
commitfb41e7a70fbd0c6ce17c50d20ece370680bff397 (patch)
treec71d0dafbbc9f987eb84a0bde4721a27ebb69948
parent79c2875eef78a5c0750b54cb69f2dde992ae33ca (diff)
downloadeclipse.platform.ui-fb41e7a70fbd0c6ce17c50d20ece370680bff397.zip
eclipse.platform.ui-fb41e7a70fbd0c6ce17c50d20ece370680bff397.tar.gz
eclipse.platform.ui-fb41e7a70fbd0c6ce17c50d20ece370680bff397.tar.bz2
bug 402781: [API] Extend the EModelService to provide factoryrefs/changes/59/11059/3
capabilities for model elements Change-Id: Ia394130f1d815508146690eae38678840057c1d1
-rw-r--r--bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java160
-rw-r--r--bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/workbench/modeling/EModelService.java64
2 files changed, 208 insertions, 16 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java
index 37476ae..868628b 100644
--- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java
+++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * Copyright (c) 2010, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,13 +16,26 @@ import java.util.List;
import org.eclipse.core.runtime.Assert;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.services.events.IEventBroker;
+import org.eclipse.e4.ui.model.application.MAddon;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.MApplicationElement;
+import org.eclipse.e4.ui.model.application.MApplicationFactory;
+import org.eclipse.e4.ui.model.application.commands.MBindingContext;
+import org.eclipse.e4.ui.model.application.commands.MBindingTable;
+import org.eclipse.e4.ui.model.application.commands.MCategory;
+import org.eclipse.e4.ui.model.application.commands.MCommand;
+import org.eclipse.e4.ui.model.application.commands.MCommandParameter;
+import org.eclipse.e4.ui.model.application.commands.MCommandsFactory;
+import org.eclipse.e4.ui.model.application.commands.MHandler;
+import org.eclipse.e4.ui.model.application.commands.MKeyBinding;
+import org.eclipse.e4.ui.model.application.commands.MParameter;
import org.eclipse.e4.ui.model.application.descriptor.basic.MPartDescriptor;
+import org.eclipse.e4.ui.model.application.ui.MCoreExpression;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.MGenericTile;
import org.eclipse.e4.ui.model.application.ui.MSnippetContainer;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
+import org.eclipse.e4.ui.model.application.ui.MUiFactory;
import org.eclipse.e4.ui.model.application.ui.SideValue;
import org.eclipse.e4.ui.model.application.ui.advanced.MAdvancedFactory;
import org.eclipse.e4.ui.model.application.ui.advanced.MArea;
@@ -30,6 +43,7 @@ import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack;
import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder;
import org.eclipse.e4.ui.model.application.ui.basic.MBasicFactory;
+import org.eclipse.e4.ui.model.application.ui.basic.MInputPart;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer;
import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainerElement;
@@ -39,7 +53,21 @@ import org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.e4.ui.model.application.ui.basic.MWindowElement;
import org.eclipse.e4.ui.model.application.ui.basic.impl.BasicFactoryImpl;
+import org.eclipse.e4.ui.model.application.ui.menu.MDirectMenuItem;
+import org.eclipse.e4.ui.model.application.ui.menu.MDirectToolItem;
+import org.eclipse.e4.ui.model.application.ui.menu.MDynamicMenuContribution;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledToolItem;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuContribution;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuSeparator;
+import org.eclipse.e4.ui.model.application.ui.menu.MPopupMenu;
+import org.eclipse.e4.ui.model.application.ui.menu.MToolBar;
+import org.eclipse.e4.ui.model.application.ui.menu.MToolBarContribution;
+import org.eclipse.e4.ui.model.application.ui.menu.MToolBarSeparator;
import org.eclipse.e4.ui.model.application.ui.menu.MToolControl;
+import org.eclipse.e4.ui.model.application.ui.menu.MTrimContribution;
import org.eclipse.e4.ui.model.internal.ModelUtils;
import org.eclipse.e4.ui.workbench.IPresentationEngine;
import org.eclipse.e4.ui.workbench.UIEvents;
@@ -96,16 +124,130 @@ public class ModelServiceImpl implements EModelService {
eventBroker.subscribe(UIEvents.UIElement.TOPIC_WIDGET, hostedElementHandler);
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.e4.ui.workbench.modeling.EModelService#createModelElement(java.lang.Class)
- *
+ /**
+ * @see EModelService#createModelElement(Class)
* @generated
*/
- public <T> T createModelElement(Class<T> clazz) {
- // TODO Auto-generated method stub
- return null;
+ @SuppressWarnings("unchecked")
+ public final <T extends MApplicationElement> T createModelElement(Class<T> elementType) {
+ // WARNING: This method is automatically generated. Do not hand modify
+ if (elementType == null) {
+ throw new NullPointerException("Argument cannot be null."); //$NON-NLS-1$
+ }
+ if (MAddon.class.equals(elementType)) {
+ return (T) MApplicationFactory.INSTANCE.createAddon();
+ }
+ if (MApplication.class.equals(elementType)) {
+ return (T) MApplicationFactory.INSTANCE.createApplication();
+ }
+ if (MArea.class.equals(elementType)) {
+ return (T) MAdvancedFactory.INSTANCE.createArea();
+ }
+ if (MBindingContext.class.equals(elementType)) {
+ return (T) MCommandsFactory.INSTANCE.createBindingContext();
+ }
+ if (MBindingTable.class.equals(elementType)) {
+ return (T) MCommandsFactory.INSTANCE.createBindingTable();
+ }
+ if (MCategory.class.equals(elementType)) {
+ return (T) MCommandsFactory.INSTANCE.createCategory();
+ }
+ if (MCommand.class.equals(elementType)) {
+ return (T) MCommandsFactory.INSTANCE.createCommand();
+ }
+ if (MCommandParameter.class.equals(elementType)) {
+ return (T) MCommandsFactory.INSTANCE.createCommandParameter();
+ }
+ if (MCoreExpression.class.equals(elementType)) {
+ return (T) MUiFactory.INSTANCE.createCoreExpression();
+ }
+ if (MDirectMenuItem.class.equals(elementType)) {
+ return (T) MMenuFactory.INSTANCE.createDirectMenuItem();
+ }
+ if (MDirectToolItem.class.equals(elementType)) {
+ return (T) MMenuFactory.INSTANCE.createDirectToolItem();
+ }
+ if (MDynamicMenuContribution.class.equals(elementType)) {
+ return (T) MMenuFactory.INSTANCE.createDynamicMenuContribution();
+ }
+ if (MHandledMenuItem.class.equals(elementType)) {
+ return (T) MMenuFactory.INSTANCE.createHandledMenuItem();
+ }
+ if (MHandledToolItem.class.equals(elementType)) {
+ return (T) MMenuFactory.INSTANCE.createHandledToolItem();
+ }
+ if (MHandler.class.equals(elementType)) {
+ return (T) MCommandsFactory.INSTANCE.createHandler();
+ }
+ if (MInputPart.class.equals(elementType)) {
+ return (T) MBasicFactory.INSTANCE.createInputPart();
+ }
+ if (MKeyBinding.class.equals(elementType)) {
+ return (T) MCommandsFactory.INSTANCE.createKeyBinding();
+ }
+ if (MMenu.class.equals(elementType)) {
+ return (T) MMenuFactory.INSTANCE.createMenu();
+ }
+ if (MMenuContribution.class.equals(elementType)) {
+ return (T) MMenuFactory.INSTANCE.createMenuContribution();
+ }
+ if (MMenuSeparator.class.equals(elementType)) {
+ return (T) MMenuFactory.INSTANCE.createMenuSeparator();
+ }
+ if (MParameter.class.equals(elementType)) {
+ return (T) MCommandsFactory.INSTANCE.createParameter();
+ }
+ if (MPart.class.equals(elementType)) {
+ return (T) MBasicFactory.INSTANCE.createPart();
+ }
+ if (MPartDescriptor.class.equals(elementType)) {
+ return (T) org.eclipse.e4.ui.model.application.descriptor.basic.MBasicFactory.INSTANCE
+ .createPartDescriptor();
+ }
+ if (MPartSashContainer.class.equals(elementType)) {
+ return (T) MBasicFactory.INSTANCE.createPartSashContainer();
+ }
+ if (MPartStack.class.equals(elementType)) {
+ return (T) MBasicFactory.INSTANCE.createPartStack();
+ }
+ if (MPerspective.class.equals(elementType)) {
+ return (T) MAdvancedFactory.INSTANCE.createPerspective();
+ }
+ if (MPerspectiveStack.class.equals(elementType)) {
+ return (T) MAdvancedFactory.INSTANCE.createPerspectiveStack();
+ }
+ if (MPlaceholder.class.equals(elementType)) {
+ return (T) MAdvancedFactory.INSTANCE.createPlaceholder();
+ }
+ if (MPopupMenu.class.equals(elementType)) {
+ return (T) MMenuFactory.INSTANCE.createPopupMenu();
+ }
+ if (MToolBar.class.equals(elementType)) {
+ return (T) MMenuFactory.INSTANCE.createToolBar();
+ }
+ if (MToolBarContribution.class.equals(elementType)) {
+ return (T) MMenuFactory.INSTANCE.createToolBarContribution();
+ }
+ if (MToolBarSeparator.class.equals(elementType)) {
+ return (T) MMenuFactory.INSTANCE.createToolBarSeparator();
+ }
+ if (MToolControl.class.equals(elementType)) {
+ return (T) MMenuFactory.INSTANCE.createToolControl();
+ }
+ if (MTrimBar.class.equals(elementType)) {
+ return (T) MBasicFactory.INSTANCE.createTrimBar();
+ }
+ if (MTrimContribution.class.equals(elementType)) {
+ return (T) MMenuFactory.INSTANCE.createTrimContribution();
+ }
+ if (MTrimmedWindow.class.equals(elementType)) {
+ return (T) MBasicFactory.INSTANCE.createTrimmedWindow();
+ }
+ if (MWindow.class.equals(elementType)) {
+ return (T) MBasicFactory.INSTANCE.createWindow();
+ }
+ throw new IllegalArgumentException(
+ "Unsupported model object type: " + elementType.getCanonicalName()); //$NON-NLS-1$
}
/**
diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/workbench/modeling/EModelService.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/workbench/modeling/EModelService.java
index addc032..20c34bd 100644
--- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/workbench/modeling/EModelService.java
+++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/workbench/modeling/EModelService.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,6 +13,7 @@ package org.eclipse.e4.ui.workbench.modeling;
import java.util.List;
import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.ui.model.application.MApplicationElement;
import org.eclipse.e4.ui.model.application.descriptor.basic.MPartDescriptor;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.MSnippetContainer;
@@ -80,14 +81,63 @@ public interface EModelService {
public static final int GLOBAL = OUTSIDE_PERSPECTIVE | IN_SHARED_AREA;
/**
- * Given a class specification will return a new instance of that class or 'null' if the class
- * is not supported.
- *
- * @param clazz
- * @return
+ * Creates instances of model elements. Supported types are
+ * <ul>
+ * <li>{@link org.eclipse.e4.ui.model.application.MAddon MAddon}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.MApplication MApplication}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.advanced.MArea MArea}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.commands.MBindingContext MBindingContext}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.commands.MBindingTable MBindingTable}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.commands.MCategory MCategory}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.commands.MCommand MCommand}</li>
+ * <li>
+ * {@link org.eclipse.e4.ui.model.application.commands.MCommandParameter MCommandParameter}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.MCoreExpression MCoreExpression}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.menu.MDirectMenuItem MDirectMenuItem}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.menu.MDirectToolItem MDirectToolItem}</li>
+ * <li>
+ * {@link org.eclipse.e4.ui.model.application.ui.menu.MDynamicMenuContribution
+ * MDynamicMenuContribution}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem MHandledMenuItem}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.menu.MHandledToolItem MHandledToolItem}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.commands.MHandler MHandler}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.basic.MInputPart MInputPart}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.commands.MKeyBinding MKeyBinding}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.menu.MMenu MMenu}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.menu.MMenuContribution MMenuContribution}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.menu.MMenuSeparator MMenuSeparator}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.commands.MParameter MParameter}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.basic.MPart MPart}</li>
+ * <li>
+ * {@link org.eclipse.e4.ui.model.application.descriptor.basic.MPartDescriptor MPartDescriptor}</li>
+ * <li>
+ * {@link org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer MPartSashContainer}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.basic.MPartStack MPartStack}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.advanced.MPerspective MPerspective}</li>
+ * <li>
+ * {@link org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack MPerspectiveStack}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder MPlaceholder}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.menu.MPopupMenu MPopupMenu}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.menu.MToolBar MToolBar}</li>
+ * <li>
+ * {@link org.eclipse.e4.ui.model.application.ui.menu.MToolBarContribution MToolBarContribution}
+ * </li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.menu.MToolBarSeparator MToolBarSeparator}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.menu.MToolControl MToolControl}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.basic.MTrimBar MTrimBar}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.menu.MTrimContribution MTrimContribution}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow MTrimmedWindow}</li>
+ * <li>{@link org.eclipse.e4.ui.model.application.ui.basic.MWindow MWindow}</li>
+ * </ul>
+ *
+ * @param elementType
+ * the class to instantiate
+ * @return a new instance or <code>null</code>
+ * @throws IllegalArgumentException
+ * if the passed class is not supported.
* @generated
*/
- public <T> T createModelElement(Class<T> clazz);
+ public <T extends MApplicationElement> T createModelElement(Class<T> elementType);
/**
* Return a list of any elements that match the given search criteria. The search is recursive