Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2015-10-23 15:32:50 +0000
committerGerrit Code Review @ Eclipse.org2015-11-26 12:25:42 +0000
commitea49a638875848683c765a1b74a90a490a7fd84e (patch)
tree7d0ccd1a32a9b9716b217be8af0af170eff2a32f /plugins/views/properties
parentb6dba49aee265c2ad8afd3d958a8fcce1ae56184 (diff)
downloadorg.eclipse.papyrus-ea49a638875848683c765a1b74a90a490a7fd84e.tar.gz
org.eclipse.papyrus-ea49a638875848683c765a1b74a90a490a7fd84e.tar.xz
org.eclipse.papyrus-ea49a638875848683c765a1b74a90a490a7fd84e.zip
480513 - [Property view] Enhance EditionDialog
Diffstat (limited to 'plugins/views/properties')
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EditionDialog.java61
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/messages/Messages.java2
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/messages/messages.properties1
3 files changed, 64 insertions, 0 deletions
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EditionDialog.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EditionDialog.java
index 1bb01240284..297fb3246cb 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EditionDialog.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EditionDialog.java
@@ -13,6 +13,7 @@
*****************************************************************************/
package org.eclipse.papyrus.views.properties.creation;
+import java.io.IOException;
import java.text.Collator;
import java.util.Collections;
import java.util.Comparator;
@@ -24,14 +25,17 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.papyrus.views.properties.Activator;
+import org.eclipse.papyrus.views.properties.contexts.Context;
import org.eclipse.papyrus.views.properties.contexts.Section;
import org.eclipse.papyrus.views.properties.contexts.Tab;
import org.eclipse.papyrus.views.properties.contexts.View;
import org.eclipse.papyrus.views.properties.messages.Messages;
+import org.eclipse.papyrus.views.properties.runtime.ConfigurationManager;
import org.eclipse.papyrus.views.properties.runtime.DefaultDisplayEngine;
import org.eclipse.papyrus.views.properties.runtime.DisplayEngine;
import org.eclipse.papyrus.views.properties.xwt.XWTSection;
@@ -137,6 +141,63 @@ public class EditionDialog extends SelectionDialog {
this.views = views;
}
+ /**
+ * Provide information about context and view, as well as the element for which the dialog
+ * should be provided. It will call setViews in turn.
+ *
+ * @param contextName The name of the context
+ * @param contextURI The URI of the context, tries to load context, if it has not been done yet
+ * @param viewName The name of the view
+ */
+ public void setViewData(String contextName, String viewName) {
+ setViewData(contextName, null, viewName);
+ }
+
+ /**
+ * Provide information about context and view, as well as the element for which the dialog
+ * should be provided.
+ *
+ * @param contextName The name of the context
+ * @param contextURI The URI of the context. If the context is not available yet, the function uses this URI to load it.
+ * @param viewName The name of the view
+ */
+ public void setViewData(String contextName, URI contextURI, String viewName) {
+
+ Context context = ConfigurationManager.getInstance().getContext(contextName);
+ if ((context == null) && (contextURI != null)) {
+ // might not have been loaded yet
+ loadFromURI(contextURI);
+ context = ConfigurationManager.getInstance().getContext(contextName);
+ }
+
+ Set<View> views = new HashSet<View>();
+
+ if (context != null) {
+ for (View view : context.getViews()) {
+ if (view.getName().equals(viewName)) {
+ views.add(view);
+ break;
+ }
+ }
+ }
+ if (views.isEmpty()) {
+ throw new RuntimeException (String.format(Messages.EditionDialog_CanNotFindview, viewName));
+ }
+ setViews(views);
+ }
+
+ /**
+ * Load the passed context into the configuration manager.
+ */
+ protected void loadFromURI(URI uri) {
+ try {
+ ConfigurationManager.getInstance().addContext(uri);
+ }
+ catch (IOException io) {
+ Activator.log.error(io);
+ }
+ }
+
private void display() {
DisplayEngine display = new DefaultDisplayEngine();
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/messages/Messages.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/messages/Messages.java
index d2f5ecfba1b..25bc1e6244c 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/messages/Messages.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/messages/Messages.java
@@ -24,6 +24,8 @@ public class Messages extends NLS {
public static String EcorePropertyEditorFactory_CreateANew;
+ public static String EditionDialog_CanNotFindview;
+
public static String EditionDialog_CreateANewElement;
public static String Preferences_ConflictWarning1;
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/messages/messages.properties b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/messages/messages.properties
index 151b75538e6..05ade3033ad 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/messages/messages.properties
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/messages/messages.properties
@@ -1,4 +1,5 @@
EcorePropertyEditorFactory_CreateANew=Create a new
+EditionDialog_CanNotFindview=Can not find view <%s>
EditionDialog_CreateANewElement=Create a new Element
Preferences_ConflictWarning1=Warning : When two sections with the same ID are displayed in the same property view, only the first of them is displayed. The following conflicts may occur : \n\n
Preferences_ConflictWarning2=\nPlease note that if these sections apply to different elements, there won't be any conflict. Do you wish to continue ?

Back to the top