| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 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 |
|
|
| 24 |
|
|
| 25 |
|
|
| 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 |
|
|
| 42 |
|
|
| 43 |
|
public SelectCoordinator() |
| 44 |
|
{ |
| 45 |
0 |
super(); |
| 46 |
0 |
} |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 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 |
|
|
| 62 |
|
|
| 63 |
|
public void commit() |
| 64 |
|
{ |
| 65 |
0 |
if( isActiveThread() ) { |
| 66 |
0 |
getActionControler().setSaveEnabled( false ); |
| 67 |
|
} |
| 68 |
0 |
} |
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 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 |
|
|
| 94 |
|
|
| 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 |
|
|
| 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 |
|
} |