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 saveMyFavorite() { Item item = vfMyFavorite.getForm().getValues(); String createId = (String) item.getItemProperty("createIn").getValue(); String newForder = (String) item.getItemProperty("newFolder").getValue(); if (FieldUtil.isNotEmpty(createId) && FieldUtil.isNotEmpty(newForder)) { Dialog dialog = new Dialog( Dialog.MODE.VALIDATE, messageResource.getMessage( "501014", locale, termResource.getTerm("Create In"), termResource.getTerm("New Folder"))); return; } String category; if (createId != null) { category = createId; } else { category = newForder; } List<Item> selection = gridFilter.getGrid().getSelection(); Item i = selection.get(0); String candidateUuid = (String) i.getItemProperty("candidateUuid").getValue(); Candidate candidate = candidateService.get(candidateUuid); CandFavorite candFavorite = new CandFavorite(); candFavorite.setCandidate(candidate); candFavorite.setCategory(category); candFavorite.setManager(currentUser); try { candFavoriteService.save(candFavorite); } catch (DuplicateConflictException d) { LOGGER.debug("DuplicateConflictException: ", d); Dialog dialog = new Dialog(Dialog.MODE.VALIDATE, d.getLocalizedMessage(locale)); return; } catch (ConstraintConflictException c) { LOGGER.debug("ConstraintConflictException: ", c); Dialog dialog = new Dialog(Dialog.MODE.VALIDATE, ViolationUtils.getViolation(c.getViolations(), locale)); return; } catch (OperationFailureException o) { LOGGER.error("Exception: ", o); Messagebox.hint(messageResource.getMessage("200001")); return; } // success Messagebox.info(messageResource.getMessage("100025")); closeMyFavorite(); refresh(); }
private void build() { layout = new VerticalLayout(); layout.setSpacing(true); layout.addStyleName("padding-20"); layout.setSizeFull(); setCompositionRoot(layout); // 因為Menu Decision要放grid當作參數 , 所以必須先new gridFilter = new GridFilter(GridFilter.MODE.FILTER_IN_WINDOW); this.grid = gridFilter.getGrid(); layout.addComponent(buildButtons()); layout.addComponent(buildGrid()); buildWindows(); }