diff --git a/org.fortiss.tooling.kernel/trunk/META-INF/MANIFEST.MF b/org.fortiss.tooling.kernel/trunk/META-INF/MANIFEST.MF index fd68a2c858208fdb4ed614d6cfeb7b6e2fe1ce65..add63a01ae79574b79cd5098f112d00ee0fe11cd 100644 --- a/org.fortiss.tooling.kernel/trunk/META-INF/MANIFEST.MF +++ b/org.fortiss.tooling.kernel/trunk/META-INF/MANIFEST.MF @@ -9,9 +9,11 @@ Require-Bundle: org.eclipse.ui;visibility:=reexport, org.eclipse.core.runtime;visibility:=reexport, org.eclipse.emf.ecore;bundle-version="2.6.1";visibility:=reexport, org.unicase.metamodel;bundle-version="0.0.1";visibility:=reexport, - org.unicase.ecp.model;bundle-version="0.0.1";visibility:=reexport, org.conqat.ide.commons;bundle-version="2.7.0";visibility:=reexport, - org.conqat.ide.commons.ui;bundle-version="2.7.0";visibility:=reexport + org.conqat.ide.commons.ui;bundle-version="2.7.0";visibility:=reexport, + org.unicase.workspace;bundle-version="1.0.0", + org.unicase.ecp.model;bundle-version="1.0.0", + org.unicase.ecpemfstorebridge;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Export-Package: org.fortiss.tooling.kernel, diff --git a/org.fortiss.tooling.kernel/trunk/icons/project.png b/org.fortiss.tooling.kernel/trunk/icons/project.png index 87a02f12f5be5b4c6b7967723664178b592875c0..fba5ebb4c5e4fd38d953e83466db6b81ea99b65d 100644 Binary files a/org.fortiss.tooling.kernel/trunk/icons/project.png and b/org.fortiss.tooling.kernel/trunk/icons/project.png differ diff --git a/org.fortiss.tooling.kernel/trunk/plugin.xml b/org.fortiss.tooling.kernel/trunk/plugin.xml index 8d113b69498ade4f42e2ff222e81c4c1e1de9a33..3581f753cfb4afe38c821c48e0d2fa3051bd10f8 100644 --- a/org.fortiss.tooling.kernel/trunk/plugin.xml +++ b/org.fortiss.tooling.kernel/trunk/plugin.xml @@ -2,6 +2,8 @@ <?eclipse version="3.4"?> <plugin> <extension-point id="modelElementHandler" name="Model Element Handler" schema="schema/modelElementHandler.exsd"/> + <extension-point id="modelPrototypeProvider" name="Model Prototype Provider" schema="schema/modelPrototypeProvider.exsd"/> + <extension-point id="modelElementCompositor" name="Model Element Compositor" schema="schema/modelElementCompositor.exsd"/> <extension point="org.eclipse.ui.views"> <view @@ -22,9 +24,16 @@ <extension point="org.fortiss.tooling.kernel.modelElementHandler"> <modelElementHandler - handler="org.fortiss.tooling.kernel.internal.handler.ECPProjectModelElementHandler" - modelElementClass="org.unicase.ecp.model.workSpaceModel.ECPProject"> + handler="org.fortiss.tooling.kernel.internal.handler.EMFStoreECPProjectModelElementHandler" + modelElementClass="org.unicase.ecpemfstorebridge.EMFStoreECPProject"> </modelElementHandler> </extension> + <extension + point="org.fortiss.tooling.kernel.modelElementCompositor"> + <modelElementCompositor + compositor="org.fortiss.tooling.kernel.internal.compose.EMFStoreECPProjectCompositor" + modelElementClass="org.unicase.ecpemfstorebridge.EMFStoreECPProject"> + </modelElementCompositor> + </extension> </plugin> diff --git a/org.fortiss.tooling.kernel/trunk/schema/modelElementCompositor.exsd b/org.fortiss.tooling.kernel/trunk/schema/modelElementCompositor.exsd new file mode 100644 index 0000000000000000000000000000000000000000..6796c9ca8b9b5beef1e44126e7eddfc6181ad64e --- /dev/null +++ b/org.fortiss.tooling.kernel/trunk/schema/modelElementCompositor.exsd @@ -0,0 +1,112 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.fortiss.tooling.kernel" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appinfo> + <meta.schema plugin="org.fortiss.tooling.kernel" id="modelElementCompositor" name="Model Element Compositor"/> + </appinfo> + <documentation> + Registers a compositor for model elements. + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appinfo> + <meta.element /> + </appinfo> + </annotation> + <complexType> + <sequence> + <element ref="modelElementCompositor" minOccurs="1" maxOccurs="unbounded"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appinfo> + <meta.attribute translatable="true"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="modelElementCompositor"> + <complexType> + <attribute name="modelElementClass" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appinfo> + <meta.attribute kind="java" basedOn=":org.eclipse.emf.ecore.EObject"/> + </appinfo> + </annotation> + </attribute> + <attribute name="compositor" type="string" use="required"> + <annotation> + <documentation> + The model element compositor. + </documentation> + <appinfo> + <meta.attribute kind="java" basedOn=":org.fortiss.tooling.kernel.interfaces.ICompositor"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appinfo> + <meta.section type="since"/> + </appinfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="examples"/> + </appinfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="apiinfo"/> + </appinfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="implementation"/> + </appinfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + +</schema> diff --git a/org.fortiss.tooling.kernel/trunk/schema/modelPrototypeProvider.exsd b/org.fortiss.tooling.kernel/trunk/schema/modelPrototypeProvider.exsd new file mode 100644 index 0000000000000000000000000000000000000000..3012b38700670b88f1d232382d61565cba0059f7 --- /dev/null +++ b/org.fortiss.tooling.kernel/trunk/schema/modelPrototypeProvider.exsd @@ -0,0 +1,102 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.fortiss.tooling.kernel" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appinfo> + <meta.schema plugin="org.fortiss.tooling.kernel" id="modelPrototypeProvider" name="Model Prototype Provider"/> + </appinfo> + <documentation> + Registers model element prototype providers. + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appinfo> + <meta.element /> + </appinfo> + </annotation> + <complexType> + <sequence> + <element ref="modelPrototypeProvider" minOccurs="1" maxOccurs="unbounded"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appinfo> + <meta.attribute translatable="true"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="modelPrototypeProvider"> + <complexType> + <attribute name="provider" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appinfo> + <meta.attribute kind="java" basedOn=":org.fortiss.tooling.kernel.interfaces.IPrototypeProvider"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appinfo> + <meta.section type="since"/> + </appinfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="examples"/> + </appinfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="apiinfo"/> + </appinfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="implementation"/> + </appinfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + +</schema> diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/base/PrototypeProviderBase.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/base/PrototypeProviderBase.java new file mode 100644 index 0000000000000000000000000000000000000000..391694c0b8d55820b640cfeeebffbd2dc9b75e6e --- /dev/null +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/base/PrototypeProviderBase.java @@ -0,0 +1,58 @@ +/*--------------------------------------------------------------------------+ +$Id$ +| | +| Copyright 2011 ForTISS GmbH | +| | +| Licensed under the Apache License, Version 2.0 (the "License"); | +| you may not use this file except in compliance with the License. | +| You may obtain a copy of the License at | +| | +| http://www.apache.org/licenses/LICENSE-2.0 | +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | +| See the License for the specific language governing permissions and | +| limitations under the License. | ++--------------------------------------------------------------------------*/ +package org.fortiss.tooling.kernel.base; + +import java.util.ArrayList; +import java.util.List; + +import org.conqat.lib.commons.collections.CollectionUtils; +import org.eclipse.emf.ecore.EObject; +import org.fortiss.tooling.kernel.interfaces.IPrototypeProvider; + +/** + * Base implementation for {@link IPrototypeProvider}s. + * + * @author hoelzlf + * @author $Author$ + * @version $Rev$ + * @levd.rating RED Rev: + */ +public abstract class PrototypeProviderBase implements IPrototypeProvider { + + /** Stores the registered prototypes. */ + private final List<Prototype> prototypes = new ArrayList<Prototype>(); + + /** Constructor. */ + public PrototypeProviderBase() { + registerPrototypes(); + } + + /** Registers all prototypes. Sub-classes must override. */ + protected abstract void registerPrototypes(); + + /** Registers the given {@link EObject} with the given name. */ + protected final void registerPrototype(String name, EObject prototype) { + prototypes.add(new Prototype(name, prototype)); + } + + /** {@inheritDoc} */ + @Override + public List<Prototype> getPrototypes() { + return CollectionUtils.asUnmodifiable(prototypes); + } +} diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/ICompositionContext.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/ICompositionContext.java new file mode 100644 index 0000000000000000000000000000000000000000..231f7902a73c018a7134fa32d294c0ac55f231b9 --- /dev/null +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/ICompositionContext.java @@ -0,0 +1,31 @@ +/*--------------------------------------------------------------------------+ +$Id$ +| | +| Copyright 2011 ForTISS GmbH | +| | +| Licensed under the Apache License, Version 2.0 (the "License"); | +| you may not use this file except in compliance with the License. | +| You may obtain a copy of the License at | +| | +| http://www.apache.org/licenses/LICENSE-2.0 | +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | +| See the License for the specific language governing permissions and | +| limitations under the License. | ++--------------------------------------------------------------------------*/ +package org.fortiss.tooling.kernel.interfaces; + +/** + * An {@link ICompositionContext} provides additional information like drop + * point positions to an {@link ICompositor}. + * + * @author hoelzlf + * @author $Author$ + * @version $Rev$ + * @levd.rating RED Rev: + */ +public interface ICompositionContext { + // this is just a marker interface +} diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/ICompositor.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/ICompositor.java new file mode 100644 index 0000000000000000000000000000000000000000..8eb8b1568fc7237d574a57992e1165260768d6ab --- /dev/null +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/ICompositor.java @@ -0,0 +1,46 @@ +/*--------------------------------------------------------------------------+ +$Id$ +| | +| Copyright 2011 ForTISS GmbH | +| | +| Licensed under the Apache License, Version 2.0 (the "License"); | +| you may not use this file except in compliance with the License. | +| You may obtain a copy of the License at | +| | +| http://www.apache.org/licenses/LICENSE-2.0 | +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | +| See the License for the specific language governing permissions and | +| limitations under the License. | ++--------------------------------------------------------------------------*/ +package org.fortiss.tooling.kernel.interfaces; + +import org.eclipse.emf.ecore.EObject; + +/** + * Interface for compositors, i.e. classes which know how to compose + * {@link EObject}s. + * + * @author hoelzlf + * @author $Author$ + * @version $Rev$ + * @levd.rating RED Rev: + */ +public interface ICompositor<T extends EObject> { + /** + * Returns whether the given container may include the given contained + * object. + */ + boolean canCompose(T container, EObject contained, + ICompositionContext context); + + /** + * Asks the compositor to insert the contained object into the container. + * The contained object may be modified (i.e. renamed, etc.) if necessary. + * This method returns a boolean, since user-interaction during compose + * might cancel the command. + */ + boolean compose(T container, EObject contained, ICompositionContext context); +} diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IPrototypeProvider.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IPrototypeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..6ad219b6ba9b8979ce7beec4550b5442b4484818 --- /dev/null +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IPrototypeProvider.java @@ -0,0 +1,73 @@ +/*--------------------------------------------------------------------------+ +$Id$ +| | +| Copyright 2011 ForTISS GmbH | +| | +| Licensed under the Apache License, Version 2.0 (the "License"); | +| you may not use this file except in compliance with the License. | +| You may obtain a copy of the License at | +| | +| http://www.apache.org/licenses/LICENSE-2.0 | +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | +| See the License for the specific language governing permissions and | +| limitations under the License. | ++--------------------------------------------------------------------------*/ +package org.fortiss.tooling.kernel.interfaces; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; + +/** + * An {@link IPrototypeProvider} offers preconfigured {@link EObject}s to be + * displayed in the model element view. + * + * @author hoelzlf + * @author $Author$ + * @version $Rev$ + * @levd.rating RED Rev: + */ +public interface IPrototypeProvider { + + /** Returns the prototypes provided by this provider. */ + List<Prototype> getPrototypes(); + + /** + * Prototypes consist of a generic description and preconfigured + * {@link EObject}. + */ + public static final class Prototype { + /** The generic prototype name. */ + private final String name; + /** the preconfigure {@link EObject}. */ + private final EObject prototype; + + /** Constructor. */ + public Prototype(String name, EObject prototype) { + this.name = name; + this.prototype = prototype; + } + + /** Returns the name. */ + public String getName() { + return name; + } + + /** Returns the prototype instance (NOT a copy!). */ + public EObject getPrototype() { + return prototype; + } + + /** + * Returns a copy of the prototype. This method is potentially + * expensive. + */ + public EObject getPrototypeCopy() { + return EcoreUtil.copy(prototype); + } + } +} diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/compose/EMFStoreECPProjectCompositor.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/compose/EMFStoreECPProjectCompositor.java new file mode 100644 index 0000000000000000000000000000000000000000..77591a0888c9822c8e553ab7a8d027493d35fcb1 --- /dev/null +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/compose/EMFStoreECPProjectCompositor.java @@ -0,0 +1,51 @@ +/*--------------------------------------------------------------------------+ +$Id$ +| | +| Copyright 2011 ForTISS GmbH | +| | +| Licensed under the Apache License, Version 2.0 (the "License"); | +| you may not use this file except in compliance with the License. | +| You may obtain a copy of the License at | +| | +| http://www.apache.org/licenses/LICENSE-2.0 | +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | +| See the License for the specific language governing permissions and | +| limitations under the License. | ++--------------------------------------------------------------------------*/ +package org.fortiss.tooling.kernel.internal.compose; + +import org.eclipse.emf.ecore.EObject; +import org.fortiss.tooling.kernel.interfaces.ICompositionContext; +import org.fortiss.tooling.kernel.interfaces.ICompositor; +import org.fortiss.tooling.kernel.model.IProjectRootElement; +import org.unicase.ecpemfstorebridge.EMFStoreECPProject; + +/** + * {@link ICompositor} implementation for the {@link IProjectRootElement}s. + * + * @author hoelzlf + * @author $Author$ + * @version $Rev$ + * @levd.rating RED Rev: + */ +public final class EMFStoreECPProjectCompositor implements + ICompositor<EMFStoreECPProject> { + + /** {@inheritDoc} */ + @Override + public boolean canCompose(EMFStoreECPProject container, EObject contained, + ICompositionContext context) { + return contained instanceof IProjectRootElement; + } + + /** {@inheritDoc} */ + @Override + public boolean compose(EMFStoreECPProject container, EObject contained, + ICompositionContext context) { + container.addModelElementToRoot(contained); + return true; + } +} diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/handler/ECPProjectModelElementHandler.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/handler/EMFStoreECPProjectModelElementHandler.java similarity index 73% rename from org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/handler/ECPProjectModelElementHandler.java rename to org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/handler/EMFStoreECPProjectModelElementHandler.java index 3c5dfa14daca8a41f83e1a6dc30d9304b2657c8b..f0fdeb9a410f0f038b66a5b6f84ef4dbe0e698dc 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/handler/ECPProjectModelElementHandler.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/handler/EMFStoreECPProjectModelElementHandler.java @@ -27,6 +27,8 @@ import org.fortiss.tooling.kernel.base.ModelElementHandlerBase; import org.fortiss.tooling.kernel.interfaces.IModelElementHandler; import org.fortiss.tooling.kernel.model.IProjectRootElement; import org.unicase.ecp.model.workSpaceModel.ECPProject; +import org.unicase.ecpemfstorebridge.EMFStoreECPProject; +import org.unicase.workspace.ProjectSpace; /** * {@link IModelElementHandler} for {@link ECPProject}s. @@ -36,19 +38,25 @@ import org.unicase.ecp.model.workSpaceModel.ECPProject; * @version $Rev$ * @levd.rating RED Rev: */ -public final class ECPProjectModelElementHandler extends - ModelElementHandlerBase<ECPProject> { +public final class EMFStoreECPProjectModelElementHandler extends + ModelElementHandlerBase<EMFStoreECPProject> { /** {@inheritDoc} */ @Override - public String getName(ECPProject element) { - return "Project"; + public String getName(EMFStoreECPProject element) { + ProjectSpace projectSpace = (ProjectSpace) element.getRootObject(); + String projectName = projectSpace.getProjectName(); + String baseRevision = " @" + + projectSpace.getBaseVersion().getIdentifier(); + String username = projectSpace.getUsersession().getUsername(); + return projectName + baseRevision + " (" + username + ")"; } /** {@inheritDoc} */ @Override - public String getDescription(ECPProject element) { - return "EMFStore Project"; + public String getDescription(EMFStoreECPProject element) { + ProjectSpace projectSpace = (ProjectSpace) element.getRootObject(); + return projectSpace.getProjectDescription(); } /** {@inheritDoc} */ @@ -59,7 +67,7 @@ public final class ECPProjectModelElementHandler extends /** {@inheritDoc} */ @Override - public List<EObject> getSubnodes(ECPProject element) { + public List<EObject> getSubnodes(EMFStoreECPProject element) { List<EObject> projectRootElements = new ArrayList<EObject>(); for (EObject pContent : element.eContents()) { if (pContent instanceof IProjectRootElement) {