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.eclipse.swt.widgets.Listener;
19  import org.seasar.uruma.binding.method.EventListenerDef;
20  import org.seasar.uruma.binding.method.GenericListener;
21  import org.seasar.uruma.binding.method.ListenerBinder;
22  import org.seasar.uruma.binding.method.MethodBinding;
23  import org.seasar.uruma.context.PartContext;
24  import org.seasar.uruma.context.WidgetHandle;
25  import org.seasar.uruma.rcp.binding.GenericHandler;
26  
27  /**
28   * {@link GenericHandler} のための {@link ListenerBinder} です。<br />
29   * 
30   * @author y-komori
31   */
32  public class GenericHandlerListenerBinder extends AbstractListenerBinder {
33  
34      /*
35       * @see org.seasar.uruma.binding.method.ListenerBinder#bindListener(org.seasar.uruma.context.WidgetHandle,
36       *      org.seasar.uruma.context.PartContext,
37       *      org.seasar.uruma.binding.method.MethodBinding,
38       *      org.seasar.uruma.binding.method.EventListenerDef)
39       */
40      public Class<?> bindListener(final WidgetHandle handle,
41              final PartContext context, final MethodBinding binding,
42              final EventListenerDef def) {
43          GenericHandler handler = handle.<GenericHandler> getCastWidget();
44          Listener listener = new GenericListener(context, binding);
45          handler.addListener(listener);
46          return GenericHandler.class;
47      }
48  
49      /*
50       * @see org.seasar.uruma.binding.method.ListenerBinder#getTargetCLass()
51       */
52      public Class<?> getTargetCLass() {
53          return GenericHandler.class;
54      }
55  }