Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2015-12-04 08:52:01 -0500
committerChristian W. Damus2015-12-08 08:58:31 -0500
commit49bd194639354cde35b15717e4ead156f4613754 (patch)
tree2f3b4a83815186201eb39fbcb058d07d8880f6d4 /plugins/views/properties
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/views/properties')
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/schema/context.exsd306
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/extensions/ContextExtensionPoint.java78
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/preferences/Preferences.java39
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConfigurationManager.java66
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/AbstractPropertyEditor.java7
5 files changed, 330 insertions, 166 deletions
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/schema/context.exsd b/plugins/views/properties/org.eclipse.papyrus.views.properties/schema/context.exsd
index 1a8c125efa6..8cec839e23e 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/schema/context.exsd
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/schema/context.exsd
@@ -1,139 +1,167 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.papyrus.views.properties" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.papyrus.views.properties" id="Context" name="Context"/>
- </appInfo>
- <documentation>
- Extension point used to provide new Contexts to the Papyrus Property View. A Context is an EMF Model conforming to http://www.eclipse.org/papyrus/properties (From org.eclipse.papyrus.views.properties.model), defining a set of Constraint descriptors, and the view to display for each.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appInfo>
- <meta.element />
- </appInfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="context" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="context">
- <complexType>
- <attribute name="contextModel" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="resource"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="isCustomizable" type="boolean" use="default" value="true">
- <annotation>
- <documentation>
- Indicates whether this property view configuration is customizable. Default is true. If this configuration is not marked as customizable, it won&apos;t appear in the Property view customization tools, and the user won&apos;t be able to disable this configuration. Use this option when the user shouldn&apos;t be allowed to modify this configuration (e.g. when the property view configuration is used in a Wizard).
- </documentation>
- </annotation>
- </attribute>
- <attribute name="appliedByDefault" type="boolean">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 0.8.0
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- &lt;extension
- point=&quot;org.eclipse.papyrus.views.properties.Context&quot;&gt;
- &lt;context contextModel=&quot;Model/UML.xmi&quot;&gt;
- &lt;/context&gt;
-&lt;/extension&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiinfo"/>
- </appInfo>
- <documentation>
- There is no API associated with this extension point.
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- Sample Implementation :
-org.eclipse.papyrus.views.properties.uml
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- /*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
- </documentation>
- </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.views.properties" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.papyrus.views.properties" id="Context" name="Context"/>
+ </appInfo>
+ <documentation>
+ Extension point used to provide new Contexts to the Papyrus Property View. A Context is an EMF Model conforming to http://www.eclipse.org/papyrus/properties (From org.eclipse.papyrus.views.properties.model), defining a set of Constraint descriptors, and the view to display for each.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <choice minOccurs="1" maxOccurs="unbounded">
+ <element ref="context"/>
+ <element ref="preferencePageBinding"/>
+ </choice>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="context">
+ <complexType>
+ <attribute name="contextModel" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="resource"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="isCustomizable" type="boolean" use="default" value="true">
+ <annotation>
+ <documentation>
+ Indicates whether this property view configuration is customizable. Default is true. If this configuration is not marked as customizable, it won&apos;t appear in the Property view customization tools, and the user won&apos;t be able to disable this configuration. Use this option when the user shouldn&apos;t be allowed to modify this configuration (e.g. when the property view configuration is used in a Wizard).
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="appliedByDefault" type="boolean">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="preferencePageBinding">
+ <annotation>
+ <documentation>
+ Specifies a binding of a particular registered Properties context model to some preference page (usually different than the default Papyrus Properties View preference page).
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="context" type="string" use="required">
+ <annotation>
+ <documentation>
+ References the Properties Context (by name) to associate with a preference page. The name is used instead of the URI because that is what the enablement preferences use to identify contexts and it is how (temporarily) missing contexts are tracked.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="page" type="string" use="required">
+ <annotation>
+ <documentation>
+ Indicates the preference page in which to present the customization of the referenced properties context.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.ui.preferencePages/page/@id"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 0.8.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ &lt;extension
+ point=&quot;org.eclipse.papyrus.views.properties.Context&quot;&gt;
+ &lt;context contextModel=&quot;Model/UML.xmi&quot;&gt;
+ &lt;/context&gt;
+&lt;/extension&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ There is no API associated with this extension point.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ Sample Implementation :
+org.eclipse.papyrus.views.properties.uml
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ /*****************************************************************************
+ * Copyright (c) 2010 CEA LIST.
+ *
+ * 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/extensions/ContextExtensionPoint.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/extensions/ContextExtensionPoint.java
index bf54e07569d..de64bdb84e0 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/extensions/ContextExtensionPoint.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/extensions/ContextExtensionPoint.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2015 CEA LIST.
+ * Copyright (c) 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
@@ -9,6 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - adds isVisible implementation
+ * Christian W. Damus - bug 469188
*
*****************************************************************************/
package org.eclipse.papyrus.views.properties.extensions;
@@ -37,6 +38,14 @@ public class ContextExtensionPoint {
/** The Constant IS_VISIBLE. */
private static final String APPLIED_BY_DEFAULT = "appliedByDefault";//$NON-NLS-1$
+ private static final String CONTEXT_MODEL = "contextModel"; //$NON-NLS-1$
+
+ private static final String CONTEXT = "context"; //$NON-NLS-1$
+
+ private static final String PREFPAGE_BINDING = "preferencePageBinding"; //$NON-NLS-1$
+
+ private static final String PAGE = "page"; //$NON-NLS-1$
+
/** The extension id. */
private final String EXTENSION_ID = "org.eclipse.papyrus.views.properties.context"; //$NON-NLS-1$
@@ -48,26 +57,15 @@ public class ContextExtensionPoint {
for (IConfigurationElement e : config) {
try {
- final String contextResource = e.getAttribute("contextModel"); //$NON-NLS-1$
-
- final boolean isCustomizable;
- if (Arrays.asList(e.getAttributeNames()).contains(IS_CUSTOMIZABLE)) {
- isCustomizable = Boolean.parseBoolean(e.getAttribute(IS_CUSTOMIZABLE));
- } else {
- isCustomizable = true; // Default value
- }
-
- final boolean appliedByDefault;
- if (Arrays.asList(e.getAttributeNames()).contains(APPLIED_BY_DEFAULT)) {
- appliedByDefault = Boolean.parseBoolean(e.getAttribute(APPLIED_BY_DEFAULT));
- } else {
- appliedByDefault = true; // Default value
+ switch (e.getName()) {
+ case CONTEXT:
+ processContext(e);
+ break;
+ case PREFPAGE_BINDING:
+ processPrefPageBinding(e);
+ break;
}
- URI uri = URI.createURI("ppe:/context/" + e.getContributor().getName() + "/" + contextResource); //$NON-NLS-1$ //$NON-NLS-2$
-
- ConfigurationManager.getInstance().addContext(uri, appliedByDefault, isCustomizable);
-
} catch (IOException ex) {
Activator.log.error("The plugin " + e.getContributor() + " contributed an invalid extension for " + EXTENSION_ID, ex); //$NON-NLS-1$//$NON-NLS-2$
} catch (Exception ex) {
@@ -75,4 +73,46 @@ public class ContextExtensionPoint {
}
}
}
+
+ private void processContext(IConfigurationElement e) throws IOException {
+ final String contextResource = e.getAttribute(CONTEXT_MODEL);
+
+ final boolean isCustomizable;
+ if (Arrays.asList(e.getAttributeNames()).contains(IS_CUSTOMIZABLE)) {
+ isCustomizable = Boolean.parseBoolean(e.getAttribute(IS_CUSTOMIZABLE));
+ } else {
+ isCustomizable = true; // Default value
+ }
+
+ final boolean appliedByDefault;
+ if (Arrays.asList(e.getAttributeNames()).contains(APPLIED_BY_DEFAULT)) {
+ appliedByDefault = Boolean.parseBoolean(e.getAttribute(APPLIED_BY_DEFAULT));
+ } else {
+ appliedByDefault = true; // Default value
+ }
+
+ URI uri = URI.createURI("ppe:/context/" + e.getContributor().getName() + "/" + contextResource); //$NON-NLS-1$ //$NON-NLS-2$
+
+ ConfigurationManager.getInstance().addContext(uri, appliedByDefault, isCustomizable);
+ }
+
+ private void processPrefPageBinding(IConfigurationElement config) {
+ boolean valid = true;
+
+ String context = config.getAttribute(CONTEXT);
+ if ((context == null) || context.isEmpty()) {
+ valid = false;
+ Activator.log.warn(String.format("Missing context name in preference page binding extension in plug-in %s", config.getContributor().getName()));
+ }
+
+ String page = config.getAttribute(PAGE);
+ if ((page == null) || page.isEmpty()) {
+ valid = false;
+ Activator.log.warn(String.format("Missing page ID in preference page binding extension in plug-in %s", config.getContributor().getName()));
+ }
+
+ if (valid) {
+ ConfigurationManager.getInstance().registerPreferencePageBinding(context, page);
+ }
+ }
}
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/preferences/Preferences.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/preferences/Preferences.java
index 8ee8990fe2e..eee6db4f44c 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/preferences/Preferences.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/preferences/Preferences.java
@@ -10,11 +10,11 @@
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus - bug 482930
* Christian W. Damus - bug 482927
+ * Christian W. Damus - bug 469188
*****************************************************************************/
package org.eclipse.papyrus.views.properties.preferences;
import java.util.Collection;
-import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
@@ -24,6 +24,9 @@ import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.PreferencePage;
@@ -49,13 +52,36 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
*
* @author Camille Letavernier
*/
-public class Preferences extends PreferencePage implements IWorkbenchPreferencePage {
+public class Preferences extends PreferencePage implements IWorkbenchPreferencePage, IExecutableExtension {
+
+ /**
+ * The unique identifier of the default preference page, covering the <b>Properties View</b>.
+ *
+ * @see #getID()
+ */
+ public static final String DEFAULT_ID = "org.eclipse.papyrus.views.properties.propertyview"; //$NON-NLS-1$
+
+ private String id;
@Override
public void init(IWorkbench workbench) {
// Nothing
}
+ /**
+ * Queries my unique identifier as configured on the extension point.
+ *
+ * @return my unique identifier
+ */
+ public final String getID() {
+ return id;
+ }
+
+ @Override
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+ this.id = config.getAttribute("id"); //$NON-NLS-1$
+ }
+
@Override
protected Control createContents(Composite parent) {
Composite self = new Composite(parent, SWT.NONE);
@@ -67,12 +93,11 @@ public class Preferences extends PreferencePage implements IWorkbenchPreferenceP
final ConfigurationManager configurationManager = ConfigurationManager.getInstance();
- // Only customizable Property view contexts should appear here
- List<Context> contexts = new java.util.ArrayList<Context>(configurationManager.getCustomizableContexts());
- contexts.addAll(configurationManager.getMissingContexts());
- Collections.sort(contexts, contextOrdering());
+ List<Context> sortedContexts = configurationManager.getContextsForPreferencePage(getID()).stream()
+ .sorted(contextOrdering())
+ .collect(Collectors.toList());
- for (Context context : contexts) {
+ for (Context context : sortedContexts) {
boolean applied = configurationManager.isApplied(context);
Button checkbox = new Button(self, SWT.CHECK);
checkbox.setText(getLabel(context));
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConfigurationManager.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConfigurationManager.java
index 6f3da4ec9ea..5cd16104c9d 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConfigurationManager.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConfigurationManager.java
@@ -11,6 +11,7 @@
* Christian W. Damus (CEA) - Factor out workspace storage for pluggable storage providers (CDO)
* Christian W. Damus (CEA) - Support implicit enablement of prototypes of unavailable contexts (CDO)
* Christian W. Damus - bug 482930
+ * Christian W. Damus - bug 469188
*****************************************************************************/
package org.eclipse.papyrus.views.properties.runtime;
@@ -27,6 +28,8 @@ import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -108,6 +111,9 @@ public class ConfigurationManager {
private IContextStorageProviderListener contextStorageProviderListener;
+ /** Map of preference page identifier to context unique identifiers. */
+ private final Map<String, Set<String>> preferencePageBindings;
+
/**
* The global constraint engine
*/
@@ -133,6 +139,7 @@ public class ConfigurationManager {
customizableContexts = new HashMap<Context, Boolean>();
contexts = new LinkedHashMap<URI, Context>();
contextStorageRegistry = new ContextStorageRegistry(resourceSet);
+ preferencePageBindings = new HashMap<>();
root = RootFactory.eINSTANCE.createPropertiesRoot();
@@ -1187,4 +1194,63 @@ public class ConfigurationManager {
public ViewConstraintEngine getConstraintEngine() {
return constraintEngine;
}
+
+ /**
+ * Registers association of a context with a preference page in which to present it
+ * for enablement/customization.
+ *
+ * @param context
+ * the context name
+ * @param page
+ * the preference page identifier
+ *
+ * @throws IllegalArgumentException
+ * if the {@code context} or {@link page} is
+ * {@code null} or empty
+ *
+ * @see #registerContext(URI, String)
+ */
+ public void registerPreferencePageBinding(String context, String page) {
+ if ((context == null) || context.isEmpty()) {
+ throw new IllegalArgumentException("context name is missing"); //$NON-NLS-1$
+ }
+ if ((page == null) || page.isEmpty()) {
+ throw new IllegalArgumentException("preference page identifier is missing"); //$NON-NLS-1$
+ }
+
+ Set<String> contexts = preferencePageBindings.get(page);
+ if (contexts == null) {
+ contexts = new HashSet<>();
+ preferencePageBindings.put(page, contexts);
+ }
+ contexts.add(context);
+ }
+
+ public List<Context> getContextsForPreferencePage(String page) {
+ return Stream.concat(getContexts().stream(), getMissingContexts().stream())
+ .filter(this::isCustomizable) // Only present customizable contexts
+ .filter(c -> isBoundToPreferencePage(c, page))
+ .collect(Collectors.toList());
+ }
+
+ private boolean isBoundToPreferencePage(Context context, String page) {
+ boolean result = false;
+ String contextName = context.getName();
+
+ if ((page == null) || page.equals(org.eclipse.papyrus.views.properties.preferences.Preferences.DEFAULT_ID)) {
+ page = org.eclipse.papyrus.views.properties.preferences.Preferences.DEFAULT_ID;
+ Set<String> explicitBindings = preferencePageBindings.getOrDefault(page, Collections.emptySet());
+
+ // Looking for bindings to the default preference page. This includes
+ // all contexts that are not bound to any page and those that are
+ // explicitly bound to the default page
+ result = explicitBindings.contains(contextName)
+ || preferencePageBindings.values().stream().noneMatch(set -> set.contains(contextName));
+ } else {
+ // Only explicit bindings
+ result = preferencePageBindings.getOrDefault(page, Collections.emptySet()).contains(contextName);
+ }
+
+ return result;
+ }
}
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/AbstractPropertyEditor.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/AbstractPropertyEditor.java
index d6f0fa7a712..4e3d23f0d74 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/AbstractPropertyEditor.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/AbstractPropertyEditor.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
@@ -12,6 +12,7 @@
* Christian W. Damus (CEA) - bug 417409
* Christian W. Damus (CEA) - bug 443417
* Christian W. Damus (CEA) - bug 444227
+ * Christian W. Damus - bug 469188
*
*****************************************************************************/
package org.eclipse.papyrus.views.properties.widgets;
@@ -253,6 +254,10 @@ public abstract class AbstractPropertyEditor implements IChangeListener, Customi
AbstractEditor editor = getEditor();
if (editor != null) {
editor.refreshValue();
+
+ // And refresh the read-only state
+ isEditable = input.isEditable(propertyPath);
+ applyReadOnly(getReadOnly());
}
}

Back to the top