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 Component buildButtons() { HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); // Decision button menu = new ResumeReviewToDoListMenu(grid); menu.setMenuBarEnabled(false); menu.addCommandExecuteListener( new CommandEvent.ExecuteListener() { @Override public void execute(ExecuteEvent event) { perform(event.getInstruction()); } }); hl.addComponent(menu); // Review Profile commandbar = new Commandbar(); Button btnCheck = new Button(termResource.getTerm("Check Details")); btnCheck.setEnabled(false); btnCheck.setIcon(FontAwesome.EYE); Button btnMyFavorite = new Button(termResource.getTerm("To My Favorite")); btnMyFavorite.setEnabled(false); btnMyFavorite.setIcon(FontAwesome.STAR); Button btnCompare = new Button(termResource.getTerm("Add To Compare")); btnCompare.setIcon(FontAwesome.ADJUST); btnCompare.setEnabled(false); commandbar.addCommand(btnCheck, COMMAND.CHECK); commandbar.addCommand(btnMyFavorite, COMMAND.POP_MY_FAVORITE); commandbar.addCommand(btnCompare, COMMAND.COMPARE); commandbar.addCommandExecuteListener( new CommandEvent.ExecuteListener() { @Override public void execute(ExecuteEvent event) { perform(event.getInstruction()); } }); hl.addComponent(commandbar); return hl; }
private Component buildMyFavorite() { VerticalLayout layout = new VerticalLayout(); layout.setWidth("100%"); layout.setHeight(null); layout.setSpacing(true); vfMyFavorite = new ViewerForm("", false); vfMyFavorite.getFieldset().addStyleName("fieldset-3-5"); vfMyFavorite.getFieldset().addStyleName("fieldset-0"); vfMyFavorite.addComboBox(termResource.getTerm("Create In"), "createIn", false); vfMyFavorite.addTextField(termResource.getTerm("New Folder"), "newFolder", false); layout.addComponent(vfMyFavorite); HorizontalLayout hl = new HorizontalLayout(); hl.setWidth("100%"); hl.setHeight(null); Commandbar commandbar = new Commandbar(); commandbar.setSizeUndefined(); Button btnSave = new Button(termResource.getTerm("Save")); btnSave.setIcon(FontAwesome.SAVE); Button btnClose = new Button(termResource.getTerm("Close")); btnClose.setIcon(FontAwesome.TIMES); commandbar.addCommand(btnSave, COMMAND.SAVE_MY_FAVORITE); commandbar.addCommand(btnClose, COMMAND.CLOSE_MY_FAVORITE); commandbar.addCommandExecuteListener( new CommandEvent.ExecuteListener() { @Override public void execute(ExecuteEvent event) { perform(event.getInstruction()); } }); hl.addComponent(commandbar); hl.setComponentAlignment(commandbar, Alignment.MIDDLE_CENTER); layout.addComponent(hl); return layout; }