/** グループボタンを削除して再作成 */ private void recreateGroupButtons() { for (Button button : this.groupButtons) { button.setMenu(null); button.dispose(); } this.groupButtons.clear(); SelectionListener listener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Button button = (Button) e.getSource(); if (button.getSelection()) { ShipFilterComposite.this.groupButtonSelected(button, button.getData()); } } }; for (ShipGroupBean group : ShipGroupConfig.get().getGroup()) { Button button = new Button(this.groupCompo, SWT.RADIO); button.setText(group.getName()); button.setData(group); button.addSelectionListener(listener); button.setMenu(this.switchMenu); if (this.shipTable.getFilter().group == group) { button.setSelection(true); } this.groupButtons.add(button); } this.groupCompo.layout(); }
/** * フィルタデータをパネルに反映 グループや艦種などが作られている必要がある * * @param filter */ public void applyFilter(ShipFilterDto filter) { // 選択状態を初期化 this.groupAllButton.setSelection(false); for (Button button : this.groupButtons) { button.setSelection(false); } for (Button button : this.typeButtons.values()) { button.setSelection(true); } this.lockedNo.setSelection(false); this.lockedOnly.setSelection(false); this.lockedAny.setSelection(false); // 名前 if (!StringUtils.isEmpty(filter.nametext)) { this.nametext.setText(filter.nametext); } // 名前.正規表現を使用する this.regexp.setSelection(filter.regexp); // 艦種設定 boolean allselected = true; if (filter.enabledType != null) { for (int i = 0; i < filter.enabledType.length; ++i) { if (this.typeButtons.containsKey(i)) { if (filter.enabledType[i] == false) { allselected = false; } this.typeButtons.get(i).setSelection(filter.enabledType[i]); } } } this.selectall.setSelection(allselected); // グループ Button selectedGroupButton = this.groupAllButton; if (filter.group != null) { int idx = ShipGroupConfig.get().getGroup().indexOf(filter.group); if (idx != -1) { selectedGroupButton = this.groupButtons.get(idx); } } this.selectedGroup = filter.group; selectedGroupButton.setSelection(true); // 鍵付き? if (filter.locked == false) { this.lockedNo.setSelection(true); } else if (filter.notlocked == false) { this.lockedOnly.setSelection(true); } else { this.lockedAny.setSelection(true); } // 艦隊に所属 if (filter.onfleet == false) { this.fleetNo.setSelection(true); } else if (filter.notonfleet == false) { this.fleetOnly.setSelection(true); } else { this.fleetAny.setSelection(true); } // 遠征中を除外 this.ignoreOnMission.setSelection(!filter.mission); // お風呂に入りたい this.needBath.setSelection(!filter.notneedbath); // タブ選択 this.setGroupMode(filter.groupMode); }