diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/.ratings index 9915c0fead5ae7a4dff9f36f10b9b4a24845f501..e3a97d52ba827fa99f31034194e9bd0c20278bc8 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/.ratings @@ -1,7 +1,7 @@ DynamicTreeContentProviderBase.java 6760a6dc5721175b1dada8f30fd9da05f7bcc4b3 GREEN DynamicTreeItem.java 75dc5534b119ffdb3c10a65810c2a0f330b7955e GREEN DynamicTreeTableUIProviderBase.java f78c0f8b52fbc939166b3f94f7f6006cc0f4d32b GREEN -DynamicTreeTableViewer.java 5e58a31a63f8e56d8c8e69e2c4d095809bc46bf1 GREEN +DynamicTreeTableViewer.java 9eb192873acf4f08ab3570c195d8828224a61934 GREEN DynamicTreeUIProviderBase.java e9b68607683de279d0cb8712a28dc131c5c33ece GREEN DynamicTreeViewer.java 725f41f4fb4b6bfa813f010fb9083ab02eea164a GREEN DynamicTreeViewerBase.java a2013538b62d86f6a09efdf2cd78babac2072484 GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableViewer.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableViewer.java index 5e58a31a63f8e56d8c8e69e2c4d095809bc46bf1..9eb192873acf4f08ab3570c195d8828224a61934 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableViewer.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableViewer.java @@ -119,14 +119,19 @@ public final class DynamicTreeTableViewer<T> extends DynamicTreeViewerBase<T> { } } - /** Expands all items on all levels. */ - public void expandAllItems() { + /** Expand all items to the given level. */ + public void expandToLevel(int revealLevel) { TreeItem<T> root = view.getRoot(); if(root == null) { return; } - expandItem(root, MAX_VALUE); + expandItem(root, revealLevel); + } + + /** Expands all items on all levels. */ + public void expandAllItems() { + expandToLevel(MAX_VALUE); } /** diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/.ratings index b2bd51c666f1d44fe1c509afafc7d3663c9faebd..96bd7fd61d7ceb3a34b8052c8dfd2a341ee94206 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/.ratings @@ -1,7 +1,7 @@ DiamondContentVisualBase.java a81e76e85706ad38b6c22bbcd1cc5a5696737e3d GREEN LineLinkGraph.java 85a06a553f88f7b9fb4bd9c06411725d9fb160fc GREEN -LineLinkVisualBase.java 74968c18bb68859bc795ed9a3b0693d1787e0806 GREEN -LineSegment.java a8658ec5bcd930d417a148861831b9ebb70bb37d GREEN +LineLinkVisualBase.java 876d6872b1844568f055809b975d2471330f719f GREEN +LineSegment.java 9ab1b97ad372db763654ef783747fa0733bec55c GREEN RectangularBorderLocation.java 824472c353534d1094ae4f735a30a231b885f050 GREEN RectangularContentAnchorageVisualBase.java 39981dc29cac42d77c6ffe855ecc8ccad1689230 GREEN RectangularContentVisualBase.java aeeda282f330180b1f339e3230810eccea2e7e7b GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/LineLinkVisualBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/LineLinkVisualBase.java index 74968c18bb68859bc795ed9a3b0693d1787e0806..876d6872b1844568f055809b975d2471330f719f 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/LineLinkVisualBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/LineLinkVisualBase.java @@ -70,7 +70,8 @@ public abstract class LineLinkVisualBase extends LinkVisualBase { double nx = bp.getX() + chg.getDeltaX(); double ny = bp.getY() + chg.getDeltaY(); segments.add(new LineSegment(bpModel, sx, sy, nx, ny, getInvisibleSelectionLineWidth(), - feedbackSize, false, false, 0, getLabelText(i, pts + 1))); + feedbackSize, false, false, 0, getLabelText(i, pts + 1), + getSimulationLabelText(i, pts + 1))); sx = nx; sy = ny; bpModel = getBendPointModel(i); @@ -80,7 +81,8 @@ public abstract class LineLinkVisualBase extends LinkVisualBase { .applyToPoint(getEndAnchorPoint()); segments.add(new LineSegment(bpModel, sx, sy, endPoint.getX(), endPoint.getY(), getInvisibleSelectionLineWidth(), 0, showArrowOnLastSegment(), useLineArrow(), - getArrowLength(), getLabelText(pts, pts + 1))); + getArrowLength(), getLabelText(pts, pts + 1), + getSimulationLabelText(pts, pts + 1))); endFeedbackHandle.setX(endPoint.getX() - fs2); endFeedbackHandle.setY(endPoint.getY() - fs2); endFeedbackHandle.setWidth(feedbackSize); @@ -90,7 +92,8 @@ public abstract class LineLinkVisualBase extends LinkVisualBase { int numberOfSegs = segments.size(); for(int i = 0; i < numberOfSegs; i++) { LineSegment ls = segments.get(i); - ls.addLinkNodes(layers, bundle, getLabelText(i, numberOfSegs)); + ls.addLinkNodes(layers, bundle, getLabelText(i, numberOfSegs), + getSimulationLabelText(i, numberOfSegs)); } linesAddedToSceneGraph = true; } @@ -156,14 +159,16 @@ public abstract class LineLinkVisualBase extends LinkVisualBase { // handle bend points for(int i = 0; i < pts; i++) { Point2D ep = getFeedbackChangeForBendPoint(i).applyToPoint(getBendPointLocation(i)); - segments.get(segIndex).update(sp, ep, feedbackSize, 0, getLabelText(i, pts)); + segments.get(segIndex).update(sp, ep, feedbackSize, 0, getLabelText(i, pts), + getSimulationLabelText(i, pts)); sp = ep; segIndex++; } // end point Point2D ep = getFeedbackChangeForBendPoint(END_OF_LINK_BEND_POINT_INDEX) .applyToPoint(getEndAnchorPoint()); - segments.get(segIndex).update(sp, ep, 0, getArrowLength(), getLabelText(pts, pts)); + segments.get(segIndex).update(sp, ep, 0, getArrowLength(), getLabelText(pts, pts), + getSimulationLabelText(pts, pts)); endFeedbackHandle.setX(ep.getX() - fs2); endFeedbackHandle.setY(ep.getY() - fs2); endFeedbackHandle.setWidth(feedbackSize); @@ -360,6 +365,19 @@ public abstract class LineLinkVisualBase extends LinkVisualBase { return null; } + /** + * Returns the simulation label text. + * + * @param currentSegment + * the current segment + * @param lastSegment + * the last index of a segment + * @return the label text for the current segment or null for no label + */ + protected String getSimulationLabelText(int currentSegment, int lastSegment) { + return null; + } + /** Returns the {@link LinkMVCBundle}. */ private LinkMVCBundle getLinkBundle() { return (LinkMVCBundle)getMVCBundle(); diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/LineSegment.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/LineSegment.java index a8658ec5bcd930d417a148861831b9ebb70bb37d..9ab1b97ad372db763654ef783747fa0733bec55c 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/LineSegment.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/LineSegment.java @@ -47,19 +47,23 @@ final class LineSegment { private final LinkArrowWidget arrowWidget; /** Stores the label. */ private Text label; + /** Stores the simulation label */ + private Text simulationLabel; + /** Offset of simulation label in y direction. */ + private final int SIMULATION_OFFSET = 1; /** Constructor. */ public LineSegment(double sx, double sy, double ex, double ey, double clickableWidth, double markerSize, boolean showArrow, boolean useLineArrow, double arrowLength, - String labelText) { + String labelText, String simulationLabelText) { this(null, sx, sy, ex, ey, clickableWidth, markerSize, showArrow, useLineArrow, arrowLength, - labelText); + labelText, simulationLabelText); } /** Constructor. */ public LineSegment(Object bendPointModel, double sx, double sy, double ex, double ey, double clickableWidth, double feedbackSize, boolean showArrow, boolean useLineArrow, - double arrowLength, String labelText) { + double arrowLength, String labelText, String simulationLabelText) { this.bendPointModel = bendPointModel; this.visibleLine = new Line(sx, sy, ex, ey); @@ -85,6 +89,14 @@ final class LineSegment { } else { label = null; } + if(simulationLabelText != null) { + simulationLabel = new Text(simulationLabelText); + simulationLabel.setTextAlignment(TextAlignment.CENTER); + simulationLabel.setTextOrigin(VPos.TOP); + simulationLabel.setFill(Color.RED); + } else { + simulationLabel = null; + } } /** Returns the bend point model. */ @@ -108,12 +120,14 @@ final class LineSegment { } /** Adds the link nodes of this segment to the link layer node. */ - public void addLinkNodes(DiagramLayers layers, ILinkMVCBundle bundle, String labelText) { + public void addLinkNodes(DiagramLayers layers, ILinkMVCBundle bundle, String labelText, + String simulationLabelText) { ILayer visualLayer = layers.getLinkLayer(); visualLayer.add(visibleLine, bundle); if(arrowWidget != null) { visualLayer.add(arrowWidget, bundle); } + if(label != null) { label.setText(labelText); double lx = (visibleLine.getStartX() + visibleLine.getEndX() - @@ -122,11 +136,26 @@ final class LineSegment { label.setX(lx); label.setY(ly); layers.getTextLayer().add(label, bundle); + if(simulationLabel != null) { + setSimulationLabel(simulationLabelText, lx, ly, + label.getBoundsInLocal().getHeight()); + layers.getTextLayer().add(simulationLabel, bundle); + } } ILayer interactionLayer = layers.getLinkInteractionLayer(); interactionLayer.add(clickableLine, bundle); } + /** + * Sets the text of the simulation label below the label of the line. + */ + private void setSimulationLabel(String simulationLabelText, double lx, double ly, + double yOffset) { + simulationLabel.setText(simulationLabelText); + simulationLabel.setX(lx); + simulationLabel.setY(ly + yOffset + SIMULATION_OFFSET); + } + /** Removes the link nodes of this segment from the link layer node. */ public void removeLinkNodes(DiagramLayers layers) { ILayer visualLayer = layers.getLinkLayer(); @@ -137,6 +166,9 @@ final class LineSegment { if(label != null) { layers.getTextLayer().remove(label); } + if(simulationLabel != null) { + layers.getTextLayer().remove(simulationLabel); + } ILayer interactionLayer = layers.getLinkInteractionLayer(); interactionLayer.remove(clickableLine); } @@ -166,7 +198,7 @@ final class LineSegment { /** Updates the line segment. */ public void update(Point2D sp, Point2D ep, double feedbackSize, double arrowLength, - String labelText) { + String labelText, String simulationLabelText) { double sx = sp.getX(); double sy = sp.getY(); visibleLine.setStartX(sx); @@ -196,6 +228,10 @@ final class LineSegment { double ly = (sy + ey) / 2; label.setX(lx); label.setY(ly); + if(simulationLabel != null) { + setSimulationLabel(simulationLabelText, lx, ly, + label.getBoundsInLocal().getHeight()); + } } } @@ -210,5 +246,8 @@ final class LineSegment { if(label != null) { label.setMouseTransparent(transparent); } + if(simulationLabel != null) { + simulationLabel.setMouseTransparent(transparent); + } } } diff --git a/org.fortiss.tooling.kernel.ui/META-INF/MANIFEST.MF b/org.fortiss.tooling.kernel.ui/META-INF/MANIFEST.MF index 65d6f76c31a5bc6a516dbd360f041b46152dadcf..6ef02a93991a98d4e4402e95f0ba0ed432aebd1d 100644 --- a/org.fortiss.tooling.kernel.ui/META-INF/MANIFEST.MF +++ b/org.fortiss.tooling.kernel.ui/META-INF/MANIFEST.MF @@ -23,6 +23,7 @@ Export-Package: org.fortiss.tooling.kernel.ui, org.fortiss.tooling.kernel.ui.internal.editor, org.fortiss.tooling.kernel.ui.internal.properties, org.fortiss.tooling.kernel.ui.internal.views, + org.fortiss.tooling.kernel.ui.internal.views.library, org.fortiss.tooling.kernel.ui.listener, org.fortiss.tooling.kernel.ui.presentation, org.fortiss.tooling.kernel.ui.service, diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/.ratings index e5179fafce002378ce1029a73e389de29079f4d5..4c8db7b8f82b4874d000ac500f3dfbe3033ec88e 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/.ratings @@ -1,3 +1,3 @@ -ESharedImages.java dd65be1d1ee807db8460064d9b970847e6303ff0 GREEN +ESharedImages.java d33fea62344c1654b5da296fb51a18098cb09eed GREEN ToolingKernelUI.java 250e5dde230272e286aa8d327fd597cf542774fe GREEN ToolingKernelUIActivator.java fc281e60592e54bd606d0b6667168afdfde8389e GREEN diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/ESharedImages.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/ESharedImages.java index dd65be1d1ee807db8460064d9b970847e6303ff0..d33fea62344c1654b5da296fb51a18098cb09eed 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/ESharedImages.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/ESharedImages.java @@ -47,6 +47,9 @@ public enum ESharedImages { /** The navigator image. */ NAVIGATOR, + /** Library image. */ + LIBRARY, + /** Error (non-overlay) icon. */ ERROR, diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/.ratings index 47d763c0b8c828c45fb79c3acb051e06400a72bd..bb65e43fe71feacf8e73f7fb1bd1b652bdc7564e 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/.ratings @@ -3,8 +3,8 @@ AllocationEditPartFactoryService.java 81bd227736013f1157ba9d0f79a9f3deefe10064 G ContextMenuService.java ca3c899293f25b70ce8e5f0d86ca2f9683329d81 GREEN EditPartFactoryService.java e9180c0020f1769d9e24ef3c08f9ca5599dbc5c3 GREEN MarkerService.java 208f97f3ccabf0947702a17ddca23d8766a268f4 GREEN -ModelEditorBindingService.java 577f5db41abf240291434dbad6bc6b0fde1eeb2b GREEN +ModelEditorBindingService.java d980691db4b700714c0669050014d08751354d5e GREEN ModelElementHandlerService.java eeb07f6926012aa98256d452d1e554a5486dc657 GREEN -NavigatorService.java 2b1361eac805996e22e5409dafff9707fbac3376 GREEN +NavigatorService.java 1d773dde3791ddf7051616fe249558e7e307757d GREEN ToolingKernelUIInternal.java a70d19883dfb315d860233156d8524cf1ac2952f GREEN TutorialUIService.java b1d632eca91b4feb583f3930cd6ee4722dd9bfed GREEN diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/ModelEditorBindingService.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/ModelEditorBindingService.java index 577f5db41abf240291434dbad6bc6b0fde1eeb2b..d980691db4b700714c0669050014d08751354d5e 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/ModelEditorBindingService.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/ModelEditorBindingService.java @@ -28,6 +28,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.conqat.ide.commons.ui.ui.WorkbenchUtils; import org.eclipse.emf.common.command.CommandStackListener; import org.eclipse.emf.ecore.EObject; import org.eclipse.ui.IEditorPart; @@ -58,9 +59,9 @@ import org.fortiss.tooling.kernel.ui.extension.ModelEditorNotAvailableBinding; import org.fortiss.tooling.kernel.ui.internal.editor.ExtendableMultiPageEditor; import org.fortiss.tooling.kernel.ui.internal.editor.ModelElementEditorInput; import org.fortiss.tooling.kernel.ui.internal.introspection.items.ModelEditorBindingServiceIntrospectionDetailsItem; +import org.fortiss.tooling.kernel.ui.internal.views.library.LibraryViewPart; import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService; import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService; -import org.fortiss.tooling.kernel.ui.service.INavigatorService; /** * This class implements the {@link IModelEditorBindingService} interface. @@ -141,7 +142,12 @@ public class ModelEditorBindingService extends EObjectAwareServiceBase<IModelEdi IModelElementHandlerService.getInstance().getModelElementHandler(libElement); if(handler != null) { EObject displayedElement = handler.handleOpenModelElementRequest(libElement); - INavigatorService.getInstance().setLibraryViewActive(); + try { + WorkbenchUtils.getActiveWorkbenchPage().showView(LibraryViewPart.ID); + } catch(PartInitException e) { + error(ToolingKernelActivator.getDefault(), + "Could not open Library View with ID " + LibraryViewPart.ID, e); + } openInEditor(displayedElement); } return; diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/NavigatorService.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/NavigatorService.java index 2b1361eac805996e22e5409dafff9707fbac3376..1d773dde3791ddf7051616fe249558e7e307757d 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/NavigatorService.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/NavigatorService.java @@ -89,7 +89,7 @@ public class NavigatorService implements INavigatorService, IPersistencyServiceL public String getIntrospectionDescription() { return getIntrospectionLabel() + "\n\nThis service manages the model element navigator view including the handling of" + - "\nsaveables, the dirty state, and the expert and library mode."; + "\nsaveables, the dirty state, and the expert mode."; } /** Initializes the service. */ @@ -362,12 +362,6 @@ public class NavigatorService implements INavigatorService, IPersistencyServiceL saveablesChanged(SaveablesLifecycleEvent.DIRTY_CHANGED, element, false); } - /** {@inheritDoc} */ - @Override - public void setLibraryViewActive() { - getNavigatorViewPart().setLibraryViewActive(); - } - /** {@inheritDoc} */ @Override public void tutorialStarted(ITutorialProvider provider) { diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/.ratings index cde02f1cf9f9a4c2db5896be05fcf3f9706f7ca1..3eaf205055aa0f29358d52b9ec081c6466a441ba 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/.ratings @@ -1,6 +1,5 @@ -DoubleClick.java fd00e7737c0bad903433c0adb67dad92220ff451 GREEN +DoubleClick.java a94d27299814a93b0d8914050a5da7378a7eccd1 GREEN GenericNewMenu.java 7e0dd435cb5ca6d4b486235ec17eef3e5c7aa5f6 GREEN -LibraryView.java 44107622da7bcf431e1177e462d711646488957f GREEN LibraryViewDragSourceAdapter.java 56ef61b214ef5d6cb5b751791a92158bda0391ec GREEN LinkWithEditorPartListener.java c5ab74424378e7b158a805c4dd14fc03c8abeded GREEN MarkerViewContentProvider.java 4cb1192baebe21bca951c439c163d0c171512515 GREEN @@ -9,4 +8,4 @@ ModelElementsViewFX.java b1d03d57b67bf2c7b1d8da0ad3b16ea7d59efab5 GREEN NavigatorNewMenu.java a35e391960d1dacbe7f77982e53e1891e9382d5a GREEN NavigatorTreeContentComparator.java d9f1354cfdff78b104b28887d2397e5ca0e9755b GREEN NavigatorTreeContentProvider.java 1fbe97bebf3805cc1af190cecd784fc1cfd12306 GREEN -NavigatorViewPart.java 79872dfaab92f20e8767cff84b66dc9e173601d1 GREEN +NavigatorViewPart.java d0d93194b40a7ecd171d0f4703a784e1fdbe9346 GREEN diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/DoubleClick.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/DoubleClick.java index fd00e7737c0bad903433c0adb67dad92220ff451..a94d27299814a93b0d8914050a5da7378a7eccd1 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/DoubleClick.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/DoubleClick.java @@ -31,7 +31,7 @@ import org.fortiss.tooling.kernel.ui.util.EObjectSelectionUtils; * * @author hoelzl */ -class DoubleClick implements IDoubleClickListener { +public class DoubleClick implements IDoubleClickListener { /** Stores the use-raw-eobject flag. */ private final boolean useRawEObject; diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/LibraryView.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/LibraryView.java deleted file mode 100644 index 44107622da7bcf431e1177e462d711646488957f..0000000000000000000000000000000000000000 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/LibraryView.java +++ /dev/null @@ -1,267 +0,0 @@ -/*-------------------------------------------------------------------------+ -| 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.ui.internal.views; - -import static org.fortiss.tooling.kernel.utils.EcoreUtils.filterOutInstanceOf; -import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement; - -import java.util.List; -import java.util.Set; - -import org.conqat.ide.commons.ui.jface.TreeContentProviderBase; -import org.conqat.ide.commons.ui.ui.EmptyPartListener; -import org.conqat.lib.commons.collections.IdentityHashSet; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.IEditorPart; -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.extension.data.LibraryPrototype; -import org.fortiss.tooling.kernel.extension.data.Prototype; -import org.fortiss.tooling.kernel.extension.data.PrototypeCategory; -import org.fortiss.tooling.kernel.model.ILibraryElement; -import org.fortiss.tooling.kernel.service.IPrototypeService; -import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler; -import org.fortiss.tooling.kernel.ui.extension.base.EditorBase; -import org.fortiss.tooling.kernel.ui.internal.editor.ExtendableMultiPageEditor; -import org.fortiss.tooling.kernel.ui.listener.ExtendableMultiPageEditorPageChangeListener; -import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService; - -/** - * {@link ViewPart} for the model element library view. - * - * @author hoelzl - * @author eder - */ -public class LibraryView extends ViewPart { - - /** The viewer. */ - private TreeViewer viewer; - - /** Filter text field for the tree viewer. */ - private FilteredTree filteredTree; - - /** Current active {@link ExtendableMultiPageEditor}. */ - private ExtendableMultiPageEditor activeBindingEditor = null; - - /** Stores the editor activation listener. */ - private EditorActivationListener editorActivationListener = new EditorActivationListener(); - - /** 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 ExtendableMultiPageEditorPageChangeListener bindingEditorPageChangeListener = - new ExtendableMultiPageEditorPageChangeListener() { - @Override - public void pageChanged() { - updateEditorFilters(activeBindingEditor.getActiveModelEditor()); - } - }; - - /** {@inheritDoc} */ - @Override - public void createPartControl(Composite parent) { - PatternFilter patternFilter = new PatternFilter(); - patternFilter.setIncludeLeadingWildcard(true); - - filteredTree = new FilteredTree(parent, SWT.H_SCROLL | SWT.V_SCROLL, patternFilter, false); - viewer = filteredTree.getViewer(); - - viewer.setContentProvider(new LibraryTreeContentProvider()); - viewer.setLabelProvider(new LibraryLabelProvider()); - - LibraryViewDragSourceAdapter dndAdapter = new LibraryViewDragSourceAdapter(viewer); - viewer.addDragSupport(dndAdapter.getSupportedDNDOperations(), - new Transfer[] {dndAdapter.getPreferredTransfer()}, dndAdapter); - - viewer.setInput(IPrototypeService.getInstance().getAllTopLevelPrototypesCategories()); - - viewer.addFilter(new LibraryViewerFilter()); - - getViewSite().setSelectionProvider(viewer); - getSite().getWorkbenchWindow().getPartService().addPartListener(editorActivationListener); - } - - /** Switches to the given workbench editor part. */ - private void switchWorkbenchEditor(IEditorPart editor) { - if(activeBindingEditor != null) { - activeBindingEditor.removeBindingEditorListener(bindingEditorPageChangeListener); - activeBindingEditor = null; - } - - if(editor instanceof ExtendableMultiPageEditor) { - activeBindingEditor = (ExtendableMultiPageEditor)editor; - activeBindingEditor.addBindingEditorListener(bindingEditorPageChangeListener); - updateEditorFilters(activeBindingEditor.getActiveModelEditor()); - } else if(editor != null) { - updateEditorFilters(editor); - } - } - - /** Updates the filters according to the given editor. */ - @SuppressWarnings("unchecked") - private void updateEditorFilters(IEditorPart editor) { - supportedBaseClasses.clear(); - if(editor instanceof EditorBase && - ((EditorBase<? extends EObject>)editor).enableLibraryView()) { - EditorBase<? extends EObject> editorBase = (EditorBase<? extends EObject>)editor; - containerObject = editorBase.getEditedObject(); - - for(Class<? extends EObject> clazz : editorBase.getVisibleEObjectTypes()) { - List<Prototype> composablePrototypes = - IPrototypeService.getInstance().getComposablePrototypes(clazz); - if(getParentElement(containerObject, ILibraryElement.class, true) == null) { - supportedBaseClasses.addAll(composablePrototypes); - } else { - supportedBaseClasses.addAll( - filterOutInstanceOf(LibraryPrototype.class, composablePrototypes)); - } - } - } else { - containerObject = null; - } - - if(!viewer.getControl().isDisposed()) { - viewer.refresh(); - viewer.expandAll(); - } - } - - /** {@inheritDoc} */ - @Override - public void setFocus() { - viewer.getControl().setFocus(); - } - - /** The label provider used in the library view. */ - private class LibraryLabelProvider extends LabelProvider { - - /** {@inheritDoc} */ - @Override - public String getText(Object element) { - if(element instanceof Prototype) { - Prototype prototype = (Prototype)element; - return prototype.getName(); - } - if(element instanceof PrototypeCategory) { - return ((PrototypeCategory)element).getName(); - } - return super.getText(element); - } - - /** {@inheritDoc} */ - @Override - public Image getImage(Object element) { - if(element instanceof Prototype) { - // delegate to the model element handlers - EObject prototype = ((Prototype)element).getPrototype(); - IModelElementHandler<EObject> handler = - IModelElementHandlerService.getInstance().getModelElementHandler(prototype); - if(handler != null) { - return handler.getIcon(prototype); - } - } - if(element instanceof PrototypeCategory && - ((PrototypeCategory)element).getChildren().length > 0) { - return getImage(((PrototypeCategory)element).getChildren()[0]); - } - return super.getImage(element); - } - } - - /** The content provider used in the library view. */ - private class LibraryTreeContentProvider extends TreeContentProviderBase { - - /** {@inheritDoc} */ - @SuppressWarnings("rawtypes") - @Override - public Object[] getElements(Object inputElement) { - if(inputElement instanceof Object[]) { - return (Object[])inputElement; - } - if(inputElement instanceof List) { - return ((List)inputElement).toArray(); - } - return new Object[0]; - } - - /** {@inheritDoc} */ - @Override - public Object[] getChildren(Object parentElement) { - if(parentElement instanceof PrototypeCategory) { - return ((PrototypeCategory)parentElement).getChildren(); - } - return new Object[0]; - } - } - - /** 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; - } - if(element instanceof PrototypeCategory) { - PrototypeCategory pc = (PrototypeCategory)element; - for(Object child : pc.getChildren()) { - if(select(viewer, pc, child)) { - return true; - } - } - return false; - } - return supportedBaseClasses.contains(element); - } - } - - /** If an editor in a different Project is opened the Model is reinitialized */ - private class EditorActivationListener extends EmptyPartListener { - - /** Change the tree viewer content whenever workbench part changes. */ - @Override - public void partActivated(IWorkbenchPart workbenchPart) { - if(!(workbenchPart instanceof IEditorPart)) { - return; - } - - Control control = viewer.getControl(); - if(control == null || control.isDisposed()) { - return; - } - - IEditorPart part = (IEditorPart)workbenchPart; - viewer.setInput(IPrototypeService.getInstance().getAllTopLevelPrototypesCategories()); - switchWorkbenchEditor(part); - } - } -} diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/NavigatorViewPart.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/NavigatorViewPart.java index 79872dfaab92f20e8767cff84b66dc9e173601d1..d0d93194b40a7ecd171d0f4703a784e1fdbe9346 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/NavigatorViewPart.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/NavigatorViewPart.java @@ -99,9 +99,6 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe /** Toggle expert view filter action. */ private Action toggleExpertViewAction = null; - /** Change to library/non-library view action. */ - private Action toggleLibraryViewAction = null; - /** Dialog setting ID for the link with editor action flag. */ private static final String LINK_WITH_EDITOR_FLAG = "navigatorSettingLinkWithEditor"; @@ -226,19 +223,6 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe linkWithEditorAction.setToolTipText("Link with editor"); linkWithEditorAction.setChecked(settings.getBoolean(LINK_WITH_EDITOR_FLAG)); - toggleLibraryViewAction = new Action("Toggle library view", SWT.TOGGLE) { - - @Override - public void run() { - ((NavigatorTreeContentProvider)viewer.getContentProvider()).toggleLibraryView(); - viewer.refresh(); - } - }; - - toggleLibraryViewAction.setImageDescriptor( - ToolingKernelUIActivator.getImageDescriptor("icons/library.png")); - toggleLibraryViewAction.setToolTipText("Toggle library view"); - toggleExpertViewAction = new Action("Toggle expert view", SWT.TOGGLE) { @Override @@ -259,7 +243,6 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe toolBarManager.insertAfter("additions", toggleExpertViewAction); toolBarManager.insertAfter("additions", linkWithEditorAction); - toolBarManager.insertAfter("additions", toggleLibraryViewAction); } /** Creates the context menu. */ @@ -418,17 +401,6 @@ public final class NavigatorViewPart extends ViewPart implements ISelectionListe return INavigatorService.getInstance().isExpertViewActive(); } - /** Sets the library view to be active. */ - public void setLibraryViewActive() { - NavigatorTreeContentProvider contentProvider = - (NavigatorTreeContentProvider)viewer.getContentProvider(); - if(!contentProvider.isLibraryViewActive()) { - contentProvider.toggleLibraryView(); - viewer.refresh(); - toggleLibraryViewAction.setChecked(true); - } - } - /** Refreshes the viewer and reveals the given element. */ public void refreshAndReveal(Object element) { elementToBeRevealed = element; diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/library/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/library/.ratings new file mode 100644 index 0000000000000000000000000000000000000000..02b479be9ed32b2728183f01b47e3c56d076b47d --- /dev/null +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/library/.ratings @@ -0,0 +1,2 @@ +LibraryTreeContentProvider.java dadf37cf8e54da481aac354d2c1b1360a018ea31 GREEN +LibraryViewPart.java ec13bcdbe0c577bb4594be3b93c4b5ba16a003cc GREEN diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/library/LibraryTreeContentProvider.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/library/LibraryTreeContentProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..dadf37cf8e54da481aac354d2c1b1360a018ea31 --- /dev/null +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/library/LibraryTreeContentProvider.java @@ -0,0 +1,88 @@ +/*-------------------------------------------------------------------------+ +| 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.ui.internal.views.library; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +import org.conqat.ide.commons.ui.jface.TreeContentProviderBase; +import org.eclipse.emf.ecore.EObject; +import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; +import org.fortiss.tooling.kernel.model.ILibrary; +import org.fortiss.tooling.kernel.model.ILibraryElementReference; +import org.fortiss.tooling.kernel.service.IPersistencyService; +import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler; +import org.fortiss.tooling.kernel.ui.internal.views.NavigatorTreeContentProvider; +import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService; + +/** + * Content provider for the library tree viewer. Reduced form of the + * {@link NavigatorTreeContentProvider}. + * + * @author eder + */ +public class LibraryTreeContentProvider extends TreeContentProviderBase { + + /** {@inheritDoc} */ + @Override + public Object[] getElements(Object inputElement) { + // delegate to the top-level element contexts of the persistency service + List<Object> result = new LinkedList<Object>(); + for(ITopLevelElement context : IPersistencyService.getInstance().getTopLevelElements()) { + EObject root = context.getRootModelElement(); + if(root instanceof ILibrary) { + result.add(root); + } + } + return result.toArray(); + } + + /** {@inheritDoc} */ + @Override + public Object[] getChildren(Object parent) { + // delegate to the model element handlers + if(parent instanceof EObject) { + EObject parentElement = (EObject)parent; + if(parentElement instanceof ILibraryElementReference) { + return new Object[0]; + } + IModelElementHandler<EObject> handler = + IModelElementHandlerService.getInstance().getModelElementHandler(parentElement); + if(handler != null) { + List<EObject> children = new ArrayList<EObject>(); + children.addAll(handler.getSubnodes(parentElement)); + children.addAll(handler.getSpecifications(parentElement)); + return children.toArray(); + } + } + return new Object[0]; + } + + /** {@inheritDoc} */ + @Override + public Object getParent(Object element) { + if(element instanceof EObject) { + EObject me = (EObject)element; + if(IPersistencyService.getInstance().isTopLevelElement(me)) { + // delegate to persistency service + return IPersistencyService.getInstance(); + } + return me.eContainer(); + } + return null; + } +} diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/library/LibraryViewPart.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/library/LibraryViewPart.java new file mode 100644 index 0000000000000000000000000000000000000000..ec13bcdbe0c577bb4594be3b93c4b5ba16a003cc --- /dev/null +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/views/library/LibraryViewPart.java @@ -0,0 +1,321 @@ +/*-------------------------------------------------------------------------+ +| 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.ui.internal.views.library; + +import static org.fortiss.tooling.kernel.ui.util.EObjectSelectionUtils.getEObjectElements; +import static org.fortiss.tooling.kernel.ui.util.EObjectSelectionUtils.getFirstElement; +import static org.fortiss.tooling.kernel.ui.util.EObjectSelectionUtils.getSelectionService; + +import java.util.List; + +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.MenuManager; +import org.eclipse.jface.viewers.DecoratingLabelProvider; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TreePath; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.ui.IDecoratorManager; +import org.eclipse.ui.ISaveablePart; +import org.eclipse.ui.ISaveablesSource; +import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchPartConstants; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.Saveable; +import org.eclipse.ui.part.ViewPart; +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.service.IPersistencyService; +import org.fortiss.tooling.kernel.ui.ESharedImages; +import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider; +import org.fortiss.tooling.kernel.ui.internal.NavigatorService; +import org.fortiss.tooling.kernel.ui.internal.views.DoubleClick; +import org.fortiss.tooling.kernel.ui.internal.views.NavigatorTreeContentComparator; +import org.fortiss.tooling.kernel.ui.internal.views.NavigatorViewPart; +import org.fortiss.tooling.kernel.ui.presentation.TutorialDefinitionModelElementLabelProvider; +import org.fortiss.tooling.kernel.ui.service.IActionService; +import org.fortiss.tooling.kernel.ui.service.IContextMenuService; +import org.fortiss.tooling.kernel.ui.service.INavigatorService; +import org.fortiss.tooling.kernel.ui.util.PropertiesConstantUtils; +import org.fortiss.tooling.kernel.ui.util.SelectionUtils; + +/** + * {@link ViewPart} for the library view. Basically, a reduced form of the + * {@link NavigatorViewPart}. + * + * @author hoelzl + * @author eder + */ +public final class LibraryViewPart extends ViewPart implements ISelectionListener, + ISelectionChangedListener, ITabbedPropertySheetPageContributor, ContextMenuContextProvider, + ISaveablesSource, ISaveablePart { + + /** The ID of this view. */ + public static final String ID = LibraryViewPart.class.getName(); + + /** Stores the TreeViewer. */ + private TreeViewer viewer; + + /** Stores the menu manager. */ + private MenuManager menuManager; + + /** Element used to ensure that the selection of the {@link LibraryViewPart} is not empty. */ + private EObject backupElementToBeSelected; + + /** Element to be revealed during the UI update. */ + private Object elementToBeRevealed = null; + + /** Stores the UI update job. */ + private final UIJob updateUI = new UIJob("Update Library View") { + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + if(viewer.getControl().isDisposed()) { + return Status.OK_STATUS; + } + IActionService.getInstance().refresh(); + viewer.refresh(); + + LibraryViewPart.this.refreshPartTitleAndImage(); + + // Ensure that the selection of the {@link NavigatorViewPart} is not empty. Otherwise + // undo/redo (and also other global commands) is not enabled when model elements are + // added directly using the context menu of the model navigator. + ISelection selection = viewer.getSelection(); + if(selection instanceof TreeSelection && !selection.isEmpty()) { + Object firstSelectedElement = ((TreeSelection)selection).getFirstElement(); + if(firstSelectedElement instanceof EObject) { + // Preserve container of current element. This is required to determine a valid + // model element in case the next operation is to delete the currently selected + // element + backupElementToBeSelected = ((EObject)firstSelectedElement).eContainer(); + } + } else if(backupElementToBeSelected != null) { + // Selection would be empty. Use backup element to force selection to the container + // of the element that has been selected last. + TreePath treePath = new TreePath(new Object[] {backupElementToBeSelected}); + viewer.setSelection(new TreeSelection(treePath)); + backupElementToBeSelected = null; + } + + if(elementToBeRevealed != null) { + revealModelElement(elementToBeRevealed); + elementToBeRevealed = null; + } + + firePropertyChange(IWorkbenchPartConstants.PROP_DIRTY); + return Status.OK_STATUS; + } + }; + + /** {@inheritDoc} */ + @Override + public void createPartControl(Composite parent) { + viewer = new TreeViewer(parent, SWT.MULTI); + + // NOTE that the order of this is important. See also JDT package + // explorer. + IDecoratorManager decoratorManager = PlatformUI.getWorkbench().getDecoratorManager(); + viewer.setLabelProvider( + new DecoratingLabelProvider(new TutorialDefinitionModelElementLabelProvider(), + decoratorManager.getLabelDecorator())); + viewer.setContentProvider(new LibraryTreeContentProvider()); + viewer.setComparator(new NavigatorTreeContentComparator()); + + getSite().setSelectionProvider(viewer); + createContextMenu(); + viewer.addSelectionChangedListener(this); + + viewer.setInput(IPersistencyService.getInstance()); + + viewer.addDoubleClickListener(new DoubleClick()); + + IActionService.getInstance().registerGlobalActions(getViewSite().getActionBars()); + + getSelectionService().addSelectionListener(this); + + refreshPartTitleAndImage(); + } + + /** Creates the context menu. */ + private void createContextMenu() { + menuManager = IContextMenuService.getInstance().createDefaultContextMenu(this); + + Menu contextMenu = menuManager.createContextMenu(viewer.getControl()); + viewer.getControl().setMenu(contextMenu); + + getSite().registerContextMenu(menuManager, viewer); + } + + /** {@inheritDoc} */ + @Override + public void setFocus() { + viewer.getControl().setFocus(); + viewer.refresh(); + } + + /** Reveals the given element in the navigator view. */ + public void revealModelElement(Object element) { + if(element == null) { + return; + } + if(!viewer.getExpandedState(element)) { + viewer.expandToLevel(element, 2); + } + viewer.setSelection(new StructuredSelection(element), true); + } + + /** {@inheritDoc} */ + @Override + public void selectionChanged(IWorkbenchPart part, ISelection selection) { + IActionService.getInstance().refresh(); + // do not fire property change here, since it was not the viewers + // selection that changed but the workbench-wide selection + } + + /** {@inheritDoc} */ + @Override + public void selectionChanged(SelectionChangedEvent event) { + // Ignore programmatic selection of backup model element + if(backupElementToBeSelected != null) { + return; + } + + IActionService.getInstance().refresh(); + // Sync selection of active editor with model navigator + SelectionUtils.setSelection(getSelectedModelElementList(), false, true); + + // fire upon viewer selection change + firePropertyChange(IWorkbenchPartConstants.PROP_DIRTY); + } + + /** {@inheritDoc} */ + @Override + public void dispose() { + ((NavigatorService)INavigatorService.getInstance()).setNavigatorViewPart(null); + + getSelectionService().removeSelectionListener(this); + getSite().setSelectionProvider(null); + + super.dispose(); + } + + /** {@inheritDoc} */ + @Override + public String getContributorId() { + return PropertiesConstantUtils.TABBED_PROPERTY_CONTRIBUTOR_ID; + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override + public <S> S getAdapter(Class<S> adapter) { + if(adapter == IPropertySheetPage.class) { + return (S)new TabbedPropertySheetPage(this); + } + return super.getAdapter(adapter); + } + + /** Refreshes the navigator view. */ + public void refresh() { + updateUI.schedule(); + } + + /** Refreshes the part's header image and title. */ + private void refreshPartTitleAndImage() { + String partName = "Library"; + Image partImage = ESharedImages.LIBRARY.getImage(); + setPartName(partName); + setTitleImage(partImage); + } + + /** {@inheritDoc} */ + @Override + public Saveable[] getSaveables() { + return INavigatorService.getInstance().getSaveables(); + } + + /** {@inheritDoc} */ + @Override + public Saveable[] getActiveSaveables() { + return INavigatorService.getInstance().getActiveSaveables(); + } + + /** {@inheritDoc} */ + @Override + public void doSave(IProgressMonitor monitor) { + // ignore. SaveableSource is used instead. + } + + /** {@inheritDoc} */ + @Override + public void doSaveAs() { + // ignore + } + + /** {@inheritDoc} */ + @Override + public boolean isDirty() { + return IPersistencyService.getInstance().isDirty(); + } + + /** {@inheritDoc} */ + @Override + public boolean isSaveAsAllowed() { + return false; + } + + /** {@inheritDoc} */ + @Override + public boolean isSaveOnCloseNeeded() { + return isDirty(); + } + + /** {@inheritDoc} */ + @Override + public EObject getSelectedModelElement() { + return getFirstElement(getSite().getSelectionProvider().getSelection()); + } + + /** {@inheritDoc} */ + @Override + public List<EObject> getSelectedModelElementList() { + return getEObjectElements(getSite().getSelectionProvider().getSelection()); + } + + /** Returns whether expert view is active. */ + public boolean isExpertViewActive() { + return INavigatorService.getInstance().isExpertViewActive(); + } + + /** Refreshes the viewer and reveals the given element. */ + public void refreshAndReveal(Object element) { + elementToBeRevealed = element; + refresh(); + } +} diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/.ratings index 1ded5ea76b623771ecae670bf1ee96d08ee6e421..c551f593428eb93077d2566f0329de729970a97a 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/.ratings @@ -5,5 +5,5 @@ IEditPartFactoryService.java c448bff63fb81f57037c9f1dc5319859c12d0c4d GREEN IMarkerService.java d433e838e387dd2fe61b8dea7395ebb7203ae39b GREEN IModelEditorBindingService.java ce2ae1957e2232bb0fac1d1d262103f9adfc5266 GREEN IModelElementHandlerService.java 748ffd22d6836a5599f8785f023469eb58c80ece GREEN -INavigatorService.java 8d2ffeb6f075d3abea904b84d8a40090d97837fd GREEN +INavigatorService.java 8fc66f7e554cfb547f2ce65dec9f48ac0559c54e GREEN ITutorialUIService.java 72707c60c3d23d8ffc5c579cb9b022bb614eb094 GREEN diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/INavigatorService.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/INavigatorService.java index 8d2ffeb6f075d3abea904b84d8a40090d97837fd..8fc66f7e554cfb547f2ce65dec9f48ac0559c54e 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/INavigatorService.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/INavigatorService.java @@ -73,7 +73,4 @@ public interface INavigatorService { /** Refreshes the navigator view part. */ void refresh(); - - /** Sets the library view active. */ - void setLibraryViewActive(); }