JavaFXModule.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.javafx;
17 
18 import griffon.core.controller.ActionFactory;
19 import griffon.core.controller.ActionManager;
20 import griffon.core.injection.Module;
21 import griffon.core.threading.UIThreadManager;
22 import griffon.core.view.WindowManager;
23 import griffon.javafx.JavaFXWindowDisplayHandler;
24 import griffon.javafx.support.ActionMatcher;
25 import org.codehaus.griffon.runtime.core.injection.AbstractModule;
26 import org.codehaus.griffon.runtime.javafx.controller.JavaFXActionFactory;
27 import org.codehaus.griffon.runtime.javafx.controller.JavaFXActionManager;
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("javafx")
39 @ServiceProviderFor(Module.class)
40 public class JavaFXModule extends AbstractModule {
41     @Override
42     protected void doConfigure() {
43         // tag::bindings[]
44         bind(JavaFXWindowDisplayHandler.class)
45             .withClassifier(named("defaultWindowDisplayHandler"))
46             .to(DefaultJavaFXWindowDisplayHandler.class)
47             .asSingleton();
48 
49         bind(JavaFXWindowDisplayHandler.class)
50             .withClassifier(named("windowDisplayHandler"))
51             .to(ConfigurableJavaFXWindowDisplayHandler.class)
52             .asSingleton();
53 
54         bind(WindowManager.class)
55             .to(DefaultJavaFXWindowManager.class)
56             .asSingleton();
57 
58         bind(UIThreadManager.class)
59             .to(JavaFXUIThreadManager.class)
60             .asSingleton();
61 
62         bind(ActionManager.class)
63             .to(JavaFXActionManager.class)
64             .asSingleton();
65 
66         bind(ActionFactory.class)
67             .to(JavaFXActionFactory.class)
68             .asSingleton();
69 
70         bind(ActionMatcher.class)
71             .toInstance(ActionMatcher.DEFAULT);
72         // end::bindings[]
73     }
74 }