| 246 | } |
| 247 | |
| 248 | private static class KitTreeViewModel implements TreeViewModel<Kit>, DataView<Kit>, |
| 249 | Filter<CharacterFacade, Kit>, ListListener<Kit> |
| 250 | { |
| 251 | |
| 252 | private static final DefaultListFacade<? extends TreeView<Kit>> TREE_VIEWS = |
| 253 | new DefaultListFacade<>(Arrays.asList(KitTreeView.values())); |
| 254 | private final List<DefaultDataViewColumn> columns; |
| 255 | private final CharacterFacade character; |
| 256 | private final boolean isAvailModel; |
| 257 | private final FilteredListFacade<CharacterFacade, Kit> kits; |
| 258 | |
| 259 | public KitTreeViewModel(CharacterFacade character, boolean isAvailModel) |
| 260 | { |
| 261 | this.character = character; |
| 262 | this.isAvailModel = isAvailModel; |
| 263 | if (isAvailModel) |
| 264 | { |
| 265 | kits = new FilteredListFacade<>(); |
| 266 | kits.setContext(character); |
| 267 | kits.setFilter(this); |
| 268 | ListFacade<Kit> kitList = new DefaultListFacade<>(character.getAvailableKits()); |
| 269 | kits.setDelegate(kitList); |
| 270 | character.getKits().addListListener(this); |
| 271 | columns = Arrays.asList(new DefaultDataViewColumn("in_descrip", String.class, false), //$NON-NLS-1$ |
| 272 | new DefaultDataViewColumn("in_source", String.class, false)); //$NON-NLS-1$ |
| 273 | } |
| 274 | else |
| 275 | { |
| 276 | kits = null; |
| 277 | columns = Arrays.asList(new DefaultDataViewColumn("in_descrip", String.class, false), //$NON-NLS-1$ |
| 278 | new DefaultDataViewColumn("in_source", String.class, false)); //$NON-NLS-1$ |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | @Override |
| 283 | public ListFacade<? extends TreeView<Kit>> getTreeViews() |
| 284 | { |
| 285 | return TREE_VIEWS; |
| 286 | } |
| 287 | |
| 288 | @Override |
| 289 | public int getDefaultTreeViewIndex() |
| 290 | { |
| 291 | return 0; |
| 292 | } |
| 293 | |
| 294 | @Override |
| 295 | public DataView<Kit> getDataView() |
| 296 | { |
| 297 | return this; |
| 298 | } |
| 299 | |
| 300 | @Override |
| 301 | public ListFacade<Kit> getDataModel() |
| 302 | { |
| 303 | if (isAvailModel) |
| 304 | { |
| 305 | return kits; |