Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2017-08-03 14:55:16 +0000
committerLaurent Redor2017-08-04 07:06:43 +0000
commita5e634fe1f011a08bd9c33448b6849087611c249 (patch)
treeb3b1d5e21b1c9c0b1df64981e58d7e7aeca52abb
parent51684694d9f3d47058bbe56094cbdfffc3256ee5 (diff)
downloadorg.eclipse.sirius-a5e634fe1f011a08bd9c33448b6849087611c249.tar.gz
org.eclipse.sirius-a5e634fe1f011a08bd9c33448b6849087611c249.tar.xz
org.eclipse.sirius-a5e634fe1f011a08bd9c33448b6849087611c249.zip
[519637] Avoid invalid properties view title after an empty selection
Bug: 519637 Change-Id: I6cfe9f10e849d94e865f2995e12034d6b227c9d3 Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/ContributorWrapper.java50
1 files changed, 31 insertions, 19 deletions
diff --git a/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/ContributorWrapper.java b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/ContributorWrapper.java
index 1762ff136e..8862c0ad4f 100644
--- a/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/ContributorWrapper.java
+++ b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/ContributorWrapper.java
@@ -51,32 +51,44 @@ public class ContributorWrapper extends AbstractEEFTabbedPropertySheetPageContri
@Override
public void updateFormTitle(Form form, ISelection selection) {
if (selection instanceof IStructuredSelection) {
+ boolean semanticElementFound = false;
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object element = structuredSelection.getFirstElement();
- if (element == null) {
- return;
- }
-
- SiriusInputDescriptor inputDescriptor = new SiriusInputDescriptor(element);
- EObject semanticElement = inputDescriptor.getSemanticElement();
- if (semanticElement != null) {
- String text = new EditingDomainServices().getLabelProviderText(semanticElement);
- if (!Util.isBlank(text)) {
- // Keep only the first line in case of multiline labels
- String[] result = LINE_SEPARATOR_PATTERN.split(text, 2);
- if (result.length >= 1) {
- form.setText(result[0]);
- }
- } else {
- form.setText(""); //$NON-NLS-1$
+ if (element != null) {
+ SiriusInputDescriptor inputDescriptor = new SiriusInputDescriptor(element);
+ EObject semanticElement = inputDescriptor.getSemanticElement();
+ if (semanticElement != null) {
+ semanticElementFound = true;
+ updateFormText(form, semanticElement);
+ form.setImage(ExtendedImageRegistry.INSTANCE.getImage(new EditingDomainServices().getLabelProviderImage(semanticElement)));
}
-
- form.setImage(ExtendedImageRegistry.INSTANCE.getImage(new EditingDomainServices().getLabelProviderImage(semanticElement)));
- } else {
+ }
+ if (!semanticElementFound) {
form.setText(""); //$NON-NLS-1$
form.setImage(null);
}
}
}
+ /**
+ * Update the text of the title of the form.
+ *
+ * @param form
+ * The form
+ * @param semanticElement
+ * The current semantic element
+ */
+ protected void updateFormText(Form form, EObject semanticElement) {
+ String text = new EditingDomainServices().getLabelProviderText(semanticElement);
+ if (!Util.isBlank(text)) {
+ // Keep only the first line in case of multiline labels
+ String[] result = LINE_SEPARATOR_PATTERN.split(text, 2);
+ if (result.length >= 1) {
+ form.setText(result[0]);
+ }
+ } else {
+ form.setText(""); //$NON-NLS-1$
+ }
+ }
+
}

Back to the top