diff options
| author | Stéphane Bégaudeau | 2016-08-04 09:59:19 +0000 |
|---|---|---|
| committer | Pierre-Charles David | 2016-08-22 14:14:33 +0000 |
| commit | 7765d65c2d18082bb757c41d712b3f42ff9cb965 (patch) | |
| tree | ee801d3b41ca1aa316978245396dda202227e47a | |
| parent | 3c3e22a501ac813e4fbf097c32244923bda3c6cb (diff) | |
| download | org.eclipse.sirius-7765d65c2d18082bb757c41d712b3f42ff9cb965.tar.gz org.eclipse.sirius-7765d65c2d18082bb757c41d712b3f42ff9cb965.tar.xz org.eclipse.sirius-7765d65c2d18082bb757c41d712b3f42ff9cb965.zip | |
[498205] Improve the refresh of the title of the Properties view
1) Fix an issue with the refresh of the title and legacy tabs
2) The title of the view is now limited to one line
Bug: 498205
Change-Id: Iabb3d1d673cd60675688a8e0d9c951d76076b677
Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr>
4 files changed, 81 insertions, 3 deletions
diff --git a/plugins/org.eclipse.sirius.ui.properties/META-INF/MANIFEST.MF b/plugins/org.eclipse.sirius.ui.properties/META-INF/MANIFEST.MF index 9f809882a4..91db8cbd22 100644 --- a/plugins/org.eclipse.sirius.ui.properties/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.sirius.ui.properties/META-INF/MANIFEST.MF @@ -26,7 +26,9 @@ Require-Bundle: org.eclipse.eef;bundle-version="1.6.0", org.eclipse.sirius.ext.emf.edit;bundle-version="4.0.0", org.eclipse.eef.properties.ui.legacy;bundle-version="1.6.0", org.eclipse.eef.ide;bundle-version="1.6.0", - org.eclipse.sirius.ui;bundle-version="4.1.0" + org.eclipse.sirius.ui;bundle-version="4.1.0", + org.eclipse.ui.forms;bundle-version="[3.0.0,4.0.0)", + org.eclipse.emf.edit.ui;bundle-version="[2.8.0,3.0.0)" Import-Package: com.ibm.icu.util;version="54.1.0", org.eclipse.sirius.ui.business.api.dialect;version="3.1.0", org.eclipse.sirius.ui.tools.api.properties;version="2.1.0" 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 new file mode 100644 index 0000000000..b7976acd9b --- /dev/null +++ b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/ContributorWrapper.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2016 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.ui.properties.internal; + +import java.util.regex.Pattern; + +import org.eclipse.eef.common.api.utils.Util; +import org.eclipse.eef.properties.ui.api.AbstractEEFTabbedPropertySheetPageContributorWrapper; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.forms.widgets.Form; + +/** + * This wrapper is used because the Sirius editors will not extend the interface + * from Eclipse EEF. + * + * @author sbegaudeau + */ +public class ContributorWrapper extends AbstractEEFTabbedPropertySheetPageContributorWrapper { + + /** + * The pattern used to separate a piece of text into an array containing all + * the lines of the text. + */ + private static final Pattern LINE_SEPARATOR_PATTERN = Pattern.compile("\r\n|\r|\n"); //$NON-NLS-1$ + + /** + * The constructor. + * + * @param realContributor + * The real contributor + * @param contributorId + * The contribution id + */ + public ContributorWrapper(Object realContributor, String contributorId) { + super(realContributor, contributorId); + } + + @Override + public void updateFormTitle(Form form, ISelection selection) { + if (selection instanceof IStructuredSelection) { + 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 SiriusToolServices().eefViewText(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]); + } + } + + form.setImage(ExtendedImageRegistry.INSTANCE.getImage(new SiriusToolServices().eefViewImage(semanticElement))); + } + } + } + +} diff --git a/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/EEFPropertySheetPageProvider.java b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/EEFPropertySheetPageProvider.java index ab7885c756..e15d2ab9f5 100644 --- a/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/EEFPropertySheetPageProvider.java +++ b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/EEFPropertySheetPageProvider.java @@ -44,7 +44,8 @@ public class EEFPropertySheetPageProvider implements ISiriusPropertySheetPagePro } } } - return new EEFTabbedPropertySheetPage(source, contributorId); + + return new EEFTabbedPropertySheetPage(new ContributorWrapper(source, contributorId)); } private boolean forcesLegacyPropertySheet(RepresentationDescription description) { diff --git a/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusToolServices.java b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusToolServices.java index d8cf7b2b7e..cd73c24587 100644 --- a/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusToolServices.java +++ b/plugins/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusToolServices.java @@ -67,7 +67,7 @@ public class SiriusToolServices { * @return The text representing the given EObject or <code>null</code> if * none could be found */ - public Object eefViewText(EObject eObject) { + public String eefViewText(EObject eObject) { return this.editServices.getLabelProviderText(eObject); } |
