View Javadoc

1   /*
2    * Copyright 2004-2008 the Seasar Foundation and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
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, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.uruma.binding.method.impl;
17  
18  import org.seasar.uruma.annotation.EventListenerType;
19  import org.seasar.uruma.binding.method.EventListenerDef;
20  import org.seasar.uruma.binding.method.ListenerBinder;
21  import org.seasar.uruma.binding.method.MethodBinding;
22  import org.seasar.uruma.binding.method.WindowCloseListener;
23  import org.seasar.uruma.context.PartContext;
24  import org.seasar.uruma.context.WidgetHandle;
25  import org.seasar.uruma.ui.UrumaApplicationWindow;
26  
27  /**
28   * {@link UrumaApplicationWindow} のための {@link ListenerBinder} です。<br />
29   * 
30   * @author y-komori
31   */
32  public class UrumaApplicationWindowListenerBinder implements ListenerBinder {
33      private static final EventListenerType[] SUPPORT_TYPES = new EventListenerType[] { EventListenerType.WINDOW_CLOSING };
34  
35      /*
36       * @see org.seasar.uruma.binding.method.ListenerBinder#bindListener(org.seasar.uruma.context.WidgetHandle,
37       *      org.seasar.uruma.context.PartContext,
38       *      org.seasar.uruma.binding.method.MethodBinding,
39       *      org.seasar.uruma.binding.method.EventListenerDef)
40       */
41      public Class<?> bindListener(final WidgetHandle handle,
42              final PartContext context, final MethodBinding binding,
43              final EventListenerDef def) {
44          UrumaApplicationWindow window = handle
45                  .<UrumaApplicationWindow> getCastWidget();
46          WindowCloseListener closeListener = new WindowCloseListener(context,
47                  binding);
48          window.addWindowCloseListener(closeListener);
49          return WindowCloseListener.class;
50      }
51  
52      /*
53       * @see org.seasar.uruma.binding.method.ListenerBinder#getTargetCLass()
54       */
55      public Class<?> getTargetCLass() {
56          return UrumaApplicationWindow.class;
57      }
58  
59      /*
60       * @see org.seasar.uruma.binding.method.ListenerBinder#getEventTypes()
61       */
62      public EventListenerType[] getEventTypes() {
63          return SUPPORT_TYPES;
64      }
65  }