Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Monnier2016-07-26 16:17:35 +0000
committerSteve Monnier2016-08-05 15:26:52 +0000
commit2793b25ff765a9ea089b57c4634f7662ad2c2dee (patch)
tree6d4172b5f9a44685d7bd8cc3a60a045f0d6f1e5a
parenta3720ecec68bbad8e40dc1278e91848eaef6be9c (diff)
downloadorg.eclipse.sirius-2793b25ff765a9ea089b57c4634f7662ad2c2dee.tar.gz
org.eclipse.sirius-2793b25ff765a9ea089b57c4634f7662ad2c2dee.tar.xz
org.eclipse.sirius-2793b25ff765a9ea089b57c4634f7662ad2c2dee.zip
[498508] Activate direct edit display on notes in two clicks
The performSelection() method on a SiriusNoteEditPart now also select the contained DescriptionCompartmentEditPart. This way only two clicks are needed (instead of three) to activate the direct edit display. Bug: 498508 Change-Id: Ie574fedad068fa7866b0e2d5a661f66e6299d435 Signed-off-by: Steve Monnier <steve.monnier@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/SnapToAllDragEditPartsTracker.java34
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.html1
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile1
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/condition/TextEditorAppearedCondition.java94
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DirectEditLabelTest.java67
5 files changed, 186 insertions, 11 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/SnapToAllDragEditPartsTracker.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/SnapToAllDragEditPartsTracker.java
index 245c1ea43e..5f2e741b7a 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/SnapToAllDragEditPartsTracker.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/SnapToAllDragEditPartsTracker.java
@@ -16,16 +16,26 @@ import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.SharedCursors;
+import org.eclipse.gef.editparts.AbstractEditPart;
import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DescriptionCompartmentEditPart;
import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx;
+import org.eclipse.sirius.diagram.ui.internal.edit.parts.SiriusNoteEditPart;
+import org.eclipse.sirius.diagram.ui.internal.edit.parts.SiriusTextEditPart;
import org.eclipse.sirius.ext.gmf.runtime.diagram.ui.tools.MoveInDiagramDragTracker;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.MouseEvent;
+import com.google.common.collect.Iterables;
+
/**
* A specific dragEditPartTracket that allows to change the behavior of
* SnapToShape (capability to snap to all shapes and not only brothers one).
+ * <br/>
+ * Furthermore, a specific selection is operated for generic diagram notes in
+ * order to trigger the direct edit mode with only two slow click, like any
+ * other diagram element.
*
* @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a>
*
@@ -151,4 +161,28 @@ public class SnapToAllDragEditPartsTracker extends DragEditPartsTrackerEx implem
}
return super.handleDragInProgress();
}
+
+ /**
+ * Overridden for Note selection. It will also select the contained
+ * DescriptionCompartmentEditPart. This way the direct edit mode is accessed
+ * after a slow double-click like any other diagram element.
+ */
+ @Override
+ protected void performSelection() {
+ super.performSelection();
+ EditPart sourceEditPart = getSourceEditPart();
+ if (sourceEditPart instanceof SiriusNoteEditPart || sourceEditPart instanceof SiriusTextEditPart) {
+ AbstractEditPart siriusNoteEditPart = (AbstractEditPart) sourceEditPart;
+ EditPartViewer viewer = siriusNoteEditPart.getViewer();
+ Iterable<DescriptionCompartmentEditPart> descriptionCompartmentEditPartsfilter = Iterables.filter(sourceEditPart.getChildren(), DescriptionCompartmentEditPart.class);
+ if (Iterables.size(descriptionCompartmentEditPartsfilter) == 1) {
+ DescriptionCompartmentEditPart descriptionCompartmentEditPart = Iterables.getOnlyElement(descriptionCompartmentEditPartsfilter);
+ if (getCurrentInput().isModKeyDown(SWT.MOD1) && viewer.getSelectedEditParts().contains(descriptionCompartmentEditPart)) {
+ viewer.deselect(descriptionCompartmentEditPart);
+ } else if (descriptionCompartmentEditPart.isSelectable()) {
+ viewer.appendSelection(descriptionCompartmentEditPart);
+ }
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
index 5f58196e14..92ca25f9cc 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
@@ -108,6 +108,7 @@
<li><span class="label label-info">Modified</span> In a diagram editor, the zoom with mouse wheel is now zooming on mouse location instead of center of the editor. See
<a href="./user/diagrams/Diagrams.html#zooming_diagram_id">user documentation</a> .
</li>
+ <li><span class="label label-info">Modified</span> The direct edit on a Note or Text is now accessible by a slow double click like any other diagram element.</li>
</ul>
<h3 id="SpecifierVisibleChanges">Specifier-Visible Changes</h3>
<ul>
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
index 0785276bac..43ae588045 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
@@ -13,6 +13,7 @@ h3. User-Visible Changes
If a viewpoint has been defined with a more recent version of Sirius than the one you are using, the @ViewpointRegistry@ will not register it and a warning is logged in the error log view to inform the user.
* <span class="label label-info">Modified</span> The "move edge group":./user/diagrams/Diagrams.html#move_edge_group feature now also work for a selection of edge group.
* <span class="label label-info">Modified</span> In a diagram editor, the zoom with mouse wheel is now zooming on mouse location instead of center of the editor. See "user documentation":./user/diagrams/Diagrams.html#zooming_diagram_id .
+* <span class="label label-info">Modified</span> The direct edit on a Note or Text is now accessible by a slow double click like any other diagram element.
h3. Specifier-Visible Changes
diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/condition/TextEditorAppearedCondition.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/condition/TextEditorAppearedCondition.java
new file mode 100644
index 0000000000..51597232c6
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/api/condition/TextEditorAppearedCondition.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * 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.tests.swtbot.support.api.condition;
+
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.sirius.diagram.ui.internal.edit.parts.SiriusNoteEditPart;
+import org.eclipse.sirius.diagram.ui.internal.edit.parts.SiriusTextEditPart;
+import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.waits.ICondition;
+
+/**
+ * An {@link org.eclipse.swtbot.swt.finder.waits.ICondition} to wait that the
+ * text editor appears (for a direct edit for example).
+ *
+ * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a>
+ */
+public class TextEditorAppearedCondition implements ICondition {
+
+ /**
+ * Current editor.
+ */
+ private SWTBotSiriusDiagramEditor editor;
+
+ /**
+ * The class of the edit part to wait for its direct edition.
+ */
+ private Class<? extends IGraphicalEditPart> editPartClass;
+
+ /**
+ * The precondition of direct edit (if any).
+ */
+ private String precondition;
+
+ /**
+ * The error message computed during test() method calls.
+ */
+ private String errorMessage;
+
+ /**
+ * Constructor.
+ *
+ * @param editor
+ * the current editor.
+ * @param editPartClass
+ * edit part class to wait for direct edit.
+ * @param precondition
+ * the precondition of direct edit (if any)
+ */
+ public TextEditorAppearedCondition(SWTBotSiriusDiagramEditor editor, Class<? extends IGraphicalEditPart> editPartClass, String precondition) {
+ this.editor = editor;
+ this.editPartClass = editPartClass;
+ this.precondition = precondition;
+ }
+
+ @Override
+ public boolean test() throws Exception {
+ boolean result = false;
+ try {
+ editor.bot().text();
+ result = true;
+ } catch (WidgetNotFoundException e) {
+ if (editPartClass.equals(SiriusNoteEditPart.class) || editPartClass.equals(SiriusTextEditPart.class)) {
+ errorMessage = "The selected element is expected to be in direct edit mode but was not: " + e.getMessage();
+ } else {
+ if (!("[false/]".equals(precondition))) {
+ errorMessage = "The direct edit mode is not accessible while there is no precondition.";
+ } else {
+ result = true;
+ }
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return errorMessage;
+ }
+
+}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DirectEditLabelTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DirectEditLabelTest.java
index daaef52a11..a013497b73 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DirectEditLabelTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DirectEditLabelTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2014 THALES GLOBAL SERVICES.
+ * Copyright (c) 2010, 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
@@ -16,6 +16,7 @@ import java.util.List;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.description.ContainerMapping;
import org.eclipse.sirius.diagram.description.DiagramDescription;
@@ -23,8 +24,12 @@ import org.eclipse.sirius.diagram.description.tool.DirectEditLabel;
import org.eclipse.sirius.diagram.description.tool.ToolFactory;
import org.eclipse.sirius.diagram.description.tool.ToolSection;
import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramContainerEditPart;
+import org.eclipse.sirius.diagram.ui.internal.edit.parts.SiriusNoteEditPart;
+import org.eclipse.sirius.diagram.ui.internal.edit.parts.SiriusTextEditPart;
import org.eclipse.sirius.tests.swtbot.support.api.AbstractSiriusSwtBotGefTestCase;
import org.eclipse.sirius.tests.swtbot.support.api.business.UIResource;
+import org.eclipse.sirius.tests.swtbot.support.api.condition.CheckSelectedCondition;
+import org.eclipse.sirius.tests.swtbot.support.api.condition.TextEditorAppearedCondition;
import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils;
import org.eclipse.sirius.viewpoint.description.Group;
import org.eclipse.sirius.viewpoint.description.tool.InitialOperation;
@@ -124,19 +129,58 @@ public class DirectEditLabelTest extends AbstractSiriusSwtBotGefTestCase {
checkDirectEditLabel(precondition);
}
+ /**
+ * Tests that the direct edit on a Note requires only two clicks.
+ *
+ * @throws Exception
+ * thrown to fail
+ */
+ public void testDirectEditOnNote() throws Exception {
+ if (!System.getProperty("os.name").equals("Linux")) {
+ editor.activateTool("Note");
+ editor.click(100, 100);
+ editor.directEditType("Note Label");
+
+ editor.click(CLASS_NAME, AbstractDiagramContainerEditPart.class);
+ SWTBotUtils.waitAllUiEvents();
+
+ checkDirectEditLabel(null, "Note Label", SiriusNoteEditPart.class);
+ }
+ }
+
+ /**
+ * Tests that the direct edit on a Note requires only two clicks.
+ *
+ * @throws Exception
+ * thrown to fail
+ */
+ public void testDirectEditOnText() throws Exception {
+ if (!System.getProperty("os.name").equals("Linux")) {
+ editor.activateTool("Text");
+ editor.click(100, 100);
+ editor.directEditType("Text Label");
+
+ editor.click(CLASS_NAME, AbstractDiagramContainerEditPart.class);
+ SWTBotUtils.waitAllUiEvents();
+
+ checkDirectEditLabel(null, "Text Label", SiriusTextEditPart.class);
+ }
+ }
+
private void checkDirectEditLabel(String precondition) {
+ checkDirectEditLabel(precondition, CLASS_NAME, AbstractDiagramContainerEditPart.class);
+ }
+
+ private void checkDirectEditLabel(String precondition, final String editPartlabel, Class<? extends IGraphicalEditPart> editPartClass) {
// Click a first time on the edit part to select it.
- editor.click(CLASS_NAME, AbstractDiagramContainerEditPart.class);
+ editor.click(editPartlabel, editPartClass);
SWTBotUtils.waitAllUiEvents();
+ bot.waitUntil(new CheckSelectedCondition(editor, editPartlabel, editPartClass));
// Click a second time on the edit part to enable the direct edit mode.
- editor.clickCentered(CLASS_NAME, AbstractDiagramContainerEditPart.class);
- SWTBotUtils.waitAllUiEvents();
+ editor.clickCentered(editPartlabel, editPartClass);
- /* wait until text widget appears */
- try {
- editor.bot().text();
- } catch (Exception e) {
- assertTrue("The direct edit mode is not accessible while there is no precondition.", "[false/]".equals(precondition));
+ bot.waitUntil(new TextEditorAppearedCondition(editor, editPartClass, precondition), 3000);
+ if ("[false/]".equals(precondition)) {
return;
}
/* Find the text widget and check its label now. */
@@ -144,8 +188,9 @@ public class DirectEditLabelTest extends AbstractSiriusSwtBotGefTestCase {
if (controls.size() == 1) {
final Text textControl = controls.get(0);
UIThreadRunnable.syncExec(new VoidResult() {
+ @Override
public void run() {
- assertEquals(CLASS_NAME, textControl.getText());
+ assertEquals(editPartlabel, textControl.getText());
}
});
} else {
@@ -154,7 +199,7 @@ public class DirectEditLabelTest extends AbstractSiriusSwtBotGefTestCase {
// Edit the current edit part by adding a suffix to its current name.
editor.directEditType("newLabel");
// Check that an editPart exists with the expected new name.
- editor.getEditPart("newLabel", AbstractDiagramContainerEditPart.class);
+ editor.getEditPart("newLabel", editPartClass);
}
private void addDirectEditToolToVSM(DiagramDescription diagramDescription, String precondition) throws Exception {

Back to the top