Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Langer2016-06-27 14:37:44 -0400
committerBenoit Maggi2016-06-28 07:55:08 -0400
commitafe216e77b80144d5020264901cd56f0ec4f41dc (patch)
tree1a30a840f2cb71dd2f3e432af97349a4bd0f65c5
parent5187372b4cd835119cfef6918a47d8755d713e04 (diff)
downloadorg.eclipse.papyrus-afe216e77b80144d5020264901cd56f0ec4f41dc.tar.gz
org.eclipse.papyrus-afe216e77b80144d5020264901cd56f0ec4f41dc.tar.xz
org.eclipse.papyrus-afe216e77b80144d5020264901cd56f0ec4f41dc.zip
Bug 495394: Hide description in TreeSelectorDialog if there is none
The description label produces empty space even if there is no description, which happens in many cases, e.g., when we click the "..." button for selecting the type in the property view of an attribute. To avoid this empty space before the filter text box, we hide the label (and prevent it from using space) if the description is null and only show it when it is not null. If the description is set at a later point, it will be still shown, as we "unhide" the label and call pack() on the parent composite. Change-Id: Idcab2f73db34544432e3dfb99c1ebf8e5f981ddb Signed-off-by: Philip Langer <planger@eclipsesource.com>
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeSelectorDialog.java26
1 files changed, 23 insertions, 3 deletions
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeSelectorDialog.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeSelectorDialog.java
index 6d09eb33775..431e74a8e39 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeSelectorDialog.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeSelectorDialog.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010, 2014 CEA LIST and others.
+ * Copyright (c) 2010, 2016 CEA LIST 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
* Christian W. Damus (CEA) - bug 408491
+ * Philip Langer (EclipseSource) planger@eclipsesource.com - bug 495394
*
*****************************************************************************/
package org.eclipse.papyrus.infra.widgets.editors;
@@ -126,7 +127,9 @@ public class TreeSelectorDialog extends SelectionDialog implements ITreeSelector
descriptionLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
if (description != null) {
- descriptionLabel.setText(description);
+ showDescriptionLabel();
+ } else {
+ hideDescriptionLabel();
}
treeViewer = new TreeViewer(getDialogArea(), SWT.BORDER);
@@ -214,6 +217,18 @@ public class TreeSelectorDialog extends SelectionDialog implements ITreeSelector
}
+ private void hideDescriptionLabel() {
+ descriptionLabel.setText(""); //$NON-NLS-1$
+ descriptionLabel.setVisible(false);
+ ((GridData)descriptionLabel.getLayoutData()).exclude = true;
+ }
+
+ private void showDescriptionLabel() {
+ descriptionLabel.setText(description);
+ descriptionLabel.setVisible(true);
+ ((GridData)descriptionLabel.getLayoutData()).exclude = false;
+ }
+
/**
* Sets the description for this Dialog. The description is displayed on
* top of the dialog
@@ -226,7 +241,12 @@ public class TreeSelectorDialog extends SelectionDialog implements ITreeSelector
this.description = description;
if ((descriptionLabel != null) && !descriptionLabel.isDisposed()) {
- descriptionLabel.setText(description == null ? "" : description); //$NON-NLS-1$
+ if (description != null) {
+ showDescriptionLabel();
+ } else {
+ hideDescriptionLabel();
+ }
+ descriptionLabel.getParent().pack();
}
}

Back to the top