Coverage Report - org.seasar.uruma.binding.method.impl.StructuredViewerListenerBinder
 
Classes in this File Line Coverage Branch Coverage Complexity
StructuredViewerListenerBinder
64%
9/14
25%
1/4
0
 
 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.jface.viewers.StructuredViewer;
 19  
 import org.seasar.uruma.annotation.EventListenerType;
 20  
 import org.seasar.uruma.binding.method.EventListenerDef;
 21  
 import org.seasar.uruma.binding.method.GenericDoubleClickListener;
 22  
 import org.seasar.uruma.binding.method.GenericSelectionChangedListener;
 23  
 import org.seasar.uruma.binding.method.ListenerBinder;
 24  
 import org.seasar.uruma.binding.method.MethodBinding;
 25  
 import org.seasar.uruma.context.PartContext;
 26  
 import org.seasar.uruma.context.WidgetHandle;
 27  
 
 28  
 /**
 29  
  * {@link StructuredViewer} のための {@link ListenerBinder} です。<br />
 30  
  * 
 31  
  * @author y-komori
 32  
  */
 33  4
 public class StructuredViewerListenerBinder implements ListenerBinder {
 34  4
     private static final EventListenerType[] SUPPORT_TYPES = new EventListenerType[] {
 35  
             EventListenerType.SELECTION, EventListenerType.MOUSE_DOUBLE_CLICK };
 36  
 
 37  
     /*
 38  
      * @see org.seasar.uruma.binding.method.ListenerBinder#bindListener(org.seasar.uruma.context.WidgetHandle,
 39  
      *      org.seasar.uruma.context.PartContext,
 40  
      *      org.seasar.uruma.binding.method.MethodBinding,
 41  
      *      org.seasar.uruma.binding.method.EventListenerDef)
 42  
      */
 43  
     public Class<?> bindListener(final WidgetHandle handle,
 44  
             final PartContext context, final MethodBinding binding,
 45  
             final EventListenerDef def) {
 46  8
         StructuredViewer viewer = handle.<StructuredViewer> getCastWidget();
 47  8
         if (def.getType() == EventListenerType.SELECTION) {
 48  8
             GenericSelectionChangedListener listener = new GenericSelectionChangedListener(
 49  
                     context, binding);
 50  8
             viewer.addSelectionChangedListener(listener);
 51  8
             return GenericSelectionChangedListener.class;
 52  0
         } else if (def.getType() == EventListenerType.MOUSE_DOUBLE_CLICK) {
 53  0
             GenericDoubleClickListener listener = new GenericDoubleClickListener(
 54  
                     context, binding);
 55  0
             viewer.addDoubleClickListener(listener);
 56  0
             return GenericDoubleClickListener.class;
 57  
         }
 58  0
         return null;
 59  
     }
 60  
 
 61  
     /*
 62  
      * @see org.seasar.uruma.binding.method.ListenerBinder#getEventTypes()
 63  
      */
 64  
     public EventListenerType[] getEventTypes() {
 65  8
         return SUPPORT_TYPES;
 66  
     }
 67  
 
 68  
     /*
 69  
      * @see org.seasar.uruma.binding.method.ListenerBinder#getTargetCLass()
 70  
      */
 71  
     public Class<?> getTargetCLass() {
 72  428
         return StructuredViewer.class;
 73  
     }
 74  
 
 75  
 }