Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2016-02-26 22:53:17 +0000
committerGerrit Code Review @ Eclipse.org2016-03-02 12:24:34 +0000
commite9bbbbcbef810b952d2c98caaa18d711eabd3a7f (patch)
tree01b7698fa73401e9b7e173cfb59b6d67d6f41202 /plugins/infra/core/org.eclipse.papyrus.infra.core/src/org
parent387194dfad69c05dae22afe2548109b267091ea1 (diff)
downloadorg.eclipse.papyrus-e9bbbbcbef810b952d2c98caaa18d711eabd3a7f.tar.gz
org.eclipse.papyrus-e9bbbbcbef810b952d2c98caaa18d711eabd3a7f.tar.xz
org.eclipse.papyrus-e9bbbbcbef810b952d2c98caaa18d711eabd3a7f.zip
Bug 474467: Papyrus editors title do not update when their label change
Add support for propagation of label-provider change events for labels that are dependent on other elements' labels. Implement such a dependent label for all notation views supported by the Viewpoints mechanism that have no names of their own, including * unnamed Diagrams * unnamed Tables Now that the table label provider depends on table prototypes, the broken prototype references in editor reload tests need to be updated (they were missed in the refactoring when all of the prototypes were removed from the builtin Viewpoints configuration model). Change-Id: I8a9c361129c996188f87ac2851db39e0f66f3acd
Diffstat (limited to 'plugins/infra/core/org.eclipse.papyrus.infra.core/src/org')
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/AbstractServiceUtils.java47
1 files changed, 44 insertions, 3 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/AbstractServiceUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/AbstractServiceUtils.java
index 54fd40a134c..5176b8d88d2 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/AbstractServiceUtils.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/AbstractServiceUtils.java
@@ -1,7 +1,6 @@
/*****************************************************************************
* Copyright (c) 2010, 2016 LIFL, CEA LIST, Christian W. Damus, and others.
*
- *
* 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
@@ -9,13 +8,14 @@
*
* Contributors:
* Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation
- * Christian W. Damus - bug 468030
- * Christian W. Damus - bug 485220
+ * Christian W. Damus - bugs 468030, 485220, 474467
*
*****************************************************************************/
package org.eclipse.papyrus.infra.core.utils;
+import java.util.Optional;
+
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.infra.core.Activator;
@@ -226,4 +226,45 @@ public abstract class AbstractServiceUtils<T> {
}
};
}
+
+ /**
+ * Attempts to obtain the service registry from the given context object.
+ *
+ * @param from
+ * the context object
+ * @return maybe the registry
+ *
+ * @since 2.0
+ */
+ protected Optional<ServicesRegistry> tryServiceRegistry(T from) {
+ try {
+ return Optional.ofNullable(getServiceRegistry(from));
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ return Optional.empty();
+ }
+ }
+
+ /**
+ * Attempts to obtain the requested from the registry associated with
+ * the given context object.
+ *
+ * @param from
+ * the context object
+ * @param serviceType
+ * the type of service to obtain
+ * @return maybe the service
+ *
+ * @since 2.0
+ */
+ public <S> Optional<S> tryService(T from, Class<S> serviceType) {
+ return tryServiceRegistry(from).map(services -> {
+ try {
+ return services.getService(serviceType);
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ return (S) null;
+ }
+ });
+ }
}

Back to the top