diff options
| author | Laurent Redor | 2016-08-12 10:57:24 +0000 |
|---|---|---|
| committer | Laurent Redor | 2016-08-12 15:30:06 +0000 |
| commit | adcb5e2ff8100c1f1acfcf1d7aeb25a2222e31d5 (patch) | |
| tree | 429e6c3c6ea90f0e8a7a1b31566881c1b66bf761 | |
| parent | 655aa41eb75a1082c8a9424a01fc932718559de5 (diff) | |
| download | org.eclipse.sirius-adcb5e2ff8100c1f1acfcf1d7aeb25a2222e31d5.tar.gz org.eclipse.sirius-adcb5e2ff8100c1f1acfcf1d7aeb25a2222e31d5.tar.xz org.eclipse.sirius-adcb5e2ff8100c1f1acfcf1d7aeb25a2222e31d5.zip | |
[498508] Activate direct edit display on notes in 2 clicks - 2nd round
This commit provides another approach than commit [1].
SiriusDescriptionCompartmentEditPart overrides the classical
DescriptionCompartmentEditPart to delegate the second selection to its
parent (Note and Text) and then the SiriusNoteEditPart (or
SiriusTextEditPart) delegates the direct edit to
SiriusDescriptionCompartmentEditPart.
[1]
http://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=2793b25ff765a9ea089b57c4634f7662ad2c2dee
Bug: 498508
Change-Id: I7eef120aee0dc721e83560120d9285889cbfc23c
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
4 files changed, 86 insertions, 3 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusDescriptionCompartmentEditPart.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusDescriptionCompartmentEditPart.java new file mode 100644 index 0000000000..b794ef4b2b --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusDescriptionCompartmentEditPart.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2016 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.diagram.ui.internal.edit.parts; + +import org.eclipse.gef.DragTracker; +import org.eclipse.gef.Request; +import org.eclipse.gmf.runtime.diagram.ui.editparts.DescriptionCompartmentEditPart; +import org.eclipse.gmf.runtime.notation.View; + +/** + * A specific DescriptionCompartmentEditPart to continue the selection with its + * parents. This allows to handle the direct edit (slow double click) directly + * on Note and Text.. + * + * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> + */ +public class SiriusDescriptionCompartmentEditPart extends DescriptionCompartmentEditPart { + + /** + * Constructor + * + * @param view + * the view controlled by this edit part + */ + public SiriusDescriptionCompartmentEditPart(View view) { + super(view); + } + + /* Send the request to the parent (Note or Text). */ + @Override + public DragTracker getDragTracker(Request request) { + return getParent().getDragTracker(request); + } +} diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusEditPartFactory.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusEditPartFactory.java index 6815e4b4f9..f58d5638ae 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusEditPartFactory.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusEditPartFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES. + * Copyright (c) 2007, 2016 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 @@ -18,6 +18,7 @@ import org.eclipse.gef.EditPart; import org.eclipse.gef.EditPartFactory; import org.eclipse.gef.GraphicalEditPart; import org.eclipse.gef.tools.CellEditorLocator; +import org.eclipse.gmf.runtime.common.ui.services.parser.CommonParserHint; import org.eclipse.gmf.runtime.diagram.core.util.ViewType; import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; @@ -152,6 +153,8 @@ public class SiriusEditPartFactory implements EditPartFactory { return new SiriusNoteEditPart(view); } else if (ViewType.TEXT.equals(view.getType())) { return new SiriusTextEditPart(view); + } else if (CommonParserHint.DESCRIPTION.equals(view.getType())) { + return new SiriusDescriptionCompartmentEditPart(view); } } } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusNoteEditPart.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusNoteEditPart.java index 1a9e21ba6c..eb83e27579 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusNoteEditPart.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusNoteEditPart.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 THALES GLOBAL SERVICES. + * Copyright (c) 2015, 2016 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 @@ -12,10 +12,13 @@ package org.eclipse.sirius.diagram.ui.internal.edit.parts; import org.eclipse.gef.DragTracker; import org.eclipse.gef.Request; +import org.eclipse.gmf.runtime.diagram.ui.editparts.DescriptionCompartmentEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.NoteEditPart; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.sirius.diagram.ui.tools.internal.ui.SnapToAllDragEditPartsTracker; +import com.google.common.collect.Iterables; + /** * A specific NoteEditPart to handle the snapToAllShapes. * @@ -37,4 +40,20 @@ public class SiriusNoteEditPart extends NoteEditPart { public DragTracker getDragTracker(Request request) { return new SnapToAllDragEditPartsTracker(this); } + + /** + * Redirect the direct edit request to the + * {@link DescriptionCompartmentEditPart}. + * + * @param request + * the direct edit request + */ + @Override + protected void performDirectEditRequest(Request request) { + Iterable<DescriptionCompartmentEditPart> descriptionCompartmentEditPartsfilter = Iterables.filter(this.getChildren(), DescriptionCompartmentEditPart.class); + if (Iterables.size(descriptionCompartmentEditPartsfilter) == 1) { + DescriptionCompartmentEditPart descriptionCompartmentEditPart = Iterables.getOnlyElement(descriptionCompartmentEditPartsfilter); + descriptionCompartmentEditPart.performRequest(request); + } + } } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusTextEditPart.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusTextEditPart.java index 95bb3a50c1..3e4048ff22 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusTextEditPart.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/SiriusTextEditPart.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 THALES GLOBAL SERVICES. + * Copyright (c) 2015, 2016 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 @@ -12,10 +12,13 @@ package org.eclipse.sirius.diagram.ui.internal.edit.parts; import org.eclipse.gef.DragTracker; import org.eclipse.gef.Request; +import org.eclipse.gmf.runtime.diagram.ui.editparts.DescriptionCompartmentEditPart; import org.eclipse.gmf.runtime.diagram.ui.internal.editparts.TextEditPart; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.sirius.diagram.ui.tools.internal.ui.SnapToAllDragEditPartsTracker; +import com.google.common.collect.Iterables; + /** * A specific TextEditPart to handle the snapToAllShapes. * @@ -37,4 +40,20 @@ public class SiriusTextEditPart extends TextEditPart { public DragTracker getDragTracker(Request request) { return new SnapToAllDragEditPartsTracker(this); } + + /** + * Redirect the direct edit request to the + * {@link DescriptionCompartmentEditPart}. + * + * @param request + * the direct edit request + */ + @Override + protected void performDirectEditRequest(Request request) { + Iterable<DescriptionCompartmentEditPart> descriptionCompartmentEditPartsfilter = Iterables.filter(this.getChildren(), DescriptionCompartmentEditPart.class); + if (Iterables.size(descriptionCompartmentEditPartsfilter) == 1) { + DescriptionCompartmentEditPart descriptionCompartmentEditPart = Iterables.getOnlyElement(descriptionCompartmentEditPartsfilter); + descriptionCompartmentEditPart.performRequest(request); + } + } } |
