diff options
Diffstat (limited to 'examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley')
6 files changed, 185 insertions, 0 deletions
diff --git a/examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley/examples/library/Activator.java b/examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley/examples/library/Activator.java new file mode 100644 index 000000000..ac7f06794 --- /dev/null +++ b/examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley/examples/library/Activator.java @@ -0,0 +1,50 @@ +package org.eclipse.emf.parsley.examples.library; + +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.emf.parsley.examples.library"; //$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) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley/examples/library/CustomEStructuralFeaturesProvider.java b/examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley/examples/library/CustomEStructuralFeaturesProvider.java new file mode 100644 index 000000000..d4a9985b5 --- /dev/null +++ b/examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley/examples/library/CustomEStructuralFeaturesProvider.java @@ -0,0 +1,26 @@ +package org.eclipse.emf.parsley.examples.library; + +import static org.eclipse.emf.parsley.examples.library.EXTLibraryPackage.Literals.*; + +import org.eclipse.emf.parsley.ui.provider.FeaturesProvider; + + +public class CustomEStructuralFeaturesProvider extends + FeaturesProvider { + + @Override + protected void buildMap(EClassToEStructuralFeatureMap map) { + super.buildMap(map); + map.mapTo(LIBRARY, + LIBRARY__NAME, + ADDRESSABLE__ADDRESS); + map.mapTo(PERSON, + PERSON__FIRST_NAME, + PERSON__LAST_NAME, + ADDRESSABLE__ADDRESS); + map.mapTo(WRITER, + PERSON__FIRST_NAME, + PERSON__LAST_NAME, + WRITER__BOOKS); + } +} diff --git a/examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley/examples/library/CustomFeatureLabelProvider.java b/examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley/examples/library/CustomFeatureLabelProvider.java new file mode 100644 index 000000000..cfae5166a --- /dev/null +++ b/examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley/examples/library/CustomFeatureLabelProvider.java @@ -0,0 +1,23 @@ +/** + * + */ +package org.eclipse.emf.parsley.examples.library; + + +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.parsley.ui.provider.PropertyDescriptionProvider; + +/** + * @author bettini + * + */ +public class CustomFeatureLabelProvider extends PropertyDescriptionProvider { + + public String text_Person_firstName(EStructuralFeature f) { + return "First name"; + } + + public String text_Person_lastName(EStructuralFeature f) { + return "Surname"; + } +} diff --git a/examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley/examples/library/CustomLabelProvider.java b/examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley/examples/library/CustomLabelProvider.java new file mode 100644 index 000000000..eae0bbfd8 --- /dev/null +++ b/examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley/examples/library/CustomLabelProvider.java @@ -0,0 +1,35 @@ +package org.eclipse.emf.parsley.examples.library; + +import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; +import org.eclipse.emf.parsley.examples.library.Book; +import org.eclipse.emf.parsley.examples.library.Library; +import org.eclipse.emf.parsley.examples.library.Person; +import org.eclipse.emf.parsley.ui.provider.ViewerLabelProvider; + +import com.google.inject.Inject; + + + +public class CustomLabelProvider extends ViewerLabelProvider { + + @Inject + public CustomLabelProvider(AdapterFactoryLabelProvider delegate) { + super(delegate); + } + + public String text(Book book) { + return "Book: " + book.getTitle(); + } + + public String image(Library l) { + return "library.gif"; + } + + public String image(Person p) { + return "person.gif"; + } + + public String image(Book b) { + return "book.png"; + } +} diff --git a/examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley/examples/library/EmfComponentsGuiceModule.java b/examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley/examples/library/EmfComponentsGuiceModule.java new file mode 100644 index 000000000..534da638f --- /dev/null +++ b/examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley/examples/library/EmfComponentsGuiceModule.java @@ -0,0 +1,30 @@ +package org.eclipse.emf.parsley.examples.library; + + +import org.eclipse.emf.parsley.ui.provider.FeaturesProvider; +import org.eclipse.emf.parsley.ui.provider.PropertyDescriptionProvider; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +public class EmfComponentsGuiceModule extends org.eclipse.emf.parsley.EmfComponentsGuiceModule { + + public EmfComponentsGuiceModule(AbstractUIPlugin plugin) { + super(plugin); + } + + @Override + public Class<? extends ILabelProvider> bindILabelProvider() { + return CustomLabelProvider.class; + } + + @Override + public Class<? extends PropertyDescriptionProvider> bindPropertyDescriptionProvider() { + return CustomFeatureLabelProvider.class; + } + + @Override + public Class<? extends FeaturesProvider> bindFeaturesProvider() { + return CustomEStructuralFeaturesProvider.class; + } + +} diff --git a/examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley/examples/library/ExecutableExtensionFactory.java b/examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley/examples/library/ExecutableExtensionFactory.java new file mode 100644 index 000000000..2b4e63f0e --- /dev/null +++ b/examples/org.eclipse.emf.parsley.examples.library.ui/src/org/eclipse/emf/parsley/examples/library/ExecutableExtensionFactory.java @@ -0,0 +1,21 @@ +package org.eclipse.emf.parsley.examples.library; + +import org.eclipse.emf.parsley.EmfComponentsExtensionFactory; +import org.eclipse.emf.parsley.EmfComponentsGuiceModule; +import org.osgi.framework.Bundle; + + +public class ExecutableExtensionFactory extends + EmfComponentsExtensionFactory { + + @Override + protected Bundle getBundle() { + return Activator.getDefault().getBundle(); + } + + @Override + protected EmfComponentsGuiceModule getModule() { + return new EmfComponentsGuiceModule(Activator.getDefault()); + } + +} |