diff options
| author | Maxime Porhel | 2015-06-30 10:16:15 +0000 |
|---|---|---|
| committer | Maxime Porhel | 2015-07-06 12:40:05 +0000 |
| commit | d30fa0d9916d0f35d519a35cd69779b9bb40479d (patch) | |
| tree | 6e39a35423bdc4a6ae117273edb7a1045d5dfaf6 | |
| parent | de0574fb0e474e98215e47e1365e7b65ed0a3b74 (diff) | |
| download | org.eclipse.sirius-d30fa0d9916d0f35d519a35cd69779b9bb40479d.tar.gz org.eclipse.sirius-d30fa0d9916d0f35d519a35cd69779b9bb40479d.tar.xz org.eclipse.sirius-d30fa0d9916d0f35d519a35cd69779b9bb40479d.zip | |
[471110] Indicate why the compartment buttons are disabled
Customize the tooltip of the group regarding the capability to configure the
current mapping as a RegionContainer mapping.
The disabled button tooltips cannot be used are they will not be
displayed when the button is disabled.
Bug: 471110
Change-Id: I6ff6b3fb32f27f4f900686b16735c03a8d0bdaac
Signed-off-by: Maxime Porhel <maxime.porhel@obeo.fr>
1 files changed, 21 insertions, 9 deletions
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/properties/section/description/containermapping/ContainerMappingChildrenPresentationPropertySectionSpec.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/properties/section/description/containermapping/ContainerMappingChildrenPresentationPropertySectionSpec.java index 279705e303..08656bc49d 100644 --- a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/properties/section/description/containermapping/ContainerMappingChildrenPresentationPropertySectionSpec.java +++ b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/properties/section/description/containermapping/ContainerMappingChildrenPresentationPropertySectionSpec.java @@ -15,6 +15,8 @@ import org.eclipse.sirius.diagram.business.api.query.ContainerMappingQuery; import org.eclipse.sirius.diagram.description.ContainerMapping; import org.eclipse.sirius.diagram.editor.properties.sections.description.containermapping.ContainerMappingChildrenPresentationPropertySection; import org.eclipse.sirius.editor.editorPlugin.SiriusEditor; +import org.eclipse.sirius.ext.base.Option; +import org.eclipse.sirius.ext.base.Options; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.widgets.Button; @@ -55,31 +57,41 @@ public class ContainerMappingChildrenPresentationPropertySectionSpec extends Con super.makeWrittable(); if (button != null && eObject instanceof ContainerMapping) { - boolean stackButtonEnabled = shouldEnableCompartiments((ContainerMapping) eObject); + Option<String> stackButtonDisabled = shouldDisableCompartiments((ContainerMapping) eObject); String hStackButtonText = getText(ContainerLayout.HORIZONTAL_STACK); String vStackButtonText = getText(ContainerLayout.VERTICAL_STACK); for (Button b : button) { if (hStackButtonText.equals(b.getText()) || vStackButtonText.equals(b.getText())) { - b.setEnabled(stackButtonEnabled); + b.setEnabled(!stackButtonDisabled.some()); + } + } + + if (group != null) { + if (stackButtonDisabled.some()) { + group.setToolTipText(stackButtonDisabled.get()); + } else { + group.setToolTipText(null); } } } } - private boolean shouldEnableCompartiments(ContainerMapping containerMapping) { + private Option<String> shouldDisableCompartiments(ContainerMapping containerMapping) { ContainerMappingQuery query = new ContainerMappingQuery(containerMapping); - boolean enableCompartiments = !query.isRegion(); - if (enableCompartiments) { + String message = query.isRegion() ? "A Region mapping cannot be a RegionContainer mapping.": null; + if (message == null) { for (ContainerMapping subContainer : containerMapping.getAllContainerMappings()) { ContainerMappingQuery subQuery = new ContainerMappingQuery(subContainer); - enableCompartiments = enableCompartiments && !subQuery.isRegionContainer(); + if (message == null && subQuery.isRegionContainer()) { + message = "The mapping contains RegionContainer sub mappings, they cannot be Region and RegionContainer."; + } } } - if (enableCompartiments) { - enableCompartiments = enableCompartiments && containerMapping.getAllNodeMappings().isEmpty(); + if (message == null && !containerMapping.getAllNodeMappings().isEmpty()) { + message = "The mapping contains node mappings, it cannot be a RegionContainer mapping."; } - return enableCompartiments; + return Options.newSome(message); } } |
