private void gridChange(Object itemId) { Collection<Object> ids = (Collection<Object>) gridFilter.getGrid().getValue(); Button btnCheck = (Button) commandbar.getButton(COMMAND.CHECK.getValue()); Button btnFavorite = (Button) commandbar.getButton(COMMAND.POP_MY_FAVORITE.getValue()); Button btnCompare = (Button) commandbar.getButton(COMMAND.COMPARE.getValue()); if (ids.size() != 0) { btnCompare.setEnabled(true); List<Item> selection = gridFilter.getGrid().getSelection(); // 選擇多筆時, 只有btnCompare有可能Enabeld if (selection.size() > 1) { menu.setMenuBarEnabled(false); btnCheck.setEnabled(false); btnFavorite.setEnabled(false); } else { menu.setMenuBarEnabled(true); btnCheck.setEnabled(true); btnFavorite.setEnabled(true); } // 沒選到任何資料時 } else { menu.setMenuBarEnabled(false); btnCheck.setEnabled(false); btnFavorite.setEnabled(false); btnCompare.setEnabled(false); } }
private void perform(String instruction) { if (instruction.equals(COMMAND.CHECK.getValue())) { check(instruction); } else if (instruction.equals(COMMAND.POP_MY_FAVORITE.getValue())) { popMyFavorite(instruction); } else if (instruction.equals(COMMAND.SAVE_MY_FAVORITE.getValue())) { saveMyFavorite(); } else if (instruction.equals(COMMAND.CLOSE_MY_FAVORITE.getValue())) { closeMyFavorite(); } else if (instruction.equals(COMMAND.COMPARE.getValue())) { compare(); } else if (instruction.equals(COMMAND.RESET.getValue())) { refresh(); } }