Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2015-12-04 13:52:01 +0000
committerChristian W. Damus2015-12-08 13:58:31 +0000
commit49bd194639354cde35b15717e4ead156f4613754 (patch)
tree2f3b4a83815186201eb39fbcb058d07d8880f6d4 /plugins/infra/emf
parented54bfa4c258ade68f0c9a4eb1263bb8aa37a92e (diff)
downloadorg.eclipse.papyrus-49bd194639354cde35b15717e4ead156f4613754.tar.gz
org.eclipse.papyrus-49bd194639354cde35b15717e4ead156f4613754.tar.xz
org.eclipse.papyrus-49bd194639354cde35b15717e4ead156f4613754.zip
Bug 469188: [Editor] Page management improvements in the Papyrus multi-editor
https://bugs.eclipse.org/bugs/show_bug.cgi?id=469188 This is a squashed commit comprising all of the changes on the committers/cdamus/469188-editor-welcome branch for the introduction of a Welcome Page in the Papyrus Editor. commit 51d64a198c2069b208b5231212a5514441514c54 Implement drag-and-drop rearrangement of the sections in the simple grid-wise layout of the Welcome Page. Persist the user's customization in the sash/di resource with the sash model, using new classes in the Welcome package. commit b59f057cf1e08b51942aac1f45226a304c48039e Fix enablement condition for Show Welcome Page action which has been broken since the page was changed from an editor to a plain composite. commit 69cee20b44c699c6a078e66bf9b16a83c1de7315 Remove the databinding properties APIs for Forms widgets that are no longer needed since the NatTable refactoring of the Diagrams table in the welcome page. commit 00cfdd106421c0b1366c2a7deade819b4a3041ef Add table of languages to the General section in the welcome page. Add section of hyperlinks to related views to the welcome page. Implement ordering of the contents of the welcome page according to tab 'afterTab' relationships and priorities. Overall the layout is still two rows with a variable number of columns. commit a7d739b8e03bea5d4cf5e4d0d3663adbc62f5018 Let the SashModel report to listeners when its storage mode changes so that the two different UI presentations of that mode can remain up-to- date at all times. commit 7fc4f8bf1f0fcee31f84b976e29cd7b3848ec47d Ensure that new models initially track the active page of each tab folder because they store their layout privately by default. commit 6d5dbf27a4428645655bcf6ff9a99d4a3c77dcb8 Implement optional tracking of the active page in the private sash model and switching between private and shared storage of the layout. Includes: * enhancement of the Sash DI model to include a currently selected page for each tab folder and a boolean flag whether to restore the last selection in each tab folder * a new editor lifecycle event for "pre display" to provide a hook to set up the page activation before the SWT controls are rendered, so that the editor doesn't open up and then change page selections while the user watches * expose the SaveLayoutBeforeClose behaviour for re-use when changing layout options in the welcome page * update enablement from editable-ness for Properties widgets that force refresh commit 97897b3d0d295a71a7173a584ceda3ac24c5c6ea Factor out some more common bits into core plug-ins (e.g., the IsWelcomeElement constraint in the properties environment). Create the list of tables in the welcome page. This requires some renaming of properties model content in the diagrams list for disambiguation. commit f73fe34e87c915cc603ec12c608c020406ea7d73 Refactor the Diagrams table as a reusable NatTable of hyperlinks. commit a6308f25a8c6e6c129174e9c418cb90e6f025e16 Move the column headers of the diagrams table out into a separate composite that does not scroll vertically with the table of hyperlinks (though it does track the table's horizontal scroll position). commit 0425bf34630e4420db3674fa8d4641820a305478 Add a separate preference page for Welcome Page Content. This depends on a new extension in the context registry for association of contexts with preferences pages (by default, associating legacy contexts with the Properties View preference page). commit 06719c107a3f323be53ca6ada4f820f2d4ef10cb Rework the contribution of welcome-page content to: * eliminate the custom extension point for section providers * use the Properties View framework to obtain welcome-page sections for the Welcome model element Update the Diagrams table provider as a property section for the Welcome model. This involves implementation of a custom table-of- hyperlinks widget. Several reusable data-bindings classes are added to the appropriate Papyrus infra-layer bundles. commit 4069f62cc89413b8739cc6c33211ac5a11942bc4 Welcome page content for diagrams. commit 8599ee6bdf7b2c7423811fee3e2441a618621ce4 The Welcome Page doesn't need to be an editor, just a composite. So, let any page part (including simple composites) be optionally closeable and change the WelcomePage into a simple composite part instead of a nested workbench editor-part. commit 83b581ea9aadb5b852b36b2fa0524ca7df60b255 Initial definition of an extension point for welcome section providers. commit f949eaf6cf131449f4584b71072033b22cd1cea2 Initial implementation of a (so far, empty) Welcome page that is always open when no other Papyrus editor pages are open. Change-Id: I351118dc0b6a0dea505719a8c62ef430c273c7cf
Diffstat (limited to 'plugins/infra/emf')
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java104
1 files changed, 76 insertions, 28 deletions
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
index 5642e88a547..3fedf630c3f 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010, 2014 CEA LIST and others.
+ * Copyright (c) 2010, 2015 CEA LIST, 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
@@ -15,6 +15,7 @@
* Christian W. Damus (CEA) - bug 408491
* Christian W. Damus (CEA) - bug 432813
* Christian W. Damus (CEA) - bug 422257
+ * Christian W. Damus - bug 469188
*
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.utils;
@@ -80,7 +81,7 @@ public class EMFHelper {
* @param className
* The EClass' name
* @return
- * The EClass instance, or null if the EClass couldn't be found
+ * The EClass instance, or null if the EClass couldn't be found
*/
public static EClass getEClass(final String nsUri, final String className) {
EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(nsUri);
@@ -99,7 +100,7 @@ public class EMFHelper {
* @param className
* The EClass' name
* @return
- * The EClass instance, or null if the EClass couldn't be found
+ * The EClass instance, or null if the EClass couldn't be found
*/
public static EClass getEClass(final EPackage metamodel, final String className) {
EClassifier classifier = metamodel.getEClassifier(className);
@@ -125,7 +126,7 @@ public class EMFHelper {
* @param metamodel
* The EPackage owning the EClass
* @return
- * True if the EObject is an instance of the EClass, or of one of the EClass' subtypes
+ * True if the EObject is an instance of the EClass, or of one of the EClass' subtypes
*/
public static boolean isInstance(final EObject element, final String className, final EPackage metamodel) {
@@ -151,7 +152,7 @@ public class EMFHelper {
* @param metamodel
* The URI of the EPackage owning the EClass
* @return
- * True if the EObject is an instance of the EClass, or of one of the EClass' subtypes
+ * True if the EObject is an instance of the EClass, or of one of the EClass' subtypes
*/
public static boolean isInstance(EObject selectedItem, String className, String nsUri) {
EClass actualEClass = selectedItem.eClass();
@@ -180,7 +181,7 @@ public class EMFHelper {
*
* @param nsUri
* @return
- * True if the EClass' name is className and the EClass' EPackage's nsURI is nsUri
+ * True if the EClass' name is className and the EClass' EPackage's nsURI is nsUri
*/
private static boolean isExactMatch(EClass eClass, String className, String nsUri) {
return className.equals(eClass.getName()) && nsUri.equals(eClass.getEPackage().getNsURI());
@@ -193,7 +194,7 @@ public class EMFHelper {
* @param eClass
* @param fromClass
* @return
- * true if eClass is a subclass of fromClass
+ * true if eClass is a subclass of fromClass
*/
public static boolean isSubclass(final EClass eClass, final EClass fromClass) {
// Everything is an EObject
@@ -287,7 +288,7 @@ public class EMFHelper {
*
* @param source
* @return
- * The source object's editing domain, or null if it couldn't be found
+ * The source object's editing domain, or null if it couldn't be found
*/
public static EditingDomain resolveEditingDomain(final Object source) {
return resolveEditingDomain(getEObject(source));
@@ -298,7 +299,7 @@ public class EMFHelper {
*
* @param source
* @return
- * The source eObject's editing domain, or null if it couldn't be found
+ * The source eObject's editing domain, or null if it couldn't be found
*/
public static EditingDomain resolveEditingDomain(final EObject source) {
EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(source);
@@ -320,7 +321,7 @@ public class EMFHelper {
* @param separator
* The separator used between each package name
* @return
- * The EClassifier' qualified name
+ * The EClassifier' qualified name
*/
public static String getQualifiedName(final EClassifier eClassifier, final String separator) {
return getQualifiedName(eClassifier.getEPackage(), separator) + separator + eClassifier.getName();
@@ -334,7 +335,7 @@ public class EMFHelper {
* @param separator
* The separator used between each package name
* @return
- * The EPackage's qualified name
+ * The EPackage's qualified name
*/
public static String getQualifiedName(final EPackage ePackage, final String separator) {
if (ePackage.getESuperPackage() == null) {
@@ -353,7 +354,7 @@ public class EMFHelper {
* @param uri
* The URI describing the location of the model to load
* @return
- * The first EObject located at the given URI
+ * The first EObject located at the given URI
* @throws IOException
* When the URI cannot be loaded
*/
@@ -417,7 +418,7 @@ public class EMFHelper {
*
* @param ePackage
* @return
- * The Root package
+ * The Root package
*/
public static EPackage getRootPackage(final EPackage ePackage) {
if (ePackage == null) {
@@ -430,6 +431,53 @@ public class EMFHelper {
return getRootPackage(ePackage.getESuperPackage());
}
+ /**
+ * Gets the object of a given {@code type} containing an {@code object}, or the
+ * {@code object} itself if it is of that {@code type}.
+ *
+ * @param object
+ * the object for which to search for a container
+ * @param type
+ * the type of container to find
+ *
+ * @return the container of the requested {@code type}, or {@code null} if none
+ */
+ public static <T extends EObject> T getContainer(EObject object, EClass type) {
+ T result = null;
+
+ for (EObject next = object; (next != null) && (result == null); next = next.eContainer()) {
+ if (type.isInstance(next)) {
+ @SuppressWarnings("unchecked")
+ T nextAsT = (T) next;
+ result = nextAsT;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Gets the object of a given {@code type} containing an {@code object}, or the
+ * {@code object} itself if it is of that {@code type}.
+ *
+ * @param object
+ * the object for which to search for a container
+ * @param type
+ * the type of container to find
+ *
+ * @return the container of the requested {@code type}, or {@code null} if none
+ */
+ public static <T extends EObject> T getContainer(EObject object, Class<T> type) {
+ T result = null;
+
+ for (EObject next = object; (next != null) && (result == null); next = next.eContainer()) {
+ if (type.isInstance(next)) {
+ result = type.cast(next);
+ }
+ }
+
+ return result;
+ }
/**
* Return the list of EClasses that are subtypes
@@ -439,7 +487,7 @@ public class EMFHelper {
* @param concreteClassesOnly
* If true, only Concrete EClasses will be returned. Abstract and Interface EClasses will be filtered
* @return
- * The list of EClasses implementing or extending the given EClass
+ * The list of EClasses implementing or extending the given EClass
*/
public static List<EClass> getSubclassesOf(final EClass type, final boolean concreteClassesOnly) {
Set<EClass> result = new LinkedHashSet<EClass>();
@@ -462,7 +510,7 @@ public class EMFHelper {
* @param packagesToBrowse
* The EPackages in which the EClasses should be retrieved
* @return
- * The list of EClasses implementing or extending the given EClass
+ * The list of EClasses implementing or extending the given EClass
*/
public static List<EClass> getSubclassesOf(final EClass type, final boolean concreteClassesOnly, Collection<EPackage> packagesToBrowse) {
Set<EClass> result = new LinkedHashSet<EClass>();
@@ -487,7 +535,7 @@ public class EMFHelper {
* If true, all registered EPackages will be navigated to retrieve the matching EClasses. Otherwise,
* only the current EPackage will be used.
* @return
- * The list of EClasses implementing or extending the given EClass
+ * The list of EClasses implementing or extending the given EClass
*/
public static List<EClass> getSubclassesOf(final EClass type, final boolean concreteClassesOnly, final boolean browseAllRegisteredPackages) {
// If the current package is a dynamic package, it may not be registered (?). Add it directly
@@ -531,7 +579,7 @@ public class EMFHelper {
*
* @param eObject
* @return
- * True if the EObject is read only on any axis
+ * True if the EObject is read only on any axis
* @see #isReadOnly(Set, EObject, EditingDomain)
*/
public static boolean isReadOnly(final EObject eObject) {
@@ -546,7 +594,7 @@ public class EMFHelper {
* a set if orthogonal axes of read-only-ness to consider. May be empty, but that would not be especially useful
* @param eObject
* @return
- * True if the EObject is read only on any of the given {@code axes}
+ * True if the EObject is read only on any of the given {@code axes}
*/
public static boolean isReadOnly(Set<ReadOnlyAxis> axes, final EObject eObject) {
EditingDomain domain = resolveEditingDomain(eObject);
@@ -560,7 +608,7 @@ public class EMFHelper {
* @param eObject
* @param domain
* @return
- * True if the EObject is read only on any axis
+ * True if the EObject is read only on any axis
*/
public static boolean isReadOnly(final EObject eObject, final EditingDomain domain) {
return isReadOnly(ReadOnlyAxis.anyAxis(), eObject, domain);
@@ -576,7 +624,7 @@ public class EMFHelper {
*
* @param domain
* @return
- * True if the EObject is read only
+ * True if the EObject is read only
*/
public static boolean isReadOnly(Set<ReadOnlyAxis> axes, final EObject eObject, final EditingDomain domain) {
if (domain != null) {
@@ -602,7 +650,7 @@ public class EMFHelper {
* @param resource
* @param domain
* @return
- * True if the Resource is read only on any axis
+ * True if the Resource is read only on any axis
*/
public static boolean isReadOnly(final Resource resource, final EditingDomain domain) {
return isReadOnly(ReadOnlyAxis.anyAxis(), resource, domain);
@@ -617,7 +665,7 @@ public class EMFHelper {
* @param resource
* @param domain
* @return
- * True if the Resource is read only on any of the given {@code axes}
+ * True if the Resource is read only on any of the given {@code axes}
*/
public static boolean isReadOnly(Set<ReadOnlyAxis> axes, final Resource resource, final EditingDomain domain) {
if (resource == null) {
@@ -657,7 +705,7 @@ public class EMFHelper {
* @param domain
* the editing domain context of the {@link eObject}
* @return
- * whether the {@code eObject} could be made writable
+ * whether the {@code eObject} could be made writable
*/
public static boolean canMakeWritable(final EObject eObject, final EditingDomain domain) {
return canMakeWritable(ReadOnlyAxis.anyAxis(), eObject, domain);
@@ -674,7 +722,7 @@ public class EMFHelper {
* @param domain
* the editing domain context of the {@link eObject}
* @return
- * whether the {@code eObject} could be made writable
+ * whether the {@code eObject} could be made writable
*/
public static boolean canMakeWritable(Set<ReadOnlyAxis> axes, final EObject eObject, final EditingDomain domain) {
if (domain != null) {
@@ -695,7 +743,7 @@ public class EMFHelper {
* @param domain
* the editing domain context of the {@link resource}
* @return
- * whether the {@code resource} could be made writable
+ * whether the {@code resource} could be made writable
*/
public static boolean canMakeWritable(final Resource resource, final EditingDomain domain) {
return canMakeWritable(ReadOnlyAxis.anyAxis(), resource, domain);
@@ -712,7 +760,7 @@ public class EMFHelper {
* @param domain
* the editing domain context of the {@link resource}
* @return
- * whether the {@code resource} could be made writable
+ * whether the {@code resource} could be made writable
*/
public static boolean canMakeWritable(Set<ReadOnlyAxis> axes, final Resource resource, final EditingDomain domain) {
if (domain != null) {
@@ -739,7 +787,7 @@ public class EMFHelper {
* @param feature
* the feature to test
* @return
- * true if the feature is required, false otherwise
+ * true if the feature is required, false otherwise
*/
public static boolean isRequired(final EStructuralFeature feature) {
EClassifier eType = feature.getEType();
@@ -835,7 +883,7 @@ public class EMFHelper {
* a resource
*
* @return
- * the list of the metamodels known by the resource
+ * the list of the metamodels known by the resource
*/
public static Set<EPackage> getMetamodels(final Resource resource) {
Set<EPackage> metamodels = new HashSet<EPackage>();

Back to the top