Package: EmfParsleyGuiceModule

EmfParsleyGuiceModule

nameinstructionbranchcomplexitylinemethod
EmfParsleyGuiceModule(AbstractUIPlugin)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
bindIImageHelper()
M: 0 C: 8
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
configure(Binder)
M: 0 C: 20
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2013 RCP Vision (http://www.rcp-vision.com) and others.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * Lorenzo Bettini - initial API and implementation
10: *******************************************************************************/
11:
12: package org.eclipse.emf.parsley;
13:
14: import org.eclipse.emf.parsley.runtime.ui.IImageHelper;
15: import org.eclipse.emf.parsley.runtime.ui.PluginImageHelper;
16: import org.eclipse.jface.dialogs.IDialogSettings;
17: import org.eclipse.ui.plugin.AbstractUIPlugin;
18:
19: import com.google.inject.Binder;
20:
21: /**
22: * Default Google Guice bindings to be used in an OSGI - Plug-in environment.
23: *
24: * @author Lorenzo Bettini
25: * @author Francesco Guidieri - only Javadocs :-)
26: *
27: */
28: public class EmfParsleyGuiceModule extends EmfParsleyJavaGuiceModule {
29:
30:         private final AbstractUIPlugin plugin;
31:
32:         /**
33:          * If the passed {@link AbstractUIPlugin} is not null, it also
34:          * performs additional Guice configuration, otherwise, this
35:          * basically behaves like {@link EmfParsleyJavaGuiceModule}
36:          *
37:          * @param plugin
38:          */
39:         public EmfParsleyGuiceModule(AbstractUIPlugin plugin) {
40:                 this.plugin = plugin;
41:         }
42:
43:         @Override
44:         public void configure(Binder binder) {
45:                 super.configure(binder);
46:•                if (plugin != null) {
47:                         binder.bind(AbstractUIPlugin.class).toInstance(plugin);
48:                         binder.bind(IDialogSettings.class).toInstance(
49:                                         plugin.getDialogSettings());
50:                 }
51:         }
52:
53:         /**
54:          * Use this binding to provide your own implementation of getImages methods.
55:          * Default implementation is {@link PluginImageHelper}.
56:          * @return a specialization of {@link IImageHelper}
57:          *
58:          */
59:         @Override
60:         public Class<? extends IImageHelper> bindIImageHelper() {
61:•                if (plugin == null) {
62:                         return super.bindIImageHelper();
63:                 }
64:                 return PluginImageHelper.class;
65:         }
66:
67: }