Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracuccuru2013-12-19 13:41:44 +0000
committeracuccuru2013-12-19 13:41:44 +0000
commitb8b97a6a0e2c4a557145befa1e08c7e57a9a85ee (patch)
tree227587f352325bb0e5882c058a0305232592340a /extraplugins/uml
parentd84e0078eda48d23a53f2f36009e2cf375f042d4 (diff)
downloadorg.eclipse.papyrus-b8b97a6a0e2c4a557145befa1e08c7e57a9a85ee.tar.gz
org.eclipse.papyrus-b8b97a6a0e2c4a557145befa1e08c7e57a9a85ee.tar.xz
org.eclipse.papyrus-b8b97a6a0e2c4a557145befa1e08c7e57a9a85ee.zip
First commit
Diffstat (limited to 'extraplugins/uml')
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.ui/src/org/eclipse/papyrus/uml/compare/ui/provider/SampleUMLProvider.java86
1 files changed, 86 insertions, 0 deletions
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.ui/src/org/eclipse/papyrus/uml/compare/ui/provider/SampleUMLProvider.java b/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.ui/src/org/eclipse/papyrus/uml/compare/ui/provider/SampleUMLProvider.java
new file mode 100644
index 00000000000..2cd609d7e36
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.ui/src/org/eclipse/papyrus/uml/compare/ui/provider/SampleUMLProvider.java
@@ -0,0 +1,86 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.compare.ui.provider;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.papyrus.infra.services.labelprovider.service.impl.LabelProviderServiceImpl;
+import org.eclipse.uml2.uml.edit.providers.UMLItemProviderAdapterFactory;
+import org.eclipse.uml2.uml.Element;
+
+
+
+public class SampleUMLProvider extends AdapterFactoryImpl {
+
+ /**
+ * The instance of the actual label provider
+ */
+ private LabelProviderAdapter instance = new LabelProviderAdapter();
+
+ /**
+ * The UMLItemProviderAdapterFactory to which production of IItemLabelProvider
+ * is delegated
+ */
+ private AdapterFactory delegate = new UMLItemProviderAdapterFactory();
+
+ /**
+ * Overrides AdapatFactoryImple.adapt so that, if the target element is an Element,
+ * and if the requested adaptation type is IItemLabelProvider,
+ * the production of the adapter is delegated to delegate.
+ *
+ * @see org.eclipse.emf.common.notify.impl.AdapterFactoryImpl#adapt(org.eclipse.emf.common.notify.Notifier, java.lang.Object)
+ */
+ @Override
+ public Adapter adapt(Notifier target, Object type) {
+ // Test on instance.isRunning to avoid a stack overflow
+ // Delegate to UML Item Label Provider
+ if (target instanceof Element && type == IItemLabelProvider.class){
+ if (! instance.isRunning){
+ return instance;
+ } else {
+ return delegate.adapt(target, type);
+ }
+ }
+ // FIXME Propose a more generic solution? (not bound directly to UML)
+ return super.adapt(target, type);
+ }
+
+ private class LabelProviderAdapter extends AdapterImpl implements IItemLabelProvider {
+
+ private boolean isRunning = false;
+
+ private LabelProviderService service = new LabelProviderServiceImpl();
+
+ public String getText(Object object) {
+ isRunning = true;
+ String result = service.getLabelProvider().getText(object);
+ isRunning = false;
+ return result;
+ }
+
+ public Object getImage(Object object) {
+ isRunning = true;
+ Object result = service.getLabelProvider().getImage(object);
+ isRunning = false;
+ return result;
+ }
+
+ };
+}

Back to the top