diff options
Diffstat (limited to 'plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet')
62 files changed, 5295 insertions, 5295 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/CustomizedContentProviderUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/CustomizedContentProviderUtils.java index d2742c1f0c9..29494fdac69 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/CustomizedContentProviderUtils.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/CustomizedContentProviderUtils.java @@ -1,77 +1,77 @@ -/*******************************************************************************
- * Copyright (c) 2012 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider
- * Nicolas Bros (Mia-Software) - Bug 380407 - Missing since tag on CustomizedContentProviderUtils
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.custom.ui;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EAttributeTreeElement;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EReferenceTreeElement;
-
-/**
- * A companion utility class for {@link ICustomizedTreeContentProvider}
- *
- * @since 0.2
- */
-public final class CustomizedContentProviderUtils {
- private CustomizedContentProviderUtils() {
- // utility class
- }
-
- /**
- * Replace proxy objects by their underlying model elements in the given selection
- *
- * @return the unwrapped version of the selection
- */
- public static ISelection resolveSelection(final ISelection selection) {
- Assert.isNotNull(selection);
- ISelection result;
- if (selection instanceof IStructuredSelection) {
- final IStructuredSelection strSelection = (IStructuredSelection) selection;
- final List<Object> resolvedElements = new ArrayList<Object>();
- final Iterator<?> iterator = strSelection.iterator();
- while (iterator.hasNext()) {
- final Object element = iterator.next();
- resolvedElements.add(resolve(element));
- }
- result = new StructuredSelection(resolvedElements);
- } else {
- throw new IllegalArgumentException("Unhandled selection type: " + selection.getClass().getName()); //$NON-NLS-1$
- }
- return result;
- }
-
- /**
- * Resolve the given UI element into the underlying model element.
- *
- * @param element
- * a UI element, that may be a proxy for a model element
- * @return the corresponding model element, or the given element if it is not a proxy
- */
- public static Object resolve(final Object element) {
- Object resolved = element;
- if (element instanceof EObjectTreeElement) {
- resolved = ((EObjectTreeElement) element).getEObject();
- } else if (element instanceof EAttributeTreeElement) {
- resolved = ((EAttributeTreeElement) element).getEAttribute();
- } else if (element instanceof EReferenceTreeElement) {
- resolved = ((EReferenceTreeElement) element).getEReference();
- }
- return resolved;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider + * Nicolas Bros (Mia-Software) - Bug 380407 - Missing since tag on CustomizedContentProviderUtils + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.custom.ui; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EAttributeTreeElement; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EReferenceTreeElement; + +/** + * A companion utility class for {@link ICustomizedTreeContentProvider} + * + * @since 0.2 + */ +public final class CustomizedContentProviderUtils { + private CustomizedContentProviderUtils() { + // utility class + } + + /** + * Replace proxy objects by their underlying model elements in the given selection + * + * @return the unwrapped version of the selection + */ + public static ISelection resolveSelection(final ISelection selection) { + Assert.isNotNull(selection); + ISelection result; + if (selection instanceof IStructuredSelection) { + final IStructuredSelection strSelection = (IStructuredSelection) selection; + final List<Object> resolvedElements = new ArrayList<Object>(); + final Iterator<?> iterator = strSelection.iterator(); + while (iterator.hasNext()) { + final Object element = iterator.next(); + resolvedElements.add(resolve(element)); + } + result = new StructuredSelection(resolvedElements); + } else { + throw new IllegalArgumentException("Unhandled selection type: " + selection.getClass().getName()); //$NON-NLS-1$ + } + return result; + } + + /** + * Resolve the given UI element into the underlying model element. + * + * @param element + * a UI element, that may be a proxy for a model element + * @return the corresponding model element, or the given element if it is not a proxy + */ + public static Object resolve(final Object element) { + Object resolved = element; + if (element instanceof EObjectTreeElement) { + resolved = ((EObjectTreeElement) element).getEObject(); + } else if (element instanceof EAttributeTreeElement) { + resolved = ((EAttributeTreeElement) element).getEAttribute(); + } else if (element instanceof EReferenceTreeElement) { + resolved = ((EReferenceTreeElement) element).getEReference(); + } + return resolved; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IContentPropertiesHandler.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IContentPropertiesHandler.java index 6ae256b8abf..4b513772626 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IContentPropertiesHandler.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IContentPropertiesHandler.java @@ -1,54 +1,54 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.custom.ui;
-
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-
-/**
- *
- * @since 0.2
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface IContentPropertiesHandler {
-
- /**
- * The isVisible customization operation
- *
- * Since Papyrus 1.2.0, this operation is only used for Objects (Not Features)
- *
- * @return
- */
- FacetOperation getIsVisible();
-
- /**
- * Return the collapseLink customization operation
- *
- * @return
- */
- public FacetOperation getCollapseLink();
-
- /**
- * Return the getVisibleAttributes customization operation
- *
- * @return
- */
- public FacetOperation getVisibleAttributes();
-
- /**
- * Return the getVisibleReferences customization operation
- *
- * @return
- */
- public FacetOperation getVisibleReferences();
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.custom.ui; + +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; + +/** + * + * @since 0.2 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface IContentPropertiesHandler { + + /** + * The isVisible customization operation + * + * Since Papyrus 1.2.0, this operation is only used for Objects (Not Features) + * + * @return + */ + FacetOperation getIsVisible(); + + /** + * Return the collapseLink customization operation + * + * @return + */ + public FacetOperation getCollapseLink(); + + /** + * Return the getVisibleAttributes customization operation + * + * @return + */ + public FacetOperation getVisibleAttributes(); + + /** + * Return the getVisibleReferences customization operation + * + * @return + */ + public FacetOperation getVisibleReferences(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IContentPropertiesHandlerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IContentPropertiesHandlerFactory.java index 2974daa3335..f3e2f25aea2 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IContentPropertiesHandlerFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IContentPropertiesHandlerFactory.java @@ -1,30 +1,30 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.custom.ui;
-
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.PropertiesHandlerFactory;
-
-/**
- *
- * @since 0.2
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface IContentPropertiesHandlerFactory {
-
- IContentPropertiesHandlerFactory DEFAULT = new PropertiesHandlerFactory();
-
- IContentPropertiesHandler createIContentPropertiesHandler(
- ICustomizationManager customizationMgr);
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.custom.ui; + +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.PropertiesHandlerFactory; + +/** + * + * @since 0.2 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface IContentPropertiesHandlerFactory { + + IContentPropertiesHandlerFactory DEFAULT = new PropertiesHandlerFactory(); + + IContentPropertiesHandler createIContentPropertiesHandler( + ICustomizationManager customizationMgr); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomOverride.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomOverride.java index b9b74222e33..8342e6d3df6 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomOverride.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomOverride.java @@ -1,31 +1,31 @@ -/**
- * Copyright (c) 2013 Soft-Maint.
- *
- * 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:
- * David Couvrand (Soft-Maint) - Bug 422058 - Implementation of strikethrough and underline in the CustomizedLabelProvider
- */
-package org.eclipse.papyrus.emf.facet.custom.ui;
-
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.core.exception.CustomizationException;
-import org.eclipse.swt.graphics.FontData;
-
-/**
- * @since 0.4
- */
-public interface ICustomOverride {
-
- String getText(String result, Object object,
- ICustomizationManager customManager,
- IFontPropertiesHandler propertiesHandler) throws CustomizationException;
-
- FontData getFont(FontData fontData, Object object,
- ICustomizationManager customManager,
- IFontPropertiesHandler propertiesHandler) throws CustomizationException;
-
-}
+/** + * Copyright (c) 2013 Soft-Maint. + * + * 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: + * David Couvrand (Soft-Maint) - Bug 422058 - Implementation of strikethrough and underline in the CustomizedLabelProvider + */ +package org.eclipse.papyrus.emf.facet.custom.ui; + +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.core.exception.CustomizationException; +import org.eclipse.swt.graphics.FontData; + +/** + * @since 0.4 + */ +public interface ICustomOverride { + + String getText(String result, Object object, + ICustomizationManager customManager, + IFontPropertiesHandler propertiesHandler) throws CustomizationException; + + FontData getFont(FontData fontData, Object object, + ICustomizationManager customManager, + IFontPropertiesHandler propertiesHandler) throws CustomizationException; + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedContentProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedContentProvider.java index c4584e9cbdc..694d8caca84 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedContentProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedContentProvider.java @@ -1,36 +1,36 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.custom.ui;
-
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-
-/**
- * This interface allow to used a {@link IContentProvider} which is implemented
- * and customizable using the EMF Facet customization mechanism.
- *
- * @author Gregoire Dupe
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @deprecated use {@link ICustomizedTreeContentProvider} (Bug 380229 - [deprecated] ICustomizedContentProvider)
- */
-@Deprecated
-public interface ICustomizedContentProvider extends IContentProvider {
- /**
- * This method returns the customization manager used by the content provider. The
- * customization stack update have to be done using this {@link ICustomizationManager}.
- *
- * @return the customization manager used by the content provider.
- */
- ICustomizationManager getCustomizationManager();
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.custom.ui; + +import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; + +/** + * This interface allow to used a {@link IContentProvider} which is implemented + * and customizable using the EMF Facet customization mechanism. + * + * @author Gregoire Dupe + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @deprecated use {@link ICustomizedTreeContentProvider} (Bug 380229 - [deprecated] ICustomizedContentProvider) + */ +@Deprecated +public interface ICustomizedContentProvider extends IContentProvider { + /** + * This method returns the customization manager used by the content provider. The + * customization stack update have to be done using this {@link ICustomizationManager}. + * + * @return the customization manager used by the content provider. + */ + ICustomizationManager getCustomizationManager(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedContentProviderFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedContentProviderFactory.java index 95da42c8c7c..d0bad7c5524 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedContentProviderFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedContentProviderFactory.java @@ -1,54 +1,54 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Mia-Software.
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider
- *******************************************************************************/
-
-package org.eclipse.papyrus.emf.facet.custom.ui;
-
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.CustomizedContentProviderFactory;
-
-/**
- * This is a factory for {@link ICustomizedContentProvider} and {@link ICustomizedTreeContentProvider}.
- *
- * @author Gregoire Dupe
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- *
- */
-public interface ICustomizedContentProviderFactory {
- /**
- * The default factory instance
- */
- ICustomizedContentProviderFactory DEFAULT = new CustomizedContentProviderFactory();
-
- /**
- * This method is used to instantiate a {@link ICustomizedContentProvider}
- *
- * @param customizationMgr
- * the customization manager which has to be used by the content provider.
- * @return a content provider
- * @deprecated Bug 380229 - [deprecated] ICustomizedContentProvider
- */
- @Deprecated
- ICustomizedContentProvider createCustomizedContentProvider(ICustomizationManager customizationMgr);
-
- /**
- * Instantiate an {@link ICustomizedTreeContentProvider}. With this content provider, your viewer's input has to be
- * an EObject or an array or collection of EObjects.F
- *
- * @param customManager
- * the customization manager used by the content provider
- * @return a tree content provider
- * @since 0.2
- */
- ICustomizedTreeContentProvider createCustomizedTreeContentProvider(ICustomizationManager customManager);
-}
+/******************************************************************************* + * Copyright (c) 2011, 2012 Mia-Software. + * 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: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider + *******************************************************************************/ + +package org.eclipse.papyrus.emf.facet.custom.ui; + +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.CustomizedContentProviderFactory; + +/** + * This is a factory for {@link ICustomizedContentProvider} and {@link ICustomizedTreeContentProvider}. + * + * @author Gregoire Dupe + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * + */ +public interface ICustomizedContentProviderFactory { + /** + * The default factory instance + */ + ICustomizedContentProviderFactory DEFAULT = new CustomizedContentProviderFactory(); + + /** + * This method is used to instantiate a {@link ICustomizedContentProvider} + * + * @param customizationMgr + * the customization manager which has to be used by the content provider. + * @return a content provider + * @deprecated Bug 380229 - [deprecated] ICustomizedContentProvider + */ + @Deprecated + ICustomizedContentProvider createCustomizedContentProvider(ICustomizationManager customizationMgr); + + /** + * Instantiate an {@link ICustomizedTreeContentProvider}. With this content provider, your viewer's input has to be + * an EObject or an array or collection of EObjects.F + * + * @param customManager + * the customization manager used by the content provider + * @return a tree content provider + * @since 0.2 + */ + ICustomizedTreeContentProvider createCustomizedTreeContentProvider(ICustomizationManager customManager); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedLabelProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedLabelProvider.java index 38e3c025f97..75d43262ea4 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedLabelProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedLabelProvider.java @@ -1,91 +1,91 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - implementation of IStyledLabelProvider
- */
-package org.eclipse.papyrus.emf.facet.custom.ui;
-
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
-import org.eclipse.jface.viewers.IColorProvider;
-import org.eclipse.jface.viewers.IFontProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.StyledString;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * This interface allows to use a {@link ILabelProvider}, an {@link IColorProvider} and an {@link IFontProvider} which is implemented and
- * customizable using the EMF Facet customization mechanism.
- *
- * @author Gregoire Dupe
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ICustomizedLabelProvider extends ILabelProvider,
- IColorProvider, IFontProvider, ICustomizedToolTipLabelProvider, IStyledLabelProvider {
- /**
- * This method returns the customization manager used by the label provider. The
- * customization stack updates have to be done using this {@link ICustomizationManager}.
- *
- * @return the customization manager used by the content provider.
- */
- ICustomizationManager getCustomizationManager();
-
- boolean isUnderlined(Object element, ETypedElement eTypedElement);
-
- boolean isStruckthrough(Object element, ETypedElement eTypedElement);
-
- Image getTopLeftOverlay(Object element, ETypedElement eTypedElement);
-
- Image getTopMiddleOverlay(Object element, ETypedElement eTypedElement);
-
- Image getTopRightOverlay(Object element, ETypedElement eTypedElement);
-
- Image getBottomLeftOverlay(Object element, ETypedElement eTypedElement);
-
- Image getBottomMiddleOverlay(Object element, ETypedElement eTypedElement);
-
- Image getBottomRightOverlay(Object element, ETypedElement eTypedElement);
-
- String getText(Object element, ETypedElement eTypedElement);
-
- Image getImage(Object element, ETypedElement eTypedElement);
-
- /**
- * @since 0.2
- */
- ICustomizedLabelProvider cloneLabelProvider();
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
- *
- * @since 3.0
- */
- @Override
- default StyledString getStyledText(final Object element) {
- return new StyledString(getText(element));
- }
-
- /**
- * Returns the styled text label for the given element.
- *
- * @since 3.0
- */
- default StyledString getStyledText(final Object element, final ETypedElement eTypedElement) {
- return new StyledString(getText(element, eTypedElement));
- }
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - implementation of IStyledLabelProvider + */ +package org.eclipse.papyrus.emf.facet.custom.ui; + +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; +import org.eclipse.jface.viewers.IColorProvider; +import org.eclipse.jface.viewers.IFontProvider; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.StyledString; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.swt.graphics.Image; + +/** + * This interface allows to use a {@link ILabelProvider}, an {@link IColorProvider} and an {@link IFontProvider} which is implemented and + * customizable using the EMF Facet customization mechanism. + * + * @author Gregoire Dupe + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ICustomizedLabelProvider extends ILabelProvider, + IColorProvider, IFontProvider, ICustomizedToolTipLabelProvider, IStyledLabelProvider { + /** + * This method returns the customization manager used by the label provider. The + * customization stack updates have to be done using this {@link ICustomizationManager}. + * + * @return the customization manager used by the content provider. + */ + ICustomizationManager getCustomizationManager(); + + boolean isUnderlined(Object element, ETypedElement eTypedElement); + + boolean isStruckthrough(Object element, ETypedElement eTypedElement); + + Image getTopLeftOverlay(Object element, ETypedElement eTypedElement); + + Image getTopMiddleOverlay(Object element, ETypedElement eTypedElement); + + Image getTopRightOverlay(Object element, ETypedElement eTypedElement); + + Image getBottomLeftOverlay(Object element, ETypedElement eTypedElement); + + Image getBottomMiddleOverlay(Object element, ETypedElement eTypedElement); + + Image getBottomRightOverlay(Object element, ETypedElement eTypedElement); + + String getText(Object element, ETypedElement eTypedElement); + + Image getImage(Object element, ETypedElement eTypedElement); + + /** + * @since 0.2 + */ + ICustomizedLabelProvider cloneLabelProvider(); + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object) + * + * @since 3.0 + */ + @Override + default StyledString getStyledText(final Object element) { + return new StyledString(getText(element)); + } + + /** + * Returns the styled text label for the given element. + * + * @since 3.0 + */ + default StyledString getStyledText(final Object element, final ETypedElement eTypedElement) { + return new StyledString(getText(element, eTypedElement)); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedLabelProviderFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedLabelProviderFactory.java index 323527db570..6fca4457e95 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedLabelProviderFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedLabelProviderFactory.java @@ -1,38 +1,38 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.custom.ui;
-
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.CustomizedLabelProviderFactory;
-
-/**
- * This class is the factory allowing to get a instance of {@link ICustomizedLabelProvider}.
- *
- * @author Gregoire Dupe
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ICustomizedLabelProviderFactory {
- ICustomizedLabelProviderFactory DEFAULT = new CustomizedLabelProviderFactory();
-
- /**
- * This method is used to instantiate a {@link ICustomizedLabelProvider}.
- *
- * @param customizationManager
- * the customization manager which has to used by the content
- * provider.
- * @return a label provider
- */
- ICustomizedLabelProvider createCustomizedLabelProvider(
- ICustomizationManager customizationMgr);
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.custom.ui; + +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.CustomizedLabelProviderFactory; + +/** + * This class is the factory allowing to get a instance of {@link ICustomizedLabelProvider}. + * + * @author Gregoire Dupe + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ICustomizedLabelProviderFactory { + ICustomizedLabelProviderFactory DEFAULT = new CustomizedLabelProviderFactory(); + + /** + * This method is used to instantiate a {@link ICustomizedLabelProvider}. + * + * @param customizationManager + * the customization manager which has to used by the content + * provider. + * @return a label provider + */ + ICustomizedLabelProvider createCustomizedLabelProvider( + ICustomizationManager customizationMgr); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedToolTipLabelProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedToolTipLabelProvider.java index 5390d6e6207..880de4f3abf 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedToolTipLabelProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedToolTipLabelProvider.java @@ -1,68 +1,68 @@ -/**
- * Copyright (c) 2012 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:
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.custom.ui;
-
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-
-/**
- *
- * This interface provides methods to customize tooltips
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ICustomizedToolTipLabelProvider {
-
- void update(ViewerCell cell);
-
- String getToolTipText(Object element, ETypedElement eTypedElement);
-
- Image getToolTipImage(Object element, ETypedElement eTypedElement);
-
- Font getToolTipFont(Object element, ETypedElement eTypedElement);
-
- Color getToolTipBackgroundColor(Object element, ETypedElement eTypedElement);
-
- Color getToolTipForegroundColor(Object element, ETypedElement eTypedElement);
-
- Image getToolTipTopLeftOverlay(Object element, ETypedElement eTypedElement);
-
- Image getToolTipTopMiddleOverlay(Object element, ETypedElement eTypedElement);
-
- Image getToolTipTopRightOverlay(Object element, ETypedElement eTypedElement);
-
- Image getToolTipBottomLeftOverlay(Object element,
- ETypedElement eTypedElement);
-
- Image getToolTipBottomMiddleOverlay(Object element,
- ETypedElement eTypedElement);
-
- Image getToolTipBottomRightOverlay(Object element,
- ETypedElement eTypedElement);
-
- int getToolTipTimeDisplayed(Object element, ETypedElement eTypedElement);
-
- int getToolTipDisplayDelayTime(Object element, ETypedElement eTypedElement);
-
- /**
- * The style can be : SWT.LEFT, SWT.CENTER, SWT.RIGHT, SWT.SHADOW_IN, SWT.SHADOW_OUT, SWT.SHADOW_NONE.
- *
- * @param element
- * @return
- */
- int getToolTipStyle(Object element, ETypedElement eTypedElement);
-}
+/** + * Copyright (c) 2012 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: + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.custom.ui; + +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.jface.viewers.ViewerCell; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; + +/** + * + * This interface provides methods to customize tooltips + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ICustomizedToolTipLabelProvider { + + void update(ViewerCell cell); + + String getToolTipText(Object element, ETypedElement eTypedElement); + + Image getToolTipImage(Object element, ETypedElement eTypedElement); + + Font getToolTipFont(Object element, ETypedElement eTypedElement); + + Color getToolTipBackgroundColor(Object element, ETypedElement eTypedElement); + + Color getToolTipForegroundColor(Object element, ETypedElement eTypedElement); + + Image getToolTipTopLeftOverlay(Object element, ETypedElement eTypedElement); + + Image getToolTipTopMiddleOverlay(Object element, ETypedElement eTypedElement); + + Image getToolTipTopRightOverlay(Object element, ETypedElement eTypedElement); + + Image getToolTipBottomLeftOverlay(Object element, + ETypedElement eTypedElement); + + Image getToolTipBottomMiddleOverlay(Object element, + ETypedElement eTypedElement); + + Image getToolTipBottomRightOverlay(Object element, + ETypedElement eTypedElement); + + int getToolTipTimeDisplayed(Object element, ETypedElement eTypedElement); + + int getToolTipDisplayDelayTime(Object element, ETypedElement eTypedElement); + + /** + * The style can be : SWT.LEFT, SWT.CENTER, SWT.RIGHT, SWT.SHADOW_IN, SWT.SHADOW_OUT, SWT.SHADOW_NONE. + * + * @param element + * @return + */ + int getToolTipStyle(Object element, ETypedElement eTypedElement); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedTreeContentProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedTreeContentProvider.java index ffee6560d31..44bcc51621e 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedTreeContentProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ICustomizedTreeContentProvider.java @@ -1,31 +1,31 @@ -/*******************************************************************************
- * Copyright (c) 2012 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.custom.ui;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-
-/**
- * An {@link ITreeContentProvider} which is implemented and customizable using the EMF Facet customization mechanisms.
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @since 0.2
- */
-public interface ICustomizedTreeContentProvider extends ITreeContentProvider {
- /**
- * This method returns the customization manager used by the content provider. Updates to the list of loaded
- * customizations have to be done using the {@link ICustomizationManager} returned by this method.
- *
- * @return the customization manager used by this content provider.
- */
- ICustomizationManager getCustomizationManager();
-}
+/******************************************************************************* + * Copyright (c) 2012 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.custom.ui; + +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; + +/** + * An {@link ITreeContentProvider} which is implemented and customizable using the EMF Facet customization mechanisms. + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @since 0.2 + */ +public interface ICustomizedTreeContentProvider extends ITreeContentProvider { + /** + * This method returns the customization manager used by the content provider. Updates to the list of loaded + * customizations have to be done using the {@link ICustomizationManager} returned by this method. + * + * @return the customization manager used by this content provider. + */ + ICustomizationManager getCustomizationManager(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IFontPropertiesHandler.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IFontPropertiesHandler.java index c00476f017e..a909beb1971 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IFontPropertiesHandler.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IFontPropertiesHandler.java @@ -1,38 +1,38 @@ -/**
- * Copyright (c) 2013 Soft-Maint.
- *
- * 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:
- * David Couvrand (Soft-Maint) - Bug 422058 - Implementation of strikethrough and underline in the CustomizedLabelProvider
- */
-package org.eclipse.papyrus.emf.facet.custom.ui;
-
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-
-/**
- * @since 0.4
- */
-public interface IFontPropertiesHandler {
-
- FacetOperation getBackgroundProperty();
-
- FacetOperation getForegroundProperty();
-
- FacetOperation getFontNameProperty();
-
- FacetOperation getFontSizeProperty();
-
- FacetOperation getIsBoldProperty();
-
- FacetOperation getIsItalicProperty();
-
- FacetOperation getIsVisible();
-
- FacetOperation getIsUnderlinedProperty();
-
- FacetOperation getIsStruckthroughProperty();
-}
+/** + * Copyright (c) 2013 Soft-Maint. + * + * 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: + * David Couvrand (Soft-Maint) - Bug 422058 - Implementation of strikethrough and underline in the CustomizedLabelProvider + */ +package org.eclipse.papyrus.emf.facet.custom.ui; + +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; + +/** + * @since 0.4 + */ +public interface IFontPropertiesHandler { + + FacetOperation getBackgroundProperty(); + + FacetOperation getForegroundProperty(); + + FacetOperation getFontNameProperty(); + + FacetOperation getFontSizeProperty(); + + FacetOperation getIsBoldProperty(); + + FacetOperation getIsItalicProperty(); + + FacetOperation getIsVisible(); + + FacetOperation getIsUnderlinedProperty(); + + FacetOperation getIsStruckthroughProperty(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IResolvingCustomizedLabelProviderFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IResolvingCustomizedLabelProviderFactory.java index 710933e217c..01d5f9278d5 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IResolvingCustomizedLabelProviderFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/IResolvingCustomizedLabelProviderFactory.java @@ -1,35 +1,35 @@ -/*******************************************************************************
- * Copyright (c) 2012 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.custom.ui;
-
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.ResolvingCustomizedLabelProviderFactory;
-
-/**
- * A factory to create instances of {@link ICustomizedLabelProvider} that work on proxy UI elements, by customizing the
- * resolved elements.
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @since 0.2
- */
-public interface IResolvingCustomizedLabelProviderFactory {
- IResolvingCustomizedLabelProviderFactory DEFAULT = new ResolvingCustomizedLabelProviderFactory();
-
- /**
- * This method is used to instantiate a {@link ICustomizedLabelProvider}.
- *
- * @param customizationManager
- * the customization manager which has to used by the content provider.
- * @return a label provider
- */
- ICustomizedLabelProvider createCustomizedLabelProvider(ICustomizationManager customizationMgr);
-}
+/******************************************************************************* + * Copyright (c) 2012 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.custom.ui; + +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.ResolvingCustomizedLabelProviderFactory; + +/** + * A factory to create instances of {@link ICustomizedLabelProvider} that work on proxy UI elements, by customizing the + * resolved elements. + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @since 0.2 + */ +public interface IResolvingCustomizedLabelProviderFactory { + IResolvingCustomizedLabelProviderFactory DEFAULT = new ResolvingCustomizedLabelProviderFactory(); + + /** + * This method is used to instantiate a {@link ICustomizedLabelProvider}. + * + * @param customizationManager + * the customization manager which has to used by the content provider. + * @return a label provider + */ + ICustomizedLabelProvider createCustomizedLabelProvider(ICustomizationManager customizationMgr); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ISelectionPropertiesHandler.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ISelectionPropertiesHandler.java index 06b72ce4a92..9d38a79b1b1 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ISelectionPropertiesHandler.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ISelectionPropertiesHandler.java @@ -1,24 +1,24 @@ -/*******************************************************************************
- * Copyright (c) 2012 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - Bug 377866 - selection customization
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.custom.ui;
-
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-
-/**
- *
- * @since 0.2
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ISelectionPropertiesHandler {
- /** This customization property returns the selection for a given source EObject and a given ETypedElement parameter */
- FacetOperation getSelectionProperty();
-}
+/******************************************************************************* + * Copyright (c) 2012 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - Bug 377866 - selection customization + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.custom.ui; + +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; + +/** + * + * @since 0.2 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ISelectionPropertiesHandler { + /** This customization property returns the selection for a given source EObject and a given ETypedElement parameter */ + FacetOperation getSelectionProperty(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ISelectionPropertiesHandlerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ISelectionPropertiesHandlerFactory.java index 2d069557554..3263e42c605 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ISelectionPropertiesHandlerFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/ISelectionPropertiesHandlerFactory.java @@ -1,29 +1,29 @@ -/*******************************************************************************
- * Copyright (c) 2012 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - Bug 377866 - selection customization
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.custom.ui;
-
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.PropertiesHandlerFactory;
-
-/**
- * Factory for {@link ISelectionPropertiesHandler}
- *
- * @since 0.2
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ISelectionPropertiesHandlerFactory {
-
- ISelectionPropertiesHandlerFactory DEFAULT = new PropertiesHandlerFactory();
-
- ISelectionPropertiesHandler createSelectionPropertiesHandler(
- ICustomizationManager customManager);
-}
+/******************************************************************************* + * Copyright (c) 2012 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - Bug 377866 - selection customization + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.custom.ui; + +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.PropertiesHandlerFactory; + +/** + * Factory for {@link ISelectionPropertiesHandler} + * + * @since 0.2 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ISelectionPropertiesHandlerFactory { + + ISelectionPropertiesHandlerFactory DEFAULT = new PropertiesHandlerFactory(); + + ISelectionPropertiesHandler createSelectionPropertiesHandler( + ICustomizationManager customManager); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/Activator.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/Activator.java index ea513089256..16d2c34a0da 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/Activator.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/Activator.java @@ -1,65 +1,65 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal;
-
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.papyrus.emf.facet.custom.ui"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(final BundleContext context) throws Exception {
- super.start(context);
- Activator.plugin = this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(final BundleContext context) throws Exception {
- Activator.plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return Activator.plugin;
- }
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.papyrus.emf.facet.custom.ui"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(final BundleContext context) throws Exception { + super.start(context); + Activator.plugin = this; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(final BundleContext context) throws Exception { + Activator.plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return Activator.plugin; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizationCommandFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizationCommandFactory.java index 1e3d5c88a49..1ddbaf520be 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizationCommandFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizationCommandFactory.java @@ -1,247 +1,247 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Nicolas Bros (Mia-Software) - Bug 378271 - [Table] Select Columns To Hide is broken
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EParameter;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.CustomFactory;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.CustomPackage;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.EClassCustomization;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementCase;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementSwitchQuery;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.FacetCustomization;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.exception.CustomizationEditRuntimeException;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.ICustomizationCommandFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.EFacetFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.EFacetPackage;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.util.emf.core.command.ICommandFactoryResult;
-import org.eclipse.papyrus.emf.facet.util.emf.core.command.ICommandFactoryResultFactory;
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.exported.ICommandFactory;
-
-public class CustomizationCommandFactory implements ICustomizationCommandFactory {
-
- private static final String CONFORM_ATT_NAME = "isConforming"; //$NON-NLS-1$
- private final EditingDomain editingDomain;
- private final ICommandFactory commandFactory;
-
- public CustomizationCommandFactory(final EditingDomain editingDomain, final ICommandFactory commandFactory) {
- this.editingDomain = editingDomain;
- this.commandFactory = commandFactory;
- }
-
- public ICommandFactoryResult<EClassCustomization> createEClassCustomization(
- final Customization customization, final EClass customedEClass,
- final Query conformanceQuery) {
- final EClassCustomization eClassCustom = CustomFactory.eINSTANCE.createEClassCustomization();
- final CompoundCommand resultCmd = new CompoundCommand(
- "Create one instance of EClassCustomization for " + customedEClass.getName()); //$NON-NLS-1$
- final Command linkToContainer = this.commandFactory
- .createAddCommand(
- this.editingDomain,
- customization,
- EcorePackage.eINSTANCE
- .getEPackage_EClassifiers(),
- eClassCustom);
- resultCmd.append(linkToContainer);
- final Command linkToEClass = this.commandFactory
- .createSetCommand(
- this.editingDomain,
- eClassCustom,
- EFacetPackage.eINSTANCE
- .getFacet_ExtendedMetaclass(),
- customedEClass);
- resultCmd.append(linkToEClass);
- if (conformanceQuery != null) {
- final ICommandFactoryResult<FacetAttribute> attResult = createConformanceOperation(eClassCustom, conformanceQuery);
- resultCmd.append(attResult.getCommand());
- }
-
- return ICommandFactoryResultFactory.DEFAULT.createCommandFactoryResult(resultCmd, eClassCustom);
- }
-
- // TODO Move to FacetCommandFactory
- private ICommandFactoryResult<FacetAttribute> createConformanceOperation(final Facet facet, final Query query) {
- final CompoundCommand resultCmd = new CompoundCommand("Creates a facet conformance attribute"); //$NON-NLS-1$
- final FacetAttribute conformanceAtt = EFacetFactory.eINSTANCE.createFacetAttribute();
- conformanceAtt.setName(CustomizationCommandFactory.CONFORM_ATT_NAME);
- conformanceAtt.setEType(EcorePackage.eINSTANCE.getEBoolean());
- conformanceAtt.setQuery(query);
- conformanceAtt.setDerived(true);
-
- final Command conformance = this.commandFactory.createSetCommand(this.editingDomain, facet, EFacetPackage.eINSTANCE.getFacet_ConformanceTypedElement(), conformanceAtt);
- resultCmd.append(conformance);
- final Command addToFacet = this.commandFactory.createAddCommand(this.editingDomain, facet, EFacetPackage.eINSTANCE.getFacet_FacetElements(), conformanceAtt);
- resultCmd.append(addToFacet);
- return ICommandFactoryResultFactory.DEFAULT.createCommandFactoryResult(resultCmd, conformanceAtt);
- }
-
- public ICommandFactoryResult<FacetCustomization> createFacetCustomization(
- final Customization customization, final Facet customizedFacet) {
- final FacetCustomization eFacetCustom = CustomFactory.eINSTANCE.createFacetCustomization();
- final CompoundCommand resultCmd = new CompoundCommand(
- "Create one instance of FacetCustomization for " + customizedFacet.getName()); //$NON-NLS-1$
- final Command linkToContainer = this.commandFactory
- .createAddCommand(this.editingDomain, customization,
- EcorePackage.eINSTANCE.getEPackage_EClassifiers(),
- eFacetCustom);
- resultCmd.append(linkToContainer);
- final Command linkToFacet = this.commandFactory
- .createAddCommand(
- this.editingDomain,
- customization,
- CustomPackage.eINSTANCE
- .getFacetCustomization_CustomizedFacet(),
- customizedFacet);
- resultCmd.append(linkToFacet);
- return ICommandFactoryResultFactory.DEFAULT.createCommandFactoryResult(resultCmd, eFacetCustom);
- }
-
- public ICommandFactoryResult<Facet> setPropertyConfig(
- final Facet typeCustomization,
- final ETypedElement customizedTElt, // customized typed element
- final FacetOperation customProperty, final Query query) {
- final CompoundCommand resultCmd = new CompoundCommand(
- "Set the value of the customization property '" + customProperty.getName() + "'"); //$NON-NLS-1$ //$NON-NLS-2$
- FacetOperation fOpToModifiy = null; // Facet operation to modify
- for (FacetOperation facetOperation : typeCustomization
- .getFacetOperations()) {
- if (facetOperation.getOverride().equals(customProperty)) {
- fOpToModifiy = facetOperation;
- }
- }
- if (fOpToModifiy == null) {
- createPropertySetting(typeCustomization, customizedTElt,
- customProperty, query, resultCmd);
- } else {
- final Query fOpQuery = fOpToModifiy.getQuery();
- if (fOpQuery instanceof ETypedElementSwitchQuery) {
- final ETypedElementSwitchQuery switchQuery = (ETypedElementSwitchQuery) fOpQuery;
- final Command setCase = setOrCreateETypedElementCase(switchQuery, customizedTElt, query);
- resultCmd.append(setCase);
- } else {
- throw new CustomizationEditRuntimeException();
- }
- }
- return ICommandFactoryResultFactory.DEFAULT.createCommandFactoryResult(resultCmd, typeCustomization);
- }
-
- private void createPropertySetting(
- final Facet typeCustomization,
- final ETypedElement customizedTElt,
- final FacetOperation customProperty, final Query query,
- final CompoundCommand resultCmd) {
- FacetOperation facetOperation = EFacetFactory.eINSTANCE.createFacetOperation();
- // link the instance of FacetOperation to its parent
- final Command linkFOpToParent = this.commandFactory.createAddCommand(
- this.editingDomain, typeCustomization,
- EFacetPackage.eINSTANCE.getFacet_FacetOperations(),
- facetOperation);
- resultCmd.append(linkFOpToParent);
- // Link the instance of FacetOperation to the overridden custom property operation.
- final Command linkToOverride = this.commandFactory.createSetCommand(
- this.editingDomain, facetOperation,
- EFacetPackage.eINSTANCE.getDerivedTypedElement_Override(),
- customProperty);
- resultCmd.append(linkToOverride);
- facetOperation.setName(customProperty.getName());
- facetOperation.setEType(customProperty.getEType());
- facetOperation.setLowerBound(customProperty.getLowerBound());
- facetOperation.setUpperBound(customProperty.getUpperBound());
-
- // add the "eStructuralFeature" EParameter that every customization operation must have
- final EParameter eParameter = EcoreFactory.eINSTANCE.createEParameter();
- eParameter.setName("eStructuralFeature"); //$NON-NLS-1$
- eParameter.setEType(EcorePackage.eINSTANCE.getETypedElement());
- facetOperation.getEParameters().add(eParameter);
-
- final ETypedElementSwitchQuery switchQuery = CustomFactory.eINSTANCE.createETypedElementSwitchQuery();
- // Link the instance of ETypedElementSwitchQuery to its parent
- final Command switchToParent = this.commandFactory
- .createSetCommand(this.editingDomain, facetOperation,
- EFacetPackage.eINSTANCE
- .getDerivedTypedElement_Query(),
- switchQuery);
- resultCmd.append(switchToParent);
- final Command setCase = setOrCreateETypedElementCase(switchQuery, customizedTElt, query);
- resultCmd.append(setCase);
- }
-
- private Command setOrCreateETypedElementCase(
- final ETypedElementSwitchQuery switchQuery,
- final ETypedElement customizedTElt, final Query query) {
- final CompoundCommand resultCmd = new CompoundCommand("Set or create an instance of ETypedElementCase"); //$NON-NLS-1$
- ETypedElementCase caseToModify = getCaseByETypedElement(switchQuery, customizedTElt);
- if (caseToModify == null) {
- caseToModify = CustomFactory.eINSTANCE.createETypedElementCase();
- final Command linkToParent = this.commandFactory.createAddCommand(
- this.editingDomain, switchQuery,
- CustomPackage.eINSTANCE.getETypedElementSwitchQuery_Cases(),
- caseToModify);
- resultCmd.append(linkToParent);
- }
- final Command setCase = this.commandFactory.createSetCommand(
- this.editingDomain, caseToModify,
- CustomPackage.eINSTANCE.getETypedElementCase_Case(),
- customizedTElt);
- resultCmd.append(setCase);
- final Command setQuery = this.commandFactory.createSetCommand(
- this.editingDomain, caseToModify,
- CustomPackage.eINSTANCE.getETypedElementCase_Value(),
- query);
- resultCmd.append(setQuery);
- return resultCmd;
- }
-
- private static ETypedElementCase getCaseByETypedElement(
- final ETypedElementSwitchQuery switchQuery,
- final ETypedElement customizedTElt) {
- ETypedElementCase caseToModify = null;
- for (ETypedElementCase casee : switchQuery.getCases()) {
- // casee has to be null if we want to customize the EObject itself.
- if (casee.getCase() == null) {
- if (customizedTElt == null) {
- caseToModify = casee;
- }
- } else {
- if (casee.getCase().equals(customizedTElt)) {
- caseToModify = casee;
- break;
- }
- }
- }
- return caseToModify;
- }
-
- public ICommandFactoryResult<Customization> createCustomization(
- final String name) {
- final Customization customization = CustomFactory.eINSTANCE
- .createCustomization();
- final Command setName = this.commandFactory.createSetCommand(
- this.editingDomain, customization,
- EcorePackage.eINSTANCE.getENamedElement_Name(), name);
- return ICommandFactoryResultFactory.DEFAULT.createCommandFactoryResult(setName, customization);
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Nicolas Bros (Mia-Software) - Bug 378271 - [Table] Select Columns To Hide is broken + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.CompoundCommand; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EParameter; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.ecore.EcoreFactory; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.CustomFactory; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.CustomPackage; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.EClassCustomization; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementCase; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementSwitchQuery; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.FacetCustomization; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.exception.CustomizationEditRuntimeException; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.ICustomizationCommandFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.EFacetFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.EFacetPackage; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.util.emf.core.command.ICommandFactoryResult; +import org.eclipse.papyrus.emf.facet.util.emf.core.command.ICommandFactoryResultFactory; +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.exported.ICommandFactory; + +public class CustomizationCommandFactory implements ICustomizationCommandFactory { + + private static final String CONFORM_ATT_NAME = "isConforming"; //$NON-NLS-1$ + private final EditingDomain editingDomain; + private final ICommandFactory commandFactory; + + public CustomizationCommandFactory(final EditingDomain editingDomain, final ICommandFactory commandFactory) { + this.editingDomain = editingDomain; + this.commandFactory = commandFactory; + } + + public ICommandFactoryResult<EClassCustomization> createEClassCustomization( + final Customization customization, final EClass customedEClass, + final Query conformanceQuery) { + final EClassCustomization eClassCustom = CustomFactory.eINSTANCE.createEClassCustomization(); + final CompoundCommand resultCmd = new CompoundCommand( + "Create one instance of EClassCustomization for " + customedEClass.getName()); //$NON-NLS-1$ + final Command linkToContainer = this.commandFactory + .createAddCommand( + this.editingDomain, + customization, + EcorePackage.eINSTANCE + .getEPackage_EClassifiers(), + eClassCustom); + resultCmd.append(linkToContainer); + final Command linkToEClass = this.commandFactory + .createSetCommand( + this.editingDomain, + eClassCustom, + EFacetPackage.eINSTANCE + .getFacet_ExtendedMetaclass(), + customedEClass); + resultCmd.append(linkToEClass); + if (conformanceQuery != null) { + final ICommandFactoryResult<FacetAttribute> attResult = createConformanceOperation(eClassCustom, conformanceQuery); + resultCmd.append(attResult.getCommand()); + } + + return ICommandFactoryResultFactory.DEFAULT.createCommandFactoryResult(resultCmd, eClassCustom); + } + + // TODO Move to FacetCommandFactory + private ICommandFactoryResult<FacetAttribute> createConformanceOperation(final Facet facet, final Query query) { + final CompoundCommand resultCmd = new CompoundCommand("Creates a facet conformance attribute"); //$NON-NLS-1$ + final FacetAttribute conformanceAtt = EFacetFactory.eINSTANCE.createFacetAttribute(); + conformanceAtt.setName(CustomizationCommandFactory.CONFORM_ATT_NAME); + conformanceAtt.setEType(EcorePackage.eINSTANCE.getEBoolean()); + conformanceAtt.setQuery(query); + conformanceAtt.setDerived(true); + + final Command conformance = this.commandFactory.createSetCommand(this.editingDomain, facet, EFacetPackage.eINSTANCE.getFacet_ConformanceTypedElement(), conformanceAtt); + resultCmd.append(conformance); + final Command addToFacet = this.commandFactory.createAddCommand(this.editingDomain, facet, EFacetPackage.eINSTANCE.getFacet_FacetElements(), conformanceAtt); + resultCmd.append(addToFacet); + return ICommandFactoryResultFactory.DEFAULT.createCommandFactoryResult(resultCmd, conformanceAtt); + } + + public ICommandFactoryResult<FacetCustomization> createFacetCustomization( + final Customization customization, final Facet customizedFacet) { + final FacetCustomization eFacetCustom = CustomFactory.eINSTANCE.createFacetCustomization(); + final CompoundCommand resultCmd = new CompoundCommand( + "Create one instance of FacetCustomization for " + customizedFacet.getName()); //$NON-NLS-1$ + final Command linkToContainer = this.commandFactory + .createAddCommand(this.editingDomain, customization, + EcorePackage.eINSTANCE.getEPackage_EClassifiers(), + eFacetCustom); + resultCmd.append(linkToContainer); + final Command linkToFacet = this.commandFactory + .createAddCommand( + this.editingDomain, + customization, + CustomPackage.eINSTANCE + .getFacetCustomization_CustomizedFacet(), + customizedFacet); + resultCmd.append(linkToFacet); + return ICommandFactoryResultFactory.DEFAULT.createCommandFactoryResult(resultCmd, eFacetCustom); + } + + public ICommandFactoryResult<Facet> setPropertyConfig( + final Facet typeCustomization, + final ETypedElement customizedTElt, // customized typed element + final FacetOperation customProperty, final Query query) { + final CompoundCommand resultCmd = new CompoundCommand( + "Set the value of the customization property '" + customProperty.getName() + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + FacetOperation fOpToModifiy = null; // Facet operation to modify + for (FacetOperation facetOperation : typeCustomization + .getFacetOperations()) { + if (facetOperation.getOverride().equals(customProperty)) { + fOpToModifiy = facetOperation; + } + } + if (fOpToModifiy == null) { + createPropertySetting(typeCustomization, customizedTElt, + customProperty, query, resultCmd); + } else { + final Query fOpQuery = fOpToModifiy.getQuery(); + if (fOpQuery instanceof ETypedElementSwitchQuery) { + final ETypedElementSwitchQuery switchQuery = (ETypedElementSwitchQuery) fOpQuery; + final Command setCase = setOrCreateETypedElementCase(switchQuery, customizedTElt, query); + resultCmd.append(setCase); + } else { + throw new CustomizationEditRuntimeException(); + } + } + return ICommandFactoryResultFactory.DEFAULT.createCommandFactoryResult(resultCmd, typeCustomization); + } + + private void createPropertySetting( + final Facet typeCustomization, + final ETypedElement customizedTElt, + final FacetOperation customProperty, final Query query, + final CompoundCommand resultCmd) { + FacetOperation facetOperation = EFacetFactory.eINSTANCE.createFacetOperation(); + // link the instance of FacetOperation to its parent + final Command linkFOpToParent = this.commandFactory.createAddCommand( + this.editingDomain, typeCustomization, + EFacetPackage.eINSTANCE.getFacet_FacetOperations(), + facetOperation); + resultCmd.append(linkFOpToParent); + // Link the instance of FacetOperation to the overridden custom property operation. + final Command linkToOverride = this.commandFactory.createSetCommand( + this.editingDomain, facetOperation, + EFacetPackage.eINSTANCE.getDerivedTypedElement_Override(), + customProperty); + resultCmd.append(linkToOverride); + facetOperation.setName(customProperty.getName()); + facetOperation.setEType(customProperty.getEType()); + facetOperation.setLowerBound(customProperty.getLowerBound()); + facetOperation.setUpperBound(customProperty.getUpperBound()); + + // add the "eStructuralFeature" EParameter that every customization operation must have + final EParameter eParameter = EcoreFactory.eINSTANCE.createEParameter(); + eParameter.setName("eStructuralFeature"); //$NON-NLS-1$ + eParameter.setEType(EcorePackage.eINSTANCE.getETypedElement()); + facetOperation.getEParameters().add(eParameter); + + final ETypedElementSwitchQuery switchQuery = CustomFactory.eINSTANCE.createETypedElementSwitchQuery(); + // Link the instance of ETypedElementSwitchQuery to its parent + final Command switchToParent = this.commandFactory + .createSetCommand(this.editingDomain, facetOperation, + EFacetPackage.eINSTANCE + .getDerivedTypedElement_Query(), + switchQuery); + resultCmd.append(switchToParent); + final Command setCase = setOrCreateETypedElementCase(switchQuery, customizedTElt, query); + resultCmd.append(setCase); + } + + private Command setOrCreateETypedElementCase( + final ETypedElementSwitchQuery switchQuery, + final ETypedElement customizedTElt, final Query query) { + final CompoundCommand resultCmd = new CompoundCommand("Set or create an instance of ETypedElementCase"); //$NON-NLS-1$ + ETypedElementCase caseToModify = getCaseByETypedElement(switchQuery, customizedTElt); + if (caseToModify == null) { + caseToModify = CustomFactory.eINSTANCE.createETypedElementCase(); + final Command linkToParent = this.commandFactory.createAddCommand( + this.editingDomain, switchQuery, + CustomPackage.eINSTANCE.getETypedElementSwitchQuery_Cases(), + caseToModify); + resultCmd.append(linkToParent); + } + final Command setCase = this.commandFactory.createSetCommand( + this.editingDomain, caseToModify, + CustomPackage.eINSTANCE.getETypedElementCase_Case(), + customizedTElt); + resultCmd.append(setCase); + final Command setQuery = this.commandFactory.createSetCommand( + this.editingDomain, caseToModify, + CustomPackage.eINSTANCE.getETypedElementCase_Value(), + query); + resultCmd.append(setQuery); + return resultCmd; + } + + private static ETypedElementCase getCaseByETypedElement( + final ETypedElementSwitchQuery switchQuery, + final ETypedElement customizedTElt) { + ETypedElementCase caseToModify = null; + for (ETypedElementCase casee : switchQuery.getCases()) { + // casee has to be null if we want to customize the EObject itself. + if (casee.getCase() == null) { + if (customizedTElt == null) { + caseToModify = casee; + } + } else { + if (casee.getCase().equals(customizedTElt)) { + caseToModify = casee; + break; + } + } + } + return caseToModify; + } + + public ICommandFactoryResult<Customization> createCustomization( + final String name) { + final Customization customization = CustomFactory.eINSTANCE + .createCustomization(); + final Command setName = this.commandFactory.createSetCommand( + this.editingDomain, customization, + EcorePackage.eINSTANCE.getENamedElement_Name(), name); + return ICommandFactoryResultFactory.DEFAULT.createCommandFactoryResult(setName, customization); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizationCommandFactoryFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizationCommandFactoryFactory.java index 37ea25553b4..2f91c591aa8 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizationCommandFactoryFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizationCommandFactoryFactory.java @@ -1,29 +1,29 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.ICustomizationCommandFactory;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.ICustomizationCommandFactoryFactory;
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.exported.ICommandFactory;
-
-public class CustomizationCommandFactoryFactory implements
- ICustomizationCommandFactoryFactory {
-
- public ICustomizationCommandFactory createCustomizationCommandFactory(
- final EditingDomain editingDomain,
- final ICommandFactory commandFactory) {
- return new CustomizationCommandFactory(editingDomain, commandFactory);
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.ICustomizationCommandFactory; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.ICustomizationCommandFactoryFactory; +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.exported.ICommandFactory; + +public class CustomizationCommandFactoryFactory implements + ICustomizationCommandFactoryFactory { + + public ICustomizationCommandFactory createCustomizationCommandFactory( + final EditingDomain editingDomain, + final ICommandFactory commandFactory) { + return new CustomizationCommandFactory(editingDomain, commandFactory); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedContentProviderFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedContentProviderFactory.java index 93e51439272..6cf30894ce1 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedContentProviderFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedContentProviderFactory.java @@ -1,32 +1,32 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal;
-
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedContentProvider;
-import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedContentProviderFactory;
-import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedTreeContentProvider;
-
-@SuppressWarnings("deprecation")
-// @SuppressWarnings("deprecation") : Bug 380229 - [deprecated] ICustomizedContentProvider
-public class CustomizedContentProviderFactory implements ICustomizedContentProviderFactory {
-
- public ICustomizedContentProvider createCustomizedContentProvider(final ICustomizationManager customManager) {
- return new CustomizedTreeContentProvider(customManager);
- }
-
- public ICustomizedTreeContentProvider createCustomizedTreeContentProvider(final ICustomizationManager customManager) {
- return new CustomizedTreeContentProvider(customManager);
- }
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal; + +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedContentProvider; +import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedContentProviderFactory; +import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedTreeContentProvider; + +@SuppressWarnings("deprecation") +// @SuppressWarnings("deprecation") : Bug 380229 - [deprecated] ICustomizedContentProvider +public class CustomizedContentProviderFactory implements ICustomizedContentProviderFactory { + + public ICustomizedContentProvider createCustomizedContentProvider(final ICustomizationManager customManager) { + return new CustomizedTreeContentProvider(customManager); + } + + public ICustomizedTreeContentProvider createCustomizedTreeContentProvider(final ICustomizationManager customManager) { + return new CustomizedTreeContentProvider(customManager); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedLabelDecorator.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedLabelDecorator.java index cce67e7f257..928f2e881a6 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedLabelDecorator.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedLabelDecorator.java @@ -1,124 +1,124 @@ -/*******************************************************************************
- * Copyright (c) 2013 Soft-Maint.
- * 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:
- * David Couvrand (Soft-Maint) - Bug 418418 - [Customization] Overlay icons not implemented
- * David Couvrand (Soft-Maint) - [Customization] NPE for CustomizableLabelProvider when no image found for image customization
- * Thomas Cicognani (Soft-Maint) - Bug 424414 - ImageManager doesn't cache images
- * Thomas Cicognani (Soft-Maint) - Bug 424416 - Plug-in for JFace Utilities
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.custom.ui.internal;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.DecorationOverlayIcon;
-import org.eclipse.jface.viewers.IDecorationContext;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.LabelDecorator;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.core.internal.exported.CustomizationUtils;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.util.jface.ui.imageprovider.IImageProvider;
-import org.eclipse.papyrus.emf.facet.util.jface.ui.imageprovider.IImageProviderFactory;
-import org.eclipse.swt.graphics.Image;
-
-public class CustomizedLabelDecorator extends LabelDecorator {
-
- private final ICustomizationManager customizationMgr;
- private final PropertiesHandler propertiesHandler;
- private final ImageManager imageManager;
-
- public CustomizedLabelDecorator(final ICustomizationManager customizationMgr) {
- super();
- this.customizationMgr = customizationMgr;
- this.propertiesHandler = new PropertiesHandler(customizationMgr);
- this.imageManager = new ImageManager();
- }
-
- public Image decorateImage(final Image image, final Object element) {
- return null;
- }
-
- public String decorateText(final String text, final Object element) {
- return null;
- }
-
- public void addListener(final ILabelProviderListener listener) {
- // Nothing to do
- }
-
- public void dispose() {
- // Nothing to do
- }
-
- public boolean isLabelProperty(final Object element, final String property) {
- return false;
- }
-
- public void removeListener(final ILabelProviderListener listener) {
- // Nothing to do
- }
-
- @Override
- public Image decorateImage(final Image image, final Object element,
- final IDecorationContext context) {
- Image result = null;
- if ((image != null) && (element instanceof EObject)) {
- final IImage bLeftIImage = getPropertyValue(element,
- this.propertiesHandler.getBottomLeftOverlayProperty(),
- null, IImage.class);
- final ImageDescriptor bottomLeftImDesc = this.imageManager
- .getImageDescriptor(bLeftIImage);
- final IImage tLeftIImage = getPropertyValue(element,
- this.propertiesHandler.getTopLeftOverlayProperty(), null,
- IImage.class);
- final ImageDescriptor topLeftImDesc = this.imageManager
- .getImageDescriptor(tLeftIImage);
- final IImage bRightIImage = getPropertyValue(element,
- this.propertiesHandler.getBottomRightOverlayProperty(),
- null, IImage.class);
- final ImageDescriptor bottomRightImDesc = this.imageManager
- .getImageDescriptor(bRightIImage);
- final IImage tRightIImage = getPropertyValue(element,
- this.propertiesHandler.getTopRightOverlayProperty(), null,
- IImage.class);
- final ImageDescriptor topRightImDesc = this.imageManager
- .getImageDescriptor(tRightIImage);
- final ImageDescriptor[] overlaysArray = new ImageDescriptor[] {
- topLeftImDesc, topRightImDesc, bottomLeftImDesc,
- bottomRightImDesc, null };
- final DecorationOverlayIcon overlayIcon = new DecorationOverlayIcon(
- image, overlaysArray);
- final IImageProvider imageProvider = IImageProviderFactory.DEFAULT
- .createIImageProvider(Activator.getDefault());
- result = imageProvider.getImage(overlayIcon);
- }
- return result;
- }
-
- @Override
- public String decorateText(final String text, final Object element,
- final IDecorationContext context) {
- return null;
- }
-
- @Override
- public boolean prepareDecoration(final Object element,
- final String originalText, final IDecorationContext context) {
- return false;
- }
-
- private <T> T getPropertyValue(final Object element,
- final FacetOperation property, final ETypedElement eTypedElement,
- final Class<T> classs) {
- return CustomizationUtils.getPropertyValue(this.customizationMgr,
- element, property, eTypedElement, classs);
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2013 Soft-Maint. + * 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: + * David Couvrand (Soft-Maint) - Bug 418418 - [Customization] Overlay icons not implemented + * David Couvrand (Soft-Maint) - [Customization] NPE for CustomizableLabelProvider when no image found for image customization + * Thomas Cicognani (Soft-Maint) - Bug 424414 - ImageManager doesn't cache images + * Thomas Cicognani (Soft-Maint) - Bug 424416 - Plug-in for JFace Utilities + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.custom.ui.internal; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.DecorationOverlayIcon; +import org.eclipse.jface.viewers.IDecorationContext; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.LabelDecorator; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.core.internal.exported.CustomizationUtils; +import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.util.jface.ui.imageprovider.IImageProvider; +import org.eclipse.papyrus.emf.facet.util.jface.ui.imageprovider.IImageProviderFactory; +import org.eclipse.swt.graphics.Image; + +public class CustomizedLabelDecorator extends LabelDecorator { + + private final ICustomizationManager customizationMgr; + private final PropertiesHandler propertiesHandler; + private final ImageManager imageManager; + + public CustomizedLabelDecorator(final ICustomizationManager customizationMgr) { + super(); + this.customizationMgr = customizationMgr; + this.propertiesHandler = new PropertiesHandler(customizationMgr); + this.imageManager = new ImageManager(); + } + + public Image decorateImage(final Image image, final Object element) { + return null; + } + + public String decorateText(final String text, final Object element) { + return null; + } + + public void addListener(final ILabelProviderListener listener) { + // Nothing to do + } + + public void dispose() { + // Nothing to do + } + + public boolean isLabelProperty(final Object element, final String property) { + return false; + } + + public void removeListener(final ILabelProviderListener listener) { + // Nothing to do + } + + @Override + public Image decorateImage(final Image image, final Object element, + final IDecorationContext context) { + Image result = null; + if ((image != null) && (element instanceof EObject)) { + final IImage bLeftIImage = getPropertyValue(element, + this.propertiesHandler.getBottomLeftOverlayProperty(), + null, IImage.class); + final ImageDescriptor bottomLeftImDesc = this.imageManager + .getImageDescriptor(bLeftIImage); + final IImage tLeftIImage = getPropertyValue(element, + this.propertiesHandler.getTopLeftOverlayProperty(), null, + IImage.class); + final ImageDescriptor topLeftImDesc = this.imageManager + .getImageDescriptor(tLeftIImage); + final IImage bRightIImage = getPropertyValue(element, + this.propertiesHandler.getBottomRightOverlayProperty(), + null, IImage.class); + final ImageDescriptor bottomRightImDesc = this.imageManager + .getImageDescriptor(bRightIImage); + final IImage tRightIImage = getPropertyValue(element, + this.propertiesHandler.getTopRightOverlayProperty(), null, + IImage.class); + final ImageDescriptor topRightImDesc = this.imageManager + .getImageDescriptor(tRightIImage); + final ImageDescriptor[] overlaysArray = new ImageDescriptor[] { + topLeftImDesc, topRightImDesc, bottomLeftImDesc, + bottomRightImDesc, null }; + final DecorationOverlayIcon overlayIcon = new DecorationOverlayIcon( + image, overlaysArray); + final IImageProvider imageProvider = IImageProviderFactory.DEFAULT + .createIImageProvider(Activator.getDefault()); + result = imageProvider.getImage(overlayIcon); + } + return result; + } + + @Override + public String decorateText(final String text, final Object element, + final IDecorationContext context) { + return null; + } + + @Override + public boolean prepareDecoration(final Object element, + final String originalText, final IDecorationContext context) { + return false; + } + + private <T> T getPropertyValue(final Object element, + final FacetOperation property, final ETypedElement eTypedElement, + final Class<T> classs) { + return CustomizationUtils.getPropertyValue(this.customizationMgr, + element, property, eTypedElement, classs); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedLabelProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedLabelProvider.java index f8981cced2f..12fc28ae088 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedLabelProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedLabelProvider.java @@ -1,626 +1,626 @@ -/**
- * Copyright (c) 2011, 2012, 2013 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Nicolas Bros (Mia-Software) - Bug 372198 - resource leak in org.eclipse.papyrus.emf.facet.custom.ui.internal.CustomizedLabelProvider
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Nicolas Bros (Mia-Software) - Bug 374941 - To be able to customize overlay icons on EClass
- * Gregoire Dupe (Mia-Software) - Bug 374941 - To be able to customize overlay icons on EClass
- * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
- * Vincent Lorenzo (CEA-LIST) - Bug 352603 - [Table] A tooltip which displays the full label of a String cell editor
- * Gr�goire Dup�(Mia-Software) - Bug 352603 - [Table] A tooltip which displays the full label of a String cell editor
- * David Couvrand (Soft-Maint) - Bug 402725 - Need a query to get an image from an URI
- * Nicolas Rault (Soft-Maint) - Bug 402725 - Need a query to get an image from an URI
- * David Couvrand (Soft-Maint) - Bug 418418 - [Customization] Overlay icons not implemented
- * David Couvrand (Soft-Maint) - Bug 422058 - Implementation of strikethrough and underline in the CustomizedLabelProvider
- * Gr�goire Dup� (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table
- * Thomas Cicognani (Soft-Maint) - Bug 424414 - ImageManager doesn't cache images
- * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - implementation of IStyledLabelProvider
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.jface.viewers.CellLabelProvider;
-import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.StyledString;
-import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManagerFactory;
-import org.eclipse.papyrus.emf.facet.custom.core.exception.CustomizationException;
-import org.eclipse.papyrus.emf.facet.custom.core.internal.exported.CustomizationUtils;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IColor;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Alignment;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Shadow;
-import org.eclipse.papyrus.emf.facet.custom.ui.ICustomOverride;
-import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.util.core.DebugUtils;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.papyrus.emf.facet.util.swt.colorprovider.IColorProvider;
-import org.eclipse.papyrus.emf.facet.util.swt.colorprovider.IColorProviderFactory;
-import org.eclipse.papyrus.emf.facet.util.swt.fontprovider.IFontProvider;
-import org.eclipse.papyrus.emf.facet.util.swt.fontprovider.IFontProviderFactory;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-public class CustomizedLabelProvider extends CellLabelProvider implements
- ICustomizedLabelProvider, IStyledLabelProvider {
-
- private static final boolean DEBUG_FONT = DebugUtils.getDebugStatus(Activator.getDefault(), "font"); //$NON-NLS-1$
- private static final boolean DEBUG_COLOR = DebugUtils.getDebugStatus(Activator.getDefault(), "color"); //$NON-NLS-1$
- private static final int RGB_MAX = 255;
- private static final RGB DEFAULT_BCKGND = new RGB(
- CustomizedLabelProvider.RGB_MAX, CustomizedLabelProvider.RGB_MAX,
- CustomizedLabelProvider.RGB_MAX);
- private static final RGB DEFAULT_FOREGND = new RGB(0, 0, 0);
- private final ICustomizationManager customManager;
- private final PropertiesHandler propertiesHandler;
- private final List<ILabelProviderListener> listeners = new ArrayList<ILabelProviderListener>();
- private final ImageManager imageManager;
- private final ICustomOverride customOverride;
-
- @Deprecated
- public CustomizedLabelProvider(final ResourceSet resourceSet) {
- this(ICustomizationManagerFactory.DEFAULT
- .getOrCreateICustomizationManager(resourceSet));
- }
-
- public CustomizedLabelProvider(final ICustomizationManager customManager) {
- super();
- this.customManager = customManager;
- this.propertiesHandler = new PropertiesHandler(customManager);
- this.imageManager = new ImageManager();
- this.customOverride = getICustomOverride();
- }
-
- private <T> T getPropertyValue(final Object element,
- final FacetOperation property, final ETypedElement eTypedElement, final Class<T> classs) {
- return CustomizationUtils.getPropertyValue(this.customManager, element,
- property, eTypedElement, classs);
- }
-
- public String getText(final Object element) {
- String result;
- if (element instanceof EObject) {
- result = getPropertyValue(element, this.propertiesHandler.getLabelProperty(), null, String.class);
-
- } else if (element == null) {
- result = Messages.CustomizedLabelProvider_null;
- } else if (element instanceof List<?>) {
- // Here we do not add any square brackets because the square
- // brackets are useful to emphases the sublists and here we will non
- // meet any sublists.
- final StringBuffer strBuffer = new StringBuffer();
- final List<?> list = (List<?>) element;
- final Iterator<?> iter = list.iterator();
- while (iter.hasNext()) {
- final Object current = iter.next();
- strBuffer.append(getText(current));
- if (iter.hasNext()) {
- strBuffer.append(", "); //$NON-NLS-1$
- }
- }
- result = strBuffer.toString();
- } else {
- result = element.toString();
- }
- if (this.customOverride != null) {
- try {
- result = this.customOverride.getText(result, element,
- this.customManager, this.propertiesHandler);
- } catch (final CustomizationException e) {
- result = "ERROR, cf. log"; //$NON-NLS-1$
- Logger.logError(e, Activator.getDefault());
- }
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider#getStyledText(java.lang.Object)
- */
- @Override
- public StyledString getStyledText(final Object element) {
- Object result = null;
- if (element instanceof EObject) {
- result = getPropertyValue(element,
- this.propertiesHandler.getLabelProperty(), null, StyledString.class);
- if (result instanceof String) {
- result = new StyledString((String) result);
- }
- } else {
- result = new StyledString(getText(element));
- }
-
- return (StyledString) result;
- }
-
- private static ICustomOverride getICustomOverride() {
- final Bundle bundle = Activator.getDefault().getBundle();
- final BundleContext bundleContext = bundle.getBundleContext();
- final ServiceReference serviceReference = bundleContext
- .getServiceReference(ICustomOverride.class.getName());
- final ICustomOverride customOverride = (ICustomOverride) bundleContext
- .getService(serviceReference);
- return customOverride;
- }
-
- public String getText(final Object object, final ETypedElement eTypedElement) {
- String result = null;
- if (object == null) {
- result = Messages.CustomizedLabelProvider_null;
- } else {
- if (object instanceof EObject) {
- final EObject eObject = (EObject) object;
- try {
- Object objectResult = this.customManager.getCustomValueOf(eObject,
- eTypedElement,
- this.propertiesHandler.getLabelProperty(),
- Object.class);
- if (objectResult instanceof StyledString) {
- result = objectResult.toString();
- } else if (objectResult instanceof String) {
- result = (String) objectResult;
- }
- } catch (CustomizationException e) {
- Logger.logError(e, Activator.getDefault());
- result = "!!! Error, cf log !!!";
- }
- } else {
- result = object.toString();
- }
-
- }
- return result;
- }
-
- @Override
- public StyledString getStyledText(final Object object, final ETypedElement eTypedElement) {
- StyledString result = null;
- if (object == null) {
- result = new StyledString(Messages.CustomizedLabelProvider_null);
- } else {
- if (object instanceof EObject) {
- final EObject eObject = (EObject) object;
- try {
- Object objectResult = this.customManager.getCustomValueOf(eObject,
- eTypedElement,
- this.propertiesHandler.getLabelProperty(),
- Object.class);
- if (objectResult instanceof StyledString) {
- result = (StyledString) objectResult;
- } else if (objectResult instanceof String) {
- result = new StyledString((String) objectResult);
- }
- } catch (CustomizationException e) {
- Logger.logError(e, Activator.getDefault());
- result = new StyledString("!!! Error, cf log !!!");
- }
- } else {
- result = new StyledString(object.toString());
- }
-
- }
- return result;
- }
-
- @Override
- public void addListener(final ILabelProviderListener listener) {
- this.listeners.add(listener);
- }
-
- @Override
- public void dispose() {
- this.listeners.clear();
- }
-
- @Override
- public boolean isLabelProperty(final Object element, final String property) {
- return false;
- }
-
- @Override
- public void removeListener(final ILabelProviderListener listener) {
- this.listeners.remove(listener);
- }
-
- private static Color getColor(final RGB rgb) {
- final Display display = Display.getDefault();
- final IColorProvider colorProvider = IColorProviderFactory.DEFAULT
- .getOrCreateIColorProvider(display);
- return colorProvider.getColor(rgb);
- }
-
- public Color getForeground(final Object element) {
- final IColor color = getPropertyValue(element,
- this.propertiesHandler.getForegroundProperty(),
- null, IColor.class);
- Color result;
- if (color == null) {
- result = getColor(CustomizedLabelProvider.DEFAULT_FOREGND);
- } else {
- result = getColor(new RGB(color.getRed(), color.getGreen(),
- color.getBlue()));
- }
- return result;
- }
-
- public Color getBackground(final Object element) {
- final IColor color = getPropertyValue(element,
- this.propertiesHandler.getBackgroundProperty(), null, IColor.class);
- Color result;
- if (color == null) {
- result = getColor(CustomizedLabelProvider.DEFAULT_BCKGND);
- } else {
- result = getColor(new RGB(color.getRed(), color.getGreen(),
- color.getBlue()));
- }
- return result;
- }
-
- private Font getFont(final FontData fontData) {
- final IFontProvider fontProvider = IFontProviderFactory.DEFAULT
- .getOrCreateIFontProvider(Display.getDefault());
- return fontProvider.getFont(fontData);
- }
-
- public Font getFont(final Object element) {
-
- String fontName = getPropertyValue(element,
- this.propertiesHandler.getFontNameProperty(), null, String.class);
- if (fontName == null) {
- final FontData[] fontData = Display.getDefault().getSystemFont()
- .getFontData();
- fontName = fontData[0].getName();
- }
-
- Integer fontSize = getPropertyValue(element,
- this.propertiesHandler.getFontSizeProperty(), null, Integer.class);
- if (fontSize == null) {
- final FontData[] fontData = Display.getDefault().getSystemFont()
- .getFontData();
- fontSize = Integer.valueOf(fontData[0].getHeight());
- }
-
- Boolean isBold = getPropertyValue(element,
- this.propertiesHandler.getIsBoldProperty(), null, Boolean.class);
- if (isBold == null) {
- isBold = Boolean.FALSE;
- }
-
- Boolean isItalic = getPropertyValue(element,
- this.propertiesHandler.getIsItalicProperty(), null, Boolean.class);
- if (isItalic == null) {
- isItalic = Boolean.FALSE;
- }
-
- int fontStyle = 0;
- if (isBold.booleanValue()) {
- fontStyle = fontStyle | SWT.BOLD;
- }
- if (isItalic.booleanValue()) {
- fontStyle = fontStyle | SWT.ITALIC;
- }
- FontData fontData = new FontData(fontName, fontSize.intValue(),
- fontStyle);
- try {
- fontData = this.customOverride.getFont(fontData, element,
- this.customManager, this.propertiesHandler);
- } catch (final CustomizationException e) {
- Logger.logError(e, Activator.getDefault());
- }
- return getFont(fontData);
- }
-
- public Image getImage(final Object element) {
- final IImage image = getPropertyValue(element,
- this.propertiesHandler.getImageProperty(), null, IImage.class);
- return this.imageManager.getImage(image);
- }
-
- public Image getImage(final Object element, final ETypedElement featureColumn) {
- return getImage(element, this.propertiesHandler.getImageProperty(), featureColumn);
- }
-
- public ICustomizationManager getCustomizationManager() {
- return this.customManager;
- }
-
- public boolean isUnderlined(final Object element,
- final ETypedElement eTypedElement) {
- return getPropertyValue(element,
- this.propertiesHandler.getIsUnderlinedProperty(), null, Boolean.class).booleanValue();
- }
-
- public boolean isStruckthrough(final Object element,
- final ETypedElement eTypedElement) {
- final Boolean propertyValue = getPropertyValue(element,
- this.propertiesHandler.getIsStruckthroughProperty(),
- eTypedElement, Boolean.class);
- boolean result = false;
- if (propertyValue != null) {
- result = propertyValue.booleanValue();
- }
- return result;
- }
-
- private Image getImage(final Object element, final FacetOperation operation, final ETypedElement feature) {
- final IImage iimage = getPropertyValue(element, operation, feature,
- IImage.class);
- return this.imageManager.getImage(iimage);
- }
-
- public Image getTopLeftOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return getImage(element, this.propertiesHandler.getTopLeftOverlayProperty(), eTypedElement);
- }
-
- public Image getTopMiddleOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return getImage(element, this.propertiesHandler.getTopMiddleOverlayProperty(), eTypedElement);
- }
-
- public Image getTopRightOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return getImage(element, this.propertiesHandler.getTopRightOverlayProperty(), eTypedElement);
- }
-
- public Image getBottomLeftOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return getImage(element, this.propertiesHandler.getBottomLeftOverlayProperty(), eTypedElement);
- }
-
- public Image getBottomMiddleOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return getImage(element, this.propertiesHandler.getBottomMiddleOverlayProperty(), eTypedElement);
- }
-
- public Image getBottomRightOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return getImage(element, this.propertiesHandler.getBottomRightOverlayProperty(), eTypedElement);
- }
-
-
- @Override
- public String getToolTipText(final Object element) {
- return getPropertyValue(element,
- this.propertiesHandler.getToolTipTextProperty(), null, String.class);
- }
-
- @Override
- public int getToolTipStyle(final Object element) {
- int style = 0;
- final Shadow shadow = getPropertyValue(element,
- this.propertiesHandler.getToolTipShadowProperty(), null,
- Shadow.class);
- switch (shadow) {
- case NONE:
- style = SWT.SHADOW_NONE;
- break;
- case IN:
- style = SWT.SHADOW_IN;
- break;
- case OUT:
- style = SWT.SHADOW_OUT;
- break;
- default:
- throw new IllegalStateException("Un expected value"); //$NON-NLS-1$
- }
-
- final Alignment alignment = getPropertyValue(element,
- this.propertiesHandler.getToolTipAlignmentProperty(), null,
- Alignment.class);
- switch (alignment) {
- case LEFT:
- style |= SWT.LEFT;
- break;
- case CENTER:
- style |= SWT.CENTER;
- break;
- case RIGHT:
- style |= SWT.RIGHT;
- break;
- default:
- throw new IllegalStateException("Un expected value"); //$NON-NLS-1$
- }
-
- return style;
- }
-
- @Override
- public Image getToolTipImage(final Object element) {
- return getPropertyValue(element,
- this.propertiesHandler.getToolTipImageProperty(), null, Image.class);
- }
-
- @Override
- public Color getToolTipBackgroundColor(final Object element) {
- final IColor color = getPropertyValue(element,
- this.propertiesHandler.getToolTipBackgroundProperty(),
- null, IColor.class);
- return getColor(new RGB(color.getRed(), color.getGreen(), color.getBlue()));
- }
-
- @Override
- public Color getToolTipForegroundColor(final Object element) {
- final IColor color = getPropertyValue(element,
- this.propertiesHandler.getToolTipForegroundProperty(),
- null, IColor.class);
- return getColor(new RGB(color.getRed(), color.getGreen(), color.getBlue()));
- }
-
- public Image getToolTipTopLeftOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return getPropertyValue(element,
- this.propertiesHandler.getToolTipTopLeftOverlayProperty(),
- null, Image.class);
- }
-
- public Image getToolTipTopMiddleOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return getPropertyValue(element,
- this.propertiesHandler.getToolTipTopMiddleOverlayProperty(),
- null, Image.class);
- }
-
- public Image getToolTipTopRightOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return getPropertyValue(element,
- this.propertiesHandler.getToolTipTopRightOverlayProperty(),
- null, Image.class);
- }
-
- public Image getToolTipBottomLeftOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return getPropertyValue(element,
- this.propertiesHandler.getToolTipBottomLeftOverlayProperty(),
- null, Image.class);
- }
-
- public Image getToolTipBottomMiddleOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return getPropertyValue(element,
- this.propertiesHandler.getToolTipBottomMiddleOverlayProperty(),
- null, Image.class);
- }
-
- public Image getToolTipBottomRightOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return getPropertyValue(element,
- this.propertiesHandler.getToolTipBottomRightOverlayProperty(),
- null, Image.class);
- }
-
- @Override
- public int getToolTipDisplayDelayTime(final Object element) {
- return getPropertyValue(element,
- this.propertiesHandler.getToolTipDisplayDelayTimeProperty(),
- null, Integer.class).intValue();
- }
-
- @Override
- public int getToolTipTimeDisplayed(final Object element) {
- return getPropertyValue(element,
- this.propertiesHandler.getToolTipTimeDisplayedProperty(), null,
- Integer.class).intValue();
-
- }
-
- @Override
- public Font getToolTipFont(final Object element) {
-
- final String fontName = getPropertyValue(element,
- this.propertiesHandler.getToolTipFontNameProperty(), null,
- String.class);
- final Integer fontSize = getPropertyValue(element,
- this.propertiesHandler.getToolTipFontSizeProperty(), null,
- Integer.class);
- final Boolean isBold = getPropertyValue(element,
- this.propertiesHandler.getToolTipIsBoldProperty(), null,
- Boolean.class);
- final Boolean isItalic = getPropertyValue(element,
- this.propertiesHandler.getToolTipIsItalicProperty(), null,
- Boolean.class);
- int fontStyle = 0;
- if (isBold.booleanValue()) {
- fontStyle = fontStyle | SWT.BOLD;
- }
- if (isItalic.booleanValue()) {
- fontStyle = fontStyle | SWT.ITALIC;
- }
- final FontData fontData = new FontData(fontName, fontSize.intValue(),
- fontStyle);
- final IFontProvider fontProvider = IFontProviderFactory.DEFAULT
- .getOrCreateIFontProvider(Display.getDefault());
- return fontProvider.getFont(fontData);
- }
-
- @Override
- public void update(final ViewerCell cell) {
- final Object element = cell.getElement();
- cell.setText(getText(element));
- cell.setBackground(getBackground(element));
- cell.setFont(getFont(element));
- cell.setForeground(getForeground(element));
- cell.setImage(getImage(element));
- }
-
- public String getToolTipText(final Object element,
- final ETypedElement eTypedElement) {
-
- return null;
- }
-
- public Image getToolTipImage(final Object element,
- final ETypedElement eTypedElement) {
-
- return null;
- }
-
- public Font getToolTipFont(final Object element,
- final ETypedElement eTypedElement) {
-
- return null;
- }
-
- public Color getToolTipBackgroundColor(final Object element,
- final ETypedElement eTypedElement) {
-
- return null;
- }
-
- public Color getToolTipForegroundColor(final Object element,
- final ETypedElement eTypedElement) {
-
- return null;
- }
-
- public int getToolTipTimeDisplayed(final Object element,
- final ETypedElement eTypedElement) {
-
- return 0;
- }
-
- public int getToolTipDisplayDelayTime(final Object element,
- final ETypedElement eTypedElement) {
-
- return 0;
- }
-
- public int getToolTipStyle(final Object element,
- final ETypedElement eTypedElement) {
-
- return 0;
- }
-
- public ICustomizedLabelProvider cloneLabelProvider() {
- return new CustomizedLabelProvider(this.customManager);
- }
-
-}
+/** + * Copyright (c) 2011, 2012, 2013 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Nicolas Bros (Mia-Software) - Bug 372198 - resource leak in org.eclipse.papyrus.emf.facet.custom.ui.internal.CustomizedLabelProvider + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Nicolas Bros (Mia-Software) - Bug 374941 - To be able to customize overlay icons on EClass + * Gregoire Dupe (Mia-Software) - Bug 374941 - To be able to customize overlay icons on EClass + * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. + * Vincent Lorenzo (CEA-LIST) - Bug 352603 - [Table] A tooltip which displays the full label of a String cell editor + * Gr�goire Dup�(Mia-Software) - Bug 352603 - [Table] A tooltip which displays the full label of a String cell editor + * David Couvrand (Soft-Maint) - Bug 402725 - Need a query to get an image from an URI + * Nicolas Rault (Soft-Maint) - Bug 402725 - Need a query to get an image from an URI + * David Couvrand (Soft-Maint) - Bug 418418 - [Customization] Overlay icons not implemented + * David Couvrand (Soft-Maint) - Bug 422058 - Implementation of strikethrough and underline in the CustomizedLabelProvider + * Gr�goire Dup� (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table + * Thomas Cicognani (Soft-Maint) - Bug 424414 - ImageManager doesn't cache images + * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - implementation of IStyledLabelProvider + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.jface.viewers.CellLabelProvider; +import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.StyledString; +import org.eclipse.jface.viewers.ViewerCell; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManagerFactory; +import org.eclipse.papyrus.emf.facet.custom.core.exception.CustomizationException; +import org.eclipse.papyrus.emf.facet.custom.core.internal.exported.CustomizationUtils; +import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IColor; +import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Alignment; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Shadow; +import org.eclipse.papyrus.emf.facet.custom.ui.ICustomOverride; +import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.util.core.DebugUtils; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.papyrus.emf.facet.util.swt.colorprovider.IColorProvider; +import org.eclipse.papyrus.emf.facet.util.swt.colorprovider.IColorProviderFactory; +import org.eclipse.papyrus.emf.facet.util.swt.fontprovider.IFontProvider; +import org.eclipse.papyrus.emf.facet.util.swt.fontprovider.IFontProviderFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Display; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; + +public class CustomizedLabelProvider extends CellLabelProvider implements + ICustomizedLabelProvider, IStyledLabelProvider { + + private static final boolean DEBUG_FONT = DebugUtils.getDebugStatus(Activator.getDefault(), "font"); //$NON-NLS-1$ + private static final boolean DEBUG_COLOR = DebugUtils.getDebugStatus(Activator.getDefault(), "color"); //$NON-NLS-1$ + private static final int RGB_MAX = 255; + private static final RGB DEFAULT_BCKGND = new RGB( + CustomizedLabelProvider.RGB_MAX, CustomizedLabelProvider.RGB_MAX, + CustomizedLabelProvider.RGB_MAX); + private static final RGB DEFAULT_FOREGND = new RGB(0, 0, 0); + private final ICustomizationManager customManager; + private final PropertiesHandler propertiesHandler; + private final List<ILabelProviderListener> listeners = new ArrayList<ILabelProviderListener>(); + private final ImageManager imageManager; + private final ICustomOverride customOverride; + + @Deprecated + public CustomizedLabelProvider(final ResourceSet resourceSet) { + this(ICustomizationManagerFactory.DEFAULT + .getOrCreateICustomizationManager(resourceSet)); + } + + public CustomizedLabelProvider(final ICustomizationManager customManager) { + super(); + this.customManager = customManager; + this.propertiesHandler = new PropertiesHandler(customManager); + this.imageManager = new ImageManager(); + this.customOverride = getICustomOverride(); + } + + private <T> T getPropertyValue(final Object element, + final FacetOperation property, final ETypedElement eTypedElement, final Class<T> classs) { + return CustomizationUtils.getPropertyValue(this.customManager, element, + property, eTypedElement, classs); + } + + public String getText(final Object element) { + String result; + if (element instanceof EObject) { + result = getPropertyValue(element, this.propertiesHandler.getLabelProperty(), null, String.class); + + } else if (element == null) { + result = Messages.CustomizedLabelProvider_null; + } else if (element instanceof List<?>) { + // Here we do not add any square brackets because the square + // brackets are useful to emphases the sublists and here we will non + // meet any sublists. + final StringBuffer strBuffer = new StringBuffer(); + final List<?> list = (List<?>) element; + final Iterator<?> iter = list.iterator(); + while (iter.hasNext()) { + final Object current = iter.next(); + strBuffer.append(getText(current)); + if (iter.hasNext()) { + strBuffer.append(", "); //$NON-NLS-1$ + } + } + result = strBuffer.toString(); + } else { + result = element.toString(); + } + if (this.customOverride != null) { + try { + result = this.customOverride.getText(result, element, + this.customManager, this.propertiesHandler); + } catch (final CustomizationException e) { + result = "ERROR, cf. log"; //$NON-NLS-1$ + Logger.logError(e, Activator.getDefault()); + } + } + return result; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider#getStyledText(java.lang.Object) + */ + @Override + public StyledString getStyledText(final Object element) { + Object result = null; + if (element instanceof EObject) { + result = getPropertyValue(element, + this.propertiesHandler.getLabelProperty(), null, StyledString.class); + if (result instanceof String) { + result = new StyledString((String) result); + } + } else { + result = new StyledString(getText(element)); + } + + return (StyledString) result; + } + + private static ICustomOverride getICustomOverride() { + final Bundle bundle = Activator.getDefault().getBundle(); + final BundleContext bundleContext = bundle.getBundleContext(); + final ServiceReference serviceReference = bundleContext + .getServiceReference(ICustomOverride.class.getName()); + final ICustomOverride customOverride = (ICustomOverride) bundleContext + .getService(serviceReference); + return customOverride; + } + + public String getText(final Object object, final ETypedElement eTypedElement) { + String result = null; + if (object == null) { + result = Messages.CustomizedLabelProvider_null; + } else { + if (object instanceof EObject) { + final EObject eObject = (EObject) object; + try { + Object objectResult = this.customManager.getCustomValueOf(eObject, + eTypedElement, + this.propertiesHandler.getLabelProperty(), + Object.class); + if (objectResult instanceof StyledString) { + result = objectResult.toString(); + } else if (objectResult instanceof String) { + result = (String) objectResult; + } + } catch (CustomizationException e) { + Logger.logError(e, Activator.getDefault()); + result = "!!! Error, cf log !!!"; + } + } else { + result = object.toString(); + } + + } + return result; + } + + @Override + public StyledString getStyledText(final Object object, final ETypedElement eTypedElement) { + StyledString result = null; + if (object == null) { + result = new StyledString(Messages.CustomizedLabelProvider_null); + } else { + if (object instanceof EObject) { + final EObject eObject = (EObject) object; + try { + Object objectResult = this.customManager.getCustomValueOf(eObject, + eTypedElement, + this.propertiesHandler.getLabelProperty(), + Object.class); + if (objectResult instanceof StyledString) { + result = (StyledString) objectResult; + } else if (objectResult instanceof String) { + result = new StyledString((String) objectResult); + } + } catch (CustomizationException e) { + Logger.logError(e, Activator.getDefault()); + result = new StyledString("!!! Error, cf log !!!"); + } + } else { + result = new StyledString(object.toString()); + } + + } + return result; + } + + @Override + public void addListener(final ILabelProviderListener listener) { + this.listeners.add(listener); + } + + @Override + public void dispose() { + this.listeners.clear(); + } + + @Override + public boolean isLabelProperty(final Object element, final String property) { + return false; + } + + @Override + public void removeListener(final ILabelProviderListener listener) { + this.listeners.remove(listener); + } + + private static Color getColor(final RGB rgb) { + final Display display = Display.getDefault(); + final IColorProvider colorProvider = IColorProviderFactory.DEFAULT + .getOrCreateIColorProvider(display); + return colorProvider.getColor(rgb); + } + + public Color getForeground(final Object element) { + final IColor color = getPropertyValue(element, + this.propertiesHandler.getForegroundProperty(), + null, IColor.class); + Color result; + if (color == null) { + result = getColor(CustomizedLabelProvider.DEFAULT_FOREGND); + } else { + result = getColor(new RGB(color.getRed(), color.getGreen(), + color.getBlue())); + } + return result; + } + + public Color getBackground(final Object element) { + final IColor color = getPropertyValue(element, + this.propertiesHandler.getBackgroundProperty(), null, IColor.class); + Color result; + if (color == null) { + result = getColor(CustomizedLabelProvider.DEFAULT_BCKGND); + } else { + result = getColor(new RGB(color.getRed(), color.getGreen(), + color.getBlue())); + } + return result; + } + + private Font getFont(final FontData fontData) { + final IFontProvider fontProvider = IFontProviderFactory.DEFAULT + .getOrCreateIFontProvider(Display.getDefault()); + return fontProvider.getFont(fontData); + } + + public Font getFont(final Object element) { + + String fontName = getPropertyValue(element, + this.propertiesHandler.getFontNameProperty(), null, String.class); + if (fontName == null) { + final FontData[] fontData = Display.getDefault().getSystemFont() + .getFontData(); + fontName = fontData[0].getName(); + } + + Integer fontSize = getPropertyValue(element, + this.propertiesHandler.getFontSizeProperty(), null, Integer.class); + if (fontSize == null) { + final FontData[] fontData = Display.getDefault().getSystemFont() + .getFontData(); + fontSize = Integer.valueOf(fontData[0].getHeight()); + } + + Boolean isBold = getPropertyValue(element, + this.propertiesHandler.getIsBoldProperty(), null, Boolean.class); + if (isBold == null) { + isBold = Boolean.FALSE; + } + + Boolean isItalic = getPropertyValue(element, + this.propertiesHandler.getIsItalicProperty(), null, Boolean.class); + if (isItalic == null) { + isItalic = Boolean.FALSE; + } + + int fontStyle = 0; + if (isBold.booleanValue()) { + fontStyle = fontStyle | SWT.BOLD; + } + if (isItalic.booleanValue()) { + fontStyle = fontStyle | SWT.ITALIC; + } + FontData fontData = new FontData(fontName, fontSize.intValue(), + fontStyle); + try { + fontData = this.customOverride.getFont(fontData, element, + this.customManager, this.propertiesHandler); + } catch (final CustomizationException e) { + Logger.logError(e, Activator.getDefault()); + } + return getFont(fontData); + } + + public Image getImage(final Object element) { + final IImage image = getPropertyValue(element, + this.propertiesHandler.getImageProperty(), null, IImage.class); + return this.imageManager.getImage(image); + } + + public Image getImage(final Object element, final ETypedElement featureColumn) { + return getImage(element, this.propertiesHandler.getImageProperty(), featureColumn); + } + + public ICustomizationManager getCustomizationManager() { + return this.customManager; + } + + public boolean isUnderlined(final Object element, + final ETypedElement eTypedElement) { + return getPropertyValue(element, + this.propertiesHandler.getIsUnderlinedProperty(), null, Boolean.class).booleanValue(); + } + + public boolean isStruckthrough(final Object element, + final ETypedElement eTypedElement) { + final Boolean propertyValue = getPropertyValue(element, + this.propertiesHandler.getIsStruckthroughProperty(), + eTypedElement, Boolean.class); + boolean result = false; + if (propertyValue != null) { + result = propertyValue.booleanValue(); + } + return result; + } + + private Image getImage(final Object element, final FacetOperation operation, final ETypedElement feature) { + final IImage iimage = getPropertyValue(element, operation, feature, + IImage.class); + return this.imageManager.getImage(iimage); + } + + public Image getTopLeftOverlay(final Object element, + final ETypedElement eTypedElement) { + return getImage(element, this.propertiesHandler.getTopLeftOverlayProperty(), eTypedElement); + } + + public Image getTopMiddleOverlay(final Object element, + final ETypedElement eTypedElement) { + return getImage(element, this.propertiesHandler.getTopMiddleOverlayProperty(), eTypedElement); + } + + public Image getTopRightOverlay(final Object element, + final ETypedElement eTypedElement) { + return getImage(element, this.propertiesHandler.getTopRightOverlayProperty(), eTypedElement); + } + + public Image getBottomLeftOverlay(final Object element, + final ETypedElement eTypedElement) { + return getImage(element, this.propertiesHandler.getBottomLeftOverlayProperty(), eTypedElement); + } + + public Image getBottomMiddleOverlay(final Object element, + final ETypedElement eTypedElement) { + return getImage(element, this.propertiesHandler.getBottomMiddleOverlayProperty(), eTypedElement); + } + + public Image getBottomRightOverlay(final Object element, + final ETypedElement eTypedElement) { + return getImage(element, this.propertiesHandler.getBottomRightOverlayProperty(), eTypedElement); + } + + + @Override + public String getToolTipText(final Object element) { + return getPropertyValue(element, + this.propertiesHandler.getToolTipTextProperty(), null, String.class); + } + + @Override + public int getToolTipStyle(final Object element) { + int style = 0; + final Shadow shadow = getPropertyValue(element, + this.propertiesHandler.getToolTipShadowProperty(), null, + Shadow.class); + switch (shadow) { + case NONE: + style = SWT.SHADOW_NONE; + break; + case IN: + style = SWT.SHADOW_IN; + break; + case OUT: + style = SWT.SHADOW_OUT; + break; + default: + throw new IllegalStateException("Un expected value"); //$NON-NLS-1$ + } + + final Alignment alignment = getPropertyValue(element, + this.propertiesHandler.getToolTipAlignmentProperty(), null, + Alignment.class); + switch (alignment) { + case LEFT: + style |= SWT.LEFT; + break; + case CENTER: + style |= SWT.CENTER; + break; + case RIGHT: + style |= SWT.RIGHT; + break; + default: + throw new IllegalStateException("Un expected value"); //$NON-NLS-1$ + } + + return style; + } + + @Override + public Image getToolTipImage(final Object element) { + return getPropertyValue(element, + this.propertiesHandler.getToolTipImageProperty(), null, Image.class); + } + + @Override + public Color getToolTipBackgroundColor(final Object element) { + final IColor color = getPropertyValue(element, + this.propertiesHandler.getToolTipBackgroundProperty(), + null, IColor.class); + return getColor(new RGB(color.getRed(), color.getGreen(), color.getBlue())); + } + + @Override + public Color getToolTipForegroundColor(final Object element) { + final IColor color = getPropertyValue(element, + this.propertiesHandler.getToolTipForegroundProperty(), + null, IColor.class); + return getColor(new RGB(color.getRed(), color.getGreen(), color.getBlue())); + } + + public Image getToolTipTopLeftOverlay(final Object element, + final ETypedElement eTypedElement) { + return getPropertyValue(element, + this.propertiesHandler.getToolTipTopLeftOverlayProperty(), + null, Image.class); + } + + public Image getToolTipTopMiddleOverlay(final Object element, + final ETypedElement eTypedElement) { + return getPropertyValue(element, + this.propertiesHandler.getToolTipTopMiddleOverlayProperty(), + null, Image.class); + } + + public Image getToolTipTopRightOverlay(final Object element, + final ETypedElement eTypedElement) { + return getPropertyValue(element, + this.propertiesHandler.getToolTipTopRightOverlayProperty(), + null, Image.class); + } + + public Image getToolTipBottomLeftOverlay(final Object element, + final ETypedElement eTypedElement) { + return getPropertyValue(element, + this.propertiesHandler.getToolTipBottomLeftOverlayProperty(), + null, Image.class); + } + + public Image getToolTipBottomMiddleOverlay(final Object element, + final ETypedElement eTypedElement) { + return getPropertyValue(element, + this.propertiesHandler.getToolTipBottomMiddleOverlayProperty(), + null, Image.class); + } + + public Image getToolTipBottomRightOverlay(final Object element, + final ETypedElement eTypedElement) { + return getPropertyValue(element, + this.propertiesHandler.getToolTipBottomRightOverlayProperty(), + null, Image.class); + } + + @Override + public int getToolTipDisplayDelayTime(final Object element) { + return getPropertyValue(element, + this.propertiesHandler.getToolTipDisplayDelayTimeProperty(), + null, Integer.class).intValue(); + } + + @Override + public int getToolTipTimeDisplayed(final Object element) { + return getPropertyValue(element, + this.propertiesHandler.getToolTipTimeDisplayedProperty(), null, + Integer.class).intValue(); + + } + + @Override + public Font getToolTipFont(final Object element) { + + final String fontName = getPropertyValue(element, + this.propertiesHandler.getToolTipFontNameProperty(), null, + String.class); + final Integer fontSize = getPropertyValue(element, + this.propertiesHandler.getToolTipFontSizeProperty(), null, + Integer.class); + final Boolean isBold = getPropertyValue(element, + this.propertiesHandler.getToolTipIsBoldProperty(), null, + Boolean.class); + final Boolean isItalic = getPropertyValue(element, + this.propertiesHandler.getToolTipIsItalicProperty(), null, + Boolean.class); + int fontStyle = 0; + if (isBold.booleanValue()) { + fontStyle = fontStyle | SWT.BOLD; + } + if (isItalic.booleanValue()) { + fontStyle = fontStyle | SWT.ITALIC; + } + final FontData fontData = new FontData(fontName, fontSize.intValue(), + fontStyle); + final IFontProvider fontProvider = IFontProviderFactory.DEFAULT + .getOrCreateIFontProvider(Display.getDefault()); + return fontProvider.getFont(fontData); + } + + @Override + public void update(final ViewerCell cell) { + final Object element = cell.getElement(); + cell.setText(getText(element)); + cell.setBackground(getBackground(element)); + cell.setFont(getFont(element)); + cell.setForeground(getForeground(element)); + cell.setImage(getImage(element)); + } + + public String getToolTipText(final Object element, + final ETypedElement eTypedElement) { + + return null; + } + + public Image getToolTipImage(final Object element, + final ETypedElement eTypedElement) { + + return null; + } + + public Font getToolTipFont(final Object element, + final ETypedElement eTypedElement) { + + return null; + } + + public Color getToolTipBackgroundColor(final Object element, + final ETypedElement eTypedElement) { + + return null; + } + + public Color getToolTipForegroundColor(final Object element, + final ETypedElement eTypedElement) { + + return null; + } + + public int getToolTipTimeDisplayed(final Object element, + final ETypedElement eTypedElement) { + + return 0; + } + + public int getToolTipDisplayDelayTime(final Object element, + final ETypedElement eTypedElement) { + + return 0; + } + + public int getToolTipStyle(final Object element, + final ETypedElement eTypedElement) { + + return 0; + } + + public ICustomizedLabelProvider cloneLabelProvider() { + return new CustomizedLabelProvider(this.customManager); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedLabelProviderFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedLabelProviderFactory.java index c945d530342..45977e083a1 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedLabelProviderFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/CustomizedLabelProviderFactory.java @@ -1,28 +1,28 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * David Couvrand (Soft-Maint) - Bug 418418 - [Customization] Overlay icons not implemented
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal;
-
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider;
-import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProviderFactory;
-
-public class CustomizedLabelProviderFactory implements
- ICustomizedLabelProviderFactory {
-
- public ICustomizedLabelProvider createCustomizedLabelProvider(
- final ICustomizationManager customizationMgr) {
- return new DecoratingCustomizedLabelProvider(
- customizationMgr);
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * David Couvrand (Soft-Maint) - Bug 418418 - [Customization] Overlay icons not implemented + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal; + +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider; +import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProviderFactory; + +public class CustomizedLabelProviderFactory implements + ICustomizedLabelProviderFactory { + + public ICustomizedLabelProvider createCustomizedLabelProvider( + final ICustomizationManager customizationMgr) { + return new DecoratingCustomizedLabelProvider( + customizationMgr); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/DecoratingCustomizedLabelProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/DecoratingCustomizedLabelProvider.java index b16b59b9798..6ec76f6dcf3 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/DecoratingCustomizedLabelProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/DecoratingCustomizedLabelProvider.java @@ -1,204 +1,204 @@ -/*******************************************************************************
- * Copyright (c) 2013 Soft-Maint.
- * 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:
- * David Couvrand (Soft-Maint) - Bug 418418 - [Customization] Overlay icons not implemented
- * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - implementation of getStyledText
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.custom.ui.internal;
-
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider;
-import org.eclipse.jface.viewers.IDecorationContext;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.StyledString;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-
-public class DecoratingCustomizedLabelProvider extends
- DecoratingStyledCellLabelProvider implements ICustomizedLabelProvider {
-
- private ICustomizedLabelProvider lblProvider;
-
- private DecoratingCustomizedLabelProvider(
- final IStyledLabelProvider labelProvider,
- final ILabelDecorator decorator,
- final IDecorationContext decorationContext) {
- super(labelProvider, decorator, decorationContext);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider#getStyledText(java.lang.Object)
- */
- @Override
- public StyledString getStyledText(final Object element) {
- return this.lblProvider.getStyledText(element);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider#getStyledText(java.lang.Object, org.eclipse.emf.ecore.ETypedElement)
- */
- @Override
- public StyledString getStyledText(final Object element, final ETypedElement eTypedElement) {
- return this.lblProvider.getStyledText(element, eTypedElement);
- }
-
- public DecoratingCustomizedLabelProvider(
- final ICustomizationManager customizationMgr) {
- this(new CustomizedLabelProvider(customizationMgr),
- new CustomizedLabelDecorator(customizationMgr), null);
- this.lblProvider = (ICustomizedLabelProvider) getStyledStringProvider();
- }
-
- public String getText(final Object element) {
- return this.lblProvider.getText(element);
- }
-
- public String getToolTipText(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getToolTipText(element, eTypedElement);
- }
-
- public Image getToolTipImage(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getToolTipImage(element, eTypedElement);
- }
-
- public Font getToolTipFont(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getToolTipFont(element, eTypedElement);
- }
-
- public Color getToolTipBackgroundColor(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getToolTipBackgroundColor(element,
- eTypedElement);
- }
-
- public Color getToolTipForegroundColor(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getToolTipForegroundColor(element,
- eTypedElement);
- }
-
- public Image getToolTipTopLeftOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider
- .getToolTipTopLeftOverlay(element, eTypedElement);
- }
-
- public Image getToolTipTopMiddleOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getToolTipTopMiddleOverlay(element,
- eTypedElement);
- }
-
- public Image getToolTipTopRightOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getToolTipTopRightOverlay(element,
- eTypedElement);
- }
-
- public Image getToolTipBottomLeftOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getToolTipBottomLeftOverlay(element,
- eTypedElement);
- }
-
- public Image getToolTipBottomMiddleOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getToolTipBottomMiddleOverlay(element,
- eTypedElement);
- }
-
- public Image getToolTipBottomRightOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getToolTipBottomRightOverlay(element,
- eTypedElement);
- }
-
- public int getToolTipTimeDisplayed(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getToolTipTimeDisplayed(element, eTypedElement);
- }
-
- public int getToolTipDisplayDelayTime(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getToolTipDisplayDelayTime(element,
- eTypedElement);
- }
-
- public int getToolTipStyle(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getToolTipStyle(element, eTypedElement);
- }
-
- public ICustomizationManager getCustomizationManager() {
- return this.lblProvider.getCustomizationManager();
- }
-
- public boolean isUnderlined(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.isUnderlined(element, eTypedElement);
- }
-
- public boolean isStruckthrough(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.isStruckthrough(element, eTypedElement);
- }
-
- public Image getTopLeftOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getTopLeftOverlay(element, eTypedElement);
- }
-
- public Image getTopMiddleOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getTopMiddleOverlay(element, eTypedElement);
- }
-
- public Image getTopRightOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getTopRightOverlay(element, eTypedElement);
- }
-
- public Image getBottomLeftOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getBottomLeftOverlay(element, eTypedElement);
- }
-
- public Image getBottomMiddleOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getBottomMiddleOverlay(element, eTypedElement);
- }
-
- public Image getBottomRightOverlay(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getBottomRightOverlay(element, eTypedElement);
- }
-
- public String getText(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getText(element, eTypedElement);
- }
-
- public Image getImage(final Object element,
- final ETypedElement eTypedElement) {
- return this.lblProvider.getImage(element, eTypedElement);
- }
-
- public ICustomizedLabelProvider cloneLabelProvider() {
- return this.lblProvider.cloneLabelProvider();
- }
-}
+/******************************************************************************* + * Copyright (c) 2013 Soft-Maint. + * 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: + * David Couvrand (Soft-Maint) - Bug 418418 - [Customization] Overlay icons not implemented + * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - implementation of getStyledText + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.custom.ui.internal; + +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider; +import org.eclipse.jface.viewers.IDecorationContext; +import org.eclipse.jface.viewers.ILabelDecorator; +import org.eclipse.jface.viewers.StyledString; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; + +public class DecoratingCustomizedLabelProvider extends + DecoratingStyledCellLabelProvider implements ICustomizedLabelProvider { + + private ICustomizedLabelProvider lblProvider; + + private DecoratingCustomizedLabelProvider( + final IStyledLabelProvider labelProvider, + final ILabelDecorator decorator, + final IDecorationContext decorationContext) { + super(labelProvider, decorator, decorationContext); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider#getStyledText(java.lang.Object) + */ + @Override + public StyledString getStyledText(final Object element) { + return this.lblProvider.getStyledText(element); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider#getStyledText(java.lang.Object, org.eclipse.emf.ecore.ETypedElement) + */ + @Override + public StyledString getStyledText(final Object element, final ETypedElement eTypedElement) { + return this.lblProvider.getStyledText(element, eTypedElement); + } + + public DecoratingCustomizedLabelProvider( + final ICustomizationManager customizationMgr) { + this(new CustomizedLabelProvider(customizationMgr), + new CustomizedLabelDecorator(customizationMgr), null); + this.lblProvider = (ICustomizedLabelProvider) getStyledStringProvider(); + } + + public String getText(final Object element) { + return this.lblProvider.getText(element); + } + + public String getToolTipText(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getToolTipText(element, eTypedElement); + } + + public Image getToolTipImage(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getToolTipImage(element, eTypedElement); + } + + public Font getToolTipFont(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getToolTipFont(element, eTypedElement); + } + + public Color getToolTipBackgroundColor(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getToolTipBackgroundColor(element, + eTypedElement); + } + + public Color getToolTipForegroundColor(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getToolTipForegroundColor(element, + eTypedElement); + } + + public Image getToolTipTopLeftOverlay(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider + .getToolTipTopLeftOverlay(element, eTypedElement); + } + + public Image getToolTipTopMiddleOverlay(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getToolTipTopMiddleOverlay(element, + eTypedElement); + } + + public Image getToolTipTopRightOverlay(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getToolTipTopRightOverlay(element, + eTypedElement); + } + + public Image getToolTipBottomLeftOverlay(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getToolTipBottomLeftOverlay(element, + eTypedElement); + } + + public Image getToolTipBottomMiddleOverlay(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getToolTipBottomMiddleOverlay(element, + eTypedElement); + } + + public Image getToolTipBottomRightOverlay(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getToolTipBottomRightOverlay(element, + eTypedElement); + } + + public int getToolTipTimeDisplayed(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getToolTipTimeDisplayed(element, eTypedElement); + } + + public int getToolTipDisplayDelayTime(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getToolTipDisplayDelayTime(element, + eTypedElement); + } + + public int getToolTipStyle(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getToolTipStyle(element, eTypedElement); + } + + public ICustomizationManager getCustomizationManager() { + return this.lblProvider.getCustomizationManager(); + } + + public boolean isUnderlined(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.isUnderlined(element, eTypedElement); + } + + public boolean isStruckthrough(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.isStruckthrough(element, eTypedElement); + } + + public Image getTopLeftOverlay(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getTopLeftOverlay(element, eTypedElement); + } + + public Image getTopMiddleOverlay(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getTopMiddleOverlay(element, eTypedElement); + } + + public Image getTopRightOverlay(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getTopRightOverlay(element, eTypedElement); + } + + public Image getBottomLeftOverlay(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getBottomLeftOverlay(element, eTypedElement); + } + + public Image getBottomMiddleOverlay(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getBottomMiddleOverlay(element, eTypedElement); + } + + public Image getBottomRightOverlay(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getBottomRightOverlay(element, eTypedElement); + } + + public String getText(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getText(element, eTypedElement); + } + + public Image getImage(final Object element, + final ETypedElement eTypedElement) { + return this.lblProvider.getImage(element, eTypedElement); + } + + public ICustomizedLabelProvider cloneLabelProvider() { + return this.lblProvider.cloneLabelProvider(); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/DefaultCustomOverride.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/DefaultCustomOverride.java index 89d896f3406..e15d3db44b8 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/DefaultCustomOverride.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/DefaultCustomOverride.java @@ -1,55 +1,55 @@ -/**
- * Copyright (c) 2013 Soft-Maint.
- *
- * 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:
- * David Couvrand (Soft-Maint) - Bug 422058 - Implementation of strikethrough and underline in the CustomizedLabelProvider
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.core.exception.CustomizationException;
-import org.eclipse.papyrus.emf.facet.custom.ui.ICustomOverride;
-import org.eclipse.papyrus.emf.facet.custom.ui.IFontPropertiesHandler;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.swt.graphics.FontData;
-
-public class DefaultCustomOverride implements ICustomOverride {
-
- public String getText(final String result, final Object object,
- final ICustomizationManager customManager,
- final IFontPropertiesHandler propertiesHandler)
- throws CustomizationException {
- String newResult = result;
- if (object instanceof EObject) {
- final EObject eObject = (EObject) object;
- final FacetOperation isStruckProp = propertiesHandler
- .getIsStruckthroughProperty();
- final boolean isStruckthrough = customManager.getCustomValueOf(
- eObject, isStruckProp, Boolean.class).booleanValue();
- if (isStruckthrough) {
- newResult = String.format("--%s--", newResult); //$NON-NLS-1$
- }
- final FacetOperation isUnderlinedProp = propertiesHandler
- .getIsUnderlinedProperty();
- final boolean isUnderlined = customManager.getCustomValueOf(
- eObject, isUnderlinedProp, Boolean.class).booleanValue();
- if (isUnderlined) {
- newResult = String.format("__%s__", newResult); //$NON-NLS-1$
- }
- }
- return newResult;
- }
-
- public FontData getFont(final FontData fontData, final Object object,
- final ICustomizationManager customManager,
- final IFontPropertiesHandler propertiesHandler) {
- return fontData;
- }
-
-}
+/** + * Copyright (c) 2013 Soft-Maint. + * + * 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: + * David Couvrand (Soft-Maint) - Bug 422058 - Implementation of strikethrough and underline in the CustomizedLabelProvider + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.core.exception.CustomizationException; +import org.eclipse.papyrus.emf.facet.custom.ui.ICustomOverride; +import org.eclipse.papyrus.emf.facet.custom.ui.IFontPropertiesHandler; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.swt.graphics.FontData; + +public class DefaultCustomOverride implements ICustomOverride { + + public String getText(final String result, final Object object, + final ICustomizationManager customManager, + final IFontPropertiesHandler propertiesHandler) + throws CustomizationException { + String newResult = result; + if (object instanceof EObject) { + final EObject eObject = (EObject) object; + final FacetOperation isStruckProp = propertiesHandler + .getIsStruckthroughProperty(); + final boolean isStruckthrough = customManager.getCustomValueOf( + eObject, isStruckProp, Boolean.class).booleanValue(); + if (isStruckthrough) { + newResult = String.format("--%s--", newResult); //$NON-NLS-1$ + } + final FacetOperation isUnderlinedProp = propertiesHandler + .getIsUnderlinedProperty(); + final boolean isUnderlined = customManager.getCustomValueOf( + eObject, isUnderlinedProp, Boolean.class).booleanValue(); + if (isUnderlined) { + newResult = String.format("__%s__", newResult); //$NON-NLS-1$ + } + } + return newResult; + } + + public FontData getFont(final FontData fontData, final Object object, + final ICustomizationManager customManager, + final IFontPropertiesHandler propertiesHandler) { + return fontData; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/ImageProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/ImageProvider.java index 0a3b73a5e82..5fbeb467f25 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/ImageProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/ImageProvider.java @@ -1,181 +1,181 @@ -/*******************************************************************************
- * Copyright (c) 2008, 2010 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- * Vincent Lorenzo (CEA-LIST) - bug 341238 - We need to be able to specify which column have to be hidden/visible using the customization mechanism
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider
- *******************************************************************************/
-
-package org.eclipse.papyrus.emf.facet.custom.ui.internal;
-
-import java.net.URL;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-/** A singleton image provider, which caches image descriptors */
-public final class ImageProvider {
-
- private ImageProvider() {
- // This class must only be instantiated by getInstance().
- }
-
- private static ImageProvider instance;
-
- public static ImageProvider getInstance() {
- if (ImageProvider.instance == null) {
- ImageProvider.instance = new ImageProvider();
- }
- return ImageProvider.instance;
- }
-
- private Image uiCustomIcon = null;
- private Image grayedUiCustomIcon;
-
- private Image linkIcon = null;
- private Image linkUniDirIcon = null;
- private Image linkFacetIcon = null;
- private Image aggregIcon = null;
- private Image aggregUniDirIcon = null;
- private Image invAggregIcon = null;
-
- private Image attributeIcon = null;
- private Image attribFacetIcon = null;
- private Image featureIcon = null;
-
- private static final String UI_CUSTOM = "icons/uiCustom.gif"; //$NON-NLS-1$
-
- private static final String AGGREG_UNIDIR = "icons/aggreg_unidir.gif"; //$NON-NLS-1$
- private static final String AGGREG_ICON_PATH = "icons/aggreg.gif"; //$NON-NLS-1$
- private static final String ATTRIBUTE_FACET = "icons/attribute_facet"; //$NON-NLS-1$
- private static final String ATTRIBUTE = "icons/attributes.gif"; //$NON-NLS-1$
- private static final String INV_AGGREG = "icons/inv_aggreg.gif"; //$NON-NLS-1$
- private static final String LINK_FACET = "icons/link_unidir_facet.gif"; //$NON-NLS-1$
- private static final String LINK_UNIDIR = "icons/link_unidir.gif"; //$NON-NLS-1$
- private static final String LINK_ICON_PATH = "icons/link.gif"; //$NON-NLS-1$
- private static final String FEATURE_ICON_PATH = "icons/feature.gif"; //$NON-NLS-1$
-
- /**
- * Create an image descriptor from a resource
- *
- * @param resourcePath
- * the path of the resource (in the bundle)
- * @return the image descriptor
- */
- private static ImageDescriptor createImageDescriptor(final String resourcePath) {
- final URL url = Activator.getDefault().getBundle().getResource(resourcePath);
- ImageDescriptor result;
- if (url == null) {
- Logger.logError(NLS.bind("Resource not found: {0}", //$NON-NLS-1$
- resourcePath), Activator.getDefault());
- result = ImageDescriptor.getMissingImageDescriptor();
- } else {
- result = ImageDescriptor.createFromURL(url);
- }
- return result;
- }
-
- /** Return an icon for "uiCustom" */
- public Image getUiCustomIcon() {
- if (this.uiCustomIcon == null) {
- this.uiCustomIcon = createImageDescriptor(ImageProvider.UI_CUSTOM)
- .createImage();
- }
- return this.uiCustomIcon;
- }
-
- public Image getGrayedUiCustomIcon() {
- if (this.grayedUiCustomIcon == null) {
- this.grayedUiCustomIcon = new Image(Display.getCurrent(), getUiCustomIcon(), SWT.IMAGE_GRAY);
- }
- return this.grayedUiCustomIcon;
- }
-
- /** Return the icon representing a bidirectional link */
- public Image getLinkIcon() {
- if (this.linkIcon == null) {
- this.linkIcon = createImageDescriptor(ImageProvider.LINK_ICON_PATH).createImage();
- }
- return this.linkIcon;
- }
-
- /** Return the icon representing an unidirectional link */
- public Image getUnidirectionalLinkIcon() {
- if (this.linkUniDirIcon == null) {
- this.linkUniDirIcon = createImageDescriptor(ImageProvider.LINK_UNIDIR)
- .createImage();
- }
- return this.linkUniDirIcon;
- }
-
- /** Return the icon representing a facet reference */
- public Image getFacetLinkIcon() {
- if (this.linkFacetIcon == null) {
- this.linkFacetIcon = createImageDescriptor(ImageProvider.LINK_FACET)
- .createImage();
- }
- return this.linkFacetIcon;
- }
-
- /** Return the icon representing a composition link */
- public Image getAggregIcon() {
- if (this.aggregIcon == null) {
- this.aggregIcon = createImageDescriptor(ImageProvider.AGGREG_ICON_PATH).createImage();
- }
- return this.aggregIcon;
- }
-
- /** Return the icon representing an unidirectional composition link */
- public Image getUnidirectionalAggregIcon() {
- if (this.aggregUniDirIcon == null) {
- this.aggregUniDirIcon = createImageDescriptor(ImageProvider.AGGREG_UNIDIR)
- .createImage();
- }
- return this.aggregUniDirIcon;
- }
-
- /** Return the icon representing a reverse composition link */
- public Image getInvAggregIcon() {
- if (this.invAggregIcon == null) {
- this.invAggregIcon = createImageDescriptor(ImageProvider.INV_AGGREG)
- .createImage();
- }
- return this.invAggregIcon;
- }
-
- /** Return the "attribute" icon */
- public Image getAttributeIcon() {
- if (this.attributeIcon == null) {
- this.attributeIcon = createImageDescriptor(ImageProvider.ATTRIBUTE)
- .createImage();
- }
- return this.attributeIcon;
- }
-
- /** Return the "facet attribute" icon */
- public Image getFacetAttributeIcon() {
- if (this.attribFacetIcon == null) {
- this.attribFacetIcon = createImageDescriptor(ImageProvider.ATTRIBUTE_FACET)
- .createImage();
- }
- return this.attribFacetIcon;
- }
-
- /** Return the "feature" icon */
- public Image getFeatureIcon() {
- if (this.featureIcon == null) {
- this.featureIcon = createImageDescriptor(ImageProvider.FEATURE_ICON_PATH).createImage();
- }
- return this.featureIcon;
- }
-}
+/******************************************************************************* + * Copyright (c) 2008, 2010 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - initial API and implementation + * Vincent Lorenzo (CEA-LIST) - bug 341238 - We need to be able to specify which column have to be hidden/visible using the customization mechanism + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider + *******************************************************************************/ + +package org.eclipse.papyrus.emf.facet.custom.ui.internal; + +import java.net.URL; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.osgi.util.NLS; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Display; + +/** A singleton image provider, which caches image descriptors */ +public final class ImageProvider { + + private ImageProvider() { + // This class must only be instantiated by getInstance(). + } + + private static ImageProvider instance; + + public static ImageProvider getInstance() { + if (ImageProvider.instance == null) { + ImageProvider.instance = new ImageProvider(); + } + return ImageProvider.instance; + } + + private Image uiCustomIcon = null; + private Image grayedUiCustomIcon; + + private Image linkIcon = null; + private Image linkUniDirIcon = null; + private Image linkFacetIcon = null; + private Image aggregIcon = null; + private Image aggregUniDirIcon = null; + private Image invAggregIcon = null; + + private Image attributeIcon = null; + private Image attribFacetIcon = null; + private Image featureIcon = null; + + private static final String UI_CUSTOM = "icons/uiCustom.gif"; //$NON-NLS-1$ + + private static final String AGGREG_UNIDIR = "icons/aggreg_unidir.gif"; //$NON-NLS-1$ + private static final String AGGREG_ICON_PATH = "icons/aggreg.gif"; //$NON-NLS-1$ + private static final String ATTRIBUTE_FACET = "icons/attribute_facet"; //$NON-NLS-1$ + private static final String ATTRIBUTE = "icons/attributes.gif"; //$NON-NLS-1$ + private static final String INV_AGGREG = "icons/inv_aggreg.gif"; //$NON-NLS-1$ + private static final String LINK_FACET = "icons/link_unidir_facet.gif"; //$NON-NLS-1$ + private static final String LINK_UNIDIR = "icons/link_unidir.gif"; //$NON-NLS-1$ + private static final String LINK_ICON_PATH = "icons/link.gif"; //$NON-NLS-1$ + private static final String FEATURE_ICON_PATH = "icons/feature.gif"; //$NON-NLS-1$ + + /** + * Create an image descriptor from a resource + * + * @param resourcePath + * the path of the resource (in the bundle) + * @return the image descriptor + */ + private static ImageDescriptor createImageDescriptor(final String resourcePath) { + final URL url = Activator.getDefault().getBundle().getResource(resourcePath); + ImageDescriptor result; + if (url == null) { + Logger.logError(NLS.bind("Resource not found: {0}", //$NON-NLS-1$ + resourcePath), Activator.getDefault()); + result = ImageDescriptor.getMissingImageDescriptor(); + } else { + result = ImageDescriptor.createFromURL(url); + } + return result; + } + + /** Return an icon for "uiCustom" */ + public Image getUiCustomIcon() { + if (this.uiCustomIcon == null) { + this.uiCustomIcon = createImageDescriptor(ImageProvider.UI_CUSTOM) + .createImage(); + } + return this.uiCustomIcon; + } + + public Image getGrayedUiCustomIcon() { + if (this.grayedUiCustomIcon == null) { + this.grayedUiCustomIcon = new Image(Display.getCurrent(), getUiCustomIcon(), SWT.IMAGE_GRAY); + } + return this.grayedUiCustomIcon; + } + + /** Return the icon representing a bidirectional link */ + public Image getLinkIcon() { + if (this.linkIcon == null) { + this.linkIcon = createImageDescriptor(ImageProvider.LINK_ICON_PATH).createImage(); + } + return this.linkIcon; + } + + /** Return the icon representing an unidirectional link */ + public Image getUnidirectionalLinkIcon() { + if (this.linkUniDirIcon == null) { + this.linkUniDirIcon = createImageDescriptor(ImageProvider.LINK_UNIDIR) + .createImage(); + } + return this.linkUniDirIcon; + } + + /** Return the icon representing a facet reference */ + public Image getFacetLinkIcon() { + if (this.linkFacetIcon == null) { + this.linkFacetIcon = createImageDescriptor(ImageProvider.LINK_FACET) + .createImage(); + } + return this.linkFacetIcon; + } + + /** Return the icon representing a composition link */ + public Image getAggregIcon() { + if (this.aggregIcon == null) { + this.aggregIcon = createImageDescriptor(ImageProvider.AGGREG_ICON_PATH).createImage(); + } + return this.aggregIcon; + } + + /** Return the icon representing an unidirectional composition link */ + public Image getUnidirectionalAggregIcon() { + if (this.aggregUniDirIcon == null) { + this.aggregUniDirIcon = createImageDescriptor(ImageProvider.AGGREG_UNIDIR) + .createImage(); + } + return this.aggregUniDirIcon; + } + + /** Return the icon representing a reverse composition link */ + public Image getInvAggregIcon() { + if (this.invAggregIcon == null) { + this.invAggregIcon = createImageDescriptor(ImageProvider.INV_AGGREG) + .createImage(); + } + return this.invAggregIcon; + } + + /** Return the "attribute" icon */ + public Image getAttributeIcon() { + if (this.attributeIcon == null) { + this.attributeIcon = createImageDescriptor(ImageProvider.ATTRIBUTE) + .createImage(); + } + return this.attributeIcon; + } + + /** Return the "facet attribute" icon */ + public Image getFacetAttributeIcon() { + if (this.attribFacetIcon == null) { + this.attribFacetIcon = createImageDescriptor(ImageProvider.ATTRIBUTE_FACET) + .createImage(); + } + return this.attribFacetIcon; + } + + /** Return the "feature" icon */ + public Image getFeatureIcon() { + if (this.featureIcon == null) { + this.featureIcon = createImageDescriptor(ImageProvider.FEATURE_ICON_PATH).createImage(); + } + return this.featureIcon; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/Messages.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/Messages.java index ce1f53830c3..925f0e21d3c 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/Messages.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/Messages.java @@ -1,70 +1,70 @@ -/*******************************************************************************
- * Copyright (c) 2009 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Nicolas Bros (Mia-Software) - Bug 372732 - [Facet] Rewrite the catalog views for 0.2
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Vincent Lorenzo (CEA-LIST) - Bug 373255 - Add tooltips providing a documentation for the selected elements in the Select ETypedElement Dialog
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.custom.ui.internal;
-
-import org.eclipse.osgi.util.NLS;
-
-public final class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.papyrus.emf.facet.custom.ui.internal.messages"; //$NON-NLS-1$
- public static String CustomizationsCatalogView_title;
- public static String CustomizationsView_allQuerySets;
- public static String CustomizationsView_jobName_RefreshCustomizationsView;
- public static String CustomizationsView_extendsColumn;
- public static String CustomizationsView_nameColumn;
- public static String CustomizationsView_documentationColumn;
- public static String CustomizedLabelProvider_null;
- public static String NewCustomizationFilePage_browserCustomization;
- public static String NewCustomizationFilePage_createsBrowserCustomization;
- public static String NewCustomizationFilePage_customizationInNonEmfFacetProject;
- public static String NewCustomizationWizard_newBrowserCustomization;
- public static String QuerySetsSelectionControl_allExistingQuerySets;
- public static String QuerySetsSelectionControl_availableQuerySets;
- public static String QuerySetsSelectionControl_deselectAll;
- public static String QuerySetsSelectionControl_querySetsSelectedBelowOnly;
- public static String QuerySetsSelectionControl_selectAll;
- public static String SelectMetamodelsPage_selectMetamodel;
- public static String SelectMetamodelsPage_selectMetamodelToCustomize;
- public static String SelectQuerySetsPage_selectAvailableQuerySets;
- public static String SelectQuerySetsPage_selectAvailableQuerySetsInCustomization;
- public static String LoadCustomizationsDialog_Add;
- public static String LoadCustomizationsDialog_Add2;
- public static String LoadCustomizationsDialog_AddAll;
- public static String LoadCustomizationsDialog_AddAll2;
- public static String LoadCustomizationsDialog_AvailiableCustom;
- public static String LoadCustomizationsDialog_Can_not_be_unload;
- public static String LoadCustomizationsDialog_Down;
- public static String LoadCustomizationsDialog_LoadedCustomizations;
- public static String LoadCustomizationsDialog_LoadCustomizationWarning;
- public static String LoadCustomizationsDialog_Loading;
- public static String LoadCustomizationsDialog_loadReferencedFacetsCheckbox;
- public static String LoadCustomizationsDialog_OK;
- public static String LoadCustomizationsDialog_Remove;
- public static String LoadCustomizationsDialog_Remove2;
- public static String LoadCustomizationsDialog_RemoveAll;
- public static String LoadCustomizationsDialog_RemoveAll2;
- public static String LoadCustomizationsDialog_title_LoadCustomizations;
- public static String LoadCustomizationsDialog_type_filter_test;
- public static String LoadCustomizationsDialog_Up;
- public static String ToolTipTextQuery_Documentation;
- public static String ToolTipTextQuery_NoDocumentation;
- static {
- // initialize resource bundle
- NLS.initializeMessages(Messages.BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- // cannot be instantiated
- }
-}
+/******************************************************************************* + * Copyright (c) 2009 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - initial API and implementation + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Nicolas Bros (Mia-Software) - Bug 372732 - [Facet] Rewrite the catalog views for 0.2 + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Vincent Lorenzo (CEA-LIST) - Bug 373255 - Add tooltips providing a documentation for the selected elements in the Select ETypedElement Dialog + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.custom.ui.internal; + +import org.eclipse.osgi.util.NLS; + +public final class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.papyrus.emf.facet.custom.ui.internal.messages"; //$NON-NLS-1$ + public static String CustomizationsCatalogView_title; + public static String CustomizationsView_allQuerySets; + public static String CustomizationsView_jobName_RefreshCustomizationsView; + public static String CustomizationsView_extendsColumn; + public static String CustomizationsView_nameColumn; + public static String CustomizationsView_documentationColumn; + public static String CustomizedLabelProvider_null; + public static String NewCustomizationFilePage_browserCustomization; + public static String NewCustomizationFilePage_createsBrowserCustomization; + public static String NewCustomizationFilePage_customizationInNonEmfFacetProject; + public static String NewCustomizationWizard_newBrowserCustomization; + public static String QuerySetsSelectionControl_allExistingQuerySets; + public static String QuerySetsSelectionControl_availableQuerySets; + public static String QuerySetsSelectionControl_deselectAll; + public static String QuerySetsSelectionControl_querySetsSelectedBelowOnly; + public static String QuerySetsSelectionControl_selectAll; + public static String SelectMetamodelsPage_selectMetamodel; + public static String SelectMetamodelsPage_selectMetamodelToCustomize; + public static String SelectQuerySetsPage_selectAvailableQuerySets; + public static String SelectQuerySetsPage_selectAvailableQuerySetsInCustomization; + public static String LoadCustomizationsDialog_Add; + public static String LoadCustomizationsDialog_Add2; + public static String LoadCustomizationsDialog_AddAll; + public static String LoadCustomizationsDialog_AddAll2; + public static String LoadCustomizationsDialog_AvailiableCustom; + public static String LoadCustomizationsDialog_Can_not_be_unload; + public static String LoadCustomizationsDialog_Down; + public static String LoadCustomizationsDialog_LoadedCustomizations; + public static String LoadCustomizationsDialog_LoadCustomizationWarning; + public static String LoadCustomizationsDialog_Loading; + public static String LoadCustomizationsDialog_loadReferencedFacetsCheckbox; + public static String LoadCustomizationsDialog_OK; + public static String LoadCustomizationsDialog_Remove; + public static String LoadCustomizationsDialog_Remove2; + public static String LoadCustomizationsDialog_RemoveAll; + public static String LoadCustomizationsDialog_RemoveAll2; + public static String LoadCustomizationsDialog_title_LoadCustomizations; + public static String LoadCustomizationsDialog_type_filter_test; + public static String LoadCustomizationsDialog_Up; + public static String ToolTipTextQuery_Documentation; + public static String ToolTipTextQuery_NoDocumentation; + static { + // initialize resource bundle + NLS.initializeMessages(Messages.BUNDLE_NAME, Messages.class); + } + + private Messages() { + // cannot be instantiated + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/PropertiesHandler.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/PropertiesHandler.java index a33fef2cef2..12a5f4d731b 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/PropertiesHandler.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/PropertiesHandler.java @@ -1,345 +1,345 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- * Gregoire Dupe (Mia-Software) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Nicolas Bros (Mia-Software) - Bug 377866 - selection customization
- * David Couvrand (Soft-Maint) - Bug 422058 - Implementation of strikethrough and underline in the CustomizedLabelProvider
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.ui.IContentPropertiesHandler;
-import org.eclipse.papyrus.emf.facet.custom.ui.IFontPropertiesHandler;
-import org.eclipse.papyrus.emf.facet.custom.ui.ISelectionPropertiesHandler;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.ILabelPropertiesHandler;
-import org.eclipse.papyrus.emf.facet.efacet.core.FacetUtils;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-
-public class PropertiesHandler implements IContentPropertiesHandler,
- ILabelPropertiesHandler, ISelectionPropertiesHandler, IFontPropertiesHandler {
- private static final String SEPARATOR = "::"; //$NON-NLS-1$
- private static final String CUSTOM_PROPERTIES = "resources/customproperties.efacet"; //$NON-NLS-1$
-
- private static final String CUSTOM = "CustomizedEObject"; //$NON-NLS-1$
- private static final String TT_CUSTOM = "CustomizedToolTipEObject"; //$NON-NLS-1$
-
- private static final String IMAGE = "image"; //$NON-NLS-1$
- private static final String LABEL = "label"; //$NON-NLS-1$
- private static final String BACKGROUND = "background"; //$NON-NLS-1$
- private static final String FOREGROUND = "foreground"; //$NON-NLS-1$
- private static final String FONT = "fontName"; //$NON-NLS-1$
- private static final String FONT_SIZE = "fontSize"; //$NON-NLS-1$
- private static final String IS_BOLD = "isBold"; //$NON-NLS-1$
- private static final String IS_ITALIC = "isItalic"; //$NON-NLS-1$
- private static final String COLLAPSE_LINK = "collapseLink"; //$NON-NLS-1$
- private static final String IS_VISIBLE = "isVisible"; //$NON-NLS-1$
- private static final String VISIBLE_REFERENCES = "visibleReferences"; //$NON-NLS-1$
- private static final String VISIBLE_ATTRIBUTES = "visibleAttributes"; //$NON-NLS-1$
- private static final String IS_UNDERLINED = "isUnderlined"; //$NON-NLS-1$
- private static final String IS_STRUCKTHROUGH = "isStruckthrough"; //$NON-NLS-1$
- private static final String TOP_L_OVERLAY = "topLeftOverlay"; //$NON-NLS-1$
- private static final String TOP_M_OVERLAY = "topMiddleOverlay"; //$NON-NLS-1$
- private static final String TOP_R_OVERLAY = "topRightOverlay"; //$NON-NLS-1$
- private static final String BOTTOM_L_OVERLAY = "bottomLeftOverlay"; //$NON-NLS-1$
- private static final String BOTTOM_M_OVERLAY = "bottomMiddleOverlay"; //$NON-NLS-1$
- private static final String BOTTOM_R_OVERLAY = "bottomRightOverlay"; //$NON-NLS-1$
- private static final String SELECTION = "selection"; //$NON-NLS-1$
-
- // for tooltips
- private static final String TEXT = "text"; //$NON-NLS-1$
- private static final String TIME_DISPLAYED = "timeDisplayed"; //$NON-NLS-1$
- private static final String DISPLAY_DELAY = "displayDelayTime"; //$NON-NLS-1$
- private static final String SHADOW = "shadow"; //$NON-NLS-1$
- private static final String ALIGNMENT = "alignment"; //$NON-NLS-1$
-
- private final Resource resource;
- private final Map<String, FacetOperation> map = new HashMap<String, FacetOperation>();
-
- /**
- *
- * @deprecated Must be replaced by
- * org.eclipse.papyrus.emf.facet.custom.ui.internal.PropertiesHandler
- * .PropertiesHandler(ICustomizationManager)
- */
- @Deprecated
- public PropertiesHandler(final ResourceSet resourceSet) {
- final String bundleName = Activator.getDefault().getBundle().getSymbolicName();
- URI propertiesUri = URI.createPlatformPluginURI(bundleName, true);
- propertiesUri = propertiesUri
- .appendSegments(PropertiesHandler.CUSTOM_PROPERTIES.split("/")); //$NON-NLS-1$
- this.resource = resourceSet.getResource(propertiesUri, true);
- }
-
- public PropertiesHandler(final ICustomizationManager customizationMgr) {
- final String bundleName = Activator.getDefault().getBundle().getSymbolicName();
- URI propertiesUri = URI.createPlatformPluginURI(bundleName, true);
- propertiesUri = propertiesUri
- .appendSegments(PropertiesHandler.CUSTOM_PROPERTIES.split("/")); //$NON-NLS-1$
- final ResourceSet resourceSet = customizationMgr.getResourceSet();
- this.resource = resourceSet.getResource(propertiesUri, true);
- final FacetSet facetSet = (FacetSet) this.resource.getContents().get(0);
- customizationMgr.getFacetManager().getManagedFacetSets()
- .add(0, facetSet);
- }
-
- private FacetOperation getPropertyByName(final String facetName,
- final String propertyName) {
- final String key = facetName + PropertiesHandler.SEPARATOR + propertyName;
- FacetOperation result = this.map.get(key);
- if (result == null) {
- final FacetSet facetSet = (FacetSet) this.resource.getContents()
- .get(0);
- final Facet facet = FacetUtils.getFacet(
- FacetUtils.getFacets(facetSet),
- facetName);
- final ETypedElement eTypedElement = FacetUtils
- .getETypedElement(facet, propertyName,
- ETypedElement.class);
- if (eTypedElement instanceof FacetOperation) {
- result = (FacetOperation) eTypedElement;
- this.map.put(key, result);
- }
- }
- return result;
- }
-
- public FacetOperation getImageProperty() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.IMAGE);
- }
-
-
- @Override
- public FacetOperation getCollapseLink() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.COLLAPSE_LINK);
- }
-
- @Override
- public FacetOperation getLabelProperty() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.LABEL);
- }
-
- @Override
- public FacetOperation getBackgroundProperty() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.BACKGROUND);
- }
-
- @Override
- public FacetOperation getForegroundProperty() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.FOREGROUND);
- }
-
- @Override
- public FacetOperation getFontNameProperty() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.FONT);
- }
-
- @Override
- public FacetOperation getFontSizeProperty() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.FONT_SIZE);
- }
-
- @Override
- public FacetOperation getIsBoldProperty() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.IS_BOLD);
- }
-
- @Override
- public FacetOperation getIsItalicProperty() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.IS_ITALIC);
- }
-
- @Override
- public FacetOperation getIsVisible() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.IS_VISIBLE);
- }
-
- @Override
- public FacetOperation getIsUnderlinedProperty() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.IS_UNDERLINED);
- }
-
- @Override
- public FacetOperation getIsStruckthroughProperty() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.IS_STRUCKTHROUGH);
- }
-
- public FacetOperation getTopLeftOverlayProperty() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.TOP_L_OVERLAY);
- }
-
- public FacetOperation getTopMiddleOverlayProperty() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.TOP_M_OVERLAY);
- }
-
- public FacetOperation getTopRightOverlayProperty() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.TOP_R_OVERLAY);
- }
-
- public FacetOperation getBottomLeftOverlayProperty() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.BOTTOM_L_OVERLAY);
- }
-
- public FacetOperation getBottomMiddleOverlayProperty() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.BOTTOM_M_OVERLAY);
- }
-
- public FacetOperation getBottomRightOverlayProperty() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.BOTTOM_R_OVERLAY);
- }
-
- @Override
- public FacetOperation getSelectionProperty() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.SELECTION);
- }
-
- // methods for tooltips
- public FacetOperation getToolTipTextProperty() {
- return getPropertyByName(PropertiesHandler.TT_CUSTOM,
- PropertiesHandler.TEXT);
- }
-
- public FacetOperation getToolTipImageProperty() {
- return getPropertyByName(PropertiesHandler.TT_CUSTOM,
- PropertiesHandler.IMAGE);
- }
-
- public FacetOperation getToolTipFontNameProperty() {
- return getPropertyByName(PropertiesHandler.TT_CUSTOM,
- PropertiesHandler.FONT);
- }
-
- public FacetOperation getToolTipFontSizeProperty() {
- return getPropertyByName(PropertiesHandler.TT_CUSTOM,
- PropertiesHandler.FONT_SIZE);
- }
-
- public FacetOperation getToolTipIsBoldProperty() {
- return getPropertyByName(PropertiesHandler.TT_CUSTOM,
- PropertiesHandler.IS_BOLD);
- }
-
- public FacetOperation getToolTipIsItalicProperty() {
- return getPropertyByName(PropertiesHandler.TT_CUSTOM,
- PropertiesHandler.IS_ITALIC);
- }
-
- public FacetOperation getToolTipBackgroundProperty() {
- return getPropertyByName(PropertiesHandler.TT_CUSTOM,
- PropertiesHandler.BACKGROUND);
- }
-
- public FacetOperation getToolTipForegroundProperty() {
- return getPropertyByName(PropertiesHandler.TT_CUSTOM,
- PropertiesHandler.FOREGROUND);
- }
-
- public FacetOperation getToolTipTopLeftOverlayProperty() {
- return getPropertyByName(PropertiesHandler.TT_CUSTOM,
- PropertiesHandler.TOP_L_OVERLAY);
- }
-
- public FacetOperation getToolTipTopMiddleOverlayProperty() {
- return getPropertyByName(PropertiesHandler.TT_CUSTOM,
- PropertiesHandler.TOP_M_OVERLAY);
- }
-
- public FacetOperation getToolTipTopRightOverlayProperty() {
- return getPropertyByName(PropertiesHandler.TT_CUSTOM,
- PropertiesHandler.TOP_R_OVERLAY);
- }
-
- public FacetOperation getToolTipBottomLeftOverlayProperty() {
- return getPropertyByName(PropertiesHandler.TT_CUSTOM,
- PropertiesHandler.BOTTOM_L_OVERLAY);
- }
-
- public FacetOperation getToolTipBottomMiddleOverlayProperty() {
- return getPropertyByName(PropertiesHandler.TT_CUSTOM,
- PropertiesHandler.BOTTOM_M_OVERLAY);
- }
-
- public FacetOperation getToolTipBottomRightOverlayProperty() {
- return getPropertyByName(PropertiesHandler.TT_CUSTOM,
- PropertiesHandler.BOTTOM_R_OVERLAY);
- }
-
- public FacetOperation getToolTipTimeDisplayedProperty() {
- return getPropertyByName(PropertiesHandler.TT_CUSTOM,
- PropertiesHandler.TIME_DISPLAYED);
- }
-
- public FacetOperation getToolTipDisplayDelayTimeProperty() {
- return getPropertyByName(PropertiesHandler.TT_CUSTOM,
- PropertiesHandler.DISPLAY_DELAY);
- }
-
- public FacetOperation getToolTipAlignmentProperty() {
- return getPropertyByName(PropertiesHandler.TT_CUSTOM,
- PropertiesHandler.ALIGNMENT);
- }
-
- public FacetOperation getToolTipShadowProperty() {
- return getPropertyByName(PropertiesHandler.TT_CUSTOM,
- PropertiesHandler.SHADOW);
- }
-
- /**
- * @see org.eclipse.papyrus.emf.facet.custom.ui.IContentPropertiesHandler#getVisibleAttributes()
- *
- * @return
- */
- @Override
- public FacetOperation getVisibleAttributes() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.VISIBLE_ATTRIBUTES);
- }
-
- /**
- * @see org.eclipse.papyrus.emf.facet.custom.ui.IContentPropertiesHandler#getVisibleReferences()
- *
- * @return
- */
- @Override
- public FacetOperation getVisibleReferences() {
- return getPropertyByName(PropertiesHandler.CUSTOM,
- PropertiesHandler.VISIBLE_REFERENCES);
- }
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + * Gregoire Dupe (Mia-Software) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Nicolas Bros (Mia-Software) - Bug 377866 - selection customization + * David Couvrand (Soft-Maint) - Bug 422058 - Implementation of strikethrough and underline in the CustomizedLabelProvider + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.ui.IContentPropertiesHandler; +import org.eclipse.papyrus.emf.facet.custom.ui.IFontPropertiesHandler; +import org.eclipse.papyrus.emf.facet.custom.ui.ISelectionPropertiesHandler; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.ILabelPropertiesHandler; +import org.eclipse.papyrus.emf.facet.efacet.core.FacetUtils; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; + +public class PropertiesHandler implements IContentPropertiesHandler, + ILabelPropertiesHandler, ISelectionPropertiesHandler, IFontPropertiesHandler { + private static final String SEPARATOR = "::"; //$NON-NLS-1$ + private static final String CUSTOM_PROPERTIES = "resources/customproperties.efacet"; //$NON-NLS-1$ + + private static final String CUSTOM = "CustomizedEObject"; //$NON-NLS-1$ + private static final String TT_CUSTOM = "CustomizedToolTipEObject"; //$NON-NLS-1$ + + private static final String IMAGE = "image"; //$NON-NLS-1$ + private static final String LABEL = "label"; //$NON-NLS-1$ + private static final String BACKGROUND = "background"; //$NON-NLS-1$ + private static final String FOREGROUND = "foreground"; //$NON-NLS-1$ + private static final String FONT = "fontName"; //$NON-NLS-1$ + private static final String FONT_SIZE = "fontSize"; //$NON-NLS-1$ + private static final String IS_BOLD = "isBold"; //$NON-NLS-1$ + private static final String IS_ITALIC = "isItalic"; //$NON-NLS-1$ + private static final String COLLAPSE_LINK = "collapseLink"; //$NON-NLS-1$ + private static final String IS_VISIBLE = "isVisible"; //$NON-NLS-1$ + private static final String VISIBLE_REFERENCES = "visibleReferences"; //$NON-NLS-1$ + private static final String VISIBLE_ATTRIBUTES = "visibleAttributes"; //$NON-NLS-1$ + private static final String IS_UNDERLINED = "isUnderlined"; //$NON-NLS-1$ + private static final String IS_STRUCKTHROUGH = "isStruckthrough"; //$NON-NLS-1$ + private static final String TOP_L_OVERLAY = "topLeftOverlay"; //$NON-NLS-1$ + private static final String TOP_M_OVERLAY = "topMiddleOverlay"; //$NON-NLS-1$ + private static final String TOP_R_OVERLAY = "topRightOverlay"; //$NON-NLS-1$ + private static final String BOTTOM_L_OVERLAY = "bottomLeftOverlay"; //$NON-NLS-1$ + private static final String BOTTOM_M_OVERLAY = "bottomMiddleOverlay"; //$NON-NLS-1$ + private static final String BOTTOM_R_OVERLAY = "bottomRightOverlay"; //$NON-NLS-1$ + private static final String SELECTION = "selection"; //$NON-NLS-1$ + + // for tooltips + private static final String TEXT = "text"; //$NON-NLS-1$ + private static final String TIME_DISPLAYED = "timeDisplayed"; //$NON-NLS-1$ + private static final String DISPLAY_DELAY = "displayDelayTime"; //$NON-NLS-1$ + private static final String SHADOW = "shadow"; //$NON-NLS-1$ + private static final String ALIGNMENT = "alignment"; //$NON-NLS-1$ + + private final Resource resource; + private final Map<String, FacetOperation> map = new HashMap<String, FacetOperation>(); + + /** + * + * @deprecated Must be replaced by + * org.eclipse.papyrus.emf.facet.custom.ui.internal.PropertiesHandler + * .PropertiesHandler(ICustomizationManager) + */ + @Deprecated + public PropertiesHandler(final ResourceSet resourceSet) { + final String bundleName = Activator.getDefault().getBundle().getSymbolicName(); + URI propertiesUri = URI.createPlatformPluginURI(bundleName, true); + propertiesUri = propertiesUri + .appendSegments(PropertiesHandler.CUSTOM_PROPERTIES.split("/")); //$NON-NLS-1$ + this.resource = resourceSet.getResource(propertiesUri, true); + } + + public PropertiesHandler(final ICustomizationManager customizationMgr) { + final String bundleName = Activator.getDefault().getBundle().getSymbolicName(); + URI propertiesUri = URI.createPlatformPluginURI(bundleName, true); + propertiesUri = propertiesUri + .appendSegments(PropertiesHandler.CUSTOM_PROPERTIES.split("/")); //$NON-NLS-1$ + final ResourceSet resourceSet = customizationMgr.getResourceSet(); + this.resource = resourceSet.getResource(propertiesUri, true); + final FacetSet facetSet = (FacetSet) this.resource.getContents().get(0); + customizationMgr.getFacetManager().getManagedFacetSets() + .add(0, facetSet); + } + + private FacetOperation getPropertyByName(final String facetName, + final String propertyName) { + final String key = facetName + PropertiesHandler.SEPARATOR + propertyName; + FacetOperation result = this.map.get(key); + if (result == null) { + final FacetSet facetSet = (FacetSet) this.resource.getContents() + .get(0); + final Facet facet = FacetUtils.getFacet( + FacetUtils.getFacets(facetSet), + facetName); + final ETypedElement eTypedElement = FacetUtils + .getETypedElement(facet, propertyName, + ETypedElement.class); + if (eTypedElement instanceof FacetOperation) { + result = (FacetOperation) eTypedElement; + this.map.put(key, result); + } + } + return result; + } + + public FacetOperation getImageProperty() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.IMAGE); + } + + + @Override + public FacetOperation getCollapseLink() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.COLLAPSE_LINK); + } + + @Override + public FacetOperation getLabelProperty() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.LABEL); + } + + @Override + public FacetOperation getBackgroundProperty() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.BACKGROUND); + } + + @Override + public FacetOperation getForegroundProperty() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.FOREGROUND); + } + + @Override + public FacetOperation getFontNameProperty() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.FONT); + } + + @Override + public FacetOperation getFontSizeProperty() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.FONT_SIZE); + } + + @Override + public FacetOperation getIsBoldProperty() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.IS_BOLD); + } + + @Override + public FacetOperation getIsItalicProperty() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.IS_ITALIC); + } + + @Override + public FacetOperation getIsVisible() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.IS_VISIBLE); + } + + @Override + public FacetOperation getIsUnderlinedProperty() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.IS_UNDERLINED); + } + + @Override + public FacetOperation getIsStruckthroughProperty() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.IS_STRUCKTHROUGH); + } + + public FacetOperation getTopLeftOverlayProperty() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.TOP_L_OVERLAY); + } + + public FacetOperation getTopMiddleOverlayProperty() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.TOP_M_OVERLAY); + } + + public FacetOperation getTopRightOverlayProperty() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.TOP_R_OVERLAY); + } + + public FacetOperation getBottomLeftOverlayProperty() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.BOTTOM_L_OVERLAY); + } + + public FacetOperation getBottomMiddleOverlayProperty() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.BOTTOM_M_OVERLAY); + } + + public FacetOperation getBottomRightOverlayProperty() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.BOTTOM_R_OVERLAY); + } + + @Override + public FacetOperation getSelectionProperty() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.SELECTION); + } + + // methods for tooltips + public FacetOperation getToolTipTextProperty() { + return getPropertyByName(PropertiesHandler.TT_CUSTOM, + PropertiesHandler.TEXT); + } + + public FacetOperation getToolTipImageProperty() { + return getPropertyByName(PropertiesHandler.TT_CUSTOM, + PropertiesHandler.IMAGE); + } + + public FacetOperation getToolTipFontNameProperty() { + return getPropertyByName(PropertiesHandler.TT_CUSTOM, + PropertiesHandler.FONT); + } + + public FacetOperation getToolTipFontSizeProperty() { + return getPropertyByName(PropertiesHandler.TT_CUSTOM, + PropertiesHandler.FONT_SIZE); + } + + public FacetOperation getToolTipIsBoldProperty() { + return getPropertyByName(PropertiesHandler.TT_CUSTOM, + PropertiesHandler.IS_BOLD); + } + + public FacetOperation getToolTipIsItalicProperty() { + return getPropertyByName(PropertiesHandler.TT_CUSTOM, + PropertiesHandler.IS_ITALIC); + } + + public FacetOperation getToolTipBackgroundProperty() { + return getPropertyByName(PropertiesHandler.TT_CUSTOM, + PropertiesHandler.BACKGROUND); + } + + public FacetOperation getToolTipForegroundProperty() { + return getPropertyByName(PropertiesHandler.TT_CUSTOM, + PropertiesHandler.FOREGROUND); + } + + public FacetOperation getToolTipTopLeftOverlayProperty() { + return getPropertyByName(PropertiesHandler.TT_CUSTOM, + PropertiesHandler.TOP_L_OVERLAY); + } + + public FacetOperation getToolTipTopMiddleOverlayProperty() { + return getPropertyByName(PropertiesHandler.TT_CUSTOM, + PropertiesHandler.TOP_M_OVERLAY); + } + + public FacetOperation getToolTipTopRightOverlayProperty() { + return getPropertyByName(PropertiesHandler.TT_CUSTOM, + PropertiesHandler.TOP_R_OVERLAY); + } + + public FacetOperation getToolTipBottomLeftOverlayProperty() { + return getPropertyByName(PropertiesHandler.TT_CUSTOM, + PropertiesHandler.BOTTOM_L_OVERLAY); + } + + public FacetOperation getToolTipBottomMiddleOverlayProperty() { + return getPropertyByName(PropertiesHandler.TT_CUSTOM, + PropertiesHandler.BOTTOM_M_OVERLAY); + } + + public FacetOperation getToolTipBottomRightOverlayProperty() { + return getPropertyByName(PropertiesHandler.TT_CUSTOM, + PropertiesHandler.BOTTOM_R_OVERLAY); + } + + public FacetOperation getToolTipTimeDisplayedProperty() { + return getPropertyByName(PropertiesHandler.TT_CUSTOM, + PropertiesHandler.TIME_DISPLAYED); + } + + public FacetOperation getToolTipDisplayDelayTimeProperty() { + return getPropertyByName(PropertiesHandler.TT_CUSTOM, + PropertiesHandler.DISPLAY_DELAY); + } + + public FacetOperation getToolTipAlignmentProperty() { + return getPropertyByName(PropertiesHandler.TT_CUSTOM, + PropertiesHandler.ALIGNMENT); + } + + public FacetOperation getToolTipShadowProperty() { + return getPropertyByName(PropertiesHandler.TT_CUSTOM, + PropertiesHandler.SHADOW); + } + + /** + * @see org.eclipse.papyrus.emf.facet.custom.ui.IContentPropertiesHandler#getVisibleAttributes() + * + * @return + */ + @Override + public FacetOperation getVisibleAttributes() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.VISIBLE_ATTRIBUTES); + } + + /** + * @see org.eclipse.papyrus.emf.facet.custom.ui.IContentPropertiesHandler#getVisibleReferences() + * + * @return + */ + @Override + public FacetOperation getVisibleReferences() { + return getPropertyByName(PropertiesHandler.CUSTOM, + PropertiesHandler.VISIBLE_REFERENCES); + } }
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/PropertiesHandlerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/PropertiesHandlerFactory.java index 22d09cf8d2c..726f46aaf08 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/PropertiesHandlerFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/PropertiesHandlerFactory.java @@ -1,53 +1,53 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Nicolas Bros (Mia-Software) - Bug 377866 - selection customization
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal;
-
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.ui.IContentPropertiesHandler;
-import org.eclipse.papyrus.emf.facet.custom.ui.IContentPropertiesHandlerFactory;
-import org.eclipse.papyrus.emf.facet.custom.ui.ISelectionPropertiesHandler;
-import org.eclipse.papyrus.emf.facet.custom.ui.ISelectionPropertiesHandlerFactory;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.ILabelPropertiesHandler;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.ILabelPropertiesHandlerFactory;
-
-public class PropertiesHandlerFactory implements
- IContentPropertiesHandlerFactory, ILabelPropertiesHandlerFactory, ISelectionPropertiesHandlerFactory {
-
- /**
- * @deprecated must be replaced by
- * org.eclipse.papyrus.emf.facet.custom.ui.internal.PropertiesHandlerFactory
- * .createIContentPropertiesHandler(ICustomizationManager)
- */
- @Deprecated
- public IContentPropertiesHandler createIContentPropertiesHandler(
- final ResourceSet resourceSet) {
- return new PropertiesHandler(resourceSet);
- }
-
- public IContentPropertiesHandler createIContentPropertiesHandler(
- final ICustomizationManager customizationMgr) {
- return new PropertiesHandler(customizationMgr);
- }
-
- public ILabelPropertiesHandler createLabelPropertiesHandler(
- final ICustomizationManager customizationMgr) {
- return new PropertiesHandler(customizationMgr);
- }
-
- public ISelectionPropertiesHandler createSelectionPropertiesHandler(final ICustomizationManager customManager) {
- return new PropertiesHandler(customManager);
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Nicolas Bros (Mia-Software) - Bug 377866 - selection customization + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.ui.IContentPropertiesHandler; +import org.eclipse.papyrus.emf.facet.custom.ui.IContentPropertiesHandlerFactory; +import org.eclipse.papyrus.emf.facet.custom.ui.ISelectionPropertiesHandler; +import org.eclipse.papyrus.emf.facet.custom.ui.ISelectionPropertiesHandlerFactory; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.ILabelPropertiesHandler; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.ILabelPropertiesHandlerFactory; + +public class PropertiesHandlerFactory implements + IContentPropertiesHandlerFactory, ILabelPropertiesHandlerFactory, ISelectionPropertiesHandlerFactory { + + /** + * @deprecated must be replaced by + * org.eclipse.papyrus.emf.facet.custom.ui.internal.PropertiesHandlerFactory + * .createIContentPropertiesHandler(ICustomizationManager) + */ + @Deprecated + public IContentPropertiesHandler createIContentPropertiesHandler( + final ResourceSet resourceSet) { + return new PropertiesHandler(resourceSet); + } + + public IContentPropertiesHandler createIContentPropertiesHandler( + final ICustomizationManager customizationMgr) { + return new PropertiesHandler(customizationMgr); + } + + public ILabelPropertiesHandler createLabelPropertiesHandler( + final ICustomizationManager customizationMgr) { + return new PropertiesHandler(customizationMgr); + } + + public ISelectionPropertiesHandler createSelectionPropertiesHandler(final ICustomizationManager customManager) { + return new PropertiesHandler(customManager); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/ResolvingCustomizedLabelProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/ResolvingCustomizedLabelProvider.java index 759b7670c68..d9596666846 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/ResolvingCustomizedLabelProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/ResolvingCustomizedLabelProvider.java @@ -1,522 +1,522 @@ -/*******************************************************************************
- * Copyright (c) 2012 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider
- * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - implementation of getStyledText
- *
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.custom.ui.internal;
-
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.StyledString;
-import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EAttributeTreeElement;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EReferenceTreeElement;
-import org.eclipse.papyrus.emf.facet.custom.ui.CustomizedContentProviderUtils;
-import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-
-public class ResolvingCustomizedLabelProvider implements ICustomizedLabelProvider {
-
- private final ICustomizedLabelProvider delegate;
-
- public ResolvingCustomizedLabelProvider(final ICustomizedLabelProvider delegate) {
- super();
- this.delegate = delegate;
- }
-
- public Image getImage(final Object element) {
- Image image;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- image = this.delegate.getImage(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- image = this.delegate.getImage(parent.getEObject(), treeElement.getEAttribute());
- }
-
- else {
- image = this.delegate.getImage(CustomizedContentProviderUtils.resolve(element));
- }
- return image;
- }
-
- public String getText(final Object element) {
- String result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getText(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getText(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getText(CustomizedContentProviderUtils.resolve(element));
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider#getStyledText(java.lang.Object)
- */
- @Override
- public StyledString getStyledText(final Object element) {
- StyledString result;
- if (delegate instanceof ICustomizedLabelProvider) {
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getStyledText(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getStyledText(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getStyledText(CustomizedContentProviderUtils.resolve(element));
- }
- } else {
- result = new StyledString(getText(element));
- }
- return result;
- }
-
- public void addListener(final ILabelProviderListener listener) {
- this.delegate.addListener(listener);
- }
-
- public void dispose() {
- this.delegate.dispose();
- }
-
- public boolean isLabelProperty(final Object element, final String property) {
- return this.delegate.isLabelProperty(CustomizedContentProviderUtils.resolve(element), property);
- }
-
- public void removeListener(final ILabelProviderListener listener) {
- this.delegate.removeListener(listener);
- }
-
- public Color getForeground(final Object element) {
- return this.delegate.getForeground(CustomizedContentProviderUtils.resolve(element));
- }
-
- public Color getBackground(final Object element) {
- return this.delegate.getBackground(CustomizedContentProviderUtils.resolve(element));
- }
-
- public Font getFont(final Object element) {
- return this.delegate.getFont(CustomizedContentProviderUtils.resolve(element));
- }
-
- public void update(final ViewerCell cell) {
- this.delegate.update(cell);
- }
-
- public String getToolTipText(final Object element, final ETypedElement eTypedElement) {
- String result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getToolTipText(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getToolTipText(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getToolTipText(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public Image getToolTipImage(final Object element, final ETypedElement eTypedElement) {
- Image result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getToolTipImage(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getToolTipImage(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getToolTipImage(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public Font getToolTipFont(final Object element, final ETypedElement eTypedElement) {
- Font result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getToolTipFont(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getToolTipFont(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getToolTipFont(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public Color getToolTipBackgroundColor(final Object element, final ETypedElement eTypedElement) {
- Color result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getToolTipBackgroundColor(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getToolTipBackgroundColor(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getToolTipBackgroundColor(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public Color getToolTipForegroundColor(final Object element, final ETypedElement eTypedElement) {
- Color result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getToolTipForegroundColor(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getToolTipForegroundColor(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getToolTipForegroundColor(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public Image getToolTipTopLeftOverlay(final Object element, final ETypedElement eTypedElement) {
- Image result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getToolTipTopLeftOverlay(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getToolTipTopLeftOverlay(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getToolTipTopLeftOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public Image getToolTipTopMiddleOverlay(final Object element, final ETypedElement eTypedElement) {
- Image result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getToolTipTopMiddleOverlay(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getToolTipTopMiddleOverlay(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getToolTipTopMiddleOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public Image getToolTipTopRightOverlay(final Object element, final ETypedElement eTypedElement) {
- Image result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getToolTipTopRightOverlay(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getToolTipTopRightOverlay(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getToolTipTopRightOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public Image getToolTipBottomLeftOverlay(final Object element, final ETypedElement eTypedElement) {
- Image result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getToolTipBottomLeftOverlay(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getToolTipBottomLeftOverlay(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getToolTipBottomLeftOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public Image getToolTipBottomMiddleOverlay(final Object element, final ETypedElement eTypedElement) {
- Image result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getToolTipBottomMiddleOverlay(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getToolTipBottomMiddleOverlay(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getToolTipBottomMiddleOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public Image getToolTipBottomRightOverlay(final Object element, final ETypedElement eTypedElement) {
- Image result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getToolTipBottomRightOverlay(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getToolTipBottomRightOverlay(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getToolTipBottomRightOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public int getToolTipTimeDisplayed(final Object element, final ETypedElement eTypedElement) {
- int result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getToolTipTimeDisplayed(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getToolTipTimeDisplayed(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getToolTipTimeDisplayed(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public int getToolTipDisplayDelayTime(final Object element, final ETypedElement eTypedElement) {
- int result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getToolTipDisplayDelayTime(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getToolTipDisplayDelayTime(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getToolTipDisplayDelayTime(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public int getToolTipStyle(final Object element, final ETypedElement eTypedElement) {
- int result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getToolTipStyle(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getToolTipStyle(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getToolTipStyle(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public ICustomizationManager getCustomizationManager() {
- return this.delegate.getCustomizationManager();
- }
-
- public boolean isUnderlined(final Object element, final ETypedElement eTypedElement) {
- boolean result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.isUnderlined(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.isUnderlined(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.isUnderlined(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public boolean isStruckthrough(final Object element, final ETypedElement eTypedElement) {
- boolean result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.isStruckthrough(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.isStruckthrough(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.isStruckthrough(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public Image getTopLeftOverlay(final Object element, final ETypedElement eTypedElement) {
- Image result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getTopLeftOverlay(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getTopLeftOverlay(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getTopLeftOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public Image getTopMiddleOverlay(final Object element, final ETypedElement eTypedElement) {
- Image result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getTopMiddleOverlay(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getTopMiddleOverlay(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getTopMiddleOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public Image getTopRightOverlay(final Object element, final ETypedElement eTypedElement) {
- Image result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getTopRightOverlay(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getTopRightOverlay(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getTopRightOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public Image getBottomLeftOverlay(final Object element, final ETypedElement eTypedElement) {
- Image result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getBottomLeftOverlay(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getBottomLeftOverlay(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getBottomLeftOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public Image getBottomMiddleOverlay(final Object element, final ETypedElement eTypedElement) {
- Image result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getBottomMiddleOverlay(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getBottomMiddleOverlay(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getBottomMiddleOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public Image getBottomRightOverlay(final Object element, final ETypedElement eTypedElement) {
- Image result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getBottomRightOverlay(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getBottomRightOverlay(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getBottomRightOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public String getText(final Object element, final ETypedElement eTypedElement) {
- String result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getText(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getText(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getText(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public Image getImage(final Object element, final ETypedElement eTypedElement) {
- Image result;
- if (element instanceof EReferenceTreeElement) {
- final EReferenceTreeElement treeElement = (EReferenceTreeElement) element;
- final EObjectTreeElement parent = treeElement.getParent();
- result = this.delegate.getImage(parent.getEObject(), treeElement.getEReference());
- } else if (element instanceof EAttributeTreeElement) {
- final EAttributeTreeElement treeElement = (EAttributeTreeElement) element;
- final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent();
- result = this.delegate.getImage(parent.getEObject(), treeElement.getEAttribute());
- } else {
- result = this.delegate.getImage(CustomizedContentProviderUtils.resolve(element), eTypedElement);
- }
- return result;
- }
-
- public ICustomizedLabelProvider cloneLabelProvider() {
- return new ResolvingCustomizedLabelProvider(this.delegate.cloneLabelProvider());
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2012 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider + * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - implementation of getStyledText + * + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.custom.ui.internal; + +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.StyledString; +import org.eclipse.jface.viewers.ViewerCell; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EAttributeTreeElement; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EReferenceTreeElement; +import org.eclipse.papyrus.emf.facet.custom.ui.CustomizedContentProviderUtils; +import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; + +public class ResolvingCustomizedLabelProvider implements ICustomizedLabelProvider { + + private final ICustomizedLabelProvider delegate; + + public ResolvingCustomizedLabelProvider(final ICustomizedLabelProvider delegate) { + super(); + this.delegate = delegate; + } + + public Image getImage(final Object element) { + Image image; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + image = this.delegate.getImage(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + image = this.delegate.getImage(parent.getEObject(), treeElement.getEAttribute()); + } + + else { + image = this.delegate.getImage(CustomizedContentProviderUtils.resolve(element)); + } + return image; + } + + public String getText(final Object element) { + String result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getText(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getText(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getText(CustomizedContentProviderUtils.resolve(element)); + } + return result; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider#getStyledText(java.lang.Object) + */ + @Override + public StyledString getStyledText(final Object element) { + StyledString result; + if (delegate instanceof ICustomizedLabelProvider) { + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getStyledText(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getStyledText(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getStyledText(CustomizedContentProviderUtils.resolve(element)); + } + } else { + result = new StyledString(getText(element)); + } + return result; + } + + public void addListener(final ILabelProviderListener listener) { + this.delegate.addListener(listener); + } + + public void dispose() { + this.delegate.dispose(); + } + + public boolean isLabelProperty(final Object element, final String property) { + return this.delegate.isLabelProperty(CustomizedContentProviderUtils.resolve(element), property); + } + + public void removeListener(final ILabelProviderListener listener) { + this.delegate.removeListener(listener); + } + + public Color getForeground(final Object element) { + return this.delegate.getForeground(CustomizedContentProviderUtils.resolve(element)); + } + + public Color getBackground(final Object element) { + return this.delegate.getBackground(CustomizedContentProviderUtils.resolve(element)); + } + + public Font getFont(final Object element) { + return this.delegate.getFont(CustomizedContentProviderUtils.resolve(element)); + } + + public void update(final ViewerCell cell) { + this.delegate.update(cell); + } + + public String getToolTipText(final Object element, final ETypedElement eTypedElement) { + String result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getToolTipText(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getToolTipText(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getToolTipText(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public Image getToolTipImage(final Object element, final ETypedElement eTypedElement) { + Image result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getToolTipImage(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getToolTipImage(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getToolTipImage(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public Font getToolTipFont(final Object element, final ETypedElement eTypedElement) { + Font result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getToolTipFont(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getToolTipFont(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getToolTipFont(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public Color getToolTipBackgroundColor(final Object element, final ETypedElement eTypedElement) { + Color result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getToolTipBackgroundColor(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getToolTipBackgroundColor(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getToolTipBackgroundColor(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public Color getToolTipForegroundColor(final Object element, final ETypedElement eTypedElement) { + Color result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getToolTipForegroundColor(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getToolTipForegroundColor(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getToolTipForegroundColor(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public Image getToolTipTopLeftOverlay(final Object element, final ETypedElement eTypedElement) { + Image result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getToolTipTopLeftOverlay(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getToolTipTopLeftOverlay(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getToolTipTopLeftOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public Image getToolTipTopMiddleOverlay(final Object element, final ETypedElement eTypedElement) { + Image result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getToolTipTopMiddleOverlay(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getToolTipTopMiddleOverlay(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getToolTipTopMiddleOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public Image getToolTipTopRightOverlay(final Object element, final ETypedElement eTypedElement) { + Image result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getToolTipTopRightOverlay(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getToolTipTopRightOverlay(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getToolTipTopRightOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public Image getToolTipBottomLeftOverlay(final Object element, final ETypedElement eTypedElement) { + Image result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getToolTipBottomLeftOverlay(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getToolTipBottomLeftOverlay(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getToolTipBottomLeftOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public Image getToolTipBottomMiddleOverlay(final Object element, final ETypedElement eTypedElement) { + Image result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getToolTipBottomMiddleOverlay(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getToolTipBottomMiddleOverlay(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getToolTipBottomMiddleOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public Image getToolTipBottomRightOverlay(final Object element, final ETypedElement eTypedElement) { + Image result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getToolTipBottomRightOverlay(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getToolTipBottomRightOverlay(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getToolTipBottomRightOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public int getToolTipTimeDisplayed(final Object element, final ETypedElement eTypedElement) { + int result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getToolTipTimeDisplayed(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getToolTipTimeDisplayed(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getToolTipTimeDisplayed(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public int getToolTipDisplayDelayTime(final Object element, final ETypedElement eTypedElement) { + int result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getToolTipDisplayDelayTime(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getToolTipDisplayDelayTime(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getToolTipDisplayDelayTime(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public int getToolTipStyle(final Object element, final ETypedElement eTypedElement) { + int result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getToolTipStyle(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getToolTipStyle(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getToolTipStyle(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public ICustomizationManager getCustomizationManager() { + return this.delegate.getCustomizationManager(); + } + + public boolean isUnderlined(final Object element, final ETypedElement eTypedElement) { + boolean result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.isUnderlined(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.isUnderlined(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.isUnderlined(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public boolean isStruckthrough(final Object element, final ETypedElement eTypedElement) { + boolean result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.isStruckthrough(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.isStruckthrough(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.isStruckthrough(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public Image getTopLeftOverlay(final Object element, final ETypedElement eTypedElement) { + Image result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getTopLeftOverlay(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getTopLeftOverlay(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getTopLeftOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public Image getTopMiddleOverlay(final Object element, final ETypedElement eTypedElement) { + Image result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getTopMiddleOverlay(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getTopMiddleOverlay(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getTopMiddleOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public Image getTopRightOverlay(final Object element, final ETypedElement eTypedElement) { + Image result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getTopRightOverlay(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getTopRightOverlay(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getTopRightOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public Image getBottomLeftOverlay(final Object element, final ETypedElement eTypedElement) { + Image result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getBottomLeftOverlay(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getBottomLeftOverlay(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getBottomLeftOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public Image getBottomMiddleOverlay(final Object element, final ETypedElement eTypedElement) { + Image result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getBottomMiddleOverlay(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getBottomMiddleOverlay(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getBottomMiddleOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public Image getBottomRightOverlay(final Object element, final ETypedElement eTypedElement) { + Image result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getBottomRightOverlay(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getBottomRightOverlay(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getBottomRightOverlay(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public String getText(final Object element, final ETypedElement eTypedElement) { + String result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getText(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getText(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getText(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public Image getImage(final Object element, final ETypedElement eTypedElement) { + Image result; + if (element instanceof EReferenceTreeElement) { + final EReferenceTreeElement treeElement = (EReferenceTreeElement) element; + final EObjectTreeElement parent = treeElement.getParent(); + result = this.delegate.getImage(parent.getEObject(), treeElement.getEReference()); + } else if (element instanceof EAttributeTreeElement) { + final EAttributeTreeElement treeElement = (EAttributeTreeElement) element; + final EObjectTreeElement parent = (EObjectTreeElement) treeElement.getParent(); + result = this.delegate.getImage(parent.getEObject(), treeElement.getEAttribute()); + } else { + result = this.delegate.getImage(CustomizedContentProviderUtils.resolve(element), eTypedElement); + } + return result; + } + + public ICustomizedLabelProvider cloneLabelProvider() { + return new ResolvingCustomizedLabelProvider(this.delegate.cloneLabelProvider()); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/ResolvingCustomizedLabelProviderFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/ResolvingCustomizedLabelProviderFactory.java index 7a7ab3e886f..bb87a7923c1 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/ResolvingCustomizedLabelProviderFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/ResolvingCustomizedLabelProviderFactory.java @@ -1,26 +1,26 @@ -/*******************************************************************************
- * Copyright (c) 2012 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider
- * David Couvrand (Soft-Maint) - Bug 418418 - [Customization] Overlay icons not implemented
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.custom.ui.internal;
-
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider;
-import org.eclipse.papyrus.emf.facet.custom.ui.IResolvingCustomizedLabelProviderFactory;
-
-public class ResolvingCustomizedLabelProviderFactory implements IResolvingCustomizedLabelProviderFactory {
-
- public ICustomizedLabelProvider createCustomizedLabelProvider(final ICustomizationManager customManager) {
- return new ResolvingCustomizedLabelProvider(
- new DecoratingCustomizedLabelProvider(
- customManager));
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2012 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider + * David Couvrand (Soft-Maint) - Bug 418418 - [Customization] Overlay icons not implemented + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.custom.ui.internal; + +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProvider; +import org.eclipse.papyrus.emf.facet.custom.ui.IResolvingCustomizedLabelProviderFactory; + +public class ResolvingCustomizedLabelProviderFactory implements IResolvingCustomizedLabelProviderFactory { + + public ICustomizedLabelProvider createCustomizedLabelProvider(final ICustomizationManager customManager) { + return new ResolvingCustomizedLabelProvider( + new DecoratingCustomizedLabelProvider( + customManager)); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/TreeElementAdapter.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/TreeElementAdapter.java index 65870956b96..fc4bdc96ec1 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/TreeElementAdapter.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/TreeElementAdapter.java @@ -1,85 +1,85 @@ -/*******************************************************************************
- * Copyright (c) 2012 Mia-Software.
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 386387 - [CustomizedTreeContentProvider] The TreeElements are not preserved between two calls to getElements()
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.custom.ui.internal;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EAttributeTreeElement;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EReferenceTreeElement;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EStructuralFeatureTreeElement;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.exception.CustomizedContentProviderRuntimeException;
-import org.eclipse.papyrus.emf.facet.util.core.DebugUtils;
-
-public class TreeElementAdapter implements Adapter {
-
- private static final boolean DEBUG = DebugUtils.getDebugStatus(Activator
- .getDefault());
-
- private final EObjectTreeElement treeElement;
-
- public TreeElementAdapter(final EObjectTreeElement treeElement) {
- this.treeElement = treeElement;
- }
-
- public void notifyChanged(final Notification notification) {
- DebugUtils.debug(DEBUG,
- "Modified element=" + this.treeElement.getEObject()); //$NON-NLS-1$
- DebugUtils.debug(DEBUG,
- "Notification feature=" + notification.getFeature()); //$NON-NLS-1$
- for (Object subElement : this.treeElement
- .getSfTreeElmement()) {
- if (subElement instanceof EStructuralFeatureTreeElement) {
- final EStructuralFeature feature = getSF((EStructuralFeatureTreeElement) subElement);
- if (feature.equals(notification.getFeature())) {
- ((EStructuralFeatureTreeElement) subElement).getReferedEObjectTE().clear();
- DebugUtils.debug(
- DEBUG,
- NLS.bind("Cleanning= {0}::{1}", //$NON-NLS-1$
- feature.getContainerClass().getName(),
- feature.getName()));
- }
- }
- }
- }
-
- private static EStructuralFeature getSF(
- final EStructuralFeatureTreeElement structFeatuteTE) {
- EStructuralFeature result;
- if (structFeatuteTE instanceof EAttributeTreeElement) {
- final EAttributeTreeElement eAttributeTE = (EAttributeTreeElement) structFeatuteTE;
- result = eAttributeTE.getEAttribute();
- } else if (structFeatuteTE instanceof EReferenceTreeElement) {
- final EReferenceTreeElement eReferenceTE = (EReferenceTreeElement) structFeatuteTE;
- result = eReferenceTE.getEReference();
- } else {
- throw new CustomizedContentProviderRuntimeException(
- "Illegal agrument: " + structFeatuteTE); //$NON-NLS-1$
- }
- return result;
- }
-
- public Notifier getTarget() {
- return null;
- }
-
- public void setTarget(final Notifier newTarget) {
- // Nothing to do
- }
-
- public boolean isAdapterForType(final Object type) {
- return false;
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2012 Mia-Software. + * 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: + * Gregoire Dupe (Mia-Software) - Bug 386387 - [CustomizedTreeContentProvider] The TreeElements are not preserved between two calls to getElements() + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.custom.ui.internal; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.osgi.util.NLS; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EAttributeTreeElement; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EReferenceTreeElement; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EStructuralFeatureTreeElement; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.exception.CustomizedContentProviderRuntimeException; +import org.eclipse.papyrus.emf.facet.util.core.DebugUtils; + +public class TreeElementAdapter implements Adapter { + + private static final boolean DEBUG = DebugUtils.getDebugStatus(Activator + .getDefault()); + + private final EObjectTreeElement treeElement; + + public TreeElementAdapter(final EObjectTreeElement treeElement) { + this.treeElement = treeElement; + } + + public void notifyChanged(final Notification notification) { + DebugUtils.debug(DEBUG, + "Modified element=" + this.treeElement.getEObject()); //$NON-NLS-1$ + DebugUtils.debug(DEBUG, + "Notification feature=" + notification.getFeature()); //$NON-NLS-1$ + for (Object subElement : this.treeElement + .getSfTreeElmement()) { + if (subElement instanceof EStructuralFeatureTreeElement) { + final EStructuralFeature feature = getSF((EStructuralFeatureTreeElement) subElement); + if (feature.equals(notification.getFeature())) { + ((EStructuralFeatureTreeElement) subElement).getReferedEObjectTE().clear(); + DebugUtils.debug( + DEBUG, + NLS.bind("Cleanning= {0}::{1}", //$NON-NLS-1$ + feature.getContainerClass().getName(), + feature.getName())); + } + } + } + } + + private static EStructuralFeature getSF( + final EStructuralFeatureTreeElement structFeatuteTE) { + EStructuralFeature result; + if (structFeatuteTE instanceof EAttributeTreeElement) { + final EAttributeTreeElement eAttributeTE = (EAttributeTreeElement) structFeatuteTE; + result = eAttributeTE.getEAttribute(); + } else if (structFeatuteTE instanceof EReferenceTreeElement) { + final EReferenceTreeElement eReferenceTE = (EReferenceTreeElement) structFeatuteTE; + result = eReferenceTE.getEReference(); + } else { + throw new CustomizedContentProviderRuntimeException( + "Illegal agrument: " + structFeatuteTE); //$NON-NLS-1$ + } + return result; + } + + public Notifier getTarget() { + return null; + } + + public void setTarget(final Notifier newTarget) { + // Nothing to do + } + + public boolean isAdapterForType(final Object type) { + return false; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/custompt/Color.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/custompt/Color.java index e5d1474cf1f..ca3a0afc838 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/custompt/Color.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/custompt/Color.java @@ -1,67 +1,67 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt;
-
-import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IColor;
-
-public class Color implements IColor {
-
- private static final long serialVersionUID = 240076770346261769L;
- private static final int BYTE_SIZE = Byte.SIZE;
- private static final int TWO_BYTE_SIZE = Byte.SIZE * 2;
- public static final int MAX_VALUE = 255;
-
- private final int red;
- private final int green;
- private final int blue;
-
- public Color(final int red, final int green, final int blue) {
- this.red = red;
- this.green = green;
- this.blue = blue;
- }
-
- public Color getColor() {
- return this.getColor();
- }
-
- public int getRed() {
- return this.red;
- }
-
- public int getGreen() {
- return this.green;
- }
-
- public int getBlue() {
- return this.blue;
- }
-
- @Override
- public boolean equals(final Object obj) {
- boolean result = false;
- if (obj instanceof Color) {
- final Color color = (Color) obj;
- result = (color.getRed() == this.red)
- && (color.getGreen() == this.green)
- && (color.getBlue() == this.blue);
- }
- return result;
- }
-
- @Override
- public int hashCode() {
- return this.red & (this.green << Color.BYTE_SIZE)
- & (this.blue << Color.TWO_BYTE_SIZE);
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt; + +import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IColor; + +public class Color implements IColor { + + private static final long serialVersionUID = 240076770346261769L; + private static final int BYTE_SIZE = Byte.SIZE; + private static final int TWO_BYTE_SIZE = Byte.SIZE * 2; + public static final int MAX_VALUE = 255; + + private final int red; + private final int green; + private final int blue; + + public Color(final int red, final int green, final int blue) { + this.red = red; + this.green = green; + this.blue = blue; + } + + public Color getColor() { + return this.getColor(); + } + + public int getRed() { + return this.red; + } + + public int getGreen() { + return this.green; + } + + public int getBlue() { + return this.blue; + } + + @Override + public boolean equals(final Object obj) { + boolean result = false; + if (obj instanceof Color) { + final Color color = (Color) obj; + result = (color.getRed() == this.red) + && (color.getGreen() == this.green) + && (color.getBlue() == this.blue); + } + return result; + } + + @Override + public int hashCode() { + return this.red & (this.green << Color.BYTE_SIZE) + & (this.blue << Color.TWO_BYTE_SIZE); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/custompt/ImageWrapper.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/custompt/ImageWrapper.java index b02236e7ac4..6ccd6fb50fc 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/custompt/ImageWrapper.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/custompt/ImageWrapper.java @@ -1,48 +1,48 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Nicolas Bros (Mia-Software) - Bug 374941 - To be able to customize overlay icons on EClass
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-
-import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.ImageLoader;
-
-public class ImageWrapper implements IImage {
-
- private static final long serialVersionUID = -2538802017710069448L;
- private final Image wrappedImage;
-
- public ImageWrapper(final Image image) {
- this.wrappedImage = image;
- }
-
- public InputStream getInputStream() {
- // note: this is an inefficient way to get an inputStream from the wrapped Image
- final ByteArrayOutputStream stream = new ByteArrayOutputStream();
- final ImageLoader loader = new ImageLoader();
- loader.data = new ImageData[] { this.wrappedImage.getImageData() };
- loader.save(stream, SWT.IMAGE_PNG);
- final byte[] byteArray = stream.toByteArray();
- return new ByteArrayInputStream(byteArray);
- }
-
- public Image getImage() {
- return this.wrappedImage;
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Nicolas Bros (Mia-Software) - Bug 374941 - To be able to customize overlay icons on EClass + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; + +import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.ImageLoader; + +public class ImageWrapper implements IImage { + + private static final long serialVersionUID = -2538802017710069448L; + private final Image wrappedImage; + + public ImageWrapper(final Image image) { + this.wrappedImage = image; + } + + public InputStream getInputStream() { + // note: this is an inefficient way to get an inputStream from the wrapped Image + final ByteArrayOutputStream stream = new ByteArrayOutputStream(); + final ImageLoader loader = new ImageLoader(); + loader.data = new ImageData[] { this.wrappedImage.getImageData() }; + loader.save(stream, SWT.IMAGE_PNG); + final byte[] byteArray = stream.toByteArray(); + return new ByteArrayInputStream(byteArray); + } + + public Image getImage() { + return this.wrappedImage; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/custompt/URIImage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/custompt/URIImage.java index 0ce0160d37d..4444e046827 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/custompt/URIImage.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/custompt/URIImage.java @@ -1,40 +1,40 @@ -/**
- * Copyright (c) 2013 Soft-Maint.
- *
- * 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:
- * David Couvrand (Soft-Maint) - Bug 402725 - Need a query to get an image from an URI
- * Nicolas Rault (Soft-Maint) - Bug 402725 - Need a query to get an image from an URI
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt;
-
-import java.io.InputStream;
-
-import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage;
-
-public class URIImage implements IImage {
-
- private static final long serialVersionUID = 6801140731857137834L;
- private String uri;
-
- public URIImage(final String uri) {
- this.uri = uri;
- }
-
- public InputStream getInputStream() {
- return null;
- }
-
- public String getUri() {
- return this.uri;
- }
-
- public void setUri(final String uri) {
- this.uri = uri;
- }
-
-}
+/** + * Copyright (c) 2013 Soft-Maint. + * + * 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: + * David Couvrand (Soft-Maint) - Bug 402725 - Need a query to get an image from an URI + * Nicolas Rault (Soft-Maint) - Bug 402725 - Need a query to get an image from an URI + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt; + +import java.io.InputStream; + +import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage; + +public class URIImage implements IImage { + + private static final long serialVersionUID = 6801140731857137834L; + private String uri; + + public URIImage(final String uri) { + this.uri = uri; + } + + public InputStream getInputStream() { + return null; + } + + public String getUri() { + return this.uri; + } + + public void setUri(final String uri) { + this.uri = uri; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/dialog/ColorLabelProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/dialog/ColorLabelProvider.java index 8604051812c..68f9f20eb1b 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/dialog/ColorLabelProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/dialog/ColorLabelProvider.java @@ -1,61 +1,61 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.dialog;
-
-import org.eclipse.jface.viewers.IColorProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.ImageProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-public class ColorLabelProvider extends LabelProvider implements IColorProvider {
-
- private final LoadCustomizationsDialog loadCustomDialog;
-
- public ColorLabelProvider(final LoadCustomizationsDialog loadCustomDialog) {
- super();
- this.loadCustomDialog = loadCustomDialog;
- }
-
- @Override
- public String getText(final Object element) {
- final Customization customization = (Customization) element;
- return customization.getName();
- }
-
- @Override
- public Image getImage(final Object element) {
- Image result;
- if (this.loadCustomDialog.getLockedCustoms().contains(element)) {
- result = ImageProvider.getInstance().getGrayedUiCustomIcon();
- } else {
- result = ImageProvider.getInstance().getUiCustomIcon();
- }
- return result;
- }
-
- public Color getForeground(final Object element) {
- Color result = null;
- if (this.loadCustomDialog.getLockedCustoms().contains(element)) {
- result = Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY);
- }
- return result;
- }
-
- public Color getBackground(final Object element) {
- return null;
- }
-
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.dialog; + +import org.eclipse.jface.viewers.IColorProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.ImageProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Display; + +public class ColorLabelProvider extends LabelProvider implements IColorProvider { + + private final LoadCustomizationsDialog loadCustomDialog; + + public ColorLabelProvider(final LoadCustomizationsDialog loadCustomDialog) { + super(); + this.loadCustomDialog = loadCustomDialog; + } + + @Override + public String getText(final Object element) { + final Customization customization = (Customization) element; + return customization.getName(); + } + + @Override + public Image getImage(final Object element) { + Image result; + if (this.loadCustomDialog.getLockedCustoms().contains(element)) { + result = ImageProvider.getInstance().getGrayedUiCustomIcon(); + } else { + result = ImageProvider.getInstance().getUiCustomIcon(); + } + return result; + } + + public Color getForeground(final Object element) { + Color result = null; + if (this.loadCustomDialog.getLockedCustoms().contains(element)) { + result = Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY); + } + return result; + } + + public Color getBackground(final Object element) { + return null; + } + }
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/dialog/LoadCustomizationsDialogFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/dialog/LoadCustomizationsDialogFactory.java index 318a90ddb24..f6b9fe81df9 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/dialog/LoadCustomizationsDialogFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/dialog/LoadCustomizationsDialogFactory.java @@ -1,46 +1,46 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.dialog;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.dialog.ILoadCustomizationsDialog;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.dialog.ILoadCustomizationsDialogFactory;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallbackWithPreCommit;
-import org.eclipse.swt.widgets.Shell;
-
-public class LoadCustomizationsDialogFactory implements ILoadCustomizationsDialogFactory {
-
- public <D> ILoadCustomizationsDialog<D> createLoadCustomizationDialog(
- final Shell parent,
- final List<Customization> availableCustoms,
- final List<Customization> selectedCustoms,
- final IDialogCallbackWithPreCommit<List<Customization>, Boolean, D> callback) {
- return new SynchronizedLoadCustomizationsDialog(parent,
- availableCustoms, selectedCustoms,
- Collections.<Customization> emptyList(), callback, ""); //$NON-NLS-1$
- }
-
- public <D> ILoadCustomizationsDialog<D> createLoadCustomizationDialog(
- final Shell parent,
- final List<Customization> availableCustoms,
- final List<Customization> selectedCustoms,
- final List<Customization> lockedCustoms,
- final IDialogCallbackWithPreCommit<List<Customization>, Boolean, D> callback,
- final String lockMsg) {
- return new SynchronizedLoadCustomizationsDialog(parent,
- availableCustoms, selectedCustoms, lockedCustoms, callback,
- lockMsg);
- }
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.dialog; + +import java.util.Collections; +import java.util.List; + +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.dialog.ILoadCustomizationsDialog; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.dialog.ILoadCustomizationsDialogFactory; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallbackWithPreCommit; +import org.eclipse.swt.widgets.Shell; + +public class LoadCustomizationsDialogFactory implements ILoadCustomizationsDialogFactory { + + public <D> ILoadCustomizationsDialog<D> createLoadCustomizationDialog( + final Shell parent, + final List<Customization> availableCustoms, + final List<Customization> selectedCustoms, + final IDialogCallbackWithPreCommit<List<Customization>, Boolean, D> callback) { + return new SynchronizedLoadCustomizationsDialog(parent, + availableCustoms, selectedCustoms, + Collections.<Customization> emptyList(), callback, ""); //$NON-NLS-1$ + } + + public <D> ILoadCustomizationsDialog<D> createLoadCustomizationDialog( + final Shell parent, + final List<Customization> availableCustoms, + final List<Customization> selectedCustoms, + final List<Customization> lockedCustoms, + final IDialogCallbackWithPreCommit<List<Customization>, Boolean, D> callback, + final String lockMsg) { + return new SynchronizedLoadCustomizationsDialog(parent, + availableCustoms, selectedCustoms, lockedCustoms, callback, + lockMsg); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/dialog/SynchronizedLoadCustomizationsDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/dialog/SynchronizedLoadCustomizationsDialog.java index 0a2515c1fbd..44d3449529f 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/dialog/SynchronizedLoadCustomizationsDialog.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/dialog/SynchronizedLoadCustomizationsDialog.java @@ -1,222 +1,222 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Nicolas Bros (Mia-Software) - Bug 372626 - Aggregates
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.dialog;
-
-import java.util.List;
-
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.dialog.ILoadCustomizationsDialog;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.exception.IllegalParameterException;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallbackWithPreCommit;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidRunnable;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.SynchronizedObject;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public class SynchronizedLoadCustomizationsDialog<D> extends
- SynchronizedObject<LoadCustomizationsDialog<D>> implements
- ILoadCustomizationsDialog<D> { // NOPMD by gdupe on 03/02/12 12:13 - We cannot do more. This class is a facade/wrapper of an other class.
-
- public SynchronizedLoadCustomizationsDialog(final Shell parent,
- final List<Customization> availableCustoms,
- final List<Customization> selectedCustoms,
- final List<Customization> lockedCustoms,
- final IDialogCallbackWithPreCommit<List<Customization>, Boolean, D> callback,
- final String lockMsg) {
- super(new LoadCustomizationsDialog(parent, availableCustoms,
- selectedCustoms, lockedCustoms, callback, lockMsg),
- initDisplay(parent));
- }
-
- private static Display initDisplay(final Shell parent) {
- Display display;
- if (parent == null) {
- display = Display.getDefault();
- } else {
- display = parent.getDisplay();
- }
- return display;
- }
-
- public int open() {
- return this.safeSyncExec(new AbstractExceptionFreeRunnable<Integer>() {
- @Override
- public Integer safeRun() {
- return Integer.valueOf(SynchronizedLoadCustomizationsDialog.this
- .getSynchronizedObject().open());
- }
- }).intValue();
- }
-
- public void asyncOpen() {
- this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- SynchronizedLoadCustomizationsDialog.this
- .getSynchronizedObject().asyncOpen();
- }
- });
- }
-
- public D pressOk() {
- return this.safeSyncExec(new AbstractExceptionFreeRunnable<D>() {
- @Override
- public D safeRun() {
- return SynchronizedLoadCustomizationsDialog.this
- .getSynchronizedObject().pressOk();
- }
- });
- }
-
- public void selectAvailableCustom(final Customization customization) {
- this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- SynchronizedLoadCustomizationsDialog.this
- .getSynchronizedObject().selectAvailableCustom(
- customization);
- }
- });
- }
-
- public void loadSelectedCustoms() {
- this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- SynchronizedLoadCustomizationsDialog.this
- .getSynchronizedObject().loadSelectedCustoms();
- }
- });
- }
-
- public void selectSelectedCustom(final Customization customization) {
- this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- SynchronizedLoadCustomizationsDialog.this
- .getSynchronizedObject().selectSelectedCustom(
- customization);
- }
- });
- }
-
- public void unloadSelectedCustoms() {
- this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- SynchronizedLoadCustomizationsDialog.this
- .getSynchronizedObject().unloadSelectedCustoms();
- }
- });
- }
-
- public void addCustomization(final Customization customization)
- throws IllegalParameterException {
- voidSyncExec(new AbstractVoidRunnable<IllegalParameterException>() {
- @Override
- public void voidRun() throws IllegalParameterException {
- getSynchronizedObject().addCustomization(customization);
- }
- });
- }
-
- public void addCustomizations(final List<Customization> customizations)
- throws IllegalParameterException {
- voidSyncExec(new AbstractVoidRunnable<IllegalParameterException>() {
- @Override
- public void voidRun() throws IllegalParameterException {
- getSynchronizedObject().addCustomizations(customizations);
- }
- });
- }
-
- public void removeCustomization(final Customization customization)
- throws IllegalParameterException {
- voidSyncExec(new AbstractVoidRunnable<IllegalParameterException>() {
- @Override
- public void voidRun() throws IllegalParameterException {
- getSynchronizedObject().removeCustomization(customization);
- }
- });
- }
-
- public void removeCustomizations(final List<Customization> customizations)
- throws IllegalParameterException {
- voidSyncExec(new AbstractVoidRunnable<IllegalParameterException>() {
- @Override
- public void voidRun() throws IllegalParameterException {
- getSynchronizedObject().removeCustomizations(customizations);
- }
- });
- }
-
- public void cancel() {
- voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- getSynchronizedObject().cancel();
- }
- });
- }
-
- public void validate() {
- voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- getSynchronizedObject().validate();
- }
- });
- }
-
- public List<Customization> getSelectedCustomizations() {
- return safeSyncExec(new AbstractExceptionFreeRunnable<List<Customization>>() {
- @Override
- public List<Customization> safeRun() {
- return getSynchronizedObject().getSelectedCustomizations();
- }
- });
- }
-
- public List<Customization> getAvailableCustomizations() {
- return safeSyncExec(new AbstractExceptionFreeRunnable<List<Customization>>() {
- @Override
- public List<Customization> safeRun() {
- return getSynchronizedObject().getAvailableCustomizations();
- }
- });
- }
-
- public void pushUp(final Customization customization)
- throws IllegalParameterException {
- voidSyncExec(new AbstractVoidRunnable<IllegalParameterException>() {
- @Override
- public void voidRun() throws IllegalParameterException {
- getSynchronizedObject().pushUp(customization);
- }
- });
- }
-
- public void pushDown(final Customization customization)
- throws IllegalParameterException {
- voidSyncExec(new AbstractVoidRunnable<IllegalParameterException>() {
- @Override
- public void voidRun() throws IllegalParameterException {
- getSynchronizedObject().pushDown(customization);
- }
- });
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Nicolas Bros (Mia-Software) - Bug 372626 - Aggregates + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.dialog; + +import java.util.List; + +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.dialog.ILoadCustomizationsDialog; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.exception.IllegalParameterException; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallbackWithPreCommit; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidRunnable; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.SynchronizedObject; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +public class SynchronizedLoadCustomizationsDialog<D> extends + SynchronizedObject<LoadCustomizationsDialog<D>> implements + ILoadCustomizationsDialog<D> { // NOPMD by gdupe on 03/02/12 12:13 - We cannot do more. This class is a facade/wrapper of an other class. + + public SynchronizedLoadCustomizationsDialog(final Shell parent, + final List<Customization> availableCustoms, + final List<Customization> selectedCustoms, + final List<Customization> lockedCustoms, + final IDialogCallbackWithPreCommit<List<Customization>, Boolean, D> callback, + final String lockMsg) { + super(new LoadCustomizationsDialog(parent, availableCustoms, + selectedCustoms, lockedCustoms, callback, lockMsg), + initDisplay(parent)); + } + + private static Display initDisplay(final Shell parent) { + Display display; + if (parent == null) { + display = Display.getDefault(); + } else { + display = parent.getDisplay(); + } + return display; + } + + public int open() { + return this.safeSyncExec(new AbstractExceptionFreeRunnable<Integer>() { + @Override + public Integer safeRun() { + return Integer.valueOf(SynchronizedLoadCustomizationsDialog.this + .getSynchronizedObject().open()); + } + }).intValue(); + } + + public void asyncOpen() { + this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + SynchronizedLoadCustomizationsDialog.this + .getSynchronizedObject().asyncOpen(); + } + }); + } + + public D pressOk() { + return this.safeSyncExec(new AbstractExceptionFreeRunnable<D>() { + @Override + public D safeRun() { + return SynchronizedLoadCustomizationsDialog.this + .getSynchronizedObject().pressOk(); + } + }); + } + + public void selectAvailableCustom(final Customization customization) { + this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + SynchronizedLoadCustomizationsDialog.this + .getSynchronizedObject().selectAvailableCustom( + customization); + } + }); + } + + public void loadSelectedCustoms() { + this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + SynchronizedLoadCustomizationsDialog.this + .getSynchronizedObject().loadSelectedCustoms(); + } + }); + } + + public void selectSelectedCustom(final Customization customization) { + this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + SynchronizedLoadCustomizationsDialog.this + .getSynchronizedObject().selectSelectedCustom( + customization); + } + }); + } + + public void unloadSelectedCustoms() { + this.voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + SynchronizedLoadCustomizationsDialog.this + .getSynchronizedObject().unloadSelectedCustoms(); + } + }); + } + + public void addCustomization(final Customization customization) + throws IllegalParameterException { + voidSyncExec(new AbstractVoidRunnable<IllegalParameterException>() { + @Override + public void voidRun() throws IllegalParameterException { + getSynchronizedObject().addCustomization(customization); + } + }); + } + + public void addCustomizations(final List<Customization> customizations) + throws IllegalParameterException { + voidSyncExec(new AbstractVoidRunnable<IllegalParameterException>() { + @Override + public void voidRun() throws IllegalParameterException { + getSynchronizedObject().addCustomizations(customizations); + } + }); + } + + public void removeCustomization(final Customization customization) + throws IllegalParameterException { + voidSyncExec(new AbstractVoidRunnable<IllegalParameterException>() { + @Override + public void voidRun() throws IllegalParameterException { + getSynchronizedObject().removeCustomization(customization); + } + }); + } + + public void removeCustomizations(final List<Customization> customizations) + throws IllegalParameterException { + voidSyncExec(new AbstractVoidRunnable<IllegalParameterException>() { + @Override + public void voidRun() throws IllegalParameterException { + getSynchronizedObject().removeCustomizations(customizations); + } + }); + } + + public void cancel() { + voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + getSynchronizedObject().cancel(); + } + }); + } + + public void validate() { + voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + getSynchronizedObject().validate(); + } + }); + } + + public List<Customization> getSelectedCustomizations() { + return safeSyncExec(new AbstractExceptionFreeRunnable<List<Customization>>() { + @Override + public List<Customization> safeRun() { + return getSynchronizedObject().getSelectedCustomizations(); + } + }); + } + + public List<Customization> getAvailableCustomizations() { + return safeSyncExec(new AbstractExceptionFreeRunnable<List<Customization>>() { + @Override + public List<Customization> safeRun() { + return getSynchronizedObject().getAvailableCustomizations(); + } + }); + } + + public void pushUp(final Customization customization) + throws IllegalParameterException { + voidSyncExec(new AbstractVoidRunnable<IllegalParameterException>() { + @Override + public void voidRun() throws IllegalParameterException { + getSynchronizedObject().pushUp(customization); + } + }); + } + + public void pushDown(final Customization customization) + throws IllegalParameterException { + voidSyncExec(new AbstractVoidRunnable<IllegalParameterException>() { + @Override + public void voidRun() throws IllegalParameterException { + getSynchronizedObject().pushDown(customization); + } + }); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exception/CustomizationEditRuntimeException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exception/CustomizationEditRuntimeException.java index 4b33e65a38c..6ef89f40d80 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exception/CustomizationEditRuntimeException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exception/CustomizationEditRuntimeException.java @@ -1,34 +1,34 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.exception;
-
-public class CustomizationEditRuntimeException extends RuntimeException {
-
- private static final long serialVersionUID = -632229513667261515L;
-
- public CustomizationEditRuntimeException() {
- super();
- }
-
- public CustomizationEditRuntimeException(final String message) {
- super(message);
- }
-
- public CustomizationEditRuntimeException(final Throwable cause) {
- super(cause);
- }
-
- public CustomizationEditRuntimeException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.exception; + +public class CustomizationEditRuntimeException extends RuntimeException { + + private static final long serialVersionUID = -632229513667261515L; + + public CustomizationEditRuntimeException() { + super(); + } + + public CustomizationEditRuntimeException(final String message) { + super(message); + } + + public CustomizationEditRuntimeException(final Throwable cause) { + super(cause); + } + + public CustomizationEditRuntimeException(final String message, final Throwable cause) { + super(message, cause); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exception/CustomizedContentProviderRuntimeException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exception/CustomizedContentProviderRuntimeException.java index b4a1b3522df..091a2d73da9 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exception/CustomizedContentProviderRuntimeException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exception/CustomizedContentProviderRuntimeException.java @@ -1,34 +1,34 @@ -/*******************************************************************************
- * Copyright (c) 2012 Mia-Software.
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 386387 - [CustomizedTreeContentProvider] The TreeElements are not preserved between two calls to getElements()
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.exception;
-
-public class CustomizedContentProviderRuntimeException extends RuntimeException {
-
- private static final long serialVersionUID = 6962461313131533003L;
-
- public CustomizedContentProviderRuntimeException() {
- super();
- }
-
- public CustomizedContentProviderRuntimeException(final String message) {
- super(message);
- }
-
- public CustomizedContentProviderRuntimeException(final Throwable cause) {
- super(cause);
- }
-
- public CustomizedContentProviderRuntimeException(final String message,
- final Throwable cause) {
- super(message, cause);
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2012 Mia-Software. + * 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: + * Gregoire Dupe (Mia-Software) - Bug 386387 - [CustomizedTreeContentProvider] The TreeElements are not preserved between two calls to getElements() + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.exception; + +public class CustomizedContentProviderRuntimeException extends RuntimeException { + + private static final long serialVersionUID = 6962461313131533003L; + + public CustomizedContentProviderRuntimeException() { + super(); + } + + public CustomizedContentProviderRuntimeException(final String message) { + super(message); + } + + public CustomizedContentProviderRuntimeException(final Throwable cause) { + super(cause); + } + + public CustomizedContentProviderRuntimeException(final String message, + final Throwable cause) { + super(message, cause); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/CustomizationUIConstants.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/CustomizationUIConstants.java index 80a9220172b..e305ffd6557 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/CustomizationUIConstants.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/CustomizationUIConstants.java @@ -1,27 +1,27 @@ -/*******************************************************************************
- * Copyright (c) 2012 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:
- * Nicolas Bros (Mia-Software) - Bug 372626 - Aggregates
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.exported;
-
-/**
- * @since 0.2
- */
-public final class CustomizationUIConstants {
-
- private static final String CATALOG_VIEW_ID = "org.eclipse.papyrus.emf.facet.custom.ui.view.catalog"; //$NON-NLS-1$
-
- private CustomizationUIConstants() {
- // utility class
- }
-
- public static String getCustomizationCatalogViewId() {
- return CustomizationUIConstants.CATALOG_VIEW_ID;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 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: + * Nicolas Bros (Mia-Software) - Bug 372626 - Aggregates + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.exported; + +/** + * @since 0.2 + */ +public final class CustomizationUIConstants { + + private static final String CATALOG_VIEW_ID = "org.eclipse.papyrus.emf.facet.custom.ui.view.catalog"; //$NON-NLS-1$ + + private CustomizationUIConstants() { + // utility class + } + + public static String getCustomizationCatalogViewId() { + return CustomizationUIConstants.CATALOG_VIEW_ID; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/ICustomizationCommandFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/ICustomizationCommandFactory.java index e1d1305b7e7..505823afcde 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/ICustomizationCommandFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/ICustomizationCommandFactory.java @@ -1,39 +1,39 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.exported;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.EClassCustomization;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.FacetCustomization;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.util.emf.core.command.ICommandFactoryResult;
-
-public interface ICustomizationCommandFactory {
-
- ICommandFactoryResult<Customization> createCustomization(
- String name);
-
- ICommandFactoryResult<EClassCustomization> createEClassCustomization(
- Customization customization, EClass customedEClass, Query conformanceQuery);
-
- ICommandFactoryResult<FacetCustomization> createFacetCustomization(
- Customization customization, Facet customizedFacet);
-
- ICommandFactoryResult<Facet> setPropertyConfig(Facet typeCustomization,
- ETypedElement customizedTElt, // customized typed element
- FacetOperation customProperty,
- Query query);
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.exported; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.EClassCustomization; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.FacetCustomization; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.util.emf.core.command.ICommandFactoryResult; + +public interface ICustomizationCommandFactory { + + ICommandFactoryResult<Customization> createCustomization( + String name); + + ICommandFactoryResult<EClassCustomization> createEClassCustomization( + Customization customization, EClass customedEClass, Query conformanceQuery); + + ICommandFactoryResult<FacetCustomization> createFacetCustomization( + Customization customization, Facet customizedFacet); + + ICommandFactoryResult<Facet> setPropertyConfig(Facet typeCustomization, + ETypedElement customizedTElt, // customized typed element + FacetOperation customProperty, + Query query); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/ICustomizationCommandFactoryFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/ICustomizationCommandFactoryFactory.java index cd6db8e91fb..6bc6ed9cc96 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/ICustomizationCommandFactoryFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/ICustomizationCommandFactoryFactory.java @@ -1,24 +1,24 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.exported;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.CustomizationCommandFactoryFactory;
-import org.eclipse.papyrus.emf.facet.util.emf.core.internal.exported.ICommandFactory;
-
-public interface ICustomizationCommandFactoryFactory {
-
- ICustomizationCommandFactoryFactory DEFAULT = new CustomizationCommandFactoryFactory();
-
- ICustomizationCommandFactory createCustomizationCommandFactory(
- EditingDomain editingDomain, ICommandFactory commandFactory);
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.exported; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.CustomizationCommandFactoryFactory; +import org.eclipse.papyrus.emf.facet.util.emf.core.internal.exported.ICommandFactory; + +public interface ICustomizationCommandFactoryFactory { + + ICustomizationCommandFactoryFactory DEFAULT = new CustomizationCommandFactoryFactory(); + + ICustomizationCommandFactory createCustomizationCommandFactory( + EditingDomain editingDomain, ICommandFactory commandFactory); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/ILabelPropertiesHandler.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/ILabelPropertiesHandler.java index 13b30fae782..3d6b73d1c28 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/ILabelPropertiesHandler.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/ILabelPropertiesHandler.java @@ -1,24 +1,24 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.exported;
-
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-
-/**
- *
- * @since 0.2
- *
- */
-public interface ILabelPropertiesHandler {
- FacetOperation getLabelProperty();
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.exported; + +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; + +/** + * + * @since 0.2 + * + */ +public interface ILabelPropertiesHandler { + FacetOperation getLabelProperty(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/ILabelPropertiesHandlerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/ILabelPropertiesHandlerFactory.java index 7f831809a69..048a0c410fc 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/ILabelPropertiesHandlerFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/ILabelPropertiesHandlerFactory.java @@ -1,29 +1,29 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.exported;
-
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.PropertiesHandlerFactory;
-
-/**
- *
- * @since 0.2
- *
- */
-public interface ILabelPropertiesHandlerFactory {
-
- ILabelPropertiesHandlerFactory DEFAULT = new PropertiesHandlerFactory();
-
- ILabelPropertiesHandler createLabelPropertiesHandler(
- ICustomizationManager customizationMgr);
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.exported; + +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.PropertiesHandlerFactory; + +/** + * + * @since 0.2 + * + */ +public interface ILabelPropertiesHandlerFactory { + + ILabelPropertiesHandlerFactory DEFAULT = new PropertiesHandlerFactory(); + + ILabelPropertiesHandler createLabelPropertiesHandler( + ICustomizationManager customizationMgr); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/dialog/ILoadCustomizationsDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/dialog/ILoadCustomizationsDialog.java index d14b76cd615..0f0c0040fca 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/dialog/ILoadCustomizationsDialog.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/dialog/ILoadCustomizationsDialog.java @@ -1,166 +1,166 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.dialog;
-
-import java.util.List;
-
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.exception.IllegalParameterException;
-
-/**
- * A dialog to load {@link Customization}s.
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @since 0.2.0
- */
-public interface ILoadCustomizationsDialog<D> {
-
- /**
- * Opens the dialog and blocks until it closes.
- *
- * @return the dialog's return code
- */
- int open();
-
- /** Opens the dialog asynchronously */
- void asyncOpen();
-
- /**
- * Emulate a press on the OK button
- *
- * @since 0.2
- */
- D pressOk();
-
- /** Selects the given customization in the left "available customizations" pane */
- void selectAvailableCustom(Customization customization);
-
- /**
- * Moves the customizations selected in the left "available customizations" pane to the right
- * "loaded customizations" pane.
- */
- void loadSelectedCustoms();
-
- /** Selects the given customization in the right "loaded customizations" pane */
- void selectSelectedCustom(Customization customization);
-
- /**
- * Moves the customizations selected in the right "loaded customizations" pane to the left
- * "available customizations" pane.
- */
- void unloadSelectedCustoms();
-
- /**
- * This method is used to add a customization on the top of the
- * customization stack.
- *
- * @param customization
- * must be one element of the list returned by {@link
- * ICustomizationLoaderDialo.getAvailableCustomizations()}
- * @throws IllegalParameterException
- * when the parameter is not one element of the list returned by {@link
- * ICustomizationLoaderDialo.getAvailableCustomizations()}
- */
- void addCustomization(Customization customization)
- throws IllegalParameterException;
-
- /**
- * This method is used to add customizations on the top of the customization
- * stack.
- *
- * @param customizations
- * must be one element of the list returned by {@link
- * ICustomizationLoaderDialo.getAvailableCustomizations()}
- * @throws IllegalParameterException
- * when one of the element of the parameter list in not one
- * element of the list returned by {@link
- * ICustomizationLoaderDialo.getAvailableCustomizations()}
- */
- void addCustomizations(List<Customization> customizations)
- throws IllegalParameterException;
-
- /**
- * This method is used to remove a customization from the list.
- *
- * @param customization
- * must be one element of the list returned by {@link
- * ICustomizationLoaderDialo.getSelectedCustomizations()}
- * @throws IllegalParameterException
- * when the parameter is not one element of the list returned by {@link ICustomizationLoaderDialo.getSelectedCustomizations()}
- */
- void removeCustomization(Customization customization)
- throws IllegalParameterException;
-
- /**
- * This method is used to remove a list of customization from the list.
- *
- * @param customizations
- * must be one element of the list returned by {@link
- * ICustomizationLoaderDialo.getSelectedCustomizations()}
- * @throws IllegalParameterException
- * when one of the element of the parameter list in not one
- * element of the list returned by {@link
- * ICustomizationLoaderDialo.getSelectedCustomizations()}
- */
- void removeCustomizations(List<Customization> customizations)
- throws IllegalParameterException;
-
- /**
- * Cancel the dialog
- */
- void cancel();
-
- /**
- * Validate the dialog
- */
- void validate();
-
- /**
- * The intersection between getSelectedCustomizations() and
- * getAvailableCustomizations') has to be empty.
- *
- * @return the customizations selected using the dialog.
- */
- List<Customization> getSelectedCustomizations();
-
- /**
- * The intersection between getSelectedCustomizations() and
- * getAvailableCustomizations') has to be empty.
- *
- * @return the available and not yet selected customizations
- */
- List<Customization> getAvailableCustomizations();
-
- /**
- * This method is used to push up a customization.
- *
- * @param customization
- * a selected customization.
- * @throws IllegalParameterException
- * when the parameter in not on element of the list returned by
- * getSelectedCustomizations().
- */
- void pushUp(Customization customization) throws IllegalParameterException;
-
- /**
- * This method is used to push down a customization.
- *
- * @param customization
- * a selected customization.
- * @throws IllegalParameterException
- * when the parameter in not on element of the list returned by
- * getSelectedCustomizations().
- */
- void pushDown(Customization customization) throws IllegalParameterException;
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.dialog; + +import java.util.List; + +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.exception.IllegalParameterException; + +/** + * A dialog to load {@link Customization}s. + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @since 0.2.0 + */ +public interface ILoadCustomizationsDialog<D> { + + /** + * Opens the dialog and blocks until it closes. + * + * @return the dialog's return code + */ + int open(); + + /** Opens the dialog asynchronously */ + void asyncOpen(); + + /** + * Emulate a press on the OK button + * + * @since 0.2 + */ + D pressOk(); + + /** Selects the given customization in the left "available customizations" pane */ + void selectAvailableCustom(Customization customization); + + /** + * Moves the customizations selected in the left "available customizations" pane to the right + * "loaded customizations" pane. + */ + void loadSelectedCustoms(); + + /** Selects the given customization in the right "loaded customizations" pane */ + void selectSelectedCustom(Customization customization); + + /** + * Moves the customizations selected in the right "loaded customizations" pane to the left + * "available customizations" pane. + */ + void unloadSelectedCustoms(); + + /** + * This method is used to add a customization on the top of the + * customization stack. + * + * @param customization + * must be one element of the list returned by {@link + * ICustomizationLoaderDialo.getAvailableCustomizations()} + * @throws IllegalParameterException + * when the parameter is not one element of the list returned by {@link + * ICustomizationLoaderDialo.getAvailableCustomizations()} + */ + void addCustomization(Customization customization) + throws IllegalParameterException; + + /** + * This method is used to add customizations on the top of the customization + * stack. + * + * @param customizations + * must be one element of the list returned by {@link + * ICustomizationLoaderDialo.getAvailableCustomizations()} + * @throws IllegalParameterException + * when one of the element of the parameter list in not one + * element of the list returned by {@link + * ICustomizationLoaderDialo.getAvailableCustomizations()} + */ + void addCustomizations(List<Customization> customizations) + throws IllegalParameterException; + + /** + * This method is used to remove a customization from the list. + * + * @param customization + * must be one element of the list returned by {@link + * ICustomizationLoaderDialo.getSelectedCustomizations()} + * @throws IllegalParameterException + * when the parameter is not one element of the list returned by {@link ICustomizationLoaderDialo.getSelectedCustomizations()} + */ + void removeCustomization(Customization customization) + throws IllegalParameterException; + + /** + * This method is used to remove a list of customization from the list. + * + * @param customizations + * must be one element of the list returned by {@link + * ICustomizationLoaderDialo.getSelectedCustomizations()} + * @throws IllegalParameterException + * when one of the element of the parameter list in not one + * element of the list returned by {@link + * ICustomizationLoaderDialo.getSelectedCustomizations()} + */ + void removeCustomizations(List<Customization> customizations) + throws IllegalParameterException; + + /** + * Cancel the dialog + */ + void cancel(); + + /** + * Validate the dialog + */ + void validate(); + + /** + * The intersection between getSelectedCustomizations() and + * getAvailableCustomizations') has to be empty. + * + * @return the customizations selected using the dialog. + */ + List<Customization> getSelectedCustomizations(); + + /** + * The intersection between getSelectedCustomizations() and + * getAvailableCustomizations') has to be empty. + * + * @return the available and not yet selected customizations + */ + List<Customization> getAvailableCustomizations(); + + /** + * This method is used to push up a customization. + * + * @param customization + * a selected customization. + * @throws IllegalParameterException + * when the parameter in not on element of the list returned by + * getSelectedCustomizations(). + */ + void pushUp(Customization customization) throws IllegalParameterException; + + /** + * This method is used to push down a customization. + * + * @param customization + * a selected customization. + * @throws IllegalParameterException + * when the parameter in not on element of the list returned by + * getSelectedCustomizations(). + */ + void pushDown(Customization customization) throws IllegalParameterException; +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/dialog/ILoadCustomizationsDialogFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/dialog/ILoadCustomizationsDialogFactory.java index 3032ec67861..661687041f7 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/dialog/ILoadCustomizationsDialogFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/dialog/ILoadCustomizationsDialogFactory.java @@ -1,72 +1,72 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.dialog;
-
-import java.util.List;
-
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.dialog.LoadCustomizationsDialogFactory;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallbackWithPreCommit;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Factory for {@link ILoadCustomizationsDialog}.
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @since 0.2.0
- */
-public interface ILoadCustomizationsDialogFactory {
- /** The default implementation */
- ILoadCustomizationsDialogFactory DEFAULT = new LoadCustomizationsDialogFactory();
-
- /**
- * @param parent
- * the parent shell
- * @param availableCustoms
- * the customizations that the user will be able to select
- * @param selectedCustoms
- * the customizations that will be selected when the dialog opens
- * @param listener
- * called when the dialog closes
- * @return the dialog
- * @since 0.2
- */
- <D> ILoadCustomizationsDialog<D> createLoadCustomizationDialog(final Shell parent,
- final List<Customization> availableCustoms,
- final List<Customization> selectedCustoms,
- IDialogCallbackWithPreCommit<List<Customization>, Boolean, D> callback);
-
- /**
- * @param parent
- * the parent shell
- * @param availableCustoms
- * the customizations that the user will be able to select
- * @param selectedCustoms
- * the customizations that will be selected when the dialog opens
- * @param lockedCustoms
- * a list of customizations that the user will not be able to unload
- * @param listener
- * called when the dialog closes
- * @param lockMsg
- * a message indicating why certain customizations cannot be unloaded
- * @return the dialog
- * @since 0.2
- */
- <D> ILoadCustomizationsDialog<D> createLoadCustomizationDialog(final Shell parent,
- final List<Customization> availableCustoms,
- final List<Customization> selectedCustoms,
- final List<Customization> lockedCustoms,
- IDialogCallbackWithPreCommit<List<Customization>, Boolean, D> callback,
- String lockMsg);
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.dialog; + +import java.util.List; + +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.dialog.LoadCustomizationsDialogFactory; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallbackWithPreCommit; +import org.eclipse.swt.widgets.Shell; + +/** + * Factory for {@link ILoadCustomizationsDialog}. + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @since 0.2.0 + */ +public interface ILoadCustomizationsDialogFactory { + /** The default implementation */ + ILoadCustomizationsDialogFactory DEFAULT = new LoadCustomizationsDialogFactory(); + + /** + * @param parent + * the parent shell + * @param availableCustoms + * the customizations that the user will be able to select + * @param selectedCustoms + * the customizations that will be selected when the dialog opens + * @param listener + * called when the dialog closes + * @return the dialog + * @since 0.2 + */ + <D> ILoadCustomizationsDialog<D> createLoadCustomizationDialog(final Shell parent, + final List<Customization> availableCustoms, + final List<Customization> selectedCustoms, + IDialogCallbackWithPreCommit<List<Customization>, Boolean, D> callback); + + /** + * @param parent + * the parent shell + * @param availableCustoms + * the customizations that the user will be able to select + * @param selectedCustoms + * the customizations that will be selected when the dialog opens + * @param lockedCustoms + * a list of customizations that the user will not be able to unload + * @param listener + * called when the dialog closes + * @param lockMsg + * a message indicating why certain customizations cannot be unloaded + * @return the dialog + * @since 0.2 + */ + <D> ILoadCustomizationsDialog<D> createLoadCustomizationDialog(final Shell parent, + final List<Customization> availableCustoms, + final List<Customization> selectedCustoms, + final List<Customization> lockedCustoms, + IDialogCallbackWithPreCommit<List<Customization>, Boolean, D> callback, + String lockMsg); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/exception/IllegalParameterException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/exception/IllegalParameterException.java index cb4d1e6de72..7ccadcfa9ac 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/exception/IllegalParameterException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/exported/exception/IllegalParameterException.java @@ -1,53 +1,53 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.exception;
-
-import java.util.List;
-
-public class IllegalParameterException extends Exception {
-
- private static final long serialVersionUID = 2470355059500176931L;
- private final List<? extends Object> illegalParameters;
-
- public IllegalParameterException(
- final List<? extends Object> illegalParameters) {
- super();
- this.illegalParameters = illegalParameters;
- }
-
- public IllegalParameterException(final String message,
- final List<? extends Object> illegalParameters) {
- super(message);
- this.illegalParameters = illegalParameters;
- }
-
- public IllegalParameterException(final Throwable cause,
- final List<? extends Object> illegalParameters) {
- super(cause);
- this.illegalParameters = illegalParameters;
- }
-
- public IllegalParameterException(final String message,
- final Throwable cause,
- final List<? extends Object> illegalParameters) {
- super(message, cause);
- this.illegalParameters = illegalParameters;
- }
-
- /**
- * @return the illegalParameters
- */
- public List<? extends Object> getIllegalParameters() {
- return this.illegalParameters;
- }
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.exported.exception; + +import java.util.List; + +public class IllegalParameterException extends Exception { + + private static final long serialVersionUID = 2470355059500176931L; + private final List<? extends Object> illegalParameters; + + public IllegalParameterException( + final List<? extends Object> illegalParameters) { + super(); + this.illegalParameters = illegalParameters; + } + + public IllegalParameterException(final String message, + final List<? extends Object> illegalParameters) { + super(message); + this.illegalParameters = illegalParameters; + } + + public IllegalParameterException(final Throwable cause, + final List<? extends Object> illegalParameters) { + super(cause); + this.illegalParameters = illegalParameters; + } + + public IllegalParameterException(final String message, + final Throwable cause, + final List<? extends Object> illegalParameters) { + super(message, cause); + this.illegalParameters = illegalParameters; + } + + /** + * @return the illegalParameters + */ + public List<? extends Object> getIllegalParameters() { + return this.illegalParameters; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/messages.properties b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/messages.properties index 2c6eb227231..d70680cffbf 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/messages.properties +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/messages.properties @@ -1,55 +1,55 @@ -###############################################################################
-# Copyright (c) 2009 Mia-Software.
-# 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:
-# Nicolas Bros (Mia-Software) - initial API and implementation
-# Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
-# Nicolas Bros (Mia-Software) - Bug 372732 - [Facet] Rewrite the catalog views for 0.2
-# Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
-# Vincent Lorenzo (CEA-LIST) - Bug 373255 - Add tooltips providing a documentation for the selected elements in the Select ETypedElement Dialog
-###############################################################################
-CustomizationsCatalogView_title=Customizations
-CustomizationsView_allQuerySets=all
-CustomizationsView_jobName_RefreshCustomizationsView=Refresh Customizations View
-CustomizationsView_extendsColumn=Extends
-CustomizationsView_nameColumn=Name
-CustomizationsView_documentationColumn=Documentation
-CustomizedLabelProvider_null=null
-NewCustomizationFilePage_browserCustomization=Browser Customization
-NewCustomizationFilePage_createsBrowserCustomization=Creates a new Browser Customization
-NewCustomizationFilePage_customizationInNonEmfFacetProject=Warning : you are creating this Customization in a non-EmfFacet project. It will not be available until moved to a EmfFacet project.
-NewCustomizationWizard_newBrowserCustomization=New Browser Customization
-QuerySetsSelectionControl_allExistingQuerySets=all existing query sets
-QuerySetsSelectionControl_availableQuerySets=Available query sets:
-QuerySetsSelectionControl_deselectAll=Deselect All
-QuerySetsSelectionControl_querySetsSelectedBelowOnly=query sets selected below only
-QuerySetsSelectionControl_selectAll=Select All
-SelectMetamodelsPage_selectMetamodel=Select Metamodel
-SelectMetamodelsPage_selectMetamodelToCustomize=Select the metamodel to which the new browser customization will apply
-SelectQuerySetsPage_selectAvailableQuerySets=Select Available Query Sets
-SelectQuerySetsPage_selectAvailableQuerySetsInCustomization=Select the query sets that will be available in the customization
-ToolTipTextQuery_Documentation={0}
-ToolTipTextQuery_NoDocumentation=No documentation
-LoadCustomizationsDialog_Add=>
-LoadCustomizationsDialog_Add2=Add
-LoadCustomizationsDialog_AddAll=>>
-LoadCustomizationsDialog_AddAll2=Add All
-LoadCustomizationsDialog_AvailiableCustom=Available Customizations
-LoadCustomizationsDialog_Can_not_be_unload=The local customization can't be unloaded.
-LoadCustomizationsDialog_Down=Down
-LoadCustomizationsDialog_LoadedCustomizations=Loaded Customizations
-LoadCustomizationsDialog_LoadCustomizationWarning=Load Customizations Warning
-LoadCustomizationsDialog_Loading=Loading...
-LoadCustomizationsDialog_loadReferencedFacetsCheckbox=Load referenced facets
-LoadCustomizationsDialog_OK=OK
-LoadCustomizationsDialog_Remove=<
-LoadCustomizationsDialog_Remove2=Remove
-LoadCustomizationsDialog_RemoveAll=<<
-LoadCustomizationsDialog_RemoveAll2=Remove All
-LoadCustomizationsDialog_title_LoadCustomizations=Load Customizations
-LoadCustomizationsDialog_type_filter_test=type filter text
-LoadCustomizationsDialog_Up=Up
+############################################################################### +# Copyright (c) 2009 Mia-Software. +# 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: +# Nicolas Bros (Mia-Software) - initial API and implementation +# Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework +# Nicolas Bros (Mia-Software) - Bug 372732 - [Facet] Rewrite the catalog views for 0.2 +# Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning +# Vincent Lorenzo (CEA-LIST) - Bug 373255 - Add tooltips providing a documentation for the selected elements in the Select ETypedElement Dialog +############################################################################### +CustomizationsCatalogView_title=Customizations +CustomizationsView_allQuerySets=all +CustomizationsView_jobName_RefreshCustomizationsView=Refresh Customizations View +CustomizationsView_extendsColumn=Extends +CustomizationsView_nameColumn=Name +CustomizationsView_documentationColumn=Documentation +CustomizedLabelProvider_null=null +NewCustomizationFilePage_browserCustomization=Browser Customization +NewCustomizationFilePage_createsBrowserCustomization=Creates a new Browser Customization +NewCustomizationFilePage_customizationInNonEmfFacetProject=Warning : you are creating this Customization in a non-EmfFacet project. It will not be available until moved to a EmfFacet project. +NewCustomizationWizard_newBrowserCustomization=New Browser Customization +QuerySetsSelectionControl_allExistingQuerySets=all existing query sets +QuerySetsSelectionControl_availableQuerySets=Available query sets: +QuerySetsSelectionControl_deselectAll=Deselect All +QuerySetsSelectionControl_querySetsSelectedBelowOnly=query sets selected below only +QuerySetsSelectionControl_selectAll=Select All +SelectMetamodelsPage_selectMetamodel=Select Metamodel +SelectMetamodelsPage_selectMetamodelToCustomize=Select the metamodel to which the new browser customization will apply +SelectQuerySetsPage_selectAvailableQuerySets=Select Available Query Sets +SelectQuerySetsPage_selectAvailableQuerySetsInCustomization=Select the query sets that will be available in the customization +ToolTipTextQuery_Documentation={0} +ToolTipTextQuery_NoDocumentation=No documentation +LoadCustomizationsDialog_Add=> +LoadCustomizationsDialog_Add2=Add +LoadCustomizationsDialog_AddAll=>> +LoadCustomizationsDialog_AddAll2=Add All +LoadCustomizationsDialog_AvailiableCustom=Available Customizations +LoadCustomizationsDialog_Can_not_be_unload=The local customization can't be unloaded. +LoadCustomizationsDialog_Down=Down +LoadCustomizationsDialog_LoadedCustomizations=Loaded Customizations +LoadCustomizationsDialog_LoadCustomizationWarning=Load Customizations Warning +LoadCustomizationsDialog_Loading=Loading... +LoadCustomizationsDialog_loadReferencedFacetsCheckbox=Load referenced facets +LoadCustomizationsDialog_OK=OK +LoadCustomizationsDialog_Remove=< +LoadCustomizationsDialog_Remove2=Remove +LoadCustomizationsDialog_RemoveAll=<< +LoadCustomizationsDialog_RemoveAll2=Remove All +LoadCustomizationsDialog_title_LoadCustomizations=Load Customizations +LoadCustomizationsDialog_type_filter_test=type filter text +LoadCustomizationsDialog_Up=Up diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/BackgroundQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/BackgroundQuery.java index cc5381e7049..914d83ab5c7 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/BackgroundQuery.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/BackgroundQuery.java @@ -1,32 +1,32 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.query;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IColor;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt.Color;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2;
-import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
-
-public class BackgroundQuery implements IJavaQuery2<EObject, IColor> {
-
- public IColor evaluate(final EObject source,
- final IParameterValueList2 parameterValues,
- final IFacetManager facetManager)
- throws DerivedTypedElementException {
- return new Color(Color.MAX_VALUE, Color.MAX_VALUE, Color.MAX_VALUE);
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.query; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IColor; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt.Color; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; + +public class BackgroundQuery implements IJavaQuery2<EObject, IColor> { + + public IColor evaluate(final EObject source, + final IParameterValueList2 parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + return new Color(Color.MAX_VALUE, Color.MAX_VALUE, Color.MAX_VALUE); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/DefaultVisibilityQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/DefaultVisibilityQuery.java index c569b36df6d..a599e21a523 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/DefaultVisibilityQuery.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/DefaultVisibilityQuery.java @@ -1,72 +1,72 @@ -/*****************************************************************************
- * Copyright (c) 2014 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.query;
-
-import java.util.Collection;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2;
-import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
-
-/**
- * Determines the default value for visibility
- *
- * False for EAttributes and empty references, true otherwise
- *
- * Default implementation in EMF Facet is always true (TrueLiteralQuery)
- *
- * @author Camille Letavernier
- *
- */
-public class DefaultVisibilityQuery implements IJavaQuery2<EObject, Boolean> {
-
- public Boolean evaluate(EObject source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException {
- ParameterValue paramValue = parameterValues.getParameterValueByName("eStructuralFeature");
- if (paramValue == null) {
- return true;
- }
-
- EStructuralFeature feature = (EStructuralFeature) paramValue.getValue();
-
- if (feature == null) {
- return true;
- }
-
- if (feature instanceof EAttribute) {
- return false;
- }
-
- if (feature instanceof FacetReference) {
- return true;
- }
-
- if (feature instanceof EReference) {
- Object value = source.eGet(feature);
- if (value == null) {
- return false;
- }
- if (value instanceof Collection<?>) {
- return !((Collection<?>) value).isEmpty();
- }
- }
-
- return true;
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2014 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: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.query; + +import java.util.Collection; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; + +/** + * Determines the default value for visibility + * + * False for EAttributes and empty references, true otherwise + * + * Default implementation in EMF Facet is always true (TrueLiteralQuery) + * + * @author Camille Letavernier + * + */ +public class DefaultVisibilityQuery implements IJavaQuery2<EObject, Boolean> { + + public Boolean evaluate(EObject source, IParameterValueList2 parameterValues, IFacetManager facetManager) throws DerivedTypedElementException { + ParameterValue paramValue = parameterValues.getParameterValueByName("eStructuralFeature"); + if (paramValue == null) { + return true; + } + + EStructuralFeature feature = (EStructuralFeature) paramValue.getValue(); + + if (feature == null) { + return true; + } + + if (feature instanceof EAttribute) { + return false; + } + + if (feature instanceof FacetReference) { + return true; + } + + if (feature instanceof EReference) { + Object value = source.eGet(feature); + if (value == null) { + return false; + } + if (value instanceof Collection<?>) { + return !((Collection<?>) value).isEmpty(); + } + } + + return true; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/FontNameQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/FontNameQuery.java index 00ae52de7e0..b8eb5cccc72 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/FontNameQuery.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/FontNameQuery.java @@ -1,31 +1,31 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.query;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2;
-import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
-import org.eclipse.swt.widgets.Display;
-
-public class FontNameQuery implements IJavaQuery2<EObject, String> {
-
- public String evaluate(final EObject source,
- final IParameterValueList2 parameterValues,
- final IFacetManager facetManager)
- throws DerivedTypedElementException {
- return Display.getDefault().getSystemFont().getFontData()[0].getName();
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.query; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; +import org.eclipse.swt.widgets.Display; + +public class FontNameQuery implements IJavaQuery2<EObject, String> { + + public String evaluate(final EObject source, + final IParameterValueList2 parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + return Display.getDefault().getSystemFont().getFontData()[0].getName(); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/FontSizeQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/FontSizeQuery.java index 246bc22d38d..b54e68ca693 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/FontSizeQuery.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/FontSizeQuery.java @@ -1,31 +1,31 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.query;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2;
-import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
-import org.eclipse.swt.widgets.Display;
-
-public class FontSizeQuery implements IJavaQuery2<EObject, Integer> {
-
- public Integer evaluate(final EObject source,
- final IParameterValueList2 parameterValues,
- final IFacetManager facetManager)
- throws DerivedTypedElementException {
- return Integer.valueOf(Display.getDefault().getSystemFont().getFontData()[0].getHeight());
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.query; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; +import org.eclipse.swt.widgets.Display; + +public class FontSizeQuery implements IJavaQuery2<EObject, Integer> { + + public Integer evaluate(final EObject source, + final IParameterValueList2 parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + return Integer.valueOf(Display.getDefault().getSystemFont().getFontData()[0].getHeight()); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ForegroundQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ForegroundQuery.java index 69b5b3d4650..954c7f9d568 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ForegroundQuery.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ForegroundQuery.java @@ -1,32 +1,32 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * 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:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.query;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IColor;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt.Color;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2;
-import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
-
-public class ForegroundQuery implements IJavaQuery2<EObject, IColor> {
-
- public IColor evaluate(final EObject source,
- final IParameterValueList2 parameterValues,
- final IFacetManager facetManager)
- throws DerivedTypedElementException {
- return new Color(0, 0, 0);
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * 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: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.query; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IColor; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt.Color; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; + +public class ForegroundQuery implements IJavaQuery2<EObject, IColor> { + + public IColor evaluate(final EObject source, + final IParameterValueList2 parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + return new Color(0, 0, 0); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ImageQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ImageQuery.java index 5635b0427de..a6530adaf63 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ImageQuery.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ImageQuery.java @@ -1,131 +1,131 @@ -/**
- * Copyright (c) 2011, 2014 Mia-Software, CEA, 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider
- * Gregoire Dupe (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table
- * Christian W. Damus (CEA) - bug 410346
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.query;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
-import org.eclipse.emf.edit.provider.IItemLabelProvider;
-import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.ImageProvider;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt.ImageWrapper;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
-import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2;
-import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
-import org.eclipse.swt.graphics.Image;
-
-public class ImageQuery implements IJavaQuery2<EObject, IImage> {
-
- public IImage evaluate(final EObject source,
- final IParameterValueList2 parameterValues,
- final IFacetManager facetManager)
- throws DerivedTypedElementException {
- IImage result = null;
- ETypedElement sfParam = null;
- if (parameterValues != null) {
- sfParam = (ETypedElement) parameterValues
- .getParameterValueByName("eStructuralFeature").getValue(); //$NON-NLS-1$
- }
- if (sfParam == null) {
- result = getEObjectImage(source);
- } else {
- result = getLinkImage(sfParam);
- }
- return result;
- }
-
- public static IImage getEObjectImage(final EObject source) {
- IImage result = null;
- final ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(
- ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
-
- try {
- final IItemLabelProvider itemLabelProvider = (IItemLabelProvider) adapterFactory.adapt(source, IItemLabelProvider.class);
- if (itemLabelProvider != null) {
- Object imageObject = itemLabelProvider.getImage(source);
- Image image = ExtendedImageRegistry.getInstance().getImage(imageObject);
- result = new ImageWrapper(image);
- // // final ImageDescriptor imgDescriptor = ExtendedImageRegistry.getInstance().getImageDescriptor(source);
- // final IImageProvider imgProvider = IImageProviderFactory.DEFAULT.createIImageProvider(Activator.getDefault());
- // if(imgDescriptor != null) {
- // final Image image = imgProvider.getImage(imgDescriptor);
- // result = new ImageWrapper(image);
- // }
- }
- } finally {
- // Dispose the adapter factory because it added an adapter that would leak, as it will never be reused
- adapterFactory.dispose();
- }
-
- return result;
- }
-
- /**
- * Returns the image for an attribute or reference link.
- *
- * @param sfParam
- * the attribute or reference
- * @param source
- * the EObject under which the attribute or reference appears
- * @return the image
- */
- private static IImage getLinkImage(final ETypedElement sfParam) {
- Image image = null;
- if (sfParam instanceof FacetReference) {
- image = ImageProvider.getInstance().getFacetLinkIcon();
- } else if (sfParam instanceof EReference) {
- image = getReferenceImage((EReference) sfParam);
- } else if (sfParam instanceof FacetAttribute) {
- image = ImageProvider.getInstance().getFacetAttributeIcon();
- } else if (sfParam instanceof EAttribute) {
- image = getAttributeImage();
- } else {
- image = ImageProvider.getInstance().getFeatureIcon();
- }
- return new ImageWrapper(image);
- }
-
- private static Image getReferenceImage(final EReference reference) {
- Image result;
- final EReference opposite = reference.getEOpposite();
- if (reference.isContainment()) {
- if (opposite == null) {
- result = ImageProvider.getInstance().getUnidirectionalAggregIcon();
- } else {
- result = ImageProvider.getInstance().getAggregIcon();
- }
- } else {
- if (opposite != null && opposite.isContainment()) {
- result = ImageProvider.getInstance().getInvAggregIcon();
- } else if (opposite == null) {
- result = ImageProvider.getInstance().getUnidirectionalLinkIcon();
- } else {
- result = ImageProvider.getInstance().getLinkIcon();
- }
- }
- return result;
- }
-
- private static Image getAttributeImage() {
- return ImageProvider.getInstance().getAttributeIcon();
- }
-}
+/** + * Copyright (c) 2011, 2014 Mia-Software, CEA, 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider + * Gregoire Dupe (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table + * Christian W. Damus (CEA) - bug 410346 + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.query; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry; +import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.ImageProvider; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt.ImageWrapper; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; +import org.eclipse.swt.graphics.Image; + +public class ImageQuery implements IJavaQuery2<EObject, IImage> { + + public IImage evaluate(final EObject source, + final IParameterValueList2 parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + IImage result = null; + ETypedElement sfParam = null; + if (parameterValues != null) { + sfParam = (ETypedElement) parameterValues + .getParameterValueByName("eStructuralFeature").getValue(); //$NON-NLS-1$ + } + if (sfParam == null) { + result = getEObjectImage(source); + } else { + result = getLinkImage(sfParam); + } + return result; + } + + public static IImage getEObjectImage(final EObject source) { + IImage result = null; + final ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory( + ComposedAdapterFactory.Descriptor.Registry.INSTANCE); + + try { + final IItemLabelProvider itemLabelProvider = (IItemLabelProvider) adapterFactory.adapt(source, IItemLabelProvider.class); + if (itemLabelProvider != null) { + Object imageObject = itemLabelProvider.getImage(source); + Image image = ExtendedImageRegistry.getInstance().getImage(imageObject); + result = new ImageWrapper(image); + // // final ImageDescriptor imgDescriptor = ExtendedImageRegistry.getInstance().getImageDescriptor(source); + // final IImageProvider imgProvider = IImageProviderFactory.DEFAULT.createIImageProvider(Activator.getDefault()); + // if(imgDescriptor != null) { + // final Image image = imgProvider.getImage(imgDescriptor); + // result = new ImageWrapper(image); + // } + } + } finally { + // Dispose the adapter factory because it added an adapter that would leak, as it will never be reused + adapterFactory.dispose(); + } + + return result; + } + + /** + * Returns the image for an attribute or reference link. + * + * @param sfParam + * the attribute or reference + * @param source + * the EObject under which the attribute or reference appears + * @return the image + */ + private static IImage getLinkImage(final ETypedElement sfParam) { + Image image = null; + if (sfParam instanceof FacetReference) { + image = ImageProvider.getInstance().getFacetLinkIcon(); + } else if (sfParam instanceof EReference) { + image = getReferenceImage((EReference) sfParam); + } else if (sfParam instanceof FacetAttribute) { + image = ImageProvider.getInstance().getFacetAttributeIcon(); + } else if (sfParam instanceof EAttribute) { + image = getAttributeImage(); + } else { + image = ImageProvider.getInstance().getFeatureIcon(); + } + return new ImageWrapper(image); + } + + private static Image getReferenceImage(final EReference reference) { + Image result; + final EReference opposite = reference.getEOpposite(); + if (reference.isContainment()) { + if (opposite == null) { + result = ImageProvider.getInstance().getUnidirectionalAggregIcon(); + } else { + result = ImageProvider.getInstance().getAggregIcon(); + } + } else { + if (opposite != null && opposite.isContainment()) { + result = ImageProvider.getInstance().getInvAggregIcon(); + } else if (opposite == null) { + result = ImageProvider.getInstance().getUnidirectionalLinkIcon(); + } else { + result = ImageProvider.getInstance().getLinkIcon(); + } + } + return result; + } + + private static Image getAttributeImage() { + return ImageProvider.getInstance().getAttributeIcon(); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/SelectionQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/SelectionQuery.java index 048b1a6c1d2..eb736312470 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/SelectionQuery.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/SelectionQuery.java @@ -1,59 +1,59 @@ -/*******************************************************************************
- * Copyright (c) 2012 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - Bug 377866 - selection customization
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.query;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.FacetManagerException;
-import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2;
-import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
-
-/**
- * This is the query that returns the default selection for a given source and feature (i.e. row and column in a table).
- * By default, the selection is the {@link EObject} (or list of {@link EObject}s) returned by evaluating the feature on
- * the source.
- */
-public class SelectionQuery implements IJavaQuery2<EObject, List<Object>> {
-
- // @SuppressWarnings("unchecked") : facet manager is not type safe
- @SuppressWarnings("unchecked")
- public List<Object> evaluate(final EObject source,
- final IParameterValueList2 parameterValues,
- final IFacetManager facetManager)
- throws DerivedTypedElementException {
- if (parameterValues.size() != 1) {
- throw new DerivedTypedElementException("the selection query expects one argument"); //$NON-NLS-1$
- }
- final Object param1 = parameterValues.get(0).getValue();
- if (!(param1 instanceof ETypedElement)) {
- throw new DerivedTypedElementException("the selection query expects an ETypedElement argument"); //$NON-NLS-1$
- }
- final ETypedElement feature = (ETypedElement) param1;
-
- final List<Object> result;
- try {
- final Object featureResult = facetManager.getOrInvoke(source, feature, null);
- if (feature.isMany()) {
- result = (List<Object>) featureResult;
- } else {
- result = Collections.singletonList(featureResult);
- }
- } catch (FacetManagerException e) {
- throw new DerivedTypedElementException(e);
- }
- return result;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - Bug 377866 - selection customization + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.query; + +import java.util.Collections; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.FacetManagerException; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; + +/** + * This is the query that returns the default selection for a given source and feature (i.e. row and column in a table). + * By default, the selection is the {@link EObject} (or list of {@link EObject}s) returned by evaluating the feature on + * the source. + */ +public class SelectionQuery implements IJavaQuery2<EObject, List<Object>> { + + // @SuppressWarnings("unchecked") : facet manager is not type safe + @SuppressWarnings("unchecked") + public List<Object> evaluate(final EObject source, + final IParameterValueList2 parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + if (parameterValues.size() != 1) { + throw new DerivedTypedElementException("the selection query expects one argument"); //$NON-NLS-1$ + } + final Object param1 = parameterValues.get(0).getValue(); + if (!(param1 instanceof ETypedElement)) { + throw new DerivedTypedElementException("the selection query expects an ETypedElement argument"); //$NON-NLS-1$ + } + final ETypedElement feature = (ETypedElement) param1; + + final List<Object> result; + try { + final Object featureResult = facetManager.getOrInvoke(source, feature, null); + if (feature.isMany()) { + result = (List<Object>) featureResult; + } else { + result = Collections.singletonList(featureResult); + } + } catch (FacetManagerException e) { + throw new DerivedTypedElementException(e); + } + return result; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipAlignmentQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipAlignmentQuery.java index f4ed2a6d56a..807d6193d0c 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipAlignmentQuery.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipAlignmentQuery.java @@ -1,37 +1,37 @@ -/*****************************************************************************
- * Copyright (c) 2012 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:
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.query;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Alignment;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2;
-import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
-
-/**
- *
- * This query is used to get the default alignment for the tooltip texts
- *
- */
-public class ToolTipAlignmentQuery implements IJavaQuery2<EObject, Alignment> {
-
- public Alignment evaluate(final EObject source,
- final IParameterValueList2 parameterValues,
- final IFacetManager facetManager)
- throws DerivedTypedElementException {
- return Alignment.LEFT;
- }
-}
+/***************************************************************************** + * Copyright (c) 2012 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: + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + * + *****************************************************************************/ + +package org.eclipse.papyrus.emf.facet.custom.ui.internal.query; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Alignment; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; + +/** + * + * This query is used to get the default alignment for the tooltip texts + * + */ +public class ToolTipAlignmentQuery implements IJavaQuery2<EObject, Alignment> { + + public Alignment evaluate(final EObject source, + final IParameterValueList2 parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + return Alignment.LEFT; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipBackgroundQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipBackgroundQuery.java index 9125f609400..d919a7bfd6c 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipBackgroundQuery.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipBackgroundQuery.java @@ -1,41 +1,41 @@ -/*****************************************************************************
- * Copyright (c) 2012 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:
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.query;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IColor;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt.Color;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2;
-import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
-
-/**
- *
- * This query is used to get the default background color for the tooltips (255,255,225)
- *
- */
-public class ToolTipBackgroundQuery implements IJavaQuery2<EObject, IColor> {
-
- private static final int BCK_GND_BLUE = 225;
-
- public IColor evaluate(final EObject source,
- final IParameterValueList2 parameterValues,
- final IFacetManager facetManager)
- throws DerivedTypedElementException {
- // default yellow background for tooltip
- return new Color(Color.MAX_VALUE, Color.MAX_VALUE, ToolTipBackgroundQuery.BCK_GND_BLUE);
- }
-}
+/***************************************************************************** + * Copyright (c) 2012 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: + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + * + *****************************************************************************/ + +package org.eclipse.papyrus.emf.facet.custom.ui.internal.query; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IColor; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt.Color; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; + +/** + * + * This query is used to get the default background color for the tooltips (255,255,225) + * + */ +public class ToolTipBackgroundQuery implements IJavaQuery2<EObject, IColor> { + + private static final int BCK_GND_BLUE = 225; + + public IColor evaluate(final EObject source, + final IParameterValueList2 parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + // default yellow background for tooltip + return new Color(Color.MAX_VALUE, Color.MAX_VALUE, ToolTipBackgroundQuery.BCK_GND_BLUE); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipDelayQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipDelayQuery.java index b3654390346..87ce7f41682 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipDelayQuery.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipDelayQuery.java @@ -1,35 +1,35 @@ -/*****************************************************************************
- * Copyright (c) 2012 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:
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- *
- *****************************************************************************/
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.query;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2;
-import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
-
-/**
- *
- * This query is used to get the default time for the tooltips
- *
- */
-public class ToolTipDelayQuery implements IJavaQuery2<EObject, Integer> {
-
- public Integer evaluate(final EObject source,
- final IParameterValueList2 parameterValues,
- final IFacetManager facetManager)
- throws DerivedTypedElementException {
- return Integer.valueOf(0);
- }
-}
+/***************************************************************************** + * Copyright (c) 2012 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: + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + * + *****************************************************************************/ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.query; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; + +/** + * + * This query is used to get the default time for the tooltips + * + */ +public class ToolTipDelayQuery implements IJavaQuery2<EObject, Integer> { + + public Integer evaluate(final EObject source, + final IParameterValueList2 parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + return Integer.valueOf(0); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipShadowQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipShadowQuery.java index 19081fe056f..356b9784ce9 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipShadowQuery.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipShadowQuery.java @@ -1,37 +1,37 @@ -/*****************************************************************************
- * Copyright (c) 2012 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:
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.query;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Shadow;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2;
-import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
-
-/**
- *
- * This query is used to get the default shadow for the tooltips
- *
- */
-public class ToolTipShadowQuery implements IJavaQuery2<EObject, Shadow> {
-
- public Shadow evaluate(final EObject source,
- final IParameterValueList2 parameterValues,
- final IFacetManager facetManager)
- throws DerivedTypedElementException {
- return Shadow.NONE;
- }
-}
+/***************************************************************************** + * Copyright (c) 2012 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: + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + * + *****************************************************************************/ + +package org.eclipse.papyrus.emf.facet.custom.ui.internal.query; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custompt.Shadow; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; + +/** + * + * This query is used to get the default shadow for the tooltips + * + */ +public class ToolTipShadowQuery implements IJavaQuery2<EObject, Shadow> { + + public Shadow evaluate(final EObject source, + final IParameterValueList2 parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + return Shadow.NONE; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipTextQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipTextQuery.java index 5de26588ffd..e541ab7af68 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipTextQuery.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ToolTipTextQuery.java @@ -1,76 +1,76 @@ -/*******************************************************************************
- * Copyright (c) 2012 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:
- * Vincent Lorenzo (CEA-LIST) - Bug 373255 - Add tooltips providing a documentation for the selected elements in the Select ETypedElement Dialog
- *
- *******************************************************************************/
-
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.query;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DocumentedElement;
-import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2;
-import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
-
-/**
- *
- * This query returns the tooltip to display for DocumentedElement and
- * EModelElement
- *
- */
-public class ToolTipTextQuery implements IJavaQuery2<EObject, String> {
-
- /** the URI used by EAnnotation for the documentation for the documentation */
- public static final String URI_GEN_MODEL = "http://www.eclipse.org/emf/2002/GenModel"; //$NON-NLS-1$
-
- /** the key to get the documentation in an EAnnotation */
- public static final String DOCUMENTATION = "documentation"; //$NON-NLS-1$
-
- /** the String displayed when there is no documentation */
- public static final String NO_DOCUMENTATION = Messages.ToolTipTextQuery_NoDocumentation;
-
- public String evaluate(final EObject source,
- final IParameterValueList2 parameterValues,
- final IFacetManager facetManager) {
- String result = null;
- final String documentation = getDocumentation(source);
- if (documentation != null) {
- result = NLS.bind(Messages.ToolTipTextQuery_Documentation,
- documentation);
- }
- return result;
- }
-
- /**
- *
- * @param source
- * @param parameterValues
- * @param facetManager
- * @return the documentation for DocumentedElement and EModelElement
- */
- private static String getDocumentation(final EObject source) {
- String documentation = ""; //$NON-NLS-1$
- if (source instanceof DocumentedElement) {
- documentation = ((DocumentedElement) source).getDocumentation();
- } else if (source instanceof EModelElement) {
- final EAnnotation eAnnotation = ((EModelElement) source)
- .getEAnnotation(ToolTipTextQuery.URI_GEN_MODEL);
- if (eAnnotation != null) {
- documentation = eAnnotation.getDetails().get(
- ToolTipTextQuery.DOCUMENTATION);
- }
- }
- return documentation;
- }
+/******************************************************************************* + * Copyright (c) 2012 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: + * Vincent Lorenzo (CEA-LIST) - Bug 373255 - Add tooltips providing a documentation for the selected elements in the Select ETypedElement Dialog + * + *******************************************************************************/ + +package org.eclipse.papyrus.emf.facet.custom.ui.internal.query; + +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EModelElement; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.osgi.util.NLS; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DocumentedElement; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; + +/** + * + * This query returns the tooltip to display for DocumentedElement and + * EModelElement + * + */ +public class ToolTipTextQuery implements IJavaQuery2<EObject, String> { + + /** the URI used by EAnnotation for the documentation for the documentation */ + public static final String URI_GEN_MODEL = "http://www.eclipse.org/emf/2002/GenModel"; //$NON-NLS-1$ + + /** the key to get the documentation in an EAnnotation */ + public static final String DOCUMENTATION = "documentation"; //$NON-NLS-1$ + + /** the String displayed when there is no documentation */ + public static final String NO_DOCUMENTATION = Messages.ToolTipTextQuery_NoDocumentation; + + public String evaluate(final EObject source, + final IParameterValueList2 parameterValues, + final IFacetManager facetManager) { + String result = null; + final String documentation = getDocumentation(source); + if (documentation != null) { + result = NLS.bind(Messages.ToolTipTextQuery_Documentation, + documentation); + } + return result; + } + + /** + * + * @param source + * @param parameterValues + * @param facetManager + * @return the documentation for DocumentedElement and EModelElement + */ + private static String getDocumentation(final EObject source) { + String documentation = ""; //$NON-NLS-1$ + if (source instanceof DocumentedElement) { + documentation = ((DocumentedElement) source).getDocumentation(); + } else if (source instanceof EModelElement) { + final EAnnotation eAnnotation = ((EModelElement) source) + .getEAnnotation(ToolTipTextQuery.URI_GEN_MODEL); + if (eAnnotation != null) { + documentation = eAnnotation.getDetails().get( + ToolTipTextQuery.DOCUMENTATION); + } + } + return documentation; + } }
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/URIImageQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/URIImageQueryImplementationFactory.java index 593a46eca24..f6bb6c16030 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/URIImageQueryImplementationFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/URIImageQueryImplementationFactory.java @@ -1,39 +1,39 @@ -/**
- * Copyright (c) 2013 Soft-Maint.
- *
- * 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:
- * David Couvrand (Soft-Maint) - Bug 402725 - Need a query to get an image from an URI
- * Nicolas Rault (Soft-Maint) - Bug 402725 - Need a query to get an image from an URI
- */
-
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.query;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_3_0.query.QueryPackage;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.querytype.URIImageQueryEvaluator;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.osgi.framework.Bundle;
-
-public class URIImageQueryImplementationFactory implements
- IQueryImplementationFactory {
-
- public IQueryImplementation create(final Query query,
- final Bundle queryBundle, final IDerivedTypedElementManager manager)
- throws DerivedTypedElementException {
- return new URIImageQueryEvaluator();
- }
-
- public EClass getManagedQueryType() {
- return QueryPackage.eINSTANCE.getURIImageQuery();
- }
-
-}
+/** + * Copyright (c) 2013 Soft-Maint. + * + * 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: + * David Couvrand (Soft-Maint) - Bug 402725 - Need a query to get an image from an URI + * Nicolas Rault (Soft-Maint) - Bug 402725 - Need a query to get an image from an URI + */ + +package org.eclipse.papyrus.emf.facet.custom.ui.internal.query; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_3_0.query.QueryPackage; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.querytype.URIImageQueryEvaluator; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.osgi.framework.Bundle; + +public class URIImageQueryImplementationFactory implements + IQueryImplementationFactory { + + public IQueryImplementation create(final Query query, + final Bundle queryBundle, final IDerivedTypedElementManager manager) + throws DerivedTypedElementException { + return new URIImageQueryEvaluator(); + } + + public EClass getManagedQueryType() { + return QueryPackage.eINSTANCE.getURIImageQuery(); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/querytype/URIImageQueryEvaluator.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/querytype/URIImageQueryEvaluator.java index cb67e77fb30..84e5aaae7ad 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/querytype/URIImageQueryEvaluator.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/querytype/URIImageQueryEvaluator.java @@ -1,53 +1,53 @@ -/**
- * Copyright (c) 2013 Soft-Maint.
- *
- * 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:
- * David Couvrand (Soft-Maint) - Bug 402725 - Need a query to get an image from an URI
- * Nicolas Rault (Soft-Maint) - Bug 402725 - Need a query to get an image from an URI
- */
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.querytype;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_3_0.query.URIImageQuery;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt.URIImage;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-
-public class URIImageQueryEvaluator implements IQueryImplementation {
-
- public void setValue(final Query query,
- final DerivedTypedElement feature, final EObject source,
- final List<ParameterValue> parameterValues,
- final Object newValue) throws DerivedTypedElementException {
- throw new DerivedTypedElementException("Not implemented method"); //$NON-NLS-1$
- }
-
- public boolean isCheckResultType() {
- return false;
- }
-
- public Object getValue(final Query query,
- final DerivedTypedElement feature, final EObject source,
- final List<ParameterValue> parameterValues,
- final IFacetManager facetManager)
- throws DerivedTypedElementException {
- // This cast is safe. The framework should only pass a query
- // instance of URIImageQuery, because it has been declared in
- // the method 'getManagedQueryType' that this query
- // implementation is dedicated to the URIImageQuery type.
- final String uri = ((URIImageQuery) query).getUri();
- return new URIImage(uri);
- }
-
-}
+/** + * Copyright (c) 2013 Soft-Maint. + * + * 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: + * David Couvrand (Soft-Maint) - Bug 402725 - Need a query to get an image from an URI + * Nicolas Rault (Soft-Maint) - Bug 402725 - Need a query to get an image from an URI + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.querytype; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_3_0.query.URIImageQuery; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt.URIImage; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; + +public class URIImageQueryEvaluator implements IQueryImplementation { + + public void setValue(final Query query, + final DerivedTypedElement feature, final EObject source, + final List<ParameterValue> parameterValues, + final Object newValue) throws DerivedTypedElementException { + throw new DerivedTypedElementException("Not implemented method"); //$NON-NLS-1$ + } + + public boolean isCheckResultType() { + return false; + } + + public Object getValue(final Query query, + final DerivedTypedElement feature, final EObject source, + final List<ParameterValue> parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + // This cast is safe. The framework should only pass a query + // instance of URIImageQuery, because it has been declared in + // the method 'getManagedQueryType' that this query + // implementation is dedicated to the URIImageQuery type. + final String uri = ((URIImageQuery) query).getUri(); + return new URIImage(uri); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/view/CustomizationsCatalogView.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/view/CustomizationsCatalogView.java index 38ad8e09a70..273f73b8830 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/view/CustomizationsCatalogView.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/view/CustomizationsCatalogView.java @@ -1,223 +1,223 @@ -/*******************************************************************************
- * Copyright (c) 2009-2012 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- * Nicolas Guyomar (Mia-Software) - Bug 333652 Extension point offering the possibility to declare an EPackage browser
- * Nicolas Bros (Mia-Software) - Bug 372732 - [Facet] Rewrite the catalog views for 0.2
- * Nicolas Bros (Mia-Software) - Bug 372626 - Aggregates
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.custom.ui.internal.view;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IExecutableExtensionFactory;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.emf.facet.common.ui.internal.exported.views.IColumnDescription;
-import org.eclipse.papyrus.emf.facet.common.ui.internal.exported.views.IElementsViewFactory;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManager;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManagerFactory;
-import org.eclipse.papyrus.emf.facet.custom.core.internal.exported.CustomizationUtils;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.ImageProvider;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DocumentedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.swt.graphics.Image;
-
-public class CustomizationsCatalogView implements IExecutableExtensionFactory, IOpenListener {
-
- public Object create() throws CoreException {
- this.customizationCatalogManager = ICustomizationCatalogManagerFactory.DEFAULT.getOrCreateCustomizationCatalogManager(new ResourceSetImpl());
- Collection<IColumnDescription> columnDescriptions = new ArrayList<IColumnDescription>();
- columnDescriptions.add(createNameColumnDescription());
- columnDescriptions.add(createExtendsColumnDescription());
- columnDescriptions.add(createDocumentationColumnDescription());
- return IElementsViewFactory.DEFAULT.createElementsView(columnDescriptions, getContentProvider(), getInput(),
- Messages.CustomizationsCatalogView_title, ImageProvider.getInstance().getUiCustomIcon(), this);
- }
-
- private static final String NAME_COLUMN = "CustomizationsView_NameColumn"; //$NON-NLS-1$
- private static final String EXTENDS_COLUMN = "CustomizationsView_ExtendsColumn"; //$NON-NLS-1$
- private static final String DOCUMENTATION_COLUMN = "CustomizationsView_DocumentationColumn"; //$NON-NLS-1$
-
- private static final int NAME_COLUMN_WIDTH = 300;
- private static final int EXTENDS_COLUMN_WIDTH = 300;
- private static final int DOCUMENTATION_COLUMN_WIDTH = 400;
-
- private ICustomizationCatalogManager customizationCatalogManager;
-
- private static IColumnDescription createNameColumnDescription() {
- ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() {
- @Override
- public String getText(final Object element) {
- String result;
- if (element instanceof ENamedElement) {
- ENamedElement namedElement = (ENamedElement) element;
- result = namedElement.getName();
- } else {
- result = "<" + element.getClass().getName() + ">"; //$NON-NLS-1$//$NON-NLS-2$
- }
- return result;
- }
-
- @Override
- public Image getImage(final Object element) {
- return ImageProvider.getInstance().getUiCustomIcon();
- }
- };
- return IElementsViewFactory.DEFAULT.createColumnDescription(Messages.CustomizationsView_nameColumn, CustomizationsCatalogView.NAME_COLUMN,
- CustomizationsCatalogView.NAME_COLUMN_WIDTH, columnLabelProvider);
- }
-
- private static IColumnDescription createExtendsColumnDescription() {
- ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() {
- @Override
- public String getText(final Object element) {
- String result = null;
- if (element instanceof Customization) {
- Customization customization = (Customization) element;
- EPackage customizedEPackage = CustomizationUtils
- .getCustomizedEPackage(customization);
- if (customizedEPackage != null) {
- result = customizedEPackage.getNsURI();
- }
- } else if (element instanceof Facet) {
- Facet facet = (Facet) element;
- EClass extendedMetaclass = facet.getExtendedMetaclass();
- if (extendedMetaclass != null) {
- result = extendedMetaclass.getName();
- }
- }
- return result;
- }
- };
- return IElementsViewFactory.DEFAULT.createColumnDescription(Messages.CustomizationsView_extendsColumn,
- CustomizationsCatalogView.EXTENDS_COLUMN,
- CustomizationsCatalogView.EXTENDS_COLUMN_WIDTH, columnLabelProvider);
- }
-
- private static IColumnDescription createDocumentationColumnDescription() {
- ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() {
- @Override
- public String getText(final Object element) {
- String result = null;
- if (element instanceof DocumentedElement) {
- DocumentedElement documentedElement = (DocumentedElement) element;
- result = documentedElement.getDocumentation();
- }
- return result;
- }
- };
- return IElementsViewFactory.DEFAULT.createColumnDescription(Messages.CustomizationsView_documentationColumn,
- CustomizationsCatalogView.DOCUMENTATION_COLUMN, CustomizationsCatalogView.DOCUMENTATION_COLUMN_WIDTH,
- columnLabelProvider);
- }
-
- protected static ITreeContentProvider getContentProvider() {
- return new ITreeContentProvider() {
- public Object[] getElements(final Object inputElement) {
- @SuppressWarnings("unchecked")
- final Collection<Customization> customizations = (Collection<Customization>) inputElement;
- return customizations.toArray();
- }
-
- public void inputChanged(final Viewer viewer, final Object oldInput,
- final Object newInput) {
- // nothing
- }
-
- public void dispose() {
- // nothing
- }
-
- public boolean hasChildren(final Object element) {
- Object[] children = getChildren(element);
- return children != null && children.length > 0;
- }
-
- public Object getParent(final Object element) {
-
- Object result;
- if (element instanceof EObject) {
- EObject eObject = (EObject) element;
- result = eObject.eContainer();
- } else {
- result = null;
- }
- return result;
- }
-
- public Object[] getChildren(final Object parentElement) {
- Object[] result;
- if (parentElement instanceof Customization) {
- final Customization customization = (Customization) parentElement;
- final List<Object> contents = new ArrayList<Object>();
- // Aggregate
- for (final FacetSet facetSet : customization.getFacetSets()) {
- if (facetSet instanceof Customization) {
- final Customization childCustom = (Customization) facetSet;
- contents.add(childCustom);
- }
- }
- contents.addAll(customization.getEClassifiers());
- result = contents.toArray();
- } else {
- result = new Object[0];
- }
- return result;
- }
- };
- }
-
- protected Object getInput() {
- return this.customizationCatalogManager.getRegisteredCustomizations();
- }
-
- public void open(final OpenEvent event) {
- // TODO: re-enable once the customization editor is written
-
- // final MetamodelView metamodelView = (MetamodelView) element;
- // // open customization in editor
- // try {
- // org.eclipse.emf.common.util.URI uri = org.eclipse.emf.common.util.URI
- // .createURI(metamodelView.getLocation());
- // if (uri.isPlatformResource()) {
- // IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(
- // new Path(uri.toPlatformString(true)));
- // FileEditorInput fileEditorInput = new FileEditorInput(file);
- // IDE.openEditor(
- // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),
- // fileEditorInput, Activator.CUSTOMIZATION_EDITOR_ID, true);
- // } else {
- // final URIEditorInput uriEditorInput = new URIEditorInput(
- // org.eclipse.emf.common.util.URI.createURI(uri.toString()));
- // IDE.openEditor(
- // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),
- // uriEditorInput, Activator.CUSTOMIZATION_EDITOR_ID, true);
- // }
- //
- // } catch (final Exception e) {
- // Activator.logException(e);
- // }
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2009-2012 Mia-Software. + * 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: + * Nicolas Bros (Mia-Software) - initial API and implementation + * Nicolas Guyomar (Mia-Software) - Bug 333652 Extension point offering the possibility to declare an EPackage browser + * Nicolas Bros (Mia-Software) - Bug 372732 - [Facet] Rewrite the catalog views for 0.2 + * Nicolas Bros (Mia-Software) - Bug 372626 - Aggregates + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.view; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IExecutableExtensionFactory; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.ENamedElement; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.jface.viewers.IOpenListener; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.OpenEvent; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.papyrus.emf.facet.common.ui.internal.exported.views.IColumnDescription; +import org.eclipse.papyrus.emf.facet.common.ui.internal.exported.views.IElementsViewFactory; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManager; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManagerFactory; +import org.eclipse.papyrus.emf.facet.custom.core.internal.exported.CustomizationUtils; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.ImageProvider; +import org.eclipse.papyrus.emf.facet.custom.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DocumentedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.swt.graphics.Image; + +public class CustomizationsCatalogView implements IExecutableExtensionFactory, IOpenListener { + + public Object create() throws CoreException { + this.customizationCatalogManager = ICustomizationCatalogManagerFactory.DEFAULT.getOrCreateCustomizationCatalogManager(new ResourceSetImpl()); + Collection<IColumnDescription> columnDescriptions = new ArrayList<IColumnDescription>(); + columnDescriptions.add(createNameColumnDescription()); + columnDescriptions.add(createExtendsColumnDescription()); + columnDescriptions.add(createDocumentationColumnDescription()); + return IElementsViewFactory.DEFAULT.createElementsView(columnDescriptions, getContentProvider(), getInput(), + Messages.CustomizationsCatalogView_title, ImageProvider.getInstance().getUiCustomIcon(), this); + } + + private static final String NAME_COLUMN = "CustomizationsView_NameColumn"; //$NON-NLS-1$ + private static final String EXTENDS_COLUMN = "CustomizationsView_ExtendsColumn"; //$NON-NLS-1$ + private static final String DOCUMENTATION_COLUMN = "CustomizationsView_DocumentationColumn"; //$NON-NLS-1$ + + private static final int NAME_COLUMN_WIDTH = 300; + private static final int EXTENDS_COLUMN_WIDTH = 300; + private static final int DOCUMENTATION_COLUMN_WIDTH = 400; + + private ICustomizationCatalogManager customizationCatalogManager; + + private static IColumnDescription createNameColumnDescription() { + ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() { + @Override + public String getText(final Object element) { + String result; + if (element instanceof ENamedElement) { + ENamedElement namedElement = (ENamedElement) element; + result = namedElement.getName(); + } else { + result = "<" + element.getClass().getName() + ">"; //$NON-NLS-1$//$NON-NLS-2$ + } + return result; + } + + @Override + public Image getImage(final Object element) { + return ImageProvider.getInstance().getUiCustomIcon(); + } + }; + return IElementsViewFactory.DEFAULT.createColumnDescription(Messages.CustomizationsView_nameColumn, CustomizationsCatalogView.NAME_COLUMN, + CustomizationsCatalogView.NAME_COLUMN_WIDTH, columnLabelProvider); + } + + private static IColumnDescription createExtendsColumnDescription() { + ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() { + @Override + public String getText(final Object element) { + String result = null; + if (element instanceof Customization) { + Customization customization = (Customization) element; + EPackage customizedEPackage = CustomizationUtils + .getCustomizedEPackage(customization); + if (customizedEPackage != null) { + result = customizedEPackage.getNsURI(); + } + } else if (element instanceof Facet) { + Facet facet = (Facet) element; + EClass extendedMetaclass = facet.getExtendedMetaclass(); + if (extendedMetaclass != null) { + result = extendedMetaclass.getName(); + } + } + return result; + } + }; + return IElementsViewFactory.DEFAULT.createColumnDescription(Messages.CustomizationsView_extendsColumn, + CustomizationsCatalogView.EXTENDS_COLUMN, + CustomizationsCatalogView.EXTENDS_COLUMN_WIDTH, columnLabelProvider); + } + + private static IColumnDescription createDocumentationColumnDescription() { + ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() { + @Override + public String getText(final Object element) { + String result = null; + if (element instanceof DocumentedElement) { + DocumentedElement documentedElement = (DocumentedElement) element; + result = documentedElement.getDocumentation(); + } + return result; + } + }; + return IElementsViewFactory.DEFAULT.createColumnDescription(Messages.CustomizationsView_documentationColumn, + CustomizationsCatalogView.DOCUMENTATION_COLUMN, CustomizationsCatalogView.DOCUMENTATION_COLUMN_WIDTH, + columnLabelProvider); + } + + protected static ITreeContentProvider getContentProvider() { + return new ITreeContentProvider() { + public Object[] getElements(final Object inputElement) { + @SuppressWarnings("unchecked") + final Collection<Customization> customizations = (Collection<Customization>) inputElement; + return customizations.toArray(); + } + + public void inputChanged(final Viewer viewer, final Object oldInput, + final Object newInput) { + // nothing + } + + public void dispose() { + // nothing + } + + public boolean hasChildren(final Object element) { + Object[] children = getChildren(element); + return children != null && children.length > 0; + } + + public Object getParent(final Object element) { + + Object result; + if (element instanceof EObject) { + EObject eObject = (EObject) element; + result = eObject.eContainer(); + } else { + result = null; + } + return result; + } + + public Object[] getChildren(final Object parentElement) { + Object[] result; + if (parentElement instanceof Customization) { + final Customization customization = (Customization) parentElement; + final List<Object> contents = new ArrayList<Object>(); + // Aggregate + for (final FacetSet facetSet : customization.getFacetSets()) { + if (facetSet instanceof Customization) { + final Customization childCustom = (Customization) facetSet; + contents.add(childCustom); + } + } + contents.addAll(customization.getEClassifiers()); + result = contents.toArray(); + } else { + result = new Object[0]; + } + return result; + } + }; + } + + protected Object getInput() { + return this.customizationCatalogManager.getRegisteredCustomizations(); + } + + public void open(final OpenEvent event) { + // TODO: re-enable once the customization editor is written + + // final MetamodelView metamodelView = (MetamodelView) element; + // // open customization in editor + // try { + // org.eclipse.emf.common.util.URI uri = org.eclipse.emf.common.util.URI + // .createURI(metamodelView.getLocation()); + // if (uri.isPlatformResource()) { + // IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile( + // new Path(uri.toPlatformString(true))); + // FileEditorInput fileEditorInput = new FileEditorInput(file); + // IDE.openEditor( + // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), + // fileEditorInput, Activator.CUSTOMIZATION_EDITOR_ID, true); + // } else { + // final URIEditorInput uriEditorInput = new URIEditorInput( + // org.eclipse.emf.common.util.URI.createURI(uri.toString())); + // IDE.openEditor( + // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), + // uriEditorInput, Activator.CUSTOMIZATION_EDITOR_ID, true); + // } + // + // } catch (final Exception e) { + // Activator.logException(e); + // } + } + +} |