01 /*
02 * Copyright 2008-2015 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 griffon.builder.swing;
17
18 import griffon.builder.swing.factory.ApplicationFactory;
19 import griffon.inject.DependsOn;
20 import groovy.swing.SwingBuilder;
21 import groovy.util.Factory;
22 import org.codehaus.griffon.runtime.groovy.view.AbstractBuilderCustomizer;
23
24 import javax.inject.Named;
25 import java.util.LinkedHashMap;
26 import java.util.Map;
27
28 /**
29 * @author Andres Almiray
30 */
31 @Named("swing")
32 @DependsOn({"core"})
33 @SuppressWarnings("rawtypes")
34 public class SwingBuilderCustomizer extends AbstractBuilderCustomizer {
35 @SuppressWarnings("unchecked")
36 public SwingBuilderCustomizer() {
37 SwingBuilder builder = new SwingBuilder();
38
39 Map<String, Factory> factories = new LinkedHashMap<>(builder.getFactories());
40 factories.put("application", new ApplicationFactory());
41 setFactories(factories);
42 setVariables(builder.getVariables());
43 setMethods(builder.getExplicitMethods());
44 setProps(builder.getExplicitProperties());
45 setAttributeDelegates(builder.getAttributeDelegates());
46 setPreInstantiateDelegates(builder.getPreInstantiateDelegates());
47 setPostInstantiateDelegates(builder.getPostInstantiateDelegates());
48 setPostNodeCompletionDelegates(builder.getPostNodeCompletionDelegates());
49 setDisposalClosures(builder.getDisposalClosures());
50 setMethodMissingDelegate(builder.getMethodMissingDelegate());
51 setPropertyMissingDelegate(builder.getPropertyMissingDelegate());
52 }
53 }
|