Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2015-02-24 17:45:21 +0000
committerChristian W. Damus2015-03-25 12:43:24 +0000
commit076626232757a6cc017b64d4d9d9d3cbe31906a1 (patch)
tree4d6410896a66ad939b0fd3ab90705d1ec5a7772c /tests/junit/plugins/junit
parent424a1bc00a5f57be8b3ea59165333fa0db45ba71 (diff)
downloadorg.eclipse.papyrus-076626232757a6cc017b64d4d9d9d3cbe31906a1.tar.gz
org.eclipse.papyrus-076626232757a6cc017b64d4d9d9d3cbe31906a1.tar.xz
org.eclipse.papyrus-076626232757a6cc017b64d4d9d9d3cbe31906a1.zip
Bug 433206: Papyrus shall enable local synchronization between graphical element and element in the model
https://bugs.eclipse.org/bugs/show_bug.cgi?id=433206 (1) Refactor the 'uml.diagram.synchronizeview' plug-in: * remove the UML dependency (supplied by a UML-specific default children strategy) * move into infra.gmfdiag component * rename for GMF-standard 'canonical' terminology * API types, extension points, etc. renamed for 'canonical' terminology * fix parsing of priorities and other problems in the extension-point loading * support listening to multiple dependent model elements for canonical refresh * add a notion of default semantic children strategies for edit-parts that don't have specific requirements but can rely on a generic implementation (2) Implement a canonical request wrapper to pass through the drop request to default drop edit policy provided by the diagram, by-passing the pluggable strategies to which the CustomizableDopEditPolicy delegates. (3) Implement a toggle action in the various diagram filter menus to toggle canonical synchronization. (4) Enable the canonical edit policy provider. This requires additional changes: * only activate the canonical edit policy when the style is applied and is enabled because otherwise GMF assumes that canonical mode is on and treats connections as canonical (GMF run-time only checks that the edit policy is installed and is active) * listen for changes to the canonical style to disable/enable the canonical edit policy on the fly (5) Fix undo/redo of canonical view creation and of canonical enablement. (6) Properties view support for model/view synchronization (canonical edit policy). (7) Adapt SysML test utility to account for possible inclusion of ToggleCanonicalModeCommand by GMF in drop commands. (8) Implement deferred loading of synch child strategies and XML enablement expressions. (9) Fix problems in handling of connections incoming and outgoing canonical top shapes. (10) Support for a CSS 'canonical' style attribute. (11) Initial simple canonical synchronization scenarios for JUnit test cases. (12) Integrate canonical edit policy tests into the build. (13) Test cases for toggling canonical on/off, with undo/redo. Test cases for adding elements to the semantic model, with undo/redo. Test cases for deleting elements from the semantic model (including by simple remove, which unlike destroy does not also deletes dependent views anyways), with undo/redo. (14) Add regression tests for creation/deletion of elements and views together per the usual diagram editing scenarios, in the context of canonical diagrams. (15) Fix problems in canonical creation (with undo and redo) of connection views for non-owned relationship elements. (16) Add tests for CSS control of canonical synchronization. Fix inability to override CSS canonical style to turn synchronization off on selected views. Bug 461629: [CSS] Diagram refresh undo/redo problems https://bugs.eclipse.org/bugs/show_bug.cgi?id=461629 Implement new DiagramHelper refresh APIs to fix a few problems: - encapsulate synchronous (forced) and asynchronous refresh in new API methods. Deprecate the old methods that required clients to follow several steps. Update various client call sites to use the new API instead of the deprecated API - add corresponding APIs for refresh of individual DiagramEditParts, with similar heuristic for dropping redundant refresh requests - re-implement asynchronous refresh to use a new TransactionalEditingDomain executor that runs tasks as pre-commit trigger commands, to capture any undo/redo information for model changes - implement a new transaction option in the Papyrus editing domain that prevents runExclusive calls creating read-only transactions nested within a write transaction, so that canonical changes ensuing from edit-part refresh during refresh tasks can be properly recorded (without unprotected writes nested in the read-only context) Bug 433206: Papyrus shall enable local synchronization between graphical element and element in the model https://bugs.eclipse.org/bugs/show_bug.cgi?id=433206 (17) Enable test cases unblocked by the fix for undo/redo problems in diagram refresh (being bug 461629). (18) Do not record the edit-part but the view in the SetCanonicalCommand to support undo/redo even if the diagram has been closed and re-opened in the mean-time. To refresh the CanonicalEditPolicy's activation state after execute/undo/redo, the command now searches on the fly for all edit-parts (in all open diagram editors) that present the view in question. (19) Implement a new 'semi-active' state in the PapyrusCanonicalEditPolicy that is its minimally active state. This allows the edit policy to react to semantic model changes to delete views for deleted model elements, where such views are ones that it had originally created by canonical refresh. This relies on new tracking of canonically- created views, which in turn relies on a new utility for digging through complex command tree structures to get the views that were created by them. Includes automated tests for non-transactional refresh creating canonical views, with undo and redo in the semantic model undoing and redoing creationg of the elements that had been canonically created, after the canonical edit policy was (non-transactionally) disabled. (20) Don't forget about views that were created canonically if the diagram happens to be closed and then re-opened. (21) Rework the CanonicalStateListener to support injection of refresh 'pokes' to trigger updates in other dependents, such as the Properties view, when change in canonical activation is detected for any reason. (22) New JUnit tests for: - undo of semantic model change that created a canonical view after canonical edit policy disabled by CSS and close/reopen of the diagram - canonical edit policy's book-keeping does not leak diagram views nor model elements (23) CanonicalStateListener should be auto-retained because it automatically installs itself, and it won't be uninstalled except when successfully released. (24) Fix layout (margins etc.) of Synchronization properties group. (25) Fix concurrent modification in iteration over diagram edit part tree. Rationalize state-transition logic in canonical edit policy. (26) Fix some problems in canonical composite structures (incomplete): - manage connections canonically on border items as well as top shapes - do not include connectors as semantic children of structured classifiers but only as connections/edges of their connected elements - do not create parts of Association type when dropping an Association onto a structured classifier - include notation context in children-strategy query to account for structures such as part-with-port in connectors to disambiguate repeated semantic elements - add canonical composite structure tests (one still failing) (27) Refactor the canonical children strategies extension point ID to make it more meaningful and less redundant. Shave some execution time off the execution of the canonical edit policy tests in the automated build environment where we don't need to see what is happening in the diagrams. This involves a refactoring of earlier infrastructure that detects the build server or local Maven/Tycho build environment. (28) Fix failure to create canonical connection views because source/target nodes that were created canonically don't yet have their edit-parts. The canonical creation of connections is now deferred using the transaction pre-commit executor, exposed as a new DiagramHelper::submit(...) API. Several JUnit tests need updating, both to correct erroneous assumptions on latent bugs now fixed, and also to add UI event-processing in undo/redo scenarios to account for deferred connection creation. Use a DeferredLayoutCommand to improve the layout of the contents added to shape compartments by canonical 'drop', which otherwise would all be stacked on top of one another. Add a new pluggable strategy for determination of the edit-part that should handle creation of views, for cases such as flows in activities where connections must be dropped into contents compartments, not onto either the source or target node shape. (29) Fix canonical presentation of activity flows on pins. Implement basics of canonical synchronization of state machine diagrams. (30) Communication diagram synchronization of messages between lifelines. Requires a new extension interface for pluggable view-children strategies, to complement the semantic-children strategies, because the views that need to be synchronized are labels of connected edges, not the edges themselves. The semantic-children strategy interface is refactored to align with the new visual-children strategy interface, and likewise the determination of existing semantic and visual children in the PapyrusCanonicalEditPolicy. This also removes redundant re-calculation on semantic node children in the second-phase processing of connections. (31) Fix exceptions in synchronization and layout of communication diagrams. Fix regression in canonical deletion of edges. (32) Fix spurious deactivation of canonical edit policy in edit-parts that had had canonical mode (refresh enablement) toggled during execution of some user command. Change-Id: I9c39f74638cb55455e2d8bc42b07e49501ec3ea7
Diffstat (limited to 'tests/junit/plugins/junit')
-rw-r--r--tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/Activator.java34
-rw-r--r--tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/JUnitUtils.java12
-rw-r--r--tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ActiveDiagram.java33
-rw-r--r--tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java91
4 files changed, 157 insertions, 13 deletions
diff --git a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/Activator.java b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/Activator.java
index 703f0b176b3..c51d331687a 100644
--- a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/Activator.java
+++ b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/Activator.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
+ * Copyright (c) 2012, 2015 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 433206
*
*****************************************************************************/
package org.eclipse.papyrus.junit.utils;
@@ -16,6 +17,8 @@ package org.eclipse.papyrus.junit.utils;
import org.eclipse.papyrus.infra.core.log.LogHelper;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.application.ApplicationHandle;
/**
* The activator class controls the plug-in life cycle
@@ -30,29 +33,34 @@ public class Activator extends AbstractUIPlugin {
public static LogHelper log;
+ private String runningApplicationID;
+
/**
* The constructor
*/
public Activator() {
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
log = new LogHelper(this);
+
+ // Get the running application ID
+ ServiceReference<ApplicationHandle> appRef = context.getServiceReference(ApplicationHandle.class);
+ if (appRef != null) {
+ ApplicationHandle appHandle = context.getService(appRef);
+ if (appHandle != null) {
+ try {
+ runningApplicationID = appHandle.getApplicationDescriptor().getApplicationId();
+ } finally {
+ context.ungetService(appRef);
+ }
+ }
+ }
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
@@ -68,4 +76,8 @@ public class Activator extends AbstractUIPlugin {
return plugin;
}
+ public String getRunningApplicationID() {
+ return (runningApplicationID == null) ? "" : runningApplicationID; //$NON-NLS-1$
+ }
+
}
diff --git a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/JUnitUtils.java b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/JUnitUtils.java
index 17bfadc190c..0982ea9fc29 100644
--- a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/JUnitUtils.java
+++ b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/JUnitUtils.java
@@ -19,7 +19,7 @@ import org.junit.rules.TestRule;
import org.junit.runner.Description;
/**
- * Utilities for working with the JUnit data model.
+ * Utilities for working with the JUnit data model and execution environment.
*/
public class JUnitUtils {
@@ -113,4 +113,14 @@ public class JUnitUtils {
return result;
}
+
+ /**
+ * Queries whether the current JUnit test execution is running in the automated build environment
+ * (whether actually on the build server or not; users can run local builds on their development systems, too).
+ *
+ * @return whether the tests are running in the automated build environment
+ */
+ public static boolean isAutomatedBuildExecution() {
+ return Activator.getDefault().getRunningApplicationID().startsWith("org.eclipse.tycho."); //$NON-NLS-1$
+ }
}
diff --git a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ActiveDiagram.java b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ActiveDiagram.java
new file mode 100644
index 00000000000..5ae3344d156
--- /dev/null
+++ b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ActiveDiagram.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2015 Christian W. Damus 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.junit.utils.rules;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Annotation on a test indicating the diagram to activate.
+ *
+ * @see PapyrusEditorFixture
+ */
+@Target({ ElementType.METHOD, ElementType.TYPE })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ActiveDiagram {
+ /**
+ * The name of the diagram to activate.
+ */
+ String value();
+}
diff --git a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java
index 959005b38de..fbc377f5de2 100644
--- a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java
+++ b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 CEA and others.
+ * Copyright (c) 2014, 2015 CEA, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Christian W. Damus (CEA) - Initial API and implementation
+ * Christian W. Damus - bug 433206
*
*/
package org.eclipse.papyrus.junit.utils.rules;
@@ -41,11 +42,15 @@ import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.RootEditPart;
import org.eclipse.gef.ui.palette.PaletteViewer;
+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IDiagramPreferenceSupport;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFlyOutPalette;
import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
+import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.editor.PapyrusMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
@@ -59,7 +64,10 @@ import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.core.utils.AdapterUtils;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel;
import org.eclipse.papyrus.junit.utils.EditorUtils;
+import org.eclipse.papyrus.junit.utils.JUnitUtils;
import org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest;
import org.eclipse.papyrus.uml.tools.model.UmlModel;
import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPage;
@@ -146,6 +154,16 @@ public class PapyrusEditorFixture extends AbstractModelFixture<TransactionalEdit
openAll(description);
+ ActiveDiagram activeDiagram = JUnitUtils.getAnnotation(description, ActiveDiagram.class);
+ if (activeDiagram != null) {
+ String name = activeDiagram.value();
+ activateDiagram(name);
+ if ((activeDiagramEditor == null) || !name.equals(getActiveDiagramEditor().getDiagram().getName())) {
+ // OK, we need to open it, then
+ openDiagram(name);
+ }
+ }
+
super.starting(description);
}
@@ -218,6 +236,7 @@ public class PapyrusEditorFixture extends AbstractModelFixture<TransactionalEdit
Display.getDefault().syncExec(new Runnable() {
+ @Override
public void run() {
try {
editor = EditorUtils.openPapyrusEditor(modelFile);
@@ -233,6 +252,7 @@ public class PapyrusEditorFixture extends AbstractModelFixture<TransactionalEdit
final IWorkbenchPage page = editor.getSite().getPage();
page.addPartListener(new IPartListener() {
+ @Override
public void partClosed(IWorkbenchPart part) {
editorsToClose.remove(part);
@@ -245,18 +265,22 @@ public class PapyrusEditorFixture extends AbstractModelFixture<TransactionalEdit
}
}
+ @Override
public void partOpened(IWorkbenchPart part) {
// Pass
}
+ @Override
public void partDeactivated(IWorkbenchPart part) {
// Pass
}
+ @Override
public void partBroughtToTop(IWorkbenchPart part) {
// Pass
}
+ @Override
public void partActivated(IWorkbenchPart part) {
// Pass
}
@@ -332,6 +356,7 @@ public class PapyrusEditorFixture extends AbstractModelFixture<TransactionalEdit
Display.getDefault().syncExec(new Runnable() {
+ @Override
public void run() {
ModelExplorerPageBookView view;
try {
@@ -426,6 +451,7 @@ public class PapyrusEditorFixture extends AbstractModelFixture<TransactionalEdit
sashContainer.visit(new IPageVisitor() {
+ @Override
public void accept(IEditorPage page) {
if (name.equals(page.getPageTitle()) && (page.getIEditorPart() instanceof DiagramEditorWithFlyOutPalette)) {
select[0] = page;
@@ -433,6 +459,7 @@ public class PapyrusEditorFixture extends AbstractModelFixture<TransactionalEdit
}
}
+ @Override
public void accept(IComponentPage page) {
// Pass
}
@@ -446,6 +473,54 @@ public class PapyrusEditorFixture extends AbstractModelFixture<TransactionalEdit
return this;
}
+ public PapyrusEditorFixture openDiagram(String name) {
+ return openDiagram(editor, name);
+ }
+
+ public PapyrusEditorFixture openDiagram(IMultiDiagramEditor editor, final String name) {
+ activate(editor);
+
+ try {
+ ModelSet modelSet = ServiceUtils.getInstance().getModelSet(editor.getServicesRegistry());
+ NotationModel notation = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID);
+ Diagram diagram = notation.getDiagram(name);
+ ServiceUtils.getInstance().getIPageManager(editor.getServicesRegistry()).openPage(diagram);
+ flushDisplayEvents();
+ } catch (Exception e) {
+ throw new IllegalStateException("Cannot initialize test", e);
+ }
+
+ return this;
+ }
+
+ public String closeDiagram() {
+ String result = getActiveDiagramEditor().getDiagram().getName();
+ closeDiagram(editor, result);
+ return result;
+ }
+
+ public PapyrusEditorFixture closeDiagram(String name) {
+ return closeDiagram(editor, name);
+ }
+
+ public PapyrusEditorFixture closeDiagram(IMultiDiagramEditor editor, final String name) {
+ try {
+ ModelSet modelSet = ServiceUtils.getInstance().getModelSet(editor.getServicesRegistry());
+ NotationModel notation = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID);
+ Diagram diagram = notation.getDiagram(name);
+
+ // If the diagram was deleted, then so too was its page
+ if (diagram != null) {
+ ServiceUtils.getInstance().getIPageManager(editor.getServicesRegistry()).closePage(diagram);
+ flushDisplayEvents();
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException("Cannot close diagram", e);
+ }
+
+ return this;
+ }
+
public DiagramEditorWithFlyOutPalette getActiveDiagramEditor() {
DiagramEditorWithFlyOutPalette result = activeDiagramEditor;
@@ -821,4 +896,18 @@ public class PapyrusEditorFixture extends AbstractModelFixture<TransactionalEdit
return ((location != null) ? location : (relativeTo == null) ? DEFAULT_LOCATION_EDITORS : DEFAULT_LOCATION_VIEW).toModelServiceLocation();
}
}
+
+ public PreferencesHint getPreferencesHint() {
+ PreferencesHint result = PreferencesHint.USE_DEFAULTS;
+
+ if (activeDiagramEditor != null) {
+ RootEditPart rootEditPart = activeDiagramEditor.getDiagramGraphicalViewer().getRootEditPart();
+ if (rootEditPart instanceof IDiagramPreferenceSupport) {
+ result = ((IDiagramPreferenceSupport) rootEditPart).getPreferencesHint();
+ }
+ }
+
+ return result;
+ }
+
}

Back to the top