Coverage report

  %line %branch
tsukuba_bunko.peko.scenario.select.SelectCoordinator
0% 
0% 

 1  
 /*
 2  
  * "Peko" Visual Novel System
 3  
  *
 4  
  * All Rights Reserved.
 5  
  * Copyright (c) 1999-2003 Tsukuba Bunko.
 6  
  *
 7  
  * $Id: SelectCoordinator.java,v 1.1 2005/07/11 12:49:19 ppoi Exp $
 8  
  */
 9  
 package tsukuba_bunko.peko.scenario.select;
 10  
 
 11  
 import	java.util.List;
 12  
 
 13  
 import	tsukuba_bunko.peko.Logger;
 14  
 
 15  
 import	tsukuba_bunko.peko.canvas.CanvasManager;
 16  
 
 17  
 import	tsukuba_bunko.peko.canvas.select.SelectItem;
 18  
 
 19  
 import	tsukuba_bunko.peko.scenario.Coordinator;
 20  
 
 21  
 
 22  
 /**
 23  
  * SelectCanvas に対する処理を取り持つコーディネータモジュールです。
 24  
  * @author	$Author: ppoi $
 25  
  * @version	$Revision: 1.1 $
 26  
  */
 27  
 public class SelectCoordinator	extends Coordinator	{
 28  
 
 29  
 	/**
 30  
 	 * 選択肢リスト
 31  
 	 */
 32  0
 	protected List	_selectItems = null;
 33  
 
 34  
 	/**
 35  
 	 * 現在アクティブなスレッド
 36  
 	 */
 37  0
 	protected Thread	_activeThread = null;
 38  
 
 39  
 
 40  
 	/**
 41  
 	 * <code>SelectCoordinator</code> のインスタンスを生成します。
 42  
 	 */
 43  
 	public SelectCoordinator()
 44  
 	{
 45  0
 		super();
 46  0
 	}
 47  
 
 48  
 
 49  
 	/**
 50  
 	 * SelectCanvas に対する操作を開始します。
 51  
 	 */
 52  
 	public void begin()
 53  
 	{
 54  0
 		if( isActiveThread() )	{
 55  0
 			getActionControler().setSaveEnabled( true );
 56  0
 			_selectItems = new java.util.ArrayList( 4 );
 57  
 		}
 58  0
 	}
 59  
 
 60  
 	/**
 61  
 	 * SelectCanvas に対する操作を終了し、キャンバスの状態を確定します。
 62  
 	 */
 63  
 	public void commit()
 64  
 	{
 65  0
 		if( isActiveThread() )	{
 66  0
 			getActionControler().setSaveEnabled( false );
 67  
 		}
 68  0
 	}
 69  
 
 70  
 	/**
 71  
 	 * 選択肢を追加します。
 72  
 	 * @param	id	選択肢 ID
 73  
 	 * @param	text	選択肢の文章
 74  
 	 */
 75  
 	public void addSelectItem( String id, String text )
 76  
 	{
 77  0
 		if( id == null )	{
 78  0
 			throw new IllegalArgumentException( "id is not specified." );
 79  
 		}
 80  0
 		else if( text == null)	{
 81  0
 			throw new IllegalArgumentException( "text is not specified." );
 82  
 		}
 83  
 
 84  0
 		if( isActiveThread() )	{
 85  0
 			SelectItem	item = new SelectItem();
 86  0
 			item.setID( id );
 87  0
 			item.setText( text );
 88  0
 			_selectItems.add( item );
 89  
 		}
 90  0
 	}
 91  
 
 92  
 	/**
 93  
 	 * ユーザーに対し選択肢を表示し、選択された ID を取得します。
 94  
 	 * @return	選択された選択肢の選択肢 ID
 95  
 	 */
 96  
 	public String select()
 97  
 	{
 98  0
 		if( isActiveThread() )	{
 99  0
 			if( (_selectItems == null) || _selectItems.isEmpty() )	{
 100  0
 				Logger.debug( "[scenario.select] no select items!" );
 101  0
 				return null;
 102  
 			}
 103  
 			else	{
 104  0
 				CanvasManager	canvasManager = getCanvasManager();
 105  0
 				String	id = canvasManager.showSelect( _selectItems );
 106  0
 				if( id == null )	{
 107  0
 					Logger.debug( "[scenario.select] canceled." );
 108  
 				}
 109  0
 				canvasManager.advancesNewPage();
 110  0
 				return id;
 111  
 			}
 112  
 		}
 113  
 		else	{
 114  0
 			return null;
 115  
 		}
 116  
 	}
 117  
 
 118  
 	/**
 119  
 	 * SelectCanvas に対する操作を終了します。
 120  
 	 */
 121  
 	public void end()
 122  
 	{
 123  0
 		if( isActiveThread() )	{
 124  0
 			_activeThread = null;
 125  0
 			if( _selectItems != null )	{
 126  0
 				_selectItems.clear();
 127  0
 				_selectItems = null;
 128  
 			}
 129  
 		}
 130  0
 	}
 131  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.