SwingModule.java
01 /*
02  * Copyright 2008-2017 the original author or authors.
03  *
04  * Licensed under the Apache License, Version 2.0 (the "License");
05  * you may not use this file except in compliance with the License.
06  * You may obtain a copy of the License at
07  *
08  *     http://www.apache.org/licenses/LICENSE-2.0
09  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.codehaus.griffon.runtime.swing;
17 
18 import griffon.core.addon.GriffonAddon;
19 import griffon.core.controller.ActionFactory;
20 import griffon.core.controller.ActionManager;
21 import griffon.core.injection.Module;
22 import griffon.core.threading.UIThreadManager;
23 import griffon.core.view.WindowManager;
24 import griffon.swing.SwingWindowDisplayHandler;
25 import org.codehaus.griffon.runtime.core.injection.AbstractModule;
26 import org.codehaus.griffon.runtime.swing.controller.SwingActionFactory;
27 import org.codehaus.griffon.runtime.swing.controller.SwingActionManager;
28 import org.kordamp.jipsy.ServiceProviderFor;
29 
30 import javax.inject.Named;
31 
32 import static griffon.util.AnnotationUtils.named;
33 
34 /**
35  @author Andres Almiray
36  @since 2.0.0
37  */
38 @Named("swing")
39 @ServiceProviderFor(Module.class)
40 public class SwingModule extends AbstractModule {
41     @Override
42     protected void doConfigure() {
43         // tag::bindings[]
44         bind(SwingWindowDisplayHandler.class)
45             .withClassifier(named("defaultWindowDisplayHandler"))
46             .to(DefaultSwingWindowDisplayHandler.class)
47             .asSingleton();
48 
49         bind(SwingWindowDisplayHandler.class)
50             .withClassifier(named("windowDisplayHandler"))
51             .to(ConfigurableSwingWindowDisplayHandler.class)
52             .asSingleton();
53 
54         bind(WindowManager.class)
55             .to(DefaultSwingWindowManager.class)
56             .asSingleton();
57 
58         bind(UIThreadManager.class)
59             .to(SwingUIThreadManager.class)
60             .asSingleton();
61 
62         bind(ActionManager.class)
63             .to(SwingActionManager.class)
64             .asSingleton();
65 
66         bind(ActionFactory.class)
67             .to(SwingActionFactory.class)
68             .asSingleton();
69 
70         bind(GriffonAddon.class)
71             .to(SwingAddon.class)
72             .asSingleton();
73         // end::bindings[]
74     }
75 }