List of usage examples for com.vaadin.ui Button addStyleName
@Override public void addStyleName(String style)
From source file:com.rex.components.valo.Tables.java
License:Apache License
static void configure(Table table, Grid grid, boolean footer, boolean sized, boolean expandRatios, boolean stripes, boolean verticalLines, boolean horizontalLines, boolean borderless, boolean headers, boolean compact, boolean small, boolean rowIndex, boolean rowCaption, boolean rowIcon, boolean componentsInRows) { table.setSelectable(true);//from ww w . j a va 2 s. c o m table.setMultiSelect(true); grid.setSelectionMode(SelectionMode.MULTI); table.setSortEnabled(true); for (Column c : grid.getColumns()) { if (!c.getPropertyId().equals("icon")) { c.setSortable(true); } c.setHidable(true); } table.setColumnCollapsingAllowed(true); table.setColumnReorderingAllowed(true); grid.setColumnReorderingAllowed(true); table.setPageLength(6); grid.setHeightByRows(6); table.addActionHandler(ReportEngineUI.getActionHandler()); table.setDragMode(TableDragMode.MULTIROW); table.setDropHandler(new DropHandler() { @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } @Override public void drop(DragAndDropEvent event) { Notification.show(event.getTransferable().toString()); } }); table.setColumnAlignment(ReportEngineUI.DESCRIPTION_PROPERTY, Align.RIGHT); table.setColumnAlignment(ReportEngineUI.INDEX_PROPERTY, Align.CENTER); table.removeContainerProperty("textfield"); table.removeGeneratedColumn("textfield"); table.removeContainerProperty("button"); table.removeGeneratedColumn("button"); table.removeContainerProperty("label"); table.removeGeneratedColumn("label"); table.removeContainerProperty("checkbox"); table.removeGeneratedColumn("checkbox"); table.removeContainerProperty("datefield"); table.removeGeneratedColumn("datefield"); table.removeContainerProperty("combobox"); table.removeGeneratedColumn("combobox"); table.removeContainerProperty("optiongroup"); table.removeGeneratedColumn("optiongroup"); table.removeContainerProperty("slider"); table.removeGeneratedColumn("slider"); table.removeContainerProperty("progress"); table.removeGeneratedColumn("progress"); if (componentsInRows) { table.addContainerProperty("textfield", TextField.class, null); table.addGeneratedColumn("textfield", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { TextField tf = new TextField(); tf.setInputPrompt("Type here"); // tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("datefield", TextField.class, null); table.addGeneratedColumn("datefield", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { DateField tf = new DateField(); tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("combobox", TextField.class, null); table.addGeneratedColumn("combobox", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { ComboBox tf = new ComboBox(); tf.setInputPrompt("Select"); tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("button", Button.class, null); table.addGeneratedColumn("button", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Button b = new Button("Button"); b.addStyleName("small"); return b; } }); table.addContainerProperty("label", TextField.class, null); table.addGeneratedColumn("label", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Label label = new Label("Label component"); label.setSizeUndefined(); label.addStyleName("bold"); return label; } }); table.addContainerProperty("checkbox", TextField.class, null); table.addGeneratedColumn("checkbox", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { CheckBox cb = new CheckBox(null, true); return cb; } }); table.addContainerProperty("optiongroup", TextField.class, null); table.addGeneratedColumn("optiongroup", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { OptionGroup op = new OptionGroup(); op.addItem("Male"); op.addItem("Female"); op.addStyleName("horizontal"); return op; } }); table.addContainerProperty("slider", TextField.class, null); table.addGeneratedColumn("slider", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Slider s = new Slider(); s.setValue(30.0); return s; } }); table.addContainerProperty("progress", TextField.class, null); table.addGeneratedColumn("progress", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { ProgressBar bar = new ProgressBar(); bar.setValue(0.7f); return bar; } }); } table.setFooterVisible(footer); if (footer) { table.setColumnFooter(ReportEngineUI.CAPTION_PROPERTY, "caption"); table.setColumnFooter(ReportEngineUI.DESCRIPTION_PROPERTY, "description"); table.setColumnFooter(ReportEngineUI.ICON_PROPERTY, "icon"); table.setColumnFooter(ReportEngineUI.INDEX_PROPERTY, "index"); } if (sized) { table.setWidth("400px"); grid.setWidth("400px"); table.setHeight("300px"); grid.setHeight("300px"); } else { table.setSizeUndefined(); grid.setSizeUndefined(); } if (componentsInRows) { table.setWidth("100%"); } else { table.setWidth(null); } if (expandRatios) { if (!sized) { table.setWidth("100%"); } } table.setColumnExpandRatio(ReportEngineUI.CAPTION_PROPERTY, expandRatios ? 1.0f : 0); table.setColumnExpandRatio(ReportEngineUI.DESCRIPTION_PROPERTY, expandRatios ? 1.0f : 0); if (!stripes) { table.addStyleName("no-stripes"); } else { table.removeStyleName("no-stripes"); } if (!verticalLines) { table.addStyleName("no-vertical-lines"); } else { table.removeStyleName("no-vertical-lines"); } if (!horizontalLines) { table.addStyleName("no-horizontal-lines"); } else { table.removeStyleName("no-horizontal-lines"); } if (borderless) { table.addStyleName("borderless"); } else { table.removeStyleName("borderless"); } if (!headers) { table.addStyleName("no-header"); } else { table.removeStyleName("no-header"); } if (compact) { table.addStyleName("compact"); } else { table.removeStyleName("compact"); } if (small) { table.addStyleName("small"); } else { table.removeStyleName("small"); } if (!rowIndex && !rowCaption && rowIcon) { table.setRowHeaderMode(RowHeaderMode.HIDDEN); } if (rowIndex) { table.setRowHeaderMode(RowHeaderMode.INDEX); } if (rowCaption) { table.setRowHeaderMode(RowHeaderMode.PROPERTY); table.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY); } else { table.setItemCaptionPropertyId(null); } if (rowIcon) { table.setRowHeaderMode(RowHeaderMode.ICON_ONLY); table.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY); } else { table.setItemIconPropertyId(null); } }
From source file:com.saax.gestorweb.presenter.ChatPresenter.java
/** * Cria botao para download de anexo//from ww w .j a v a 2s. c o m */ private Button buildButtonDownload(Anexo anexos) { Button exportar = new Button(); exportar.setIcon(FontAwesome.DOWNLOAD); exportar.addStyleName(ValoTheme.BUTTON_ICON_ONLY); exportar.addStyleName(ValoTheme.BUTTON_BORDERLESS); FileDownloader fd = new FileDownloader(new FileResource(new File(anexos.getCaminhoCompleto()))); fd.extend(exportar); return exportar; }
From source file:com.save.client.promodeals.PDDataGridProperties.java
Window delete(Object itemId, int promoId) { Window sub = new Window("REMOVE PROMO DEAL"); sub.setWidth("250px"); sub.setModal(true);//from www . ja va2 s . c om sub.center(); VerticalLayout v = new VerticalLayout(); v.setWidth("100%"); v.setMargin(true); Button delBtn = new Button("CONFIRM DELETE?", (Button.ClickEvent event) -> { boolean result = pds.delete(promoId, "removed"); getContainerDataSource().removeItem(itemId); sub.close(); }); delBtn.setWidth("100%"); delBtn.addStyleName(ValoTheme.BUTTON_PRIMARY); delBtn.addStyleName(ValoTheme.BUTTON_SMALL); v.addComponent(delBtn); sub.setContent(v); return sub; }
From source file:com.save.client.promodeals.PromoUI.java
public PromoUI(int clientId) { this.clientId = clientId; setWidth("90%"); setHeight("100%"); setMargin(new MarginInfo(true, true, false, false)); PDDataGridProperties dataGrid = new PDDataGridProperties(getClientId()); Button button = new Button("Acknowledgement Form"); button.setWidthUndefined();//from w w w .j av a 2s . c o m button.setIcon(FontAwesome.OPENID); button.addStyleName(ValoTheme.BUTTON_LINK); button.addStyleName(ValoTheme.BUTTON_SMALL); button.addClickListener((Button.ClickEvent event) -> { Window sub = new com.save.clients.AcknowledgementPromoForm(getClientId()); if (sub.getParent() == null) { UI.getCurrent().addWindow(sub); } sub.addCloseListener((Window.CloseEvent e) -> { dataGrid.getContainerDataSource().removeAllItems(); dataGrid.setContainerDataSource(new PDDataContainer(getClientId())); }); }); addComponent(button); setComponentAlignment(button, Alignment.TOP_RIGHT); addComponent(dataGrid); setExpandRatio(dataGrid, 2); }
From source file:com.save.employee.maintenance.MRDataGridProperties.java
Window deletConfirmationWindow(int mrId, Object itemId) { Window sub = new Window(); sub.setCaption("CONFIRM DELETE"); sub.setWidth("250px"); sub.setModal(true);//w w w. jav a2 s . c om VerticalLayout v = new VerticalLayout(); v.setWidth("100%"); v.setMargin(true); Button deleteBtn = new Button("DELETE?"); deleteBtn.setWidth("100%"); deleteBtn.addStyleName(ValoTheme.BUTTON_PRIMARY); deleteBtn.addClickListener((Button.ClickEvent event) -> { boolean result = mrs.removeMaintenanceReimbursement(mrId); if (result) { getContainerDataSource().removeItem(itemId); sub.close(); } }); v.addComponent(deleteBtn); sub.setContent(v); sub.getContent().setHeightUndefined(); return sub; }
From source file:com.save.employee.maintenance.MRUI.java
public MRUI(int employeeId) { this.employeeId = employeeId; setWidth("90%"); setHeight("100%"); setMargin(new MarginInfo(true, false, false, false)); MRDataGridProperties dataGrid = new MRDataGridProperties(getEmployeeId()); Button mrForm = new Button("Maintenance/Reimbursement Form"); mrForm.setWidthUndefined();/*from ww w . ja v a2 s . c o m*/ mrForm.setIcon(FontAwesome.OPENID); mrForm.addStyleName(ValoTheme.BUTTON_SMALL); mrForm.addStyleName(ValoTheme.BUTTON_LINK); mrForm.addClickListener((Button.ClickEvent event) -> { Window sub = new MRFormWindow(getEmployeeId()); if (sub.getParent() == null) { UI.getCurrent().addWindow(sub); } sub.addCloseListener((Window.CloseEvent e) -> { dataGrid.getContainerDataSource().removeAllItems(); dataGrid.setContainerDataSource(new MRDataContainer(getEmployeeId())); }); }); addComponent(mrForm); setComponentAlignment(mrForm, Alignment.MIDDLE_RIGHT); addComponent(dataGrid); setExpandRatio(dataGrid, 2); }
From source file:com.save.employee.request.RequestFormWindow.java
Component buildRequestForm() { GridLayout glayout = new GridLayout(4, 7); glayout.setSizeFull();//w ww . j a va2s.c om glayout.setSpacing(true); glayout.setMargin(true); controlNo = new TextField("Control No."); controlNo.setWidth("100%"); controlNo.addStyleName(ValoTheme.TEXTFIELD_SMALL); glayout.addComponent(controlNo, 0, 0); dateOfActivity = new DateField("Date of Activity: "); dateOfActivity.setWidth("100%"); dateOfActivity.addStyleName(ValoTheme.DATEFIELD_SMALL); glayout.addComponent(dateOfActivity, 1, 0); area = CommonComboBox.areas(); area.setWidth("100%"); glayout.addComponent(area, 2, 0); activity = new TextField("Activity: "); activity.setWidth("100%"); activity.addStyleName(ValoTheme.TEXTFIELD_SMALL); glayout.addComponent(activity, 0, 1, 1, 1); venue = new TextField("Venue: "); venue.setWidth("100%"); venue.addStyleName(ValoTheme.TEXTFIELD_SMALL); glayout.addComponent(venue, 0, 2, 1, 2); requirements = new TextArea("Requirements: "); requirements.setWidth("100%"); requirements.addStyleName(ValoTheme.TEXTAREA_SMALL); glayout.addComponent(requirements, 2, 1, 3, 2); Label lodging = new Label("Lodging: "); lodging.setWidthUndefined(); glayout.addComponent(lodging, 0, 3); glayout.setComponentAlignment(lodging, Alignment.MIDDLE_CENTER); lodgingPax = new TextField("Pax: "); lodgingPax.setWidth("100%"); lodgingPax.setValue("0"); lodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); lodgingPax.addStyleName("align-right"); glayout.addComponent(lodgingPax, 1, 3); lodgingAmount = new TextField("Amount: "); lodgingAmount.setWidth("100%"); lodgingAmount.setValue("0.00"); lodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); lodgingAmount.addStyleName("align-right"); lodgingAmount.setEnabled(false); lodgingAmount.setImmediate(true); glayout.addComponent(lodgingAmount, 3, 3); lodgingBudget = new TextField("Budget: "); lodgingBudget.setWidth("100%"); lodgingBudget.setValue("0.00"); lodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); lodgingBudget.addStyleName("align-right"); lodgingBudget.addValueChangeListener((ValueChangeEvent event) -> { if (!CommonUtilities.checkInputIfInteger(lodgingPax.getValue().trim())) { Notification.show("Enter a numeric value for Pax", Notification.Type.ERROR_MESSAGE); return; } if (!CommonUtilities.checkInputIfDouble(lodgingBudget.getValue().trim())) { Notification.show("Enter a numeric value for Budget", Notification.Type.ERROR_MESSAGE); return; } lodgingAmount.setValue(String.valueOf(CommonUtilities.convertStringToInt(lodgingPax.getValue().trim()) * CommonUtilities.convertStringToDouble(lodgingBudget.getValue().trim()))); }); lodgingBudget.setImmediate(true); glayout.addComponent(lodgingBudget, 2, 3); Label meals = new Label("Meals: "); meals.setWidthUndefined(); glayout.addComponent(meals, 0, 4); glayout.setComponentAlignment(meals, Alignment.MIDDLE_CENTER); mealsPax = new TextField("Pax: "); mealsPax.setWidth("100%"); mealsPax.setValue("0"); mealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); mealsPax.addStyleName("align-right"); glayout.addComponent(mealsPax, 1, 4); mealsAmount = new TextField("Amount: "); mealsAmount.setWidth("100%"); mealsAmount.setValue("0.00"); mealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); mealsAmount.addStyleName("align-right"); mealsAmount.setEnabled(false); mealsAmount.setImmediate(liquidated); glayout.addComponent(mealsAmount, 3, 4); mealsBudget = new TextField("Budget: "); mealsBudget.setWidth("100%"); mealsBudget.setValue("0.00"); mealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); mealsBudget.addStyleName("align-right"); mealsBudget.addValueChangeListener((ValueChangeEvent event) -> { if (!CommonUtilities.checkInputIfInteger(mealsPax.getValue().trim())) { Notification.show("Enter a numeric value for Pax", Notification.Type.ERROR_MESSAGE); return; } if (!CommonUtilities.checkInputIfDouble(mealsBudget.getValue().trim())) { Notification.show("Enter a numeric value for Budget", Notification.Type.ERROR_MESSAGE); return; } mealsAmount.setValue(String.valueOf(CommonUtilities.convertStringToInt(mealsPax.getValue().trim()) * CommonUtilities.convertStringToDouble(mealsBudget.getValue().trim()))); }); mealsAmount.setImmediate(true); glayout.addComponent(mealsBudget, 2, 4); others = new TextArea("Others: "); others.setWidth("100%"); others.setRows(3); others.addStyleName(ValoTheme.TEXTAREA_SMALL); glayout.addComponent(others, 0, 5, 2, 6); othersAmount = new TextField("Amount: "); othersAmount.setWidth("100%"); othersAmount.setValue("0.00"); othersAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); othersAmount.addStyleName("align-right"); glayout.addComponent(othersAmount, 3, 5); glayout.setComponentAlignment(othersAmount, Alignment.TOP_CENTER); Button rlButton = new Button(); rlButton.setCaption("SAVE"); rlButton.setWidth("100%"); rlButton.addStyleName(ValoTheme.BUTTON_PRIMARY); rlButton.addStyleName(ValoTheme.BUTTON_SMALL); rlButton.addClickListener(buttonClickListener); glayout.addComponent(rlButton, 3, 6); glayout.setComponentAlignment(rlButton, Alignment.TOP_CENTER); if (getRequestId() != 0) { LiquidationForm lf = rls.getRLById(getRequestId()); controlNo.setValue(String.valueOf(lf.getControlNo())); dateOfActivity.setValue(lf.getDateOfActivity()); area.setValue(lf.getAreaId()); activity.setValue(lf.getActivity()); requirements.setValue(lf.getRequirements()); venue.setValue(lf.getVenue()); others.setValue(lf.getOthersRemarks()); othersAmount.setValue(String.valueOf(lf.getOthersAmount())); lodgingAmount.setValue(String.valueOf(lf.getLodgingAmount())); mealsAmount.setValue(String.valueOf(lf.getMealsAmount())); if (getLiquidated() == true) { setCaption("LIQUIDATE FROM"); rlButton.setCaption("LIQUIDATE"); controlNo.setReadOnly(liquidated); dateOfActivity.setReadOnly(liquidated); area.setReadOnly(liquidated); activity.setReadOnly(liquidated); requirements.setReadOnly(liquidated); venue.setReadOnly(liquidated); } else { rlButton.setCaption("EDIT"); lodgingPax.setValue(String.valueOf(lf.getLodgingPax())); lodgingBudget.setValue(String.valueOf(lf.getLodgingBudget())); mealsPax.setValue(String.valueOf(lf.getMealsPax())); mealsBudget.setValue(String.valueOf(lf.getMealsBudget())); rlButton.setEnabled(rls.getRLById(getRequestId()).getLiquidated() == 0); } // delete.setVisible(true); } return glayout; }
From source file:com.save.employee.request.RequestFormWindow.java
Window deleteRequestForm() { Window sub = new Window("DELETE REQUEST"); sub.setWidth("280px"); sub.setModal(true);/*from w w w. ja va2 s .c om*/ sub.center(); VerticalLayout v = new VerticalLayout(); v.setWidth("100%"); v.setMargin(true); Button delete = new Button(); delete.setCaption("CONFIRM DELETE REQUEST?"); delete.setWidth("100%"); delete.addStyleName(ValoTheme.BUTTON_PRIMARY); delete.addStyleName(ValoTheme.BUTTON_SMALL); delete.addClickListener((Button.ClickEvent event) -> { boolean result = rls.deleteRequestById(getRequestId()); if (result) { sub.close(); close(); } }); v.addComponent(delete); sub.setContent(v); sub.getContent().setHeightUndefined(); return sub; }
From source file:com.save.employee.request.RLDataGridProperties.java
Window deletConfirmationWindow(int rlId, Object itemId) { Window sub = new Window(); sub.setCaption("CONFIRM DELETE"); sub.setWidth("250px"); sub.setModal(true);// w w w . j a va 2 s.c om VerticalLayout v = new VerticalLayout(); v.setWidth("100%"); v.setMargin(true); Button deleteBtn = new Button("DELETE?"); deleteBtn.setWidth("100%"); deleteBtn.addStyleName(ValoTheme.BUTTON_PRIMARY); deleteBtn.addClickListener((Button.ClickEvent event) -> { boolean result = rls.deleteRequestById(rlId); if (result) { getContainerDataSource().removeItem(itemId); sub.close(); } }); v.addComponent(deleteBtn); sub.setContent(v); sub.getContent().setHeightUndefined(); return sub; }
From source file:com.save.employee.request.RLUI.java
public RLUI(int employeeId) { this.employeeId = employeeId; setWidth("90%"); setHeight("100%"); setMargin(new MarginInfo(true, false, false, false)); RLDataGridProperties dataGrid = new RLDataGridProperties(getEmployeeId()); Button rlForm = new Button("Request/Liquidation FORM"); rlForm.setIcon(FontAwesome.OPENID);//from w w w . j a v a2 s. co m rlForm.addStyleName(ValoTheme.BUTTON_SMALL); rlForm.addStyleName(ValoTheme.BUTTON_LINK); rlForm.addClickListener((Button.ClickEvent event) -> { Window sub = new RequestFormWindow(getEmployeeId(), 0, false, dataGrid); if (sub.getParent() == null) { UI.getCurrent().addWindow(sub); } sub.addCloseListener((Window.CloseEvent e) -> { dataGrid.getContainerDataSource().removeAllItems(); dataGrid.setContainerDataSource(new RLDataContainer(getEmployeeId())); }); }); addComponent(rlForm); setComponentAlignment(rlForm, Alignment.MIDDLE_RIGHT); addComponent(dataGrid); setExpandRatio(dataGrid, 2); }