diff options
| author | Pierre Guilet | 2018-07-05 13:53:40 +0000 |
|---|---|---|
| committer | Pierre Guilet | 2018-08-09 13:33:56 +0000 |
| commit | 0e972c80a789f47fc33de935122e9c56dec12aac (patch) | |
| tree | 795de1b1f457000d14b3d7fbdb5bda5b5db6d60a | |
| parent | 6e574f4ac213201a87de34334850de01c04a1d76 (diff) | |
| download | org.eclipse.sirius-0e972c80a789f47fc33de935122e9c56dec12aac.tar.gz org.eclipse.sirius-0e972c80a789f47fc33de935122e9c56dec12aac.tar.xz org.eclipse.sirius-0e972c80a789f47fc33de935122e9c56dec12aac.zip | |
[527109] Fix wrong behaviors with double click in show/hide mode
The double click on a visible diagram element now changes the user
filters instead of DDiagramElement that is computed from other sources.
Fix labels that were not handled when double clicking to make those
filtered by user.
Bug: 527109
Change-Id: I3f5699aa402a5db7b2137a099c1a2bb7c115765b
Signed-off-by: Pierre Guilet <pierre.guilet@obeo.fr>
9 files changed, 224 insertions, 72 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/view/ShowingViewUtil.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/view/ShowingViewUtil.java index a5f1266ae1..d3d566d32f 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/view/ShowingViewUtil.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/view/ShowingViewUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017 THALES GLOBAL SERVICES and others. + * Copyright (c) 2017, 2018 THALES GLOBAL SERVICES and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,7 +29,7 @@ import org.eclipse.sirius.diagram.ui.business.api.query.ViewQuery; import org.eclipse.sirius.diagram.ui.edit.internal.part.DiagramElementEditPartOperation; /** - * This utility class contains methods to handle {@link View} and taking in consideration the activation status of the + * This utility class contains methods to handle {@link View} and to take in consideration the activation status of the * showing mode. * * @author <a href="mailto:pierre.guilet@obeo.fr">Pierre Guilet</a> @@ -126,8 +126,8 @@ public final class ShowingViewUtil { } else { figure.setVisible(visibility); } - figure.revalidate(); + figure.repaint(); } /** diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/AbstractDiagramEdgeEditPart.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/AbstractDiagramEdgeEditPart.java index 21f13cbc85..ecb0c06646 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/AbstractDiagramEdgeEditPart.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/api/part/AbstractDiagramEdgeEditPart.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2017 THALES GLOBAL SERVICES and others. + * Copyright (c) 2008, 2018 THALES GLOBAL SERVICES and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -461,6 +461,36 @@ public abstract class AbstractDiagramEdgeEditPart extends ConnectionNodeEditPart */ public class ViewEdgeFigure extends PolylineConnectionEx implements ITreeConnection { /** + * Label figure that allows to set the model {@link View}. These labels are created before label edit parts are + * created so we need to be able to attached the right view after. + * + * @author <a href="mailto:pierre.guilet@obeo.fr">Pierre Guilet</a> + * + */ + public final class SiriusWrapLabelWithAttachmentWithModel extends SiriusWrapLabelWithAttachment { + private View model; + + private SiriusWrapLabelWithAttachmentWithModel(int location, Polyline attachment) { + super(location, attachment); + } + + public void setModel(View model) { + this.model = model; + } + + @Override + public void paint(Graphics graphics) { + ShowingViewUtil.initGraphicsForVisibleAndInvisibleElements(this, graphics, model); + try { + super.paint(graphics); + graphics.restoreState(); + } finally { + graphics.popState(); + } + } + } + + /** * @was-generated */ private SiriusWrapLabelWithAttachment fFigureViewEdgeNameFigure; @@ -545,8 +575,8 @@ public abstract class AbstractDiagramEdgeEditPart extends ConnectionNodeEditPart */ private void createCenterLabelFigure(final EObject element) { attachmentToEdgeNameFigure = addNewAttachmentFigure(); + fFigureViewEdgeNameFigure = getLabelFigure(LabelViewConstants.MIDDLE_LOCATION, attachmentToEdgeNameFigure); - fFigureViewEdgeNameFigure = new SiriusWrapLabelWithAttachment(LabelViewConstants.MIDDLE_LOCATION, attachmentToEdgeNameFigure); if (element instanceof DEdge) { DEdge edge = (DEdge) element; fFigureViewEdgeNameFigure.setText(edge.getName()); @@ -567,7 +597,7 @@ public abstract class AbstractDiagramEdgeEditPart extends ConnectionNodeEditPart private void createBeginLabelFigure(final EObject element) { attachmentToEdgeBeginNameFigure = addNewAttachmentFigure(); - fFigureViewEdgeBeginNameFigure = new SiriusWrapLabelWithAttachment(LabelViewConstants.SOURCE_LOCATION, attachmentToEdgeBeginNameFigure); + fFigureViewEdgeBeginNameFigure = getLabelFigure(LabelViewConstants.SOURCE_LOCATION, attachmentToEdgeBeginNameFigure); if (element instanceof DEdge) { DEdge edge = (DEdge) element; fFigureViewEdgeBeginNameFigure.setText(edge.getBeginLabel()); @@ -602,7 +632,7 @@ public abstract class AbstractDiagramEdgeEditPart extends ConnectionNodeEditPart private void createEndLabelFigure(final EObject element) { attachmentToEdgeEndNameFigure = addNewAttachmentFigure(); - fFigureViewEdgeEndNameFigure = new SiriusWrapLabelWithAttachment(LabelViewConstants.TARGET_LOCATION, attachmentToEdgeEndNameFigure); + fFigureViewEdgeEndNameFigure = getLabelFigure(LabelViewConstants.TARGET_LOCATION, attachmentToEdgeEndNameFigure); if (element instanceof DEdge) { DEdge edge = (DEdge) element; fFigureViewEdgeEndNameFigure.setText(edge.getEndLabel()); @@ -617,6 +647,10 @@ public abstract class AbstractDiagramEdgeEditPart extends ConnectionNodeEditPart } + private SiriusWrapLabelWithAttachment getLabelFigure(int location, Polyline theAttachmentToEdgeNameFigure) { + return new SiriusWrapLabelWithAttachmentWithModel(location, attachmentToEdgeNameFigure); + } + @SuppressWarnings("deprecation") @Override public void layout() { diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/DoubleClickEditPolicy.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/DoubleClickEditPolicy.java index f6a41f8d3b..cbceea465b 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/DoubleClickEditPolicy.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/DoubleClickEditPolicy.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2017 THALES GLOBAL SERVICES. + * Copyright (c) 2007, 2018 THALES GLOBAL SERVICES. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,10 +10,11 @@ *******************************************************************************/ package org.eclipse.sirius.diagram.ui.graphical.edit.policies; +import java.util.HashSet; +import java.util.Set; + import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.transaction.RecordingCommand; import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.emf.transaction.util.TransactionUtil; import org.eclipse.gef.EditPart; import org.eclipse.gef.Request; import org.eclipse.gef.commands.Command; @@ -23,10 +24,14 @@ import org.eclipse.gmf.runtime.diagram.ui.editpolicies.OpenEditPolicy; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.sirius.diagram.DDiagram; import org.eclipse.sirius.diagram.DDiagramElement; -import org.eclipse.sirius.diagram.Messages; +import org.eclipse.sirius.diagram.DEdge; +import org.eclipse.sirius.diagram.EdgeTarget; +import org.eclipse.sirius.diagram.business.api.query.DDiagramElementQuery; import org.eclipse.sirius.diagram.description.DiagramElementMapping; import org.eclipse.sirius.diagram.tools.api.command.IDiagramCommandFactory; import org.eclipse.sirius.diagram.tools.api.command.IDiagramCommandFactoryProvider; +import org.eclipse.sirius.diagram.ui.internal.edit.parts.AbstractGeneratedDiagramNameEditPart; +import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNodeListElementEditPart; import org.eclipse.sirius.diagram.ui.tools.api.command.GMFCommandWrapper; import org.eclipse.sirius.diagram.ui.tools.api.editor.DDiagramEditor; @@ -38,11 +43,6 @@ import org.eclipse.sirius.diagram.ui.tools.api.editor.DDiagramEditor; */ public class DoubleClickEditPolicy extends OpenEditPolicy { - /** - * {@inheritDoc} - * - * @see org.eclipse.gmf.runtime.diagram.ui.editpolicies.OpenEditPolicy#getOpenCommand(org.eclipse.gef.Request) - */ @Override protected Command getOpenCommand(Request request) { Command result = null; @@ -55,28 +55,32 @@ public class DoubleClickEditPolicy extends OpenEditPolicy { DiagramElementMapping diagramElementMapping = ddiagramElement.getDiagramElementMapping(); DDiagram parentDiagram = ddiagramElement.getParentDiagram(); if (parentDiagram.isIsInShowingMode()) { - final TransactionalEditingDomain transactionalEditingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); - RecordingCommand cmd = new RecordingCommand(transactionalEditingDomain) { - @Override - protected void doExecute() { - ddiagramElement.setVisible(!ddiagramElement.isVisible()); - } - - @Override - public String getLabel() { - if (ddiagramElement.isVisible()) { - return Messages.HideDDiagramElement_hideElementLabel; + org.eclipse.emf.common.command.Command cmd = null; + final IDiagramCommandFactory emfCommandFactory = getCommandFactory(editPart); + EditPart targetEditPart = this.getTargetEditPart(request); + if (targetEditPart instanceof AbstractGeneratedDiagramNameEditPart && !(targetEditPart instanceof DNodeListElementEditPart)) { + // label case + DDiagramElementQuery query = new DDiagramElementQuery(ddiagramElement); + // CHECKSTYLE:OFF + if (query.canHideLabel()) { + if (query.isLabelHidden()) { + cmd = revealElement(ddiagramElement, emfCommandFactory, true); + } else { + cmd = hideElement(ddiagramElement, emfCommandFactory, true); } - return Messages.RevealDDiagramElements_revealElementLabel; } - }; - result = new ICommandProxy(new GMFCommandWrapper(transactionalEditingDomain, cmd)); + // CHECKSTYLE:ON + } else { + if (!ddiagramElement.isVisible()) { + cmd = revealElement(ddiagramElement, emfCommandFactory, false); + } else { + cmd = hideElement(ddiagramElement, emfCommandFactory, false); + } + } + final TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); + result = new ICommandProxy(new GMFCommandWrapper(editingDomain, cmd)); } else if (diagramElementMapping.getDoubleClickDescription() != null) { - final TransactionalEditingDomain transactionalEditingDomain = TransactionUtil.getEditingDomain(element); - final DDiagramEditor diagramEditor = (DDiagramEditor) this.getHost().getViewer().getProperty(DDiagramEditor.EDITOR_ID); - final Object adapter = diagramEditor.getAdapter(IDiagramCommandFactoryProvider.class); - final IDiagramCommandFactoryProvider cmdFactoryProvider = (IDiagramCommandFactoryProvider) adapter; - final IDiagramCommandFactory emfCommandFactory = cmdFactoryProvider.getCommandFactory(transactionalEditingDomain); + final IDiagramCommandFactory emfCommandFactory = getCommandFactory(editPart); final org.eclipse.emf.common.command.Command cmd = emfCommandFactory.buildDoubleClickOnElementCommandFromTool(ddiagramElement, diagramElementMapping.getDoubleClickDescription()); final TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); result = new ICommandProxy(new GMFCommandWrapper(editingDomain, cmd)); @@ -86,4 +90,91 @@ public class DoubleClickEditPolicy extends OpenEditPolicy { return result; } + /** + * Hides the given {@link DDiagramElement}. + * + * @param ddiagramElement + * element to reveal. + * @param emfCommandFactory + * factory for command creation. + * @param hideLabel + * true if we are hiding a label. False for any other element. + * @return the command doing the hiding. + */ + private org.eclipse.emf.common.command.Command hideElement(final DDiagramElement ddiagramElement, final IDiagramCommandFactory emfCommandFactory, boolean hideLabel) { + org.eclipse.emf.common.command.Command cmd; + Set<EObject> elementSet = new HashSet<>(); + elementSet.add(ddiagramElement); + if (hideLabel) { + cmd = emfCommandFactory.buildHideLabelCommand(elementSet); + } else { + cmd = emfCommandFactory.buildHideCommand(elementSet); + } + return cmd; + } + + /** + * Reveals the given {@link DDiagramElement} and all its parents recursively. If the element in an edge, also reveal + * the source and target and their parent recursively. + * + * @param ddiagramElement + * element to reveal. + * @param emfCommandFactory + * factory for command creation. + * @param hideLabel + * true if we are hiding a label. False for any other element. + * @return the command doing the revelation. + */ + private org.eclipse.emf.common.command.Command revealElement(final DDiagramElement ddiagramElement, final IDiagramCommandFactory emfCommandFactory, boolean hideLabel) { + org.eclipse.emf.common.command.Command cmd; + Set<DDiagramElement> elementSet = new HashSet<>(); + elementSet.add(ddiagramElement); + if (ddiagramElement instanceof DEdge) { + // we show source and target node as well as the edge. + DEdge edge = (DEdge) ddiagramElement; + EdgeTarget sourceNode = edge.getSourceNode(); + EdgeTarget targetNode = edge.getTargetNode(); + if (sourceNode instanceof DDiagramElement && targetNode instanceof DDiagramElement) { + elementSet.add((DDiagramElement) sourceNode); + elementSet.add((DDiagramElement) targetNode); + addAllParentRecursively(elementSet, (DDiagramElement) sourceNode); + addAllParentRecursively(elementSet, (DDiagramElement) targetNode); + } + } else { + addAllParentRecursively(elementSet, ddiagramElement); + } + if (hideLabel) { + cmd = emfCommandFactory.buildRevealLabelCommand(ddiagramElement); + } else { + + cmd = emfCommandFactory.buildRevealElementsCommand(elementSet); + } + return cmd; + } + + /** + * Add all parents recursively of the given {@link DDiagramElement} in the given set. + * + * @param elementSet + * the set where to add parents. + * @param ddiagramElement + * the element from which parents will be added. + */ + private void addAllParentRecursively(Set<DDiagramElement> elementSet, DDiagramElement ddiagramElement) { + EObject eContainer = ddiagramElement.eContainer(); + if (eContainer instanceof DDiagramElement) { + elementSet.add((DDiagramElement) eContainer); + addAllParentRecursively(elementSet, (DDiagramElement) eContainer); + } + } + + private IDiagramCommandFactory getCommandFactory(EditPart editPart) { + final TransactionalEditingDomain transactionalEditingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); + final DDiagramEditor diagramEditor = (DDiagramEditor) editPart.getViewer().getProperty(DDiagramEditor.EDITOR_ID); + final Object adapter = diagramEditor.getAdapter(IDiagramCommandFactoryProvider.class); + final IDiagramCommandFactoryProvider cmdFactoryProvider = (IDiagramCommandFactoryProvider) adapter; + final IDiagramCommandFactory emfCommandFactory = cmdFactoryProvider.getCommandFactory(transactionalEditingDomain); + return emfCommandFactory; + } + } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/AbstractDEdgeNameEditPart.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/AbstractDEdgeNameEditPart.java index c6d6ec1a07..7d2544dcea 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/AbstractDEdgeNameEditPart.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/AbstractDEdgeNameEditPart.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2017 THALES GLOBAL SERVICES and others. + * Copyright (c) 2007, 2018 THALES GLOBAL SERVICES and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,6 +30,7 @@ import org.eclipse.sirius.diagram.DEdge; import org.eclipse.sirius.diagram.DiagramPackage; import org.eclipse.sirius.diagram.business.api.query.IEdgeMappingQuery; import org.eclipse.sirius.diagram.description.EdgeMapping; +import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramEdgeEditPart.ViewEdgeFigure.SiriusWrapLabelWithAttachmentWithModel; import org.eclipse.sirius.diagram.ui.graphical.edit.policies.DEdgeNameSelectionFeedbackEditPolicy; import org.eclipse.sirius.diagram.ui.graphical.edit.policies.ResizableShapeLabelEditPolicy; import org.eclipse.sirius.diagram.ui.graphical.edit.policies.SiriusPropertyHandlerEditPolicy; @@ -71,6 +72,9 @@ public class AbstractDEdgeNameEditPart extends AbstractGeneratedDiagramNameEditP } public void setLabel(SiriusWrapLabel figure) { + if (figure instanceof SiriusWrapLabelWithAttachmentWithModel) { + ((SiriusWrapLabelWithAttachmentWithModel) figure).setModel((View) getModel()); + } unregisterVisuals(); setFigure(figure); defaultText = getLabelTextHelper(figure); @@ -126,8 +130,7 @@ public class AbstractDEdgeNameEditPart extends AbstractGeneratedDiagramNameEditP } /** - * Handles resizable label refresh bounds. "Override" to use a specific - * {@link EdgeLabelLocator}. + * Handles resizable label refresh bounds. "Override" to use a specific {@link EdgeLabelLocator}. */ private void handleResizableRefreshBounds() { int dx = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/DNodeListElementEditPart.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/DNodeListElementEditPart.java index 36bd35eea1..0d8a4528f6 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/DNodeListElementEditPart.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/DNodeListElementEditPart.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES and others. + * Copyright (c) 2007, 2018 THALES GLOBAL SERVICES and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.sirius.diagram.ui.internal.edit.parts; +import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.IFigure; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.EObject; @@ -24,6 +25,7 @@ import org.eclipse.gmf.runtime.emf.type.core.IElementType; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.sirius.diagram.DDiagramElement; import org.eclipse.sirius.diagram.DiagramPackage; +import org.eclipse.sirius.diagram.ui.business.internal.view.ShowingViewUtil; import org.eclipse.sirius.diagram.ui.edit.api.part.DiagramNameEditPartOperation; import org.eclipse.sirius.diagram.ui.edit.internal.part.DiagramElementEditPartOperation; import org.eclipse.sirius.diagram.ui.graphical.edit.policies.LaunchToolEditPolicy; @@ -188,7 +190,18 @@ public class DNodeListElementEditPart extends AbstractGeneratedDiagramNameEditPa * @not-generated */ protected IFigure createFigurePrim() { - SiriusWrapLabel safeWrapLabel = new SiriusWrapLabel(); + SiriusWrapLabel safeWrapLabel = new SiriusWrapLabel() { + @Override + public void paint(Graphics graphics) { + ShowingViewUtil.initGraphicsForVisibleAndInvisibleElements(this, graphics, (View) getModel()); + try { + super.paint(graphics); + graphics.restoreState(); + } finally { + graphics.popState(); + } + } + }; safeWrapLabel.setTextWrap(true); return safeWrapLabel; } @@ -212,8 +225,7 @@ public class DNodeListElementEditPart extends AbstractGeneratedDiagramNameEditPa @Override public void enableEditMode() { /* - * We want to be sure nobody is enabling the edit mode if the element is - * locked. + * We want to be sure nobody is enabling the edit mode if the element is locked. */ if (!this.getEditPartAuthorityListener().isLocked()) { super.enableEditMode(); diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/DNodeNameEditPart.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/DNodeNameEditPart.java index 94b3d98807..12d85e549b 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/DNodeNameEditPart.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/DNodeNameEditPart.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES and others. + * Copyright (c) 2007, 2018 THALES GLOBAL SERVICES and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.sirius.diagram.ui.internal.edit.parts; +import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; @@ -25,6 +26,7 @@ import org.eclipse.sirius.diagram.DNode; import org.eclipse.sirius.diagram.DiagramPackage; import org.eclipse.sirius.diagram.LabelPosition; import org.eclipse.sirius.diagram.NodeStyle; +import org.eclipse.sirius.diagram.ui.business.internal.view.ShowingViewUtil; import org.eclipse.sirius.diagram.ui.internal.providers.SiriusElementTypes; import org.eclipse.sirius.diagram.ui.part.SiriusVisualIDRegistry; import org.eclipse.sirius.diagram.ui.tools.api.figure.SiriusWrapLabel; @@ -56,6 +58,7 @@ public class DNodeNameEditPart extends AbstractGeneratedDiagramNameEditPart impl * * @not-generated */ + @Override protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); } @@ -63,6 +66,7 @@ public class DNodeNameEditPart extends AbstractGeneratedDiagramNameEditPart impl /** * @was-generated */ + @Override public IBorderItemLocator getBorderItemLocator() { final IFigure parentFigure = getFigure().getParent(); if (parentFigure != null && parentFigure.getLayoutManager() != null) { @@ -75,6 +79,7 @@ public class DNodeNameEditPart extends AbstractGeneratedDiagramNameEditPart impl /** * @not-generated */ + @Override public void refreshBounds() { final EObject eObj = this.resolveSemanticElement(); if (eObj instanceof DNode) { @@ -94,6 +99,7 @@ public class DNodeNameEditPart extends AbstractGeneratedDiagramNameEditPart impl /** * @was-generated */ + @Override public void setLabel(final IFigure figure) { unregisterVisuals(); setFigure(figure); @@ -108,9 +114,9 @@ public class DNodeNameEditPart extends AbstractGeneratedDiagramNameEditPart impl } /** - * @not-generated : the label is invisible when we must show the center - * label. + * @not-generated : the label is invisible when we must show the center label. */ + @Override protected void refreshVisuals() { super.refreshVisuals(); final EObject eObj = this.resolveSemanticElement(); @@ -126,6 +132,7 @@ public class DNodeNameEditPart extends AbstractGeneratedDiagramNameEditPart impl /** * @was-generated */ + @Override protected void handleNotificationEvent(final Notification event) { final Object feature = event.getFeature(); if (DiagramPackage.eINSTANCE.getDNode_OwnedStyle() == feature) { @@ -137,6 +144,7 @@ public class DNodeNameEditPart extends AbstractGeneratedDiagramNameEditPart impl /** * @was-generated */ + @Override protected IFigure createFigure() { final IFigure label = createFigurePrim(); defaultText = getLabelTextHelper(label); @@ -152,10 +160,18 @@ public class DNodeNameEditPart extends AbstractGeneratedDiagramNameEditPart impl return figure; } - /** - * @not-generated - */ - public static class ViewNodeNameFigureDesc extends SiriusWrapLabel { + public class ViewNodeNameFigureDesc extends SiriusWrapLabel { + + @Override + public void paint(Graphics graphics) { + ShowingViewUtil.initGraphicsForVisibleAndInvisibleElements(this, graphics, (View) getModel()); + try { + super.paint(graphics); + graphics.restoreState(); + } finally { + graphics.popState(); + } + } /** * @was-generated diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/SiriusWrapLabelWithAttachment.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/SiriusWrapLabelWithAttachment.java index 5d6867a51c..d6c137efc9 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/SiriusWrapLabelWithAttachment.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/SiriusWrapLabelWithAttachment.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016 THALES GLOBAL SERVICES. + * Copyright (c) 2016, 2018 THALES GLOBAL SERVICES. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,8 +21,8 @@ import org.eclipse.sirius.diagram.ui.provider.DiagramUIPlugin; import org.eclipse.sirius.diagram.ui.tools.api.preferences.SiriusDiagramUiPreferencesKeys; /** - * A specific SiriusWrapLabel for labels of edges that allow to show/hide a - * label attachment connected between label and edge during selection. + * A specific SiriusWrapLabel for labels of edges that allow to show/hide a label attachment connected between label and + * edge during selection. * * @author Laurent Redor */ @@ -30,12 +30,9 @@ public class SiriusWrapLabelWithAttachment extends SiriusWrapLabel { /** * The location of the label (one of - * {@link org.eclipse.gmf.runtime.diagram.ui.internal.util.LabelViewConstants.SOURCE_LOCATION} - * , - * {@link org.eclipse.gmf.runtime.diagram.ui.internal.util.LabelViewConstants.MIDDLE_LOCATION} - * or - * {@link org.eclipse.gmf.runtime.diagram.ui.internal.util.LabelViewConstants.TARGET_LOCATION} - * ). + * {@link org.eclipse.gmf.runtime.diagram.ui.internal.util.LabelViewConstants.SOURCE_LOCATION} , + * {@link org.eclipse.gmf.runtime.diagram.ui.internal.util.LabelViewConstants.MIDDLE_LOCATION} or + * {@link org.eclipse.gmf.runtime.diagram.ui.internal.util.LabelViewConstants.TARGET_LOCATION} ). */ private int location; @@ -46,12 +43,9 @@ public class SiriusWrapLabelWithAttachment extends SiriusWrapLabel { * * @param location * The location of the label (one of - * {@link org.eclipse.gmf.runtime.diagram.ui.internal.util.LabelViewConstants.SOURCE_LOCATION} - * , - * {@link org.eclipse.gmf.runtime.diagram.ui.internal.util.LabelViewConstants.MIDDLE_LOCATION} - * or - * {@link org.eclipse.gmf.runtime.diagram.ui.internal.util.LabelViewConstants.TARGET_LOCATION} - * ). + * {@link org.eclipse.gmf.runtime.diagram.ui.internal.util.LabelViewConstants.SOURCE_LOCATION} , + * {@link org.eclipse.gmf.runtime.diagram.ui.internal.util.LabelViewConstants.MIDDLE_LOCATION} or + * {@link org.eclipse.gmf.runtime.diagram.ui.internal.util.LabelViewConstants.TARGET_LOCATION} ). * @param attachment * The corresponding polyline attachment */ @@ -81,8 +75,8 @@ public class SiriusWrapLabelWithAttachment extends SiriusWrapLabel { } /** - * Set the attachment location (starting and ending points) according to the - * <code>location</code> of label on the edge and to the <label bounds. + * Set the attachment location (starting and ending points) according to the <code>location</code> of label on the + * edge and to the <label bounds. */ protected void setAttachmentLocation() { PointList ptList = ((Connection) getParent()).getPoints(); @@ -127,8 +121,7 @@ public class SiriusWrapLabelWithAttachment extends SiriusWrapLabel { } /** - * Method to make attachment unvisible (called on Edge or Label - * deselection). + * Method to make attachment unvisible (called on Edge or Label deselection). */ public void hideAttachment() { if (attachment != null) { diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/ShowingModeSwitchingAction.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/ShowingModeSwitchingAction.java index 3199111801..7d597067f5 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/ShowingModeSwitchingAction.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/ShowingModeSwitchingAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017 THALES GLOBAL SERVICES and others. + * Copyright (c) 2017, 2018 THALES GLOBAL SERVICES and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -70,9 +70,11 @@ public class ShowingModeSwitchingAction extends DiagramAction { super(workbenchPage); setId(ActionIds.SWITCH_SHOWING_MODE); this.ddiagram = editorDiagram; - setImageDescriptor(ACTIVATE_SHOW_HIDE_MODE_IMAGE_DESCRIPTOR); - setTextAndStatusAccordingToShowingMode(); - setChecked(ddiagram.isIsInShowingMode()); + if (ddiagram != null) { + setImageDescriptor(ACTIVATE_SHOW_HIDE_MODE_IMAGE_DESCRIPTOR); + setTextAndStatusAccordingToShowingMode(); + setChecked(ddiagram.isIsInShowingMode()); + } } /** diff --git a/plugins/org.eclipse.sirius.doc/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.sirius.doc/.settings/org.eclipse.core.resources.prefs index a80cf58475..4da89a098f 100644 --- a/plugins/org.eclipse.sirius.doc/.settings/org.eclipse.core.resources.prefs +++ b/plugins/org.eclipse.sirius.doc/.settings/org.eclipse.core.resources.prefs @@ -32,3 +32,4 @@ encoding//specs/proposal/466598_improveResourceStrategy/466598.html=UTF-8 encoding//specs/proposal/491895_paste_special/491895.html=UTF-8 encoding//specs/proposal/506259_DecoratorDescription/506259_DecoratorDescription.html=UTF-8 encoding//specs/proposal/518136_RemoveBendpoints/518136_RemoveBendpoints.html=UTF-8 +encoding//specs/proposal/527109_ShowHidePinUnpin/showHidePinUnpinSpec.html=UTF-8 |
