LanternaModule.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.lanterna;
17 
18 import com.googlecode.lanterna.gui.GUIScreen;
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.lanterna.LanternaWindowDisplayHandler;
25 import org.codehaus.griffon.runtime.core.injection.AbstractModule;
26 import org.codehaus.griffon.runtime.lanterna.controller.LanternaActionFactory;
27 import org.codehaus.griffon.runtime.lanterna.controller.LanternaActionManager;
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("lanterna")
39 @ServiceProviderFor(Module.class)
40 public class LanternaModule extends AbstractModule {
41     @Override
42     protected void doConfigure() {
43         // tag::bindings[]
44         bind(GUIScreen.class)
45             .toProvider(GUIScreenProvider.class)
46             .asSingleton();
47 
48         bind(LanternaWindowDisplayHandler.class)
49             .withClassifier(named("defaultWindowDisplayHandler"))
50             .to(DefaultLanternaWindowDisplayHandler.class)
51             .asSingleton();
52 
53         bind(LanternaWindowDisplayHandler.class)
54             .withClassifier(named("windowDisplayHandler"))
55             .to(ConfigurableLanternaWindowDisplayHandler.class)
56             .asSingleton();
57 
58         bind(WindowManager.class)
59             .to(DefaultLanternaWindowManager.class)
60             .asSingleton();
61 
62         bind(UIThreadManager.class)
63             .to(LanternaUIThreadManager.class)
64             .asSingleton();
65 
66         bind(ActionManager.class)
67             .to(LanternaActionManager.class)
68             .asSingleton();
69 
70         bind(ActionFactory.class)
71             .to(LanternaActionFactory.class)
72             .asSingleton();
73         // end::bindings[]
74     }
75 }