Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre GAUTIER2017-09-14 06:44:26 +0000
committervincent lorenzo2017-09-21 08:43:23 +0000
commit3d9fa51ba009bac2e5888768a6840a07b0698ede (patch)
treee96c2f3e61edf636dd6bfef3d0b4c36bfe76a0f2 /plugins/uml/properties
parentbcc1383b24cfe7cc8fc427aba8dde06de6b43e09 (diff)
downloadorg.eclipse.papyrus-3d9fa51ba009bac2e5888768a6840a07b0698ede.tar.gz
org.eclipse.papyrus-3d9fa51ba009bac2e5888768a6840a07b0698ede.tar.xz
org.eclipse.papyrus-3d9fa51ba009bac2e5888768a6840a07b0698ede.zip
Bug 521865 - [Property View][Profile] Truncated editors for datatype's attribute.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=521865 add ScrolledComposite in EObjectContentsEditor Change-Id: Id1bb3362f493dea1b0133c4a408792527ab74571 Signed-off-by: Pierre GAUTIER <pierre.gautier@cea.fr> Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
Diffstat (limited to 'plugins/uml/properties')
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF2
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml2
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/messages/Messages.java10
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/messages/messages.properties2
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EObjectContentsEditor.java95
5 files changed, 100 insertions, 11 deletions
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF
index b8c8e212fc7..cc7f38b971f 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF
@@ -38,7 +38,7 @@ Require-Bundle: org.eclipse.papyrus.uml.profile;bundle-version="[3.0.0,4.0.0)";v
org.eclipse.papyrus.infra.internationalization;bundle-version="[1.0.0,2.0.0)"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.papyrus.uml.properties.constraints"
-Bundle-Version: 3.0.0.qualifier
+Bundle-Version: 3.1.0.qualifier
Bundle-Name: %pluginName
Bundle-Localization: plugin
Bundle-Activator: org.eclipse.papyrus.uml.properties.Activator
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml
index 0315d0071b1..7e68d88667f 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml
@@ -8,6 +8,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.uml.properties</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/messages/Messages.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/messages/Messages.java
index 4327e1cb391..342f2761d35 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/messages/Messages.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/messages/Messages.java
@@ -17,6 +17,16 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.papyrus.uml.properties.messages.messages"; //$NON-NLS-1$
+ /**
+ * @since 3.1
+ */
+ public static String EObjectContentsEditor_CreateElement;
+
+ /**
+ * @since 3.1
+ */
+ public static String EObjectContentsEditor_UnsetValue;
+
public static String ExpressionLanguageFactory_EditLanguage;
public static String ExpressionLanguageFactory_LanguageDuplicateError;
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/messages/messages.properties b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/messages/messages.properties
index c6215cdcc08..8a7fe61e5d6 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/messages/messages.properties
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/messages/messages.properties
@@ -1,3 +1,5 @@
+EObjectContentsEditor_CreateElement=Create element
+EObjectContentsEditor_UnsetValue=Unset value
ExpressionEditor_BodyLabel=Body
ProfileApplicationEditor_ApplyProfile=Apply profile
ProfileApplicationEditor_ApplyProfilesDialogDescription=Choose profiles to apply
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EObjectContentsEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EObjectContentsEditor.java
index 8966fcd5ea0..3e4816e3024 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EObjectContentsEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EObjectContentsEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2017 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Camille Letavernier (camille.letavernier@cea.fr) - Initial API and implementation
+ * Pierre GAUTIER (CEA LIST) - bug 521865
*
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.widgets;
@@ -34,15 +35,20 @@ import org.eclipse.papyrus.infra.ui.emf.providers.EMFLabelProvider;
import org.eclipse.papyrus.infra.ui.emf.utils.ProviderHelper;
import org.eclipse.papyrus.uml.properties.Activator;
import org.eclipse.papyrus.uml.properties.creation.UMLPropertyEditorFactory;
+import org.eclipse.papyrus.uml.properties.messages.Messages;
import org.eclipse.papyrus.uml.tools.providers.UMLContainerContentProvider;
import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider;
import org.eclipse.papyrus.uml.tools.providers.UMLFilteredLabelProvider;
import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseWheelListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
@@ -75,6 +81,25 @@ public class EObjectContentsEditor extends Composite {
protected Composite self;
+ /**
+ * the right scrollbar
+ */
+ private final ScrolledComposite scrolled;
+
+ /**
+ * listener to be be able to move the scrollbar with the mouse wheel
+ *
+ */
+ private final MouseWheelListener mouseWheelListener = new MouseWheelListener() {
+
+ @Override
+ public void mouseScrolled(final MouseEvent e) {
+ final Point or = EObjectContentsEditor.this.scrolled.getOrigin();
+ or.y += -e.count * EObjectContentsEditor.this.scrolled.getVerticalBar().getIncrement();
+ EObjectContentsEditor.this.scrolled.setOrigin(or);
+ }
+ };
+
public EObjectContentsEditor(Composite parent, int style, EReference reference) {
super(parent, style);
@@ -82,7 +107,15 @@ public class EObjectContentsEditor extends Composite {
self = new Group(this, SWT.NONE);
- ((Group) self).setText(reference.getName() + ": " + reference.getEType().getName());
+ final StringBuilder builder = new StringBuilder();
+ if (null != reference) {
+ builder.append(reference.getName());
+ builder.append(":"); //$NON-NLS-1$
+ if (null != reference.getEType()) {
+ builder.append(reference.getEType().getName());
+ }
+ }
+ ((Group) self).setText(builder.toString());
self.setLayout(new PropertiesLayout());
buttonsBar = new Composite(self, SWT.NONE);
@@ -94,9 +127,20 @@ public class EObjectContentsEditor extends Composite {
updateButtonsBar();
- contents = new Composite(self, SWT.NONE);
+ scrolled = new ScrolledComposite(self, SWT.V_SCROLL);
+ scrolled.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ scrolled.setLayout(new PropertiesLayout());
+ scrolled.setExpandHorizontal(true);
+ scrolled.setExpandVertical(true);
+ scrolled.setMinSize(250, 100);
+
+ contents = new Composite(scrolled, SWT.NONE);
contents.setLayout(new PropertiesLayout());
contents.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ contents.setBackgroundMode(SWT.INHERIT_DEFAULT);
+ contents.setBackground(self.getBackground());
+
+ scrolled.setContent(contents);
this.reference = reference;
@@ -135,7 +179,7 @@ public class EObjectContentsEditor extends Composite {
protected void updateContents() {
EObject dataTypeInstance = (EObject) modelElementObservable.getValue();
-
+ unregisteredMouseWheelListener(scrolled);
for (Control child : contents.getChildren()) {
child.dispose();
}
@@ -166,11 +210,44 @@ public class EObjectContentsEditor extends Composite {
}
}
+ scrolled.setMinSize(contents.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+
+ registerMouseWheelListener(scrolled);
updateButtonsBar();
layout();
}
+ /**
+ * Register the mouse wheel listener for the control and its children
+ *
+ * @param control
+ * a control
+ */
+ private void registerMouseWheelListener(final Control control) {
+ control.addMouseWheelListener(this.mouseWheelListener);
+ if (control instanceof Composite) {
+ for (Control ctrl : ((Composite) control).getChildren()) {
+ registerMouseWheelListener(ctrl);
+ }
+ }
+ }
+
+ /**
+ * Unregister the mouse wheel listener for the control and its children
+ *
+ * @param control
+ * a control
+ */
+ private void unregisteredMouseWheelListener(final Control control) {
+ control.removeMouseWheelListener(this.mouseWheelListener);
+ if (control instanceof Composite) {
+ for (Control ctrl : ((Composite) control).getChildren()) {
+ unregisteredMouseWheelListener(ctrl);
+ }
+ }
+ }
+
@Override
public void layout() {
contents.layout();
@@ -181,8 +258,8 @@ public class EObjectContentsEditor extends Composite {
protected void createAddButton() {
addButton = new Button(buttonsBar, SWT.PUSH);
- addButton.setImage(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("icons/Add_12x12.gif"));
- addButton.setToolTipText("Create element");
+ addButton.setImage(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("icons/Add_12x12.gif")); //$NON-NLS-1$
+ addButton.setToolTipText(Messages.EObjectContentsEditor_CreateElement);
addButton.addSelectionListener(new SelectionListener() {
@@ -213,8 +290,8 @@ public class EObjectContentsEditor extends Composite {
protected void createDeleteButton() {
deleteButton = new Button(buttonsBar, SWT.PUSH);
- deleteButton.setImage(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("icons/Delete_12x12.gif"));
- deleteButton.setToolTipText("Unset value");
+ deleteButton.setImage(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("icons/Delete_12x12.gif")); //$NON-NLS-1$
+ deleteButton.setToolTipText(Messages.EObjectContentsEditor_UnsetValue);
deleteButton.addSelectionListener(new SelectionListener() {
@@ -245,7 +322,7 @@ public class EObjectContentsEditor extends Composite {
ITreeContentProvider contentProvider = new UMLContainerContentProvider(dataTypeInstance, reference);
- EMFGraphicalContentProvider provider = ProviderHelper.encapsulateProvider(contentProvider, dataTypeInstance.eResource().getResourceSet(), HistoryUtil.getHistoryID(dataTypeInstance, reference, "container"));
+ EMFGraphicalContentProvider provider = ProviderHelper.encapsulateProvider(contentProvider, dataTypeInstance.eResource().getResourceSet(), HistoryUtil.getHistoryID(dataTypeInstance, reference, "container")); //$NON-NLS-1$
factory.setContainerContentProvider(provider);
factory.setReferenceContentProvider(new FeatureContentProvider(type));

Back to the top