List of usage examples for com.vaadin.ui Button setDisableOnClick
public void setDisableOnClick(boolean disableOnClick)
From source file:annis.gui.docbrowser.DocBrowserTable.java
License:Apache License
private Panel generateVisualizerLinks(String docName) { Panel p = new Panel(); VerticalLayout l = new VerticalLayout(); p.addStyleName(ChameleonTheme.PANEL_BORDERLESS); if (docVisualizerConfig != null) { Visualizer[] visualizers = docVisualizerConfig.getVisualizers(); if (visualizers != null) { for (Visualizer visualizer : visualizers) { Button openVis = new Button(visualizer.getDisplayName()); openVis.setDescription("open visualizer with the full text of " + docName); openVis.addClickListener(new OpenVisualizerWindow(docName, visualizer, openVis)); openVis.setStyleName(BaseTheme.BUTTON_LINK); openVis.setDisableOnClick(true); l.addComponent(openVis); }/*from ww w .j a v a 2 s .c om*/ } } p.setContent(l); return p; }
From source file:com.anphat.list.controller.MapStaffCustomerController.java
/** * Khoi tao cac bang// w w w .j a v a 2s. co m */ private void initTables() { tblUtils = new TableUtils(); //Khoi tao bang khach hang panelTableCustomer = mapStaffCustomerDialog.getPanelTblCustomer(); tblCustomer = panelTableCustomer.getMainTable(); tblUtils.generateColumn(tblCustomer); containerCustomer = new BeanItemContainer(CustomerDTO.class); CommonFunctionTableFilter.initTable(panelTableCustomer, HEADER_CUSTOMER, containerCustomer, CAPTION_CUSTOMER, 5, "customer"); //Khoi tao bang khach hang panelTableMapStaffCustomer = mapStaffCustomerDialog.getPanelTblCustomerStatus(); tblStaffMapCustomer = panelTableMapStaffCustomer.getMainTable(); tblUtils.generateColumn(tblStaffMapCustomer); containerMapStaffCustomer = new BeanItemContainer(StaffDTO.class); containerMapStaffCustomer.addAll(lstStaffs); //Them nut chi tiet tblStaffMapCustomer.addGeneratedColumn("detail", new CustomTable.ColumnGenerator() { @Override public Object generateCell(CustomTable source, Object itemId, Object columnId) { final StaffDTO staff = (StaffDTO) itemId; if (DataUtil.isListNullOrEmpty(staff.getLstCustomers())) { return ""; } else { Button btnDetail = new Button(BundleUtils.getString("statistic.list.detail")); btnDetail.setDisableOnClick(true); btnDetail.addStyleName(Runo.BUTTON_LINK); btnDetail.addStyleName("v-link-button-left"); btnDetail.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { CustomerDialog customerDialog = new CustomerDialog(mapServices, mapCustServiceStatus); customerDialog.setData2Table(staff.getLstCustomers()); UI.getCurrent().addWindow(customerDialog); event.getButton().setEnabled(true); } }); return btnDetail; } } }); //Them nut so luong tblStaffMapCustomer.addGeneratedColumn("quanlity", new CustomTable.ColumnGenerator() { @Override public Object generateCell(CustomTable source, Object itemId, Object columnId) { StaffDTO staff = (StaffDTO) itemId; if (DataUtil.isListNullOrEmpty(staff.getLstCustomers())) { return 0; } else { return staff.getLstCustomers().size(); } } }); CommonFunctionTableFilter.initTable(panelTableMapStaffCustomer, HEADER_MAP_STAFF_CUSTOMER, containerMapStaffCustomer, CAPTION_MAP_STAFF_CUSTOMER, 5, "customerStatusForm"); }
From source file:com.anphat.list.controller.MapStaffCustomerViewController.java
/** * Khoi tao cac bang/*from ww w . j av a 2s .c om*/ */ private void initTables() { tblUtils = new TableUtils(); //Khoi tao bang khach hang panelTableCustomer = mapStaffCustomerView.getPanelTblCustomer(); tblCustomer = panelTableCustomer.getMainTable(); tblUtils.generateColumn(tblCustomer); containerCustomer = new BeanItemContainer(CustomerDTO.class); CommonFunctionTableFilter.initTable(panelTableCustomer, HEADER_CUSTOMER, containerCustomer, CAPTION_CUSTOMER, 5, "customer"); CommonUtils.convertFieldTable(tblCustomer, "taxAuthority", mapTaxAuthority); // name#1,startTime#2,endTime#2,taxAuthority#1 tblCustomer.setColumnExpandRatio("taxCode", 1); tblCustomer.setColumnExpandRatio("name", 2); tblCustomer.setColumnExpandRatio("startTime", 1); tblCustomer.setColumnExpandRatio("endTime", 1); tblCustomer.setColumnExpandRatio("taxAuthority", 1); //Khoi tao bang khach hang panelTableMapStaffCustomer = mapStaffCustomerView.getPanelTblCustomerStatus(); tblStaffMapCustomer = panelTableMapStaffCustomer.getMainTable(); tblUtils.generateColumn(tblStaffMapCustomer); containerMapStaffCustomer = new BeanItemContainer(StaffDTO.class); containerMapStaffCustomer.addAll(lstStaffs); //Them nut chi tiet tblStaffMapCustomer.addGeneratedColumn("detail", new CustomTable.ColumnGenerator() { @Override public Object generateCell(CustomTable source, Object itemId, Object columnId) { try { final StaffDTO staff = (StaffDTO) itemId; if (DataUtil.isStringNullOrEmpty(staff.getQuanlity()) || "0".equals(staff.getQuanlity())) { return null; } else { Button btnDetail = new Button(BundleUtils.getString("statistic.list.detail")); btnDetail.setDisableOnClick(true); btnDetail.addStyleName(Runo.BUTTON_LINK); btnDetail.addStyleName("v-link-button-left"); btnDetail.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { CustomerDialog customerDialog = new CustomerDialog(mapServices, mapCustServiceStatus); customerDialog.setData2Table(staff.getLstCustomers()); UI.getCurrent().addWindow(customerDialog); event.getButton().setEnabled(true); } }); return btnDetail; } } catch (NullValueInNestedPathException nvnpe) { return null; } } }); //Them nut huy bo tblStaffMapCustomer.addGeneratedColumn("cancel", new CustomTable.ColumnGenerator() { @Override public Object generateCell(final CustomTable source, Object itemId, Object columnId) { try { final StaffDTO staff = (StaffDTO) itemId; if (DataUtil.isStringNullOrEmpty(staff.getQuanlity()) || "0".equals(staff.getQuanlity())) { return null; } else { Button btnDetail = new Button(BundleUtils.getString("statistic.list.cancel")); btnDetail.setDisableOnClick(true); btnDetail.addStyleName(Runo.BUTTON_LINK); btnDetail.addStyleName("v-link-button-left"); btnDetail.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { doReset(staff); } }); return btnDetail; } } catch (NullValueInNestedPathException nvnpe) { return null; } } }); CommonFunctionTableFilter.initTable(panelTableMapStaffCustomer, HEADER_MAP_STAFF_CUSTOMER, containerMapStaffCustomer, CAPTION_MAP_STAFF_CUSTOMER, 5, "customerStatusForm"); }
From source file:com.peergreen.webconsole.scope.system.internal.bundle.BundleView.java
License:Open Source License
@PostConstruct public void createView() { setMargin(true);/* ww w . jav a2 s . c o m*/ setSpacing(true); /* Page.Styles styles = Page.getCurrent().getStyles(); styles.add(".no-padding {padding: 0em 0em 0em 0em !important; }"); */ HorizontalLayout header = new HorizontalLayout(); // header.setWidth("100%"); header.setSpacing(true); header.setMargin(true); Label title = new Label("OSGi Bundles"); title.addStyleName("h1"); // title.setSizeUndefined(); header.addComponent(title); header.setComponentAlignment(title, Alignment.MIDDLE_LEFT); final TextField filter = new TextField(); filter.addTextChangeListener(new FieldEvents.TextChangeListener() { @Override public void textChange(final FieldEvents.TextChangeEvent event) { data.removeAllContainerFilters(); String trimmed = event.getText().trim(); Container.Filter or = new Or(new SimpleStringFilter(BUNDLE_ID_COLUMN, trimmed, true, false), new SimpleStringFilter(BUNDLE_NAME_COLUMN, trimmed, true, false), new SimpleStringFilter(BUNDLE_SYMBOLICNAME_COLUMN, trimmed, true, false), new SimpleStringFilter(VERSION_COLUMN, trimmed, true, false), new SimpleStringFilter(PRETTY_STATE_COLUMN, trimmed, true, false)); data.addContainerFilter(or); } }); filter.setInputPrompt("Filter"); filter.addShortcutListener(new ShortcutListener("Clear", ShortcutAction.KeyCode.ESCAPE, null) { @Override public void handleAction(Object sender, Object target) { filter.setValue(""); data.removeAllContainerFilters(); } }); header.addComponent(filter); header.setExpandRatio(filter, 1); header.setComponentAlignment(filter, Alignment.MIDDLE_LEFT); // Store the header in the vertical layout (this) addComponent(header); addComponent(tabSheet); table = new Table(); table.setContainerDataSource(data); table.setSizeFull(); table.setSortContainerPropertyId(BUNDLE_ID_COLUMN); table.setSortAscending(true); table.setImmediate(true); table.setColumnHeader(BUNDLE_ID_COLUMN, "Bundle ID"); table.setColumnHeader(PRETTY_NAME_COLUMN, "Bundle Name"); table.setColumnHeader(VERSION_COLUMN, "Version"); table.setColumnHeader(PRETTY_STATE_COLUMN, "State"); table.setColumnHeader("actions", "Actions"); table.setColumnWidth(BUNDLE_ID_COLUMN, 100); table.setColumnAlignment(BUNDLE_ID_COLUMN, Table.Align.CENTER); table.setColumnAlignment(PRETTY_STATE_COLUMN, Table.Align.CENTER); table.setColumnAlignment(VERSION_COLUMN, Table.Align.CENTER); table.addGeneratedColumn("actions", new Table.ColumnGenerator() { @Override public Object generateCell(final Table source, final Object itemId, final Object columnId) { HorizontalLayout layout = new HorizontalLayout(); BeanItem<BundleItem> item = (BeanItem<BundleItem>) source.getContainerDataSource().getItem(itemId); Bundle bundle = item.getBean().getBundle(); if (BundleHelper.isState(bundle, Bundle.INSTALLED) || BundleHelper.isState(bundle, Bundle.RESOLVED)) { Button changeState = new Button(); changeState.addClickListener(new StartBundleClickListener(bundle, notifierService)); //changeState.addStyleName("no-padding"); changeState.setCaption("Start"); //changeState.setIcon(new ClassResource(BundleViewer.class, "/images/go-next.png")); if (!securityManager.isUserInRole("admin")) { changeState.setDisableOnClick(true); } layout.addComponent(changeState); } if (BundleHelper.isState(bundle, Bundle.ACTIVE)) { Button changeState = new Button(); changeState.addClickListener(new StopBundleClickListener(bundle, notifierService)); //changeState.addStyleName("no-padding"); changeState.setCaption("Stop"); if (!securityManager.isUserInRole("admin")) { changeState.setDisableOnClick(true); } //changeState.setIcon(new ClassResource(BundleViewer.class, "/images/media-record.png")); layout.addComponent(changeState); } // Update Button update = new Button(); update.addClickListener(new UpdateBundleClickListener(bundle, notifierService)); //update.addStyleName("no-padding"); update.setCaption("Update"); if (!securityManager.isUserInRole("admin")) { update.setDisableOnClick(true); } //update.setIcon(new ClassResource(BundleViewer.class, "/images/view-refresh.png")); layout.addComponent(update); // Trash Button trash = new Button(); trash.addClickListener(new UninstallBundleClickListener(bundle, notifierService)); //trash.addStyleName("no-padding"); trash.setCaption("Delete"); if (!securityManager.isUserInRole("admin")) { trash.setDisableOnClick(true); } //trash.setIcon(new ClassResource(BundleViewer.class, "/images/user-trash-full.png")); layout.addComponent(trash); return layout; } }); table.setVisibleColumns(BUNDLE_ID_COLUMN, PRETTY_NAME_COLUMN, VERSION_COLUMN, PRETTY_STATE_COLUMN, "actions"); table.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(final ItemClickEvent event) { if (event.isDoubleClick()) { BeanItem<BundleItem> item = (BeanItem<BundleItem>) table.getContainerDataSource() .getItem(event.getItemId()); Bundle bundle = item.getBean().getBundle(); showBundle(bundle); } } }); createBundleTracker(); tabSheet.setSizeFull(); selectedTabListener = new SelectedTabListener(uiContext.getViewNavigator()); selectedTabListener.addLocation(table, uiContext.getViewNavigator().getLocation(this.getClass().getName())); tabSheet.addSelectedTabChangeListener(selectedTabListener); tabSheet.addTab(table, "Bundles", new ClassResource(BundleView.class, "/images/22x22/user-home.png")); setExpandRatio(tabSheet, 1.5f); tabSheet.setCloseHandler(new TabSheet.CloseHandler() { @Override public void onTabClose(TabSheet tabsheet, Component tabContent) { for (Map.Entry<Long, Component> tab : openTabs.entrySet()) { if (tabContent.equals(tab.getValue())) { openTabs.remove(tab.getKey()); } } tabsheet.removeComponent(tabContent); selectedTabListener.removeLocation(tabContent); } }); }
From source file:com.yoncabt.ebr.ui.ReportWindow.java
@Override protected void init(VaadinRequest request) { reportType.setNullSelectionAllowed(false); reportLocale.setNullSelectionAllowed(false); reportLocale.addItem("tr_TR"); reportLocale.setItemCaption("tr_TR", "Trke"); reportLocale.addItem("en_US"); reportLocale.setItemCaption("en_US", "English"); email.setEnabled(mailSender.isConfigured()); grid = new Grid(); try {//from ww w .j a v a 2 s. c o m MenuBar mb = createMenuBar(); HorizontalLayout hl = new HorizontalLayout(mb); setContent(hl); } catch (IOException | JRException ex) { Notification.show("Hata", Notification.Type.ERROR_MESSAGE); Logger.getLogger(ReportWindow.class.getName()).log(Level.SEVERE, null, ex); } Button btnReload = new Button(FontAwesome.LIST_ALT); btnReload.setDisableOnClick(true); btnReload.addClickListener((Button.ClickEvent event) -> { try { fillTheGrid(); } catch (Exception ex) { Notification.show("Hata", Notification.Type.ERROR_MESSAGE); Logger.getLogger(ReportWindow.class.getName()).log(Level.SEVERE, null, ex); } event.getButton().setEnabled(true); }); gridLayout = new HorizontalLayout(); if (report instanceof SQLReport) { createGrid(); } btnExport = YoncaGridXLSExporter.createDownloadButton(grid, "raporlar.xls"); gridLayout.setSizeFull(); window.setSizeUndefined(); window.setContent(new VerticalLayout(formLayout, new HorizontalLayout(btnExport, btnReload), gridLayout)); window.setClosable(false); addWindow(window); window.center(); getPage().addUriFragmentChangedListener((Page.UriFragmentChangedEvent event) -> { String frag = event.getUriFragment(); ReportWindow.this.uriFragmentChanged(frag); }); if (StringUtils.isNotEmpty(getPage().getUriFragment())) { ReportWindow.this.uriFragmentChanged(getPage().getUriFragment()); } }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultFormView.java
License:Apache License
@SuppressWarnings("serial") private void createFooterAndPopulateActions(FormActions actions) { CssLayout buttons = new CssLayout(); buttons.setStyleName("actions"); boolean allHidden = true; for (final FormAction action : actions) { final Button button = new Button(action.getTitle()); button.setDisableOnClick(true); button.addClickListener(new ClickListener() { @Override//from w w w . jav a2 s. c o m public void buttonClick(ClickEvent event) { try { presenter.executeAction(action); } finally { button.setEnabled(true); } } }); if (action.getActionHandler() instanceof SearchFormAction) { if (searchAction == null) { searchAction = action; // button.setClickShortcut(KeyCode.ENTER); } } if (action.isHidden()) { button.setVisible(false); } else { allHidden = false; } buttons.addComponent(button); } if (!allHidden) { rootLayout.addComponent(buttons); } }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultTableView.java
License:Apache License
private void addCustomButtonsListeners() { if (!actionButtons.isEmpty()) { for (final Button button : actionButtons.values()) { button.setDisableOnClick(true); final TableAction action = buttonToTableActionMap.get(button); button.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 42L; @Override//from w w w . j a v a2 s . c o m public void buttonClick(ClickEvent event) { try { presenter.callClosure(action); if (action.isExportAction()) { switch (action.getExportType()) { case XLS: exportExcelSheet(action.generateExportFilename()); break; case CSV: exportCSVSheet(action.generateExportFilename()); break; default: throw new IllegalArgumentException("Unknown export type '" + action.getExportType() + "' set on action with title '" + action.getTitle() + "' and id '" + action.getId() + "'"); } } } finally { button.setEnabled(true); } } }); } } }
From source file:info.magnolia.dam.app.assets.field.PermissionedUploadAndEditActionRenderer.java
License:Open Source License
@Override public View start(ActionDefinition definition, ActionListener listener) { View view = super.start(definition, listener); final Button button = (Button) view.asVaadinComponent(); // don't disable on click or action may be wrongly unavailable button.setDisableOnClick(false); chooseDialogEventBus.addHandler(SelectionChangedEvent.class, new SelectionChangedEvent.Handler() { @Override/*from w ww .j av a2 s .c om*/ public void onSelectionChanged(SelectionChangedEvent event) { // inner availability logic here mirrors the one in UpladAssetActionRenderer (in use for DirectUploadAction) Set<Object> itemIds = event.getItemIds(); if (itemIds == null || itemIds.isEmpty()) { return; } try { JcrNodeItemId nodeItemId = (JcrNodeItemId) itemIds.iterator().next(); javax.jcr.Node node = MgnlContext.getJCRSession(nodeItemId.getWorkspace()) .getNodeByIdentifier(nodeItemId.getUuid()); boolean uploadAllowed = itemIds.size() == 1; if (uploadAllowed) { uploadAllowed &= NodeUtil.isNodeType(node, NodeTypes.Folder.NAME) || NodeUtil.getAncestors(node).isEmpty(); } if (uploadAllowed) uploadAllowed &= node.getSession().hasPermission(node.getPath(), "add_node"); button.setEnabled(uploadAllowed); } catch (RepositoryException e) { button.setEnabled(false); } } }); return view; }
From source file:org.apache.ace.webui.vaadin.component.BaseObjectPanel.java
License:Apache License
/** * Creates a remove-item button for the given repository object. * //from w ww. ja v a 2 s .co m * @param object * the object to create a remove-item button, cannot be <code>null</code>; * @param displayName * the display name for the description of the button, cannot be <code>null</code>. * @return a remove-item button, never <code>null</code>. */ protected final Button createRemoveItemButton(RepositoryObject object, String displayName) { Button result = new Button(); result.setIcon(createIconResource("trash")); result.setData(object.getDefinition()); result.setStyleName("small tiny"); result.setDescription("Delete " + displayName); result.setDisableOnClick(true); result.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { try { handleItemRemoveObject(event.getButton().getData()); } catch (Exception e) { // ACE-246: notify user when the removal failed! getWindow().showNotification("Failed to remove item!", "<br/>Reason: " + e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } }); return result; }
From source file:org.apache.ace.webui.vaadin.component.BaseObjectPanel.java
License:Apache License
/** * Creates a remove-link button for the given repository object. * // w ww .j a v a2 s . com * @param object * the object to create a remove-link button, cannot be <code>null</code>; * @param displayName * the display name for the description of the button, cannot be <code>null</code>. * @return a remove-link button, never <code>null</code>. */ protected final Button createRemoveLinkButton(RepositoryObject object, String displayName) { Button result = new Button(); result.setIcon(createIconResource("unlink")); result.setStyleName("small tiny"); result.setData(object.getDefinition()); result.setDescription("Unlink " + displayName); // Only enable this button when actually selected... result.setEnabled(false); result.setDisableOnClick(true); result.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { handleItemRemoveLink(event.getButton().getData()); } }); return result; }