Skip to content
Snippets Groups Projects
Commit 28ff244e authored by Andreas Bayha's avatar Andreas Bayha
Browse files

Merge remote-tracking branch 'origin/master' into 4240

parents a4d5b88b 06e507fb
No related branches found
No related tags found
1 merge request!1784240
Pipeline #38405 passed
Pipeline: maven-releng

#38406

    Showing
    with 206 additions and 91 deletions
    CurvedLinkLayoutedContentAnchorangeController.java 249629c966a1f92fc28294ef62117439799d7315 GREEN CurvedLinkLayoutedContentAnchorangeController.java 249629c966a1f92fc28294ef62117439799d7315 GREEN
    CurvedLinkLayoutedDiagramAnchorangeController.java de1ab32e11205435cf7a89d2dcc352683ef8b39e GREEN CurvedLinkLayoutedDiagramAnchorangeController.java de1ab32e11205435cf7a89d2dcc352683ef8b39e GREEN
    EObjectDiagramController.java 45f5b1439f33685523b035d2603e8329b647b62a GREEN EObjectDiagramController.java 4b51e73023a8e5dd7f5ae12b495b25f22c1b58bd GREEN
    EObjectEllipticResizableContentControllerBase.java f12e8f5a646a23fe428ed4768bf041c8b885ec81 GREEN EObjectEllipticResizableContentControllerBase.java 7021ae2cadf40bdd099964908cc881644ad9ffb3 GREEN
    EObjectModelChangeProvider.java f4b60cebb088a5c81ca92a41614e1a5d40030502 GREEN EObjectModelChangeProvider.java f4b60cebb088a5c81ca92a41614e1a5d40030502 GREEN
    EObjectRectangularResizableContentControllerBase.java cde6c13659611d927691c03ecd2621cff2414b03 GREEN EObjectRectangularResizableContentControllerBase.java dbeb8371fdac0838c9a23b9dcff63f81aae1265b GREEN
    KernelServiceBasedModelChangeProviderBase.java 8d1f8ef79ecd383ff74e5a2bbcf24345aabe70af GREEN KernelServiceBasedModelChangeProviderBase.java 8d1f8ef79ecd383ff74e5a2bbcf24345aabe70af GREEN
    LayoutedContentAnchorageController.java 83f066a151dd2984c4bef64daf8165a0cd53b00f GREEN LayoutedContentAnchorageController.java 83f066a151dd2984c4bef64daf8165a0cd53b00f GREEN
    LayoutedCurveLinkBendPointController.java d963a5e227de7bd8ba910c733df2ac7acf4fa1fa GREEN LayoutedCurveLinkBendPointController.java d963a5e227de7bd8ba910c733df2ac7acf4fa1fa GREEN
    ...@@ -12,5 +12,5 @@ LayoutedEllipticResizableContentController.java 00037188773eb65866863ab89331bc98 ...@@ -12,5 +12,5 @@ LayoutedEllipticResizableContentController.java 00037188773eb65866863ab89331bc98
    LayoutedLineLinkBendPointController.java 8022cc66c4d33d7bf357ceb4c9ca1694f4f2fda8 GREEN LayoutedLineLinkBendPointController.java 8022cc66c4d33d7bf357ceb4c9ca1694f4f2fda8 GREEN
    LayoutedLinkBendPointController.java d3f22ffb43426da62e849074a9d5a64e4d70a7ad GREEN LayoutedLinkBendPointController.java d3f22ffb43426da62e849074a9d5a64e4d70a7ad GREEN
    LayoutedRectangularResizableContentController.java 341f4a7da0d69360d7026af6d9b3d44dfd7d9bb1 GREEN LayoutedRectangularResizableContentController.java 341f4a7da0d69360d7026af6d9b3d44dfd7d9bb1 GREEN
    ModelElementFXEditorUIProviderBase.java 6bdd31d033228315e99c973b4986cdabc135ec9f GREEN ModelElementFXEditorUIProviderBase.java 1ab1d053029e14510ff97c84821a62ddeaf595e7 GREEN
    NamedCommentedLayoutModelChangeProvider.java 223e82c1b1cba842f6fae115182f5d0c6acb44b0 GREEN NamedCommentedLayoutModelChangeProvider.java 223e82c1b1cba842f6fae115182f5d0c6acb44b0 GREEN
    ...@@ -85,6 +85,8 @@ public class EObjectDiagramController<T extends EObject> extends DefaultDiagramC ...@@ -85,6 +85,8 @@ public class EObjectDiagramController<T extends EObject> extends DefaultDiagramC
    IElementCompositionContext edc = createElementCompositionContext(modelParent, x, y, true, IElementCompositionContext edc = createElementCompositionContext(modelParent, x, y, true,
    getViewer().getFeatures().getCurrentZoomFactor()); getViewer().getFeatures().getCurrentZoomFactor());
    List<MenuItem> result = createPrototypeMenu(modelParent, edc); List<MenuItem> result = createPrototypeMenu(modelParent, edc);
    // Adds all menu items from the context menu service.
    result.addAll(IContextMenuService.getInstance().getFXMenuItemsForElement(modelParent, null));
    // Adds "Display" and "Zoom" menus // Adds "Display" and "Zoom" menus
    result.addAll(super.contextMenuContributions(node, diagramLocation)); result.addAll(super.contextMenuContributions(node, diagramLocation));
    if(modelParent instanceof IHierarchicElement && enableAutoLayout()) { if(modelParent instanceof IHierarchicElement && enableAutoLayout()) {
    ......
    ...@@ -38,6 +38,7 @@ import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext; ...@@ -38,6 +38,7 @@ import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
    import org.fortiss.tooling.kernel.model.INamedCommentedElement; import org.fortiss.tooling.kernel.model.INamedCommentedElement;
    import org.fortiss.tooling.kernel.service.IElementCompositorService; import org.fortiss.tooling.kernel.service.IElementCompositorService;
    import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler; import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
    import org.fortiss.tooling.kernel.ui.service.IContextMenuService;
    import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService; import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
    import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService; import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
    ...@@ -133,7 +134,10 @@ public abstract class EObjectEllipticResizableContentControllerBase<T extends IN ...@@ -133,7 +134,10 @@ public abstract class EObjectEllipticResizableContentControllerBase<T extends IN
    EObject modelParent = (EObject)getModel(); EObject modelParent = (EObject)getModel();
    IElementCompositionContext edc = createElementCompositionContext(modelParent, x, y, false, IElementCompositionContext edc = createElementCompositionContext(modelParent, x, y, false,
    getViewer().getFeatures().getCurrentZoomFactor()); getViewer().getFeatures().getCurrentZoomFactor());
    return createPrototypeMenu(modelParent, edc); List<MenuItem> menuItems = createPrototypeMenu(modelParent, edc);
    menuItems.addAll(
    IContextMenuService.getInstance().getFXMenuItemsForElement(modelParent, null));
    return menuItems;
    } }
    /** {@inheritDoc} */ /** {@inheritDoc} */
    ......
    ...@@ -44,6 +44,7 @@ import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext; ...@@ -44,6 +44,7 @@ import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
    import org.fortiss.tooling.kernel.model.INamedCommentedElement; import org.fortiss.tooling.kernel.model.INamedCommentedElement;
    import org.fortiss.tooling.kernel.service.IElementCompositorService; import org.fortiss.tooling.kernel.service.IElementCompositorService;
    import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler; import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
    import org.fortiss.tooling.kernel.ui.service.IContextMenuService;
    import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService; import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
    import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService; import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
    ...@@ -164,7 +165,10 @@ public abstract class EObjectRectangularResizableContentControllerBase<T extends ...@@ -164,7 +165,10 @@ public abstract class EObjectRectangularResizableContentControllerBase<T extends
    EObject modelParent = (EObject)getModel(); EObject modelParent = (EObject)getModel();
    IElementCompositionContext edc = createElementCompositionContext(modelParent, x, y, false, IElementCompositionContext edc = createElementCompositionContext(modelParent, x, y, false,
    getViewer().getFeatures().getCurrentZoomFactor()); getViewer().getFeatures().getCurrentZoomFactor());
    return createPrototypeMenu(modelParent, edc); List<MenuItem> menuItems = createPrototypeMenu(modelParent, edc);
    menuItems.addAll(
    IContextMenuService.getInstance().getFXMenuItemsForElement(modelParent, null));
    return menuItems;
    } }
    /** {@inheritDoc} */ /** {@inheritDoc} */
    ......
    ...@@ -22,6 +22,7 @@ import org.eclipse.jface.viewers.StructuredSelection; ...@@ -22,6 +22,7 @@ import org.eclipse.jface.viewers.StructuredSelection;
    import org.fortiss.tooling.base.model.element.IModelElement; import org.fortiss.tooling.base.model.element.IModelElement;
    import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableUIProviderBase; import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableUIProviderBase;
    import org.fortiss.tooling.kernel.ui.extension.base.FXEditorBase; import org.fortiss.tooling.kernel.ui.extension.base.FXEditorBase;
    import org.fortiss.tooling.kernel.ui.service.IContextMenuService;
    import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService; import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
    import javafx.scene.Node; import javafx.scene.Node;
    ...@@ -60,6 +61,8 @@ public abstract class ModelElementFXEditorUIProviderBase<T extends IModelElement ...@@ -60,6 +61,8 @@ public abstract class ModelElementFXEditorUIProviderBase<T extends IModelElement
    } }
    ContextMenu contextMenu = new ContextMenu(); ContextMenu contextMenu = new ContextMenu();
    contextMenu.getItems().addAll(createPrototypeMenu(element, null)); contextMenu.getItems().addAll(createPrototypeMenu(element, null));
    contextMenu.getItems()
    .addAll(IContextMenuService.getInstance().getFXMenuItemsForElement(element, null));
    return contextMenu; return contextMenu;
    } }
    ......
    AbstractNameEditingSupport.java c57336a0e0da18711a1610ca667dfea76728807f GREEN AbstractNameEditingSupport.java c57336a0e0da18711a1610ca667dfea76728807f GREEN
    ActionUtils.java 322f43d4f92f992daef8ac88eb0f9197c840c89b GREEN ActionUtils.java 322f43d4f92f992daef8ac88eb0f9197c840c89b GREEN
    ContextMenuUtils.java 1b4f2a63dfca9ad363942baf320c93145c251836 GREEN ContextMenuUtils.java a55ceed42f2eb88ba263a6fbcb394ddb80b1eda0 GREEN
    EllipseLayoutUIUtils.java 0af2cfc038661828b1bb8c51c0a3816d453e8313 GREEN EllipseLayoutUIUtils.java 0af2cfc038661828b1bb8c51c0a3816d453e8313 GREEN
    FXDNDUtils.java 6ce94e239e68f9e2b3cc0524b072606f4a120076 GREEN FXDNDUtils.java 6ce94e239e68f9e2b3cc0524b072606f4a120076 GREEN
    FontUtils.java a167a05bdaa8da9853705cc5134f30f6d81bc9f2 GREEN FontUtils.java a167a05bdaa8da9853705cc5134f30f6d81bc9f2 GREEN
    ......
    ...@@ -91,6 +91,7 @@ public final class ContextMenuUtils { ...@@ -91,6 +91,7 @@ public final class ContextMenuUtils {
    if(!newMenu.getItems().isEmpty()) { if(!newMenu.getItems().isEmpty()) {
    result.add(newMenu); result.add(newMenu);
    } }
    return result; return result;
    } }
    ......
    ...@@ -5,7 +5,7 @@ DynamicTextFieldTreeTableCell.java 62fa0c08b11d87e0eed41f84be85505c2740e75d GREE ...@@ -5,7 +5,7 @@ DynamicTextFieldTreeTableCell.java 62fa0c08b11d87e0eed41f84be85505c2740e75d GREE
    DynamicTreeContentProviderBase.java 91896b1fb5104d126544c44c1ff8c30f2a13a8d6 GREEN DynamicTreeContentProviderBase.java 91896b1fb5104d126544c44c1ff8c30f2a13a8d6 GREEN
    DynamicTreeItem.java 7e81ea98038b5eca90df583e0268d4e8f37aaf25 GREEN DynamicTreeItem.java 7e81ea98038b5eca90df583e0268d4e8f37aaf25 GREEN
    DynamicTreeItemBase.java d883066ecc181120302ca32f328538de7a45b093 GREEN DynamicTreeItemBase.java d883066ecc181120302ca32f328538de7a45b093 GREEN
    DynamicTreeTableUIProviderBase.java 29aa753793ab90676d45e5b76b11f7b46ce02a97 GREEN DynamicTreeTableUIProviderBase.java 360df9d5114c5d4a391a7a7afe70a5b8ad584490 GREEN
    DynamicTreeTableViewer.java 77e9995a3bee37d57578dad9434a53c702128efa YELLOW DynamicTreeTableViewer.java 77e9995a3bee37d57578dad9434a53c702128efa YELLOW
    DynamicTreeUIProviderBase.java 82d3c051213f0147f4c67ad247a08696cee73110 GREEN DynamicTreeUIProviderBase.java 82d3c051213f0147f4c67ad247a08696cee73110 GREEN
    DynamicTreeViewer.java 33066062a82101cf28410e4d04f85bb9c24251db GREEN DynamicTreeViewer.java 33066062a82101cf28410e4d04f85bb9c24251db GREEN
    ......
    ...@@ -322,6 +322,8 @@ public abstract class DynamicTreeTableUIProviderBase<T> { ...@@ -322,6 +322,8 @@ public abstract class DynamicTreeTableUIProviderBase<T> {
    final Node icon = getIconNode(data, columnIndex); final Node icon = getIconNode(data, columnIndex);
    cell.setGraphic(icon); cell.setGraphic(icon);
    cell.setStyle(getCellStyle(data, columnIndex)); cell.setStyle(getCellStyle(data, columnIndex));
    addContextMenuToCell(cell, columnIndex);
    } else { } else {
    // reset icon for cases, in which a row was styled before, but became empty by now. // reset icon for cases, in which a row was styled before, but became empty by now.
    cell.setGraphic(null); cell.setGraphic(null);
    ...@@ -585,7 +587,7 @@ public abstract class DynamicTreeTableUIProviderBase<T> { ...@@ -585,7 +587,7 @@ public abstract class DynamicTreeTableUIProviderBase<T> {
    * @param columnIndex * @param columnIndex
    * The column index of the given {@code cell}. * The column index of the given {@code cell}.
    */ */
    private void addContextMenuToCell(TreeTableCell<T, String> cell, int columnIndex) { private void addContextMenuToCell(TreeTableCell<T, ?> cell, int columnIndex) {
    ContextMenu menu; ContextMenu menu;
    T data = cell.getTreeTableRow().getItem(); T data = cell.getTreeTableRow().getItem();
    ...@@ -603,7 +605,7 @@ public abstract class DynamicTreeTableUIProviderBase<T> { ...@@ -603,7 +605,7 @@ public abstract class DynamicTreeTableUIProviderBase<T> {
    * {@link DynamicTreeViewer} due to the absence of proper selection interfaces in * {@link DynamicTreeViewer} due to the absence of proper selection interfaces in
    * JFX. * JFX.
    */ */
    private void addContextMenuHandler(TreeTableCell<T, String> cell, ContextMenu menu, T element) { private void addContextMenuHandler(TreeTableCell<T, ?> cell, ContextMenu menu, T element) {
    cell.getTreeTableView().addEventHandler(MouseEvent.MOUSE_RELEASED, e -> { cell.getTreeTableView().addEventHandler(MouseEvent.MOUSE_RELEASED, e -> {
    if(e.getButton() == MouseButton.SECONDARY) { if(e.getButton() == MouseButton.SECONDARY) {
    TreeItem<T> selected = TreeItem<T> selected =
    ......
    ...@@ -6,6 +6,6 @@ DefaultDiagramController.java 3f60229b2e0fe0b6ac40c617858cc5a0685a59eb GREEN ...@@ -6,6 +6,6 @@ DefaultDiagramController.java 3f60229b2e0fe0b6ac40c617858cc5a0685a59eb GREEN
    DelegatingContentAnchorageController.java 1889628a346a2183082ffe213978f9d15a949494 GREEN DelegatingContentAnchorageController.java 1889628a346a2183082ffe213978f9d15a949494 GREEN
    DragControllerBase.java b15ff874304f679fe494d85f57cc8cbe4d0d1d15 GREEN DragControllerBase.java b15ff874304f679fe494d85f57cc8cbe4d0d1d15 GREEN
    DraggingUtils.java 95117e2ea4c36b6c6a31f8088bb95b484e0e6612 GREEN DraggingUtils.java 95117e2ea4c36b6c6a31f8088bb95b484e0e6612 GREEN
    LinkControllerBase.java b59796a87ac5d5e054c332d0867d5e3d308d9936 GREEN LinkControllerBase.java 0fc15aa254831d741b6819d8b41a92e16e69141d GREEN
    MoveControllerBase.java 38d632e31f5e27d112ecdd4933e3a331378180d0 GREEN MoveControllerBase.java 38d632e31f5e27d112ecdd4933e3a331378180d0 GREEN
    ResizableContentControllerBase.java 898500d389b035f8138308d496d2d24be501c719 GREEN ResizableContentControllerBase.java 898500d389b035f8138308d496d2d24be501c719 GREEN
    ...@@ -138,14 +138,16 @@ public abstract class LinkControllerBase extends MVCBundlePartBase implements IC ...@@ -138,14 +138,16 @@ public abstract class LinkControllerBase extends MVCBundlePartBase implements IC
    @Override @Override
    public Change secondaryClick(MouseEvent event, Node node, public Change secondaryClick(MouseEvent event, Node node,
    DiagramCoordinate locationOnNode) { DiagramCoordinate locationOnNode) {
    DiagramViewer viewer = getViewer();
    if(event.isControlDown()) { if(event.isControlDown()) {
    // link must be primary selected // link must be primary selected
    DiagramViewer viewer = getViewer();
    if(viewer.isPrimarySelected(getMVCBundle())) { if(viewer.isPrimarySelected(getMVCBundle())) {
    // control+right-click deletes the link // control+right-click deletes the link
    return () -> deleteLink(); return () -> deleteLink();
    } }
    } }
    viewer.showContextMenu(node, locationOnNode, getMVCBundle());
    return null; return null;
    } }
    }; };
    ......
    ...@@ -7,4 +7,4 @@ ITutorialStepUI.java b8aee2b95857484ab6ad9ecd55b5de9f0ea158e5 GREEN ...@@ -7,4 +7,4 @@ ITutorialStepUI.java b8aee2b95857484ab6ad9ecd55b5de9f0ea158e5 GREEN
    ITutorialUIProvider.java aa0ff5db4d7ba0953e34edeb99f3e8279567e18f GREEN ITutorialUIProvider.java aa0ff5db4d7ba0953e34edeb99f3e8279567e18f GREEN
    ITutorialUIWhitelistProvider.java d703c1531c6ae7677c2d94cbc95d498dfa4a7e9b GREEN ITutorialUIWhitelistProvider.java d703c1531c6ae7677c2d94cbc95d498dfa4a7e9b GREEN
    ModelEditorNotAvailableBinding.java ba0ea0fe9004cf16579d053d0ddf7eb3f35ed101 GREEN ModelEditorNotAvailableBinding.java ba0ea0fe9004cf16579d053d0ddf7eb3f35ed101 GREEN
    RevealMenu.java e1c1a36da89ab3dac6e85c0d99425b4753a3da62 GREEN RevealMenu.java 9a6ea3ec03ca9d9e762d7f7beee23d2a43991ea9 GREEN
    ...@@ -30,6 +30,7 @@ import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider; ...@@ -30,6 +30,7 @@ import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider;
    import org.fortiss.tooling.kernel.ui.internal.views.NavigatorTreeContentProvider; import org.fortiss.tooling.kernel.ui.internal.views.NavigatorTreeContentProvider;
    import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService; import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
    import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService; import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
    import org.fortiss.tooling.kernel.ui.service.INavigatorService;
    /** /**
    * Context menu entry to reveal an element in its editor. * Context menu entry to reveal an element in its editor.
    ...@@ -101,7 +102,7 @@ public class RevealMenu implements IContextMenuContributor { ...@@ -101,7 +102,7 @@ public class RevealMenu implements IContextMenuContributor {
    ContextMenuContextProvider contextProvider) { ContextMenuContextProvider contextProvider) {
    EObject element = openModelElementRequest(selection); EObject element = openModelElementRequest(selection);
    if(element == null) { if(element == null || !INavigatorService.getInstance().isNavigatorView(contextProvider)) {
    return emptyList(); return emptyList();
    } }
    Object parent = treeNavigatorTreeContentProvider.getParent(selection); Object parent = treeNavigatorTreeContentProvider.getParent(selection);
    ......
    ActionService.java e29126b5947c9fd2f1d82bb87001b9d0ead50c3b GREEN ActionService.java e29126b5947c9fd2f1d82bb87001b9d0ead50c3b GREEN
    ContextMenuService.java 9021e4eeb5d7be5d73d87e5947564bdf17f07b9d GREEN ContextMenuService.java 752ecb95721c4ff31583095bdb06b71ef28c4dcf GREEN
    MarkerService.java 92c9e7410a39040554473bd59d7b75a76ad47f97 YELLOW MarkerService.java 92c9e7410a39040554473bd59d7b75a76ad47f97 YELLOW
    ModelEditorBindingService.java f304addb514cd2de443997e0b52cef7a3a9897bf GREEN ModelEditorBindingService.java f304addb514cd2de443997e0b52cef7a3a9897bf GREEN
    ModelElementHandlerService.java 34adeef844bf98c69f1b9a7252f34d0a2b741b54 GREEN ModelElementHandlerService.java 34adeef844bf98c69f1b9a7252f34d0a2b741b54 GREEN
    ......
    ...@@ -15,20 +15,27 @@ ...@@ -15,20 +15,27 @@
    +--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
    package org.fortiss.tooling.kernel.ui.internal; package org.fortiss.tooling.kernel.ui.internal;
    import static java.util.Arrays.asList;
    import static java.util.Collections.emptyList; import static java.util.Collections.emptyList;
    import static javafx.embed.swt.SWTFXUtils.toFXImage;
    import java.util.ArrayList; import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List; import java.util.List;
    import java.util.Map;
    import java.util.function.Predicate; import java.util.function.Predicate;
    import java.util.stream.Collectors; import java.util.stream.Collectors;
    import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
    import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
    import org.eclipse.jface.action.ActionContributionItem;
    import org.eclipse.jface.action.IAction;
    import org.eclipse.jface.action.IContributionItem; import org.eclipse.jface.action.IContributionItem;
    import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuListener;
    import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IMenuManager;
    import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.MenuManager;
    import org.eclipse.jface.action.Separator; import org.eclipse.jface.action.Separator;
    import org.eclipse.jface.resource.ImageDescriptor;
    import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.IWorkbenchActionConstants;
    import org.fortiss.tooling.kernel.ToolingKernelActivator; import org.fortiss.tooling.kernel.ToolingKernelActivator;
    import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem; import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
    ...@@ -48,6 +55,11 @@ import org.fortiss.tooling.kernel.utils.ExtensionPointUtils; ...@@ -48,6 +55,11 @@ import org.fortiss.tooling.kernel.utils.ExtensionPointUtils;
    import org.fortiss.tooling.kernel.utils.LoggingUtils; import org.fortiss.tooling.kernel.utils.LoggingUtils;
    import org.osgi.framework.Bundle; import org.osgi.framework.Bundle;
    import javafx.scene.control.MenuItem;
    import javafx.scene.control.SeparatorMenuItem;
    import javafx.scene.image.Image;
    import javafx.scene.image.ImageView;
    /** /**
    * This class implements the {@link IContextMenuService} interface. * This class implements the {@link IContextMenuService} interface.
    * *
    ...@@ -73,8 +85,13 @@ public class ContextMenuService implements IContextMenuService, IIntrospectiveKe ...@@ -73,8 +85,13 @@ public class ContextMenuService implements IContextMenuService, IIntrospectiveKe
    private static final String HANDLER_CLASS_ATTRIBUTE_NAME = "contributor"; private static final String HANDLER_CLASS_ATTRIBUTE_NAME = "contributor";
    /** Stores the registered context menu contributors. */ /** Stores the registered context menu contributors. */
    private final List<IContextMenuContributor> contextMenuContributorList = private final List<IContextMenuContributor> contextMenuContributorList = new ArrayList<>();
    new ArrayList<IContextMenuContributor>();
    /** An ordered list of all menu sections from top to bottom. */
    private static final String[] MENU_SECTIONS = {TOP_MOST_MENU_SECTION_ID,
    BEFORE_GLOBAL_MENU_SECTION_ID, ActionService.GLOBAL_DEFAULT_MENU_SECTION_ID,
    AFTER_GLOBAL_MENU_SECTION_ID, REPOSITORY_MENU_SECTION_ID,
    IWorkbenchActionConstants.MB_ADDITIONS, BOTTOM_MOST_MENU_SECTION_ID};
    /** Initializes the service. */ /** Initializes the service. */
    public void initializeService() { public void initializeService() {
    ...@@ -149,25 +166,20 @@ public class ContextMenuService implements IContextMenuService, IIntrospectiveKe ...@@ -149,25 +166,20 @@ public class ContextMenuService implements IContextMenuService, IIntrospectiveKe
    if(!menu.isEmpty()) { if(!menu.isEmpty()) {
    return; return;
    } }
    addVisibleSectionSeparator(menu, TOP_MOST_MENU_SECTION_ID); for(String section : MENU_SECTIONS) {
    addVisibleSectionSeparator(menu, BEFORE_GLOBAL_MENU_SECTION_ID); addVisibleSectionSeparator(menu, section);
    addVisibleSectionSeparator(menu, ActionService.GLOBAL_DEFAULT_MENU_SECTION_ID); }
    addVisibleSectionSeparator(menu, AFTER_GLOBAL_MENU_SECTION_ID);
    addVisibleSectionSeparator(menu, REPOSITORY_MENU_SECTION_ID);
    addVisibleSectionSeparator(menu, IWorkbenchActionConstants.MB_ADDITIONS);
    addVisibleSectionSeparator(menu, BOTTOM_MOST_MENU_SECTION_ID);
    addContributions(menu, contextProvider); addContributions(menu, contextProvider);
    IActionService as = IActionService.getInstance();
    if(!ITutorialService.getInstance().isTutorialActive()) { if(!ITutorialService.getInstance().isTutorialActive()) {
    IActionService.getInstance().addGlobalDefaultActionSectionToMenu(menu); as.addGlobalDefaultActionSectionToMenu(menu);
    } else { } else {
    ITutorialUIService tsUI = ITutorialUIService.getInstance();
    IActionService.getInstance().addGlobalEditingActionsToMenu(menu, as.addGlobalEditingActionsToMenu(menu, tsUI.globalCopyPasteActionsVisible(),
    ITutorialUIService.getInstance().globalCopyPasteActionsVisible(), tsUI.globalDeleteActionVisible(), tsUI.globalRenameActionVisible(),
    ITutorialUIService.getInstance().globalDeleteActionVisible(), tsUI.globalSelectAllActionVisible());
    ITutorialUIService.getInstance().globalRenameActionVisible(),
    ITutorialUIService.getInstance().globalSelectAllActionVisible());
    } }
    } }
    } }
    ...@@ -175,90 +187,145 @@ public class ContextMenuService implements IContextMenuService, IIntrospectiveKe ...@@ -175,90 +187,145 @@ public class ContextMenuService implements IContextMenuService, IIntrospectiveKe
    /** Adds registered contributions to the given menu. */ /** Adds registered contributions to the given menu. */
    private void addContributions(IMenuManager menu, ContextMenuContextProvider contextProvider) { private void addContributions(IMenuManager menu, ContextMenuContextProvider contextProvider) {
    List<EObject> selection = contextProvider.getSelectedModelElementList(); List<EObject> selection = contextProvider.getSelectedModelElementList();
    if(selection == null) {
    // do nothing
    } else if(selection.size() == 1) {
    singleSelectionElementContributions(menu, contextProvider);
    } else if(selection.size() > 1) {
    addMultiSelectionContributions(menu, contextProvider, selection);
    }
    }
    /** Populates the menu with contributions to a single model element selection. */ Map<String, List<IContributionItem>> contributions =
    private void singleSelectionElementContributions(IMenuManager menu, getContributionsForElements(selection, contextProvider);
    ContextMenuContextProvider contextProvider) {
    EObject selectionElem = contextProvider.getSelectedModelElement(); for(String menuSectionID : contributions.keySet()) {
    for(IContextMenuContributor contributor : contextMenuContributorList) { List<IContributionItem> items = contributions.get(menuSectionID);
    if(!INavigatorService.getInstance().isExpertViewActive() && if(items == null) {
    contributor.hiddenInNonExpertView()) {
    continue; continue;
    } }
    String menuSectionID = contributor.getMenuSectionID(); // populate menu
    if(menuSectionID == null) { for(IContributionItem item : items) {
    menuSectionID = IWorkbenchActionConstants.MB_ADDITIONS; menu.appendToGroup(menuSectionID, item);
    } }
    }
    }
    // get contributions from contributor /** {@inheritDoc} */
    List<IContributionItem> items = @Override
    contributor.getContributedItems(selectionElem, contextProvider); public List<MenuItem> getFXMenuItemsForElements(List<EObject> elements,
    if(items == null) { ContextMenuContextProvider contextProvider) {
    List<MenuItem> ret = new ArrayList<MenuItem>();
    Map<String, List<IContributionItem>> contributions =
    getContributionsForElements(elements, contextProvider);
    // Create menu items for all sections
    for(String menuID : MENU_SECTIONS) {
    List<IContributionItem> menuItems = contributions.get(menuID);
    if(menuItems == null) {
    continue; continue;
    } }
    // active tutorial may filter contributions for(IContributionItem c : menuItems) {
    if(ITutorialService.getInstance().isTutorialActive()) { if(c instanceof ActionContributionItem) {
    ITutorialUIService service = ITutorialUIService.getInstance(); IAction action = ((ActionContributionItem)c).getAction();
    Predicate<? super IContributionItem> isVisible =
    i -> service.contextMenuContributionVisible(selectionElem, i); // Create a wrapper MenuItem for the jface Action
    items = items.stream().filter(isVisible).collect(Collectors.toList()); MenuItem menuItem = new MenuItem(action.getText());
    } menuItem.setOnAction(evt -> {
    if(items == null) { action.run();
    continue; });
    // Add Icon
    ImageDescriptor imageDescriptor = action.getImageDescriptor();
    if(imageDescriptor != null) {
    Image fxImage =
    toFXImage(imageDescriptor.createImage().getImageData(), null);
    ImageView icon = new ImageView(fxImage);
    menuItem.setGraphic(icon);
    }
    ret.add(menuItem);
    }
    } }
    // populate menu // Add a separator after non-empty sections.
    for(IContributionItem item : items) { if(menuItems.size() > 0) {
    menu.appendToGroup(menuSectionID, item); ret.add(new SeparatorMenuItem());
    } }
    } }
    // If the last menu item is a separator, it can be removed.
    int retLastIndex = ret.size() - 1;
    if(retLastIndex > 0 && ret.get(retLastIndex) instanceof SeparatorMenuItem) {
    ret.remove(retLastIndex);
    }
    return ret;
    }
    /** {@inheritDoc} */
    @Override
    public List<MenuItem> getFXMenuItemsForElement(EObject element,
    ContextMenuContextProvider contextProvider) {
    return getFXMenuItemsForElements(asList(element), contextProvider);
    } }
    /** Populates the menu with contributions to multiple model element selection. */ /**
    private void addMultiSelectionContributions(IMenuManager menu, * Retrieves a map from menu section ids to a list {@link IContributionItem}s for the given
    ContextMenuContextProvider contextProvider, List<EObject> selection) { * selectedElements.
    */
    private Map<String, List<IContributionItem>> getContributionsForElements(
    List<EObject> selectedElements, ContextMenuContextProvider contextProvider) {
    Map<String, List<IContributionItem>> ret = new HashMap<String, List<IContributionItem>>();
    for(IContextMenuContributor contributor : contextMenuContributorList) { for(IContextMenuContributor contributor : contextMenuContributorList) {
    if(contributor instanceof IContextMenuMultiSelectionContributor) { if(!INavigatorService.getInstance().isExpertViewActive() &&
    if(!INavigatorService.getInstance().isExpertViewActive() && contributor.hiddenInNonExpertView()) {
    contributor.hiddenInNonExpertView()) { continue;
    }
    // get contributions from contributor
    List<IContributionItem> items = null;
    boolean isTutorialActive = ITutorialService.getInstance().isTutorialActive();
    if(selectedElements.size() == 1) {
    // Size checked.
    EObject selectedElement = selectedElements.get(0);
    items = contributor.getContributedItems(selectedElement, contextProvider);
    // active tutorial may filter contributions
    if(isTutorialActive) {
    ITutorialUIService service = ITutorialUIService.getInstance();
    Predicate<? super IContributionItem> isVisible =
    i -> service.contextMenuContributionVisible(selectedElement, i);
    items = items.stream().filter(isVisible).collect(Collectors.toList());
    }
    } else if(selectedElements.size() > 1 &&
    contributor instanceof IContextMenuMultiSelectionContributor) {
    // active tutorial does not support multiple selections
    if(isTutorialActive) {
    continue; continue;
    } }
    IContextMenuMultiSelectionContributor multicontributor = IContextMenuMultiSelectionContributor multiContributor =
    (IContextMenuMultiSelectionContributor)contributor; (IContextMenuMultiSelectionContributor)contributor;
    String menuSectionID = contributor.getMenuSectionID(); items = multiContributor.getContributedItems(selectedElements, contextProvider);
    if(menuSectionID == null) { }
    menuSectionID = IWorkbenchActionConstants.MB_ADDITIONS;
    }
    // get contributions from contributor if(items == null) {
    List<IContributionItem> items = continue;
    multicontributor.getContributedItems(selection, contextProvider); }
    if(items == null) {
    continue;
    }
    // active tutorial does not support multiple selections String menuSectionID = contributor.getMenuSectionID();
    if(ITutorialService.getInstance().isTutorialActive()) { if(menuSectionID == null) {
    continue; menuSectionID = IWorkbenchActionConstants.MB_ADDITIONS;
    } }
    // populate menu List<IContributionItem> sectionItems = ret.get(menuSectionID);
    for(IContributionItem item : items) { if(sectionItems == null) {
    menu.appendToGroup(menuSectionID, item); sectionItems = new ArrayList<IContributionItem>();
    } ret.put(menuSectionID, sectionItems);
    } }
    sectionItems.addAll(items);
    } }
    return ret;
    } }
    /** Adds a visible section separator. */ /** Adds a visible section separator. */
    ......
    IActionService.java 22eafafc8708cbff7f855f7b1b9bef042c127f25 GREEN IActionService.java 22eafafc8708cbff7f855f7b1b9bef042c127f25 GREEN
    IContextMenuService.java cfb6b8237b6cd2b0e461991a9ceb95969f330265 GREEN IContextMenuService.java 10fdd339b5e902c99578caa98d631f2d551a6e29 GREEN
    IMarkerService.java 82486a5656cd907926fcdf1ca1ab801290f8514c GREEN IMarkerService.java 82486a5656cd907926fcdf1ca1ab801290f8514c GREEN
    IModelEditorBindingService.java ce2ae1957e2232bb0fac1d1d262103f9adfc5266 GREEN IModelEditorBindingService.java ce2ae1957e2232bb0fac1d1d262103f9adfc5266 GREEN
    IModelElementHandlerService.java 23353de6b85af0e9d44a1c926174fa4ed5152af0 GREEN IModelElementHandlerService.java 23353de6b85af0e9d44a1c926174fa4ed5152af0 GREEN
    ......
    ...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
    +--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
    package org.fortiss.tooling.kernel.ui.service; package org.fortiss.tooling.kernel.ui.service;
    import java.util.List;
    import org.eclipse.emf.ecore.EObject;
    import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.MenuManager;
    import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.IWorkbenchActionConstants;
    import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor; import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor;
    ...@@ -22,6 +25,8 @@ import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider; ...@@ -22,6 +25,8 @@ import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider;
    import org.fortiss.tooling.kernel.ui.internal.ActionService; import org.fortiss.tooling.kernel.ui.internal.ActionService;
    import org.fortiss.tooling.kernel.ui.internal.ContextMenuService; import org.fortiss.tooling.kernel.ui.internal.ContextMenuService;
    import javafx.scene.control.MenuItem;
    /** /**
    * The context menu service allows registration for model element specific * The context menu service allows registration for model element specific
    * context menus. The context menu consists of a stack of separated sections * context menus. The context menu consists of a stack of separated sections
    ...@@ -74,4 +79,28 @@ public interface IContextMenuService { ...@@ -74,4 +79,28 @@ public interface IContextMenuService {
    /** Registers the given contributor with the kernel. */ /** Registers the given contributor with the kernel. */
    void registerContextMenuContributor(IContextMenuContributor contributor); void registerContextMenuContributor(IContextMenuContributor contributor);
    /**
    * Retrieves JavaFX {@link MenuItem}s for the given elements.
    *
    * @param elements
    * A {@link List} of {@link EObject}s to get context menu entries for.
    * @param contextProvider
    * The {@link ContextMenuContextProvider} to be used.
    * @return A {@link List} of {@link MenuItem}s.
    */
    public List<MenuItem> getFXMenuItemsForElements(List<EObject> elements,
    ContextMenuContextProvider contextProvider);
    /**
    * Retrieves JavaFX {@link MenuItem}s for the given element.
    *
    * @param element
    * An {@link EObject}s to get context menu entries for.
    * @param contextProvider
    * The {@link ContextMenuContextProvider} to be used.
    * @return A {@link List} of {@link MenuItem}s.
    */
    public List<MenuItem> getFXMenuItemsForElement(EObject element,
    ContextMenuContextProvider contextProvider);
    } }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment