From 7df5731885448e78c63fbf9337994c0c5894a640 Mon Sep 17 00:00:00 2001 From: Florian Hoelzl <hoelzl@fortiss.org> Date: Wed, 1 Jun 2011 14:45:54 +0000 Subject: [PATCH] Added link with editor feature to navigator. Added view icons on navigator and library. Added editor-dependent filter for library view. --- .../trunk/icons/library.png | Bin 0 -> 3159 bytes .../trunk/icons/link_with_editor.gif | Bin 0 -> 160 bytes .../trunk/icons/tumlogo.png | Bin 0 -> 182 bytes org.fortiss.tooling.kernel/trunk/plugin.xml | 4 +- ...jectAction.java => EObjectActionBase.java} | 4 +- .../tooling/kernel/base/EditorBase.java | 18 +- .../IBindingEditorPageChangeListener.java | 7 +- .../kernel/interfaces/ICompositor.java | 10 + .../kernel/internal/ActionService.java | 8 +- .../kernel/internal/CompositorService.java | 17 ++ .../kernel/internal/NavigatorService.java | 6 + .../kernel/internal/PrototypeService.java | 17 ++ .../kernel/internal/editor/BindingEditor.java | 36 ++- .../editor/ModelElementEditorInput.java | 6 +- .../navigator/LinkWithEditorPartListener.java | 96 +++++++ .../internal/navigator/NavigatorViewPart.java | 91 ++++++- .../kernel/internal/views/LibraryView.java | 252 +++++++++++++----- .../kernel/services/ICompositorService.java | 12 + .../kernel/services/INavigatorService.java | 4 + .../kernel/services/IPrototypeService.java | 9 + 20 files changed, 515 insertions(+), 82 deletions(-) create mode 100644 org.fortiss.tooling.kernel/trunk/icons/library.png create mode 100644 org.fortiss.tooling.kernel/trunk/icons/link_with_editor.gif create mode 100644 org.fortiss.tooling.kernel/trunk/icons/tumlogo.png rename org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/base/{EObjectAction.java => EObjectActionBase.java} (93%) rename org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/{internal/views => interfaces}/IBindingEditorPageChangeListener.java (87%) create mode 100644 org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/navigator/LinkWithEditorPartListener.java diff --git a/org.fortiss.tooling.kernel/trunk/icons/library.png b/org.fortiss.tooling.kernel/trunk/icons/library.png new file mode 100644 index 0000000000000000000000000000000000000000..35a3b9b945078b8ff2ad510597c4a1ff7aec3faf GIT binary patch literal 3159 zcmV-d45;&oP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV000V4X+uL$P-t&- zZ*ypGa3D!TLm+T+Z)Rz1WdHzp+MQEpR8#2|J@?-9LQ9B%luK_?6$l_wLW_VDktQl3 z2@pz%A)(n7QNa;KMFbnjpojyGj)066Q7jCK3fKqaA)=0hqlk*i`{8?|Yu3E?=FR@K z*FNX0^PRKL2fzpnmPj*EHGmAMLLL#|gU7_i;p8qrfeIvW01ybXWFd3?BLM*Temp!Y zBESc}00DT@3kU$fO`E_l9Ebl8>Oz@Z0f2-7z;ux~O9+4z06=<<LZ$#fMgf4Gm?l#I zpacM5%VT2W08lLeU?+d((*S^-_?deF09%wH6#<};03Z`(h(rKrI{>WDR*FRcSTFz- zW=q650N5=6FiBTtNC2?60Km==3$g$R3;-}uh=nNt1bYBr$Ri_o0EC$U6h`t_Jn<{8 z5a%iY0C<_QJh>z}MS)ugEpZ1|S1ukX&Pf+56gFW3VVXcL!g-k)GJ!M?;PcD?0HBc- z5#WRK{dmp}uFlRjj<yb8E$Y7p{~}^y<NoE(t8hR70O53g(f%wivl@Uq27qn;q9yJG zXkH7Tb@z*AvJXJD0HEpGSMzZAemp!yp^&-R+2!Qq*h<7gTVcvqeg0>{U%*%WZ25jX z{P*?XzTzZ-GF^d31o+^>%=Ap99M6&ogks$0k4OBs3;+Bb(;~!4V!2o<6ys46agIcq zjPo+3B8fthDa9qy|77CdEc*jK-!%ZRYCZvbku9iQV*~a}ClFY4z~c7+0P?$U!PF=S z1Au6Q;m>#f??3%Vpd|o+W=WE9003S@Bra6Svp>fO002awfhw>;8}z{#EWidF!3EsG z3;bX<ghC|5!a@*23S@vBa$qT}f<h>U&9EIRU@z1_9W=mEXoiz;4lcq~xDGvV5BgyU zp1~-*fe8db$Osc*A=-!mVv1NJjtCc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9 literal 0 HcmV?d00001 diff --git a/org.fortiss.tooling.kernel/trunk/icons/link_with_editor.gif b/org.fortiss.tooling.kernel/trunk/icons/link_with_editor.gif new file mode 100644 index 0000000000000000000000000000000000000000..870934b6934844102afd508e067750591ccc34c0 GIT binary patch literal 160 zcmV;R0AK${Nk%w1VGsZi0J9GOy@VF3ZxE(y5d7@1`{kGX@x%S`!~Xs6{OYOw_SL$V zCjR)|{`lSf_}%;LvH$=7A^8LW000jFEC2ui01yBW000C{@W}_jyqF%FF*sXy0Zg-0 zXf+mw!4@wZTmfPScs^qRLF}SQ4@gmna3g>*IQghNsY+tXkpKpcfp)vCJ_O*fz()`; OzdrMMtX{Vt5db^*GD&v; literal 0 HcmV?d00001 diff --git a/org.fortiss.tooling.kernel/trunk/icons/tumlogo.png b/org.fortiss.tooling.kernel/trunk/icons/tumlogo.png new file mode 100644 index 0000000000000000000000000000000000000000..d3f3895395477c473ccbdebace1f639723aeb9b3 GIT binary patch literal 182 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!93?!50ihlx9JOMr-u0hjx{r~^}%$YL{4GjjC z$NmGw8I!!-T^Kr8Wj%l#&H|6fVg?3oVGw3ym^DWND9B#o>FdgVgN={hRE%MM+iIYY zfv1aONX4z>AN(vl;m*#7C6~3ewHX>17#TQpaQ5ji@rZ8_<TH4r<-s1IKZ8M%m0`Z7 W#ERxkcNYNlGI+ZBxvX<aXaWEvKQJi( literal 0 HcmV?d00001 diff --git a/org.fortiss.tooling.kernel/trunk/plugin.xml b/org.fortiss.tooling.kernel/trunk/plugin.xml index 02b98324e..94c410998 100644 --- a/org.fortiss.tooling.kernel/trunk/plugin.xml +++ b/org.fortiss.tooling.kernel/trunk/plugin.xml @@ -26,13 +26,15 @@ point="org.eclipse.ui.views"> <view class="org.fortiss.tooling.kernel.internal.navigator.NavigatorViewPart" + icon="icons/tumlogo.png" id="org.fortiss.tooling.kernel.model.navigator" name="Model Navigator" restorable="true"> </view> <view class="org.fortiss.tooling.kernel.internal.views.LibraryView" - id="org.fortiss.tooling.kernel.internal.views" + icon="icons/library.png" + id="org.fortiss.tooling.kernel.model.element.library" name="Model Elements" restorable="true"> </view> diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/base/EObjectAction.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/base/EObjectActionBase.java similarity index 93% rename from org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/base/EObjectAction.java rename to org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/base/EObjectActionBase.java index 5c020c251..26bb88a2c 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/base/EObjectAction.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/base/EObjectActionBase.java @@ -29,13 +29,13 @@ import org.eclipse.jface.resource.ImageDescriptor; * @version $Rev$ * @ConQAT.Rating RED Hash: C4F9557D8CC494C748E0C75BF07DC40C */ -public abstract class EObjectAction extends Action { +public abstract class EObjectActionBase extends Action { /** Stores the target {@link EObject}. */ private EObject target; /** Constructor. */ - public EObjectAction(String text, ImageDescriptor image) { + public EObjectActionBase(String text, ImageDescriptor image) { super(text, image); } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/base/EditorBase.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/base/EditorBase.java index a8618702e..6685e78df 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/base/EditorBase.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/base/EditorBase.java @@ -52,6 +52,22 @@ public abstract class EditorBase<T extends EObject> extends EditorPart { /** Databinding context used for model changes. */ protected final DataBindingContext dbc = new DataBindingContext(); + /** Returns the edited object. */ + public EObject getEditedObject() { + return editedObject; + } + + /** + * Returns the list of visible model element classes. This list is used to + * determine, which elements are to be included in the model element + * library. Sub-classes should override the default behavior, which returns + * the class of the {@link #editedObject}. + */ + @SuppressWarnings("unchecked") + public Class<? extends EObject>[] getVisibleEObjectTypes() { + return new Class[] { editedObject.getClass() }; + } + /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override @@ -63,7 +79,7 @@ public abstract class EditorBase<T extends EObject> extends EditorPart { } ModelElementEditorInput meInput = (ModelElementEditorInput) input; - editedObject = (T) meInput.getEditorInput(); + editedObject = (T) meInput.getModelElement(); if (editedObject == null) { throw new PartInitException("Missing model element!"); } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/views/IBindingEditorPageChangeListener.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IBindingEditorPageChangeListener.java similarity index 87% rename from org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/views/IBindingEditorPageChangeListener.java rename to org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IBindingEditorPageChangeListener.java index 55d1e4cee..fc145d11e 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/views/IBindingEditorPageChangeListener.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/interfaces/IBindingEditorPageChangeListener.java @@ -15,11 +15,14 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ | See the License for the specific language governing permissions and | | limitations under the License. | +--------------------------------------------------------------------------*/ -package org.fortiss.tooling.kernel.internal.views; +package org.fortiss.tooling.kernel.interfaces; + +import org.fortiss.tooling.kernel.internal.editor.BindingEditor; /** + * Listener for page changes of the {@link BindingEditor}. * - * @author Eder + * @author hoelzl * @author $Author: hoelzl $ * @version $Rev: 18709 $ * @ConQAT.Rating RED Hash: F730F4FC380A1FD636CAE29BDBA5E643 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 index 58d25dce9..057671a31 100644 --- 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 @@ -18,6 +18,7 @@ $Id$ package org.fortiss.tooling.kernel.interfaces; import org.eclipse.emf.ecore.EObject; +import org.fortiss.tooling.kernel.services.IPrototypeService.Prototype; /** * Interface for compositors, i.e. classes which know how to compose @@ -43,4 +44,13 @@ public interface ICompositor<T extends EObject> extends IEObjectAware<T> { * might cancel the command. */ boolean compose(T container, EObject contained, ICompositionContext context); + + /** + * Returns whether this compositor is able to compose the given prototype. + * While {@link #canCompose(EObject, EObject, ICompositionContext)} + * considers a concrete composition between the container and contained + * element, this method returns this compositor's ability to accept the + * given prototype in general. + */ + boolean canComposePrototype(Prototype prototype); } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ActionService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ActionService.java index 934d250d9..d41a98079 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ActionService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ActionService.java @@ -26,7 +26,7 @@ import org.eclipse.ui.ISharedImages; import org.eclipse.ui.IViewSite; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.ActionFactory; -import org.fortiss.tooling.kernel.base.EObjectAction; +import org.fortiss.tooling.kernel.base.EObjectActionBase; import org.fortiss.tooling.kernel.model.IRemovable; import org.fortiss.tooling.kernel.services.IActionService; import org.fortiss.tooling.kernel.services.ICommandStackService; @@ -47,7 +47,7 @@ public class ActionService implements IActionService { public static final String GROUP_GLOBAL_DEFAULTS = "globalDefaults"; /** The global undo action. */ - public final EObjectAction globalUndoAction = new EObjectAction("Undo", + public final EObjectActionBase globalUndoAction = new EObjectActionBase("Undo", PlatformUI.getWorkbench().getSharedImages() .getImageDescriptor(ISharedImages.IMG_TOOL_UNDO)) { @@ -60,7 +60,7 @@ public class ActionService implements IActionService { }; /** The global redo action. */ - public final EObjectAction globalRedoAction = new EObjectAction("Redo", + public final EObjectActionBase globalRedoAction = new EObjectActionBase("Redo", PlatformUI.getWorkbench().getSharedImages() .getImageDescriptor(ISharedImages.IMG_TOOL_UNDO)) { @@ -73,7 +73,7 @@ public class ActionService implements IActionService { }; /** The global delete action. */ - public final EObjectAction globalDeleteAction = new EObjectAction("Delete", + public final EObjectActionBase globalDeleteAction = new EObjectActionBase("Delete", PlatformUI.getWorkbench().getSharedImages() .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)) { @Override diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/CompositorService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/CompositorService.java index 1c63b24ca..84f834399 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/CompositorService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/CompositorService.java @@ -24,6 +24,7 @@ import org.fortiss.tooling.kernel.base.EObjectAwareServiceBase; import org.fortiss.tooling.kernel.interfaces.ICompositionContext; import org.fortiss.tooling.kernel.interfaces.ICompositor; import org.fortiss.tooling.kernel.services.ICompositorService; +import org.fortiss.tooling.kernel.services.IPrototypeService.Prototype; /** * This class implements the {@link ICompositorService} interface. @@ -61,6 +62,22 @@ public final class CompositorService extends container, element, context); } + /** {@inheritDoc} */ + @Override + public boolean canComposePrototype(Class<? extends EObject> containerClass, + Prototype prototype) { + List<ICompositor<EObject>> list = getRegisteredHandlers(containerClass); + if (list == null) { + return false; + } + for (ICompositor<EObject> compositor : list) { + if (compositor.canComposePrototype(prototype)) { + return true; + } + } + return false; + } + /** * Returns the first {@link ICompositor} which can compose the given element * (or <code>null</code>). diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/NavigatorService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/NavigatorService.java index 6b0e615d6..1a8e399f3 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/NavigatorService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/NavigatorService.java @@ -190,4 +190,10 @@ public class NavigatorService implements INavigatorService, return context.hashCode(); } } + + /** {@inheritDoc} */ + @Override + public void revealModelElement(EObject modelElement) { + navigatorViewPart.revealModelElement(modelElement); + } } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PrototypeService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PrototypeService.java index 3908312da..c1f6434f1 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PrototypeService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PrototypeService.java @@ -18,6 +18,7 @@ $Id$ package org.fortiss.tooling.kernel.internal; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import org.conqat.ide.commons.ui.extension.ExtensionPointUtils; @@ -25,8 +26,10 @@ import org.conqat.ide.commons.ui.logging.LoggingUtils; import org.conqat.lib.commons.collections.CollectionUtils; import org.conqat.lib.commons.collections.UnmodifiableList; import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.emf.ecore.EObject; import org.fortiss.tooling.kernel.ToolingKernelActivator; import org.fortiss.tooling.kernel.interfaces.IPrototypeProvider; +import org.fortiss.tooling.kernel.services.ICompositorService; import org.fortiss.tooling.kernel.services.IPrototypeService; import org.osgi.framework.Bundle; @@ -88,4 +91,18 @@ public class PrototypeService implements IPrototypeService { } return CollectionUtils.asUnmodifiable(result); } + + /** {@inheritDoc} */ + @Override + public List<Prototype> getComposablePrototypes( + Class<? extends EObject> modelElementType) { + List<Prototype> result = new LinkedList<Prototype>(); + for (Prototype prototype : getAllPrototypes()) { + if (ICompositorService.INSTANCE.canComposePrototype( + modelElementType, prototype)) { + result.add(prototype); + } + } + return result; + } } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/editor/BindingEditor.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/editor/BindingEditor.java index 91ed7f0c3..9e1629188 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/editor/BindingEditor.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/editor/BindingEditor.java @@ -17,7 +17,10 @@ $Id$ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.internal.editor; +import java.util.Collection; + import org.conqat.ide.commons.ui.logging.LoggingUtils; +import org.conqat.lib.commons.collections.IdentityHashSet; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.emf.common.notify.Adapter; @@ -33,6 +36,7 @@ import org.eclipse.ui.views.properties.IPropertySheetPage; import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor; import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; import org.fortiss.tooling.kernel.ToolingKernelActivator; +import org.fortiss.tooling.kernel.interfaces.IBindingEditorPageChangeListener; import org.fortiss.tooling.kernel.interfaces.IEditorBinding; import org.fortiss.tooling.kernel.interfaces.IHandler; import org.fortiss.tooling.kernel.services.IEditorService; @@ -74,6 +78,31 @@ public class BindingEditor extends MultiPageEditorPart implements } }; + /** Stores the binding editor listeners. */ + private final Collection<IBindingEditorPageChangeListener> bindingEditorListeners = new IdentityHashSet<IBindingEditorPageChangeListener>(); + + /** Adds a page change listener. */ + public void addBindingEditorListener( + IBindingEditorPageChangeListener listener) { + bindingEditorListeners.add(listener); + } + + /** Removes a page change listener. */ + public void removeBindingEditorListener( + IBindingEditorPageChangeListener listener) { + bindingEditorListeners.remove(listener); + } + + /** {@inheritDoc} */ + @Override + protected void pageChange(int newPageIndex) { + super.pageChange(newPageIndex); + + for (final IBindingEditorPageChangeListener listener : bindingEditorListeners) { + listener.pageChanged(); + } + } + /** * This is called whenever something about the currently edited object * changes. This is used to update the part name and to close the editor if @@ -88,6 +117,11 @@ public class BindingEditor extends MultiPageEditorPart implements } } + /** Returns the active editor. */ + public IEditorPart getActiveEditorPart() { + return getActiveEditor(); + } + /** {@inheritDoc} */ @Override public void init(IEditorSite site, IEditorInput input) @@ -99,7 +133,7 @@ public class BindingEditor extends MultiPageEditorPart implements super.init(site, input); ModelElementEditorInput meInput = ((ModelElementEditorInput) input); - editedObject = meInput.getEditorInput(); + editedObject = meInput.getModelElement(); if (editedObject == null) { throw new PartInitException("Missing model element!"); } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/editor/ModelElementEditorInput.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/editor/ModelElementEditorInput.java index 226ca953e..8fedaab0e 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/editor/ModelElementEditorInput.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/editor/ModelElementEditorInput.java @@ -47,8 +47,8 @@ public final class ModelElementEditorInput implements IEditorInput { .getModelElementHandler(modelElement); } - /** Returns the editor input {@link EObject}. */ - public EObject getEditorInput() { + /** Returns the editor input's {@link EObject} model element. */ + public EObject getModelElement() { return modelElement; } @@ -61,7 +61,7 @@ public final class ModelElementEditorInput implements IEditorInput { @Override public boolean equals(Object obj) { return obj instanceof ModelElementEditorInput - && ((ModelElementEditorInput) obj).getEditorInput().equals( + && ((ModelElementEditorInput) obj).getModelElement().equals( modelElement); } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/navigator/LinkWithEditorPartListener.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/navigator/LinkWithEditorPartListener.java new file mode 100644 index 000000000..a8f604f47 --- /dev/null +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/navigator/LinkWithEditorPartListener.java @@ -0,0 +1,96 @@ +/*--------------------------------------------------------------------------+ +$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.navigator; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorReference; +import org.eclipse.ui.IPartListener2; +import org.eclipse.ui.IWorkbenchPartReference; +import org.fortiss.tooling.kernel.internal.editor.ModelElementEditorInput; +import org.fortiss.tooling.kernel.services.INavigatorService; + +/** + * + * @author hoelzlf + * @author $Author$ + * @version $Rev$ + * @ConQAT.Rating RED Rev: + */ +final class LinkWithEditorPartListener implements IPartListener2 { + + /** {@inheritDoc} */ + @Override + public void partActivated(IWorkbenchPartReference partRef) { + revealModelElementInNavigator(partRef); + } + + /** {@inheritDoc} */ + @Override + public void partInputChanged(IWorkbenchPartReference partRef) { + revealModelElementInNavigator(partRef); + } + + /** Calls {@link INavigatorService} to reveal the editor input element. */ + private void revealModelElementInNavigator(IWorkbenchPartReference partRef) { + if (partRef instanceof IEditorReference) { + IEditorPart editor = ((IEditorReference) partRef).getEditor(true); + if (editor.getEditorInput() instanceof ModelElementEditorInput) { + EObject editorInput = ((ModelElementEditorInput) editor + .getEditorInput()).getModelElement(); + INavigatorService.INSTANCE.revealModelElement(editorInput); + } + } + } + + /** {@inheritDoc} */ + @Override + public void partBroughtToTop(IWorkbenchPartReference partRef) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void partClosed(IWorkbenchPartReference partRef) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void partDeactivated(IWorkbenchPartReference partRef) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void partOpened(IWorkbenchPartReference partRef) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void partHidden(IWorkbenchPartReference partRef) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void partVisible(IWorkbenchPartReference partRef) { + // ignore + } +} diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/navigator/NavigatorViewPart.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/navigator/NavigatorViewPart.java index 6c6536eaa..190668de2 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/navigator/NavigatorViewPart.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/navigator/NavigatorViewPart.java @@ -24,8 +24,11 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IContributionItem; +import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; import org.eclipse.jface.viewers.DecoratingLabelProvider; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; @@ -33,11 +36,14 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Menu; import org.eclipse.ui.IDecoratorManager; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IPartListener2; import org.eclipse.ui.ISaveablePart; import org.eclipse.ui.ISaveablesSource; import org.eclipse.ui.ISelectionListener; @@ -50,8 +56,11 @@ import org.eclipse.ui.progress.UIJob; import org.eclipse.ui.views.properties.IPropertySheetPage; import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor; import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; +import org.fortiss.tooling.kernel.ToolingKernelActivator; import org.fortiss.tooling.kernel.interfaces.ICustomMenuContributor; import org.fortiss.tooling.kernel.internal.NavigatorService; +import org.fortiss.tooling.kernel.internal.editor.BindingEditor; +import org.fortiss.tooling.kernel.internal.editor.ModelElementEditorInput; import org.fortiss.tooling.kernel.services.IActionService; import org.fortiss.tooling.kernel.services.IContextMenuService; import org.fortiss.tooling.kernel.services.IEditorService; @@ -79,6 +88,18 @@ public final class NavigatorViewPart extends ViewPart implements /** Stores the menu manager. */ private MenuManager menuManager; + /** Stores the part listener for editor link support. */ + private IPartListener2 partListener; + + /** Stores the toggle action flag for editor linkage. */ + private boolean isLinkedWithEditor = false; + + /** Stores the toggle action for editor linkage. */ + private Action linkWithEditorAction = null; + + /** Dialog setting ID for the link with editor action flag. */ + private static final String LINK_WITH_EDITOR_FLAG = "navigatorSettingLinkWithEditor"; + /** Stores the UI update job. */ private final UIJob updateUI = new UIJob("Update Model Navigator") { @Override @@ -121,15 +142,60 @@ public final class NavigatorViewPart extends ViewPart implements viewer.addDoubleClickListener(this); IActionService.INSTANCE.registerGlobalActions(getViewSite()); + createLinkWithEditorAction(); PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getSelectionService().addSelectionListener(this); - // FIXME (FH): whats that good for? - // if (viewer.getTree().getItems().length > 0) { - // setActiveECPProject(viewer.getTree().getItem(0).getData()); - // viewer.getTree().select(viewer.getTree().getItem(0)); - // } + getSite().getPage().addPartListener(partListener); + } + + /** Creates the part listener and the view action. */ + private void createLinkWithEditorAction() { + partListener = new LinkWithEditorPartListener(); + + isLinkedWithEditor = ToolingKernelActivator.getDefault() + .getDialogSettings().getBoolean(LINK_WITH_EDITOR_FLAG); + if (isLinkedWithEditor) { + getSite().getPage().addPartListener(partListener); + } + + linkWithEditorAction = new Action("Link with editor", SWT.TOGGLE) { + + @Override + public void run() { + if (isLinkedWithEditor) { + isLinkedWithEditor = false; + getSite().getPage().removePartListener(partListener); + } else { + isLinkedWithEditor = true; + getSite().getPage().addPartListener(partListener); + IEditorPart editor = getSite().getPage().getActiveEditor(); + if (editor instanceof BindingEditor + && editor.getEditorInput() instanceof ModelElementEditorInput) { + revealModelElement(((ModelElementEditorInput) editor + .getEditorInput()).getModelElement()); + } + } + + ToolingKernelActivator.getDefault().getDialogSettings() + .put(LINK_WITH_EDITOR_FLAG, this.isChecked()); + } + + }; + + linkWithEditorAction.setImageDescriptor(ToolingKernelActivator + .getImageDescriptor("icons/link_with_editor.gif")); + linkWithEditorAction.setToolTipText("Link with editor"); + linkWithEditorAction.setChecked(ToolingKernelActivator.getDefault() + .getDialogSettings().getBoolean(LINK_WITH_EDITOR_FLAG)); + + IToolBarManager toolBarManager = getViewSite().getActionBars() + .getToolBarManager(); + Separator additionsSeperator = new Separator("additions"); + additionsSeperator.setVisible(true); + toolBarManager.add(additionsSeperator); + toolBarManager.insertAfter("additions", linkWithEditorAction); } /** Creates the context menu. */ @@ -143,14 +209,23 @@ public final class NavigatorViewPart extends ViewPart implements getSite().registerContextMenu(menuManager, viewer); } - /** Creates the actions. */ - /** {@inheritDoc} */ @Override public void setFocus() { viewer.getControl().setFocus(); } + /** Reveals the given model element in the navigator view. */ + public void revealModelElement(EObject modelElement) { + if (modelElement == null) { + return; + } + if (!viewer.getExpandedState(modelElement)) { + viewer.expandToLevel(modelElement, 2); + } + viewer.setSelection(new StructuredSelection(modelElement), true); + } + /** {@inheritDoc} */ @Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { @@ -174,6 +249,8 @@ public final class NavigatorViewPart extends ViewPart implements .getSelectionService().removeSelectionListener(this); getSite().setSelectionProvider(null); + getSite().getPage().removePartListener(partListener); + super.dispose(); } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/views/LibraryView.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/views/LibraryView.java index d9ccff36d..a1900d273 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/views/LibraryView.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/views/LibraryView.java @@ -17,6 +17,10 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.internal.views; +import java.util.Set; + +import org.conqat.lib.commons.collections.IdentityHashSet; +import org.eclipse.emf.ecore.EObject; import org.eclipse.gef.dnd.TemplateTransfer; import org.eclipse.jface.util.LocalSelectionTransfer; import org.eclipse.jface.viewers.ITreeContentProvider; @@ -27,25 +31,57 @@ import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.Transfer; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IPartListener; +import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.dialogs.FilteredTree; import org.eclipse.ui.dialogs.PatternFilter; import org.eclipse.ui.part.ViewPart; +import org.fortiss.tooling.kernel.base.EditorBase; +import org.fortiss.tooling.kernel.interfaces.IBindingEditorPageChangeListener; +import org.fortiss.tooling.kernel.interfaces.IHandler; +import org.fortiss.tooling.kernel.internal.editor.BindingEditor; +import org.fortiss.tooling.kernel.services.IModelElementService; import org.fortiss.tooling.kernel.services.IPrototypeService; import org.fortiss.tooling.kernel.services.IPrototypeService.Prototype; /** + * {@link ViewPart} for the model element library view. * - * @author Eder + * @author eder * @author $Author: hoelzl $ * @version $Rev: 18709 $ * @ConQAT.Rating RED Hash: A43DAF31B100FF92B123EA6A31C86CBA */ public class LibraryView extends ViewPart { - TreeViewer viewer; + /** The viewer. */ + private TreeViewer viewer; + + /** Filter text field for the tree viewer. */ + private FilteredTree filteredTree; + + /** Current active {@link BindingEditor}. */ + private BindingEditor activeBindingEditor = null; + + /** Stores the editor activation listener. */ + private EditorActivationListener editorActivationListener = new EditorActivationListener(); - FilteredTree filteredTree; + /** The container object used. */ + private EObject containerObject = null; + + /** The prototypes supported by the current editor. */ + private Set<Prototype> supportedBaseClasses = new IdentityHashSet<Prototype>(); + + /** Listener for reacting to changes of the embedded editor. */ + private final IBindingEditorPageChangeListener bindingEditorPageChangeListener = new IBindingEditorPageChangeListener() { + @Override + public void pageChanged() { + updateEditorFilters(activeBindingEditor.getActiveEditorPart()); + } + }; /** {@inheritDoc} */ @Override @@ -57,46 +93,9 @@ public class LibraryView extends ViewPart { | SWT.V_SCROLL, patternFilter, false); viewer = filteredTree.getViewer(); - viewer.setContentProvider(new ITreeContentProvider() { - - @Override - public Object[] getChildren(Object parentElement) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Object getParent(Object element) { - return null; - } - - @Override - public boolean hasChildren(Object element) { - return false; - } - - @Override - public Object[] getElements(Object inputElement) { - if (inputElement instanceof Object[]) { - return (Object[]) inputElement; - } - return new Object[0]; - } - - @Override - public void dispose() { - // TODO Auto-generated method stub - - } - - @Override - public void inputChanged(Viewer viewer, Object oldInput, - Object newInput) { - // TODO Auto-generated method stub - - } - }); + viewer.setContentProvider(new LibraryTreeContentProvider()); viewer.setLabelProvider(new LibraryLabelProvider()); + viewer.addDragSupport(DND.DROP_COPY, new Transfer[] { TemplateTransfer.getInstance(), LocalSelectionTransfer.getTransfer() }, @@ -104,22 +103,47 @@ public class LibraryView extends ViewPart { viewer.setInput(IPrototypeService.INSTANCE.getAllPrototypes().toArray()); - viewer.addFilter(new ViewerFilter() { + viewer.addFilter(new LibraryViewerFilter()); - @Override - public boolean select(Viewer viewer, Object parentElement, - Object element) { + getViewSite().setSelectionProvider(viewer); + getSite().getWorkbenchWindow().getPartService() + .addPartListener(editorActivationListener); + } - /* - * if (element instanceof Prototype) { EObject prototypeObject = - * ((Prototype) element).getPrototype(); return true; } - */ - return true; - } + /** Switches to the given workbench editor part. */ + private void switchWorkbenchEditor(IEditorPart editor) { + if (activeBindingEditor != null) { + activeBindingEditor + .removeBindingEditorListener(bindingEditorPageChangeListener); + activeBindingEditor = null; + } - }); + if (editor instanceof BindingEditor) { + activeBindingEditor = (BindingEditor) editor; + activeBindingEditor + .addBindingEditorListener(bindingEditorPageChangeListener); + updateEditorFilters(activeBindingEditor.getActiveEditorPart()); + } else if (editor != null) { + updateEditorFilters(editor); + } + } - getViewSite().setSelectionProvider(viewer); + /** Updates the filters according to the given editor. */ + @SuppressWarnings("unchecked") + private void updateEditorFilters(IEditorPart editor) { + supportedBaseClasses.clear(); + if (editor instanceof EditorBase) { + EditorBase<? extends EObject> editorBase = (EditorBase<? extends EObject>) editor; + containerObject = editorBase.getEditedObject(); + for (Class<? extends EObject> clazz : editorBase + .getVisibleEObjectTypes()) { + supportedBaseClasses.addAll(IPrototypeService.INSTANCE + .getComposablePrototypes(clazz)); + } + } else { + containerObject = null; + } + viewer.refresh(); } /** {@inheritDoc} */ @@ -128,7 +152,7 @@ public class LibraryView extends ViewPart { viewer.getControl().setFocus(); } - /** The label provider used here-in. */ + /** The label provider used in the library view. */ private class LibraryLabelProvider extends LabelProvider { /** {@inheritDoc} */ @@ -142,13 +166,119 @@ public class LibraryView extends ViewPart { } - // TODO (JE): getImage - /* - * @Override public Image getImage(Object element) { if (element - * instanceof Prototype) { Prototype prototype = (Prototype) element; - * return ModelElementService.getInstance().getImage( - * prototype.getPrototypeObject()); } return super.getImage(element); } + /** {@inheritDoc} */ + @Override + public Image getImage(Object element) { + if (element instanceof Prototype) { + Prototype prototype = (Prototype) element; + // delegate to the model element handlers + if (element instanceof EObject) { + IHandler<EObject> handler = IModelElementService.INSTANCE + .getModelElementHandler(prototype.getPrototype()); + if (handler != null) { + return handler.getIcon(); + } + } + } + return super.getImage(element); + } + } + + /** The content provider used in the library view. */ + private class LibraryTreeContentProvider implements ITreeContentProvider { + + /** {@inheritDoc} */ + @Override + public Object[] getElements(Object inputElement) { + if (inputElement instanceof Object[]) { + return (Object[]) inputElement; + } + return new Object[0]; + } + + /** {@inheritDoc} */ + @Override + public void dispose() { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public Object[] getChildren(Object parentElement) { + return null; + } + + /** {@inheritDoc} */ + @Override + public Object getParent(Object element) { + return null; + } + + /** {@inheritDoc} */ + @Override + public boolean hasChildren(Object element) { + return false; + } + } + + /** The filter used in the library view. */ + private class LibraryViewerFilter extends ViewerFilter { + + /** {@inheritDoc} */ + @Override + public boolean select(Viewer viewer, Object parentElement, + Object element) { + if (containerObject == null || supportedBaseClasses.isEmpty()) { + return false; + } + return supportedBaseClasses.contains(element); + } + } + + /** If an editor in a different Project is opened the Model is reinitialized */ + private class EditorActivationListener implements IPartListener { + + /** + * Change the tree viewer content whenever workbench part changes. */ + @Override + public void partActivated(IWorkbenchPart workbenchPart) { + if (!(workbenchPart instanceof IEditorPart)) { + return; + } + + IEditorPart part = (IEditorPart) workbenchPart; + switchWorkbenchEditor(part); + } + + /** {@inheritDoc} */ + @Override + public void partBroughtToTop(IWorkbenchPart part) { + // to react on activated is enough + } + + /** {@inheritDoc} */ + @Override + public void partClosed(IWorkbenchPart part) { + // nothing to do + } + + /** {@inheritDoc} */ + @Override + public void partDeactivated(IWorkbenchPart part) { + // nothing to do + } + /** {@inheritDoc} */ + @Override + public void partOpened(IWorkbenchPart part) { + // nothing to do + } } } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/ICompositorService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/ICompositorService.java index 8bddb993d..394690e5a 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/ICompositorService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/ICompositorService.java @@ -19,7 +19,9 @@ package org.fortiss.tooling.kernel.services; 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.internal.CompositorService; +import org.fortiss.tooling.kernel.services.IPrototypeService.Prototype; /** * The compositor service provides registration and access to model element @@ -48,4 +50,14 @@ public interface ICompositorService { */ boolean compose(EObject container, EObject element, ICompositionContext context); + + /** + * Returns whether given prototype can be composed with containers of the + * given class. This method searches for an {@link ICompositor} that is able + * to handle the composition in general. + * + * @see ICompositor#canComposePrototype(org.fortiss.tooling.kernel.services.IPrototypeService.Prototype) + */ + boolean canComposePrototype(Class<? extends EObject> containerClass, + Prototype prototype); } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/INavigatorService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/INavigatorService.java index 0b001a5a8..1fa2b9edc 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/INavigatorService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/INavigatorService.java @@ -17,6 +17,7 @@ $Id$ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.services; +import org.eclipse.emf.ecore.EObject; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.Saveable; import org.eclipse.ui.part.ViewPart; @@ -52,4 +53,7 @@ public interface INavigatorService { /** Returns the saveables of the current selection. */ Saveable[] getActiveSaveables(); + + /** Reveals the given model element. */ + void revealModelElement(EObject modelElement); } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/IPrototypeService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/IPrototypeService.java index 2f9b421d7..339596917 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/IPrototypeService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/services/IPrototypeService.java @@ -17,6 +17,8 @@ $Id$ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.services; +import java.util.List; + import org.conqat.lib.commons.collections.UnmodifiableList; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.util.EcoreUtil; @@ -43,6 +45,13 @@ public interface IPrototypeService { /** Returns the list of all prototypes registered any provider. */ UnmodifiableList<Prototype> getAllPrototypes(); + /** + * Returns the list of all prototypes composable with the given model + * element class. + */ + List<Prototype> getComposablePrototypes( + Class<? extends EObject> modelElementType); + /** * Prototypes consist of a generic description and pre-configured * {@link EObject}. -- GitLab