List of usage examples for com.vaadin.ui HorizontalLayout setMargin
@Override public void setMargin(boolean enabled)
From source file:com.mechanicshop.components.MaintenanceLayout.java
private void buildLayout() { HorizontalLayout layoutTitle = new HorizontalLayout(); layoutTitle.setSizeUndefined();//from w w w .j a v a 2 s . c o m layoutTitle.setWidth("100%"); layoutTitle.setSpacing(false); layoutTitle.setMargin(false); titleLabel.addStyleName(ValoTheme.LABEL_H2); titleLabel.addStyleName(ValoTheme.LABEL_COLORED); titleLabel.addStyleName(ValoTheme.LABEL_NO_MARGIN); titleLabel.addStyleName(ValoTheme.LABEL_BOLD); titleLabel.setSizeUndefined(); layoutTitle.addComponent(titleLabel); layoutTitle.setComponentAlignment(titleLabel, Alignment.MIDDLE_CENTER); VerticalLayout layoutTable = new VerticalLayout(); layoutTable.setSizeFull(); layoutTable.setSpacing(true); HorizontalLayout layoutButtons = new HorizontalLayout(); layoutButtons.setMargin(false); layoutButtons.setSpacing(true); layoutButtons.setSizeUndefined(); Button passwordBtn = new Button("Edit Password"); passwordBtn.addClickListener(passwordListener); passwordBtn.setImmediate(true); passwordBtn.setIcon(FontAwesome.EDIT); passwordBtn.setStyleName(ValoTheme.BUTTON_TINY); Button media1Btn = new Button("Media 1 Default Text"); media1Btn.setStyleName(ValoTheme.BUTTON_TINY); media1Btn.setImmediate(true); media1Btn.setIcon(FontAwesome.EDIT); media1Btn.addClickListener(media1Listener); Button media2Btn = new Button("Media 2 Default Text"); media2Btn.setStyleName(ValoTheme.BUTTON_TINY); media2Btn.setImmediate(true); media2Btn.setIcon(FontAwesome.EDIT); media2Btn.addClickListener(media2Listener); layoutButtons.addComponents(passwordBtn, media1Btn, media2Btn); layoutButtons.setComponentAlignment(passwordBtn, Alignment.MIDDLE_LEFT); layoutButtons.setComponentAlignment(media1Btn, Alignment.MIDDLE_LEFT); layoutButtons.setComponentAlignment(media2Btn, Alignment.MIDDLE_LEFT); addComponent(layoutTitle); addComponent(layoutTable); layoutTable.addComponent(layoutButtons); layoutTable.addComponent(table); layoutTable.setComponentAlignment(table, Alignment.TOP_CENTER); layoutTable.setExpandRatio(table, 3); setComponentAlignment(layoutTitle, Alignment.TOP_CENTER); setComponentAlignment(layoutTable, Alignment.TOP_CENTER); setExpandRatio(layoutTable, 3); setSpacing(true); setMargin(true); }
From source file:com.mechanicshop.components.TableLayout.java
private void buildLayout() { HorizontalLayout layoutTitle = new HorizontalLayout(); layoutTitle.setSizeUndefined();/* w w w.j av a2 s . co m*/ layoutTitle.setWidth("100%"); layoutTitle.setSpacing(false); layoutTitle.setMargin(false); titleLabel.addStyleName(ValoTheme.LABEL_H2); titleLabel.addStyleName(ValoTheme.LABEL_COLORED); titleLabel.addStyleName(ValoTheme.LABEL_NO_MARGIN); titleLabel.addStyleName(ValoTheme.LABEL_BOLD); titleLabel.setSizeUndefined(); layoutTitle.addComponent(titleLabel); layoutTitle.setComponentAlignment(titleLabel, Alignment.MIDDLE_CENTER); VerticalLayout layoutTable = new VerticalLayout(); layoutTable.addComponent(table); layoutTable.setComponentAlignment(table, Alignment.TOP_CENTER); layoutTable.setSizeFull(); layoutTable.setSpacing(true); HorizontalLayout layoutButtons = new HorizontalLayout(); layoutButtons.setMargin(false); layoutButtons.setSpacing(true); layoutButtons.setSizeUndefined(); layoutButtons.setWidth("100%"); Button addBtn = new Button("Add new Car"); addBtn.addClickListener(addBtnListener); addBtn.setImmediate(true); addBtn.setStyleName(ValoTheme.BUTTON_TINY); addBtn.addStyleName(ValoTheme.BUTTON_FRIENDLY); Button deleteBtn = new Button("Delete Selected"); deleteBtn.setStyleName(ValoTheme.BUTTON_TINY); deleteBtn.addStyleName(ValoTheme.BUTTON_DANGER); deleteBtn.setImmediate(true); deleteBtn.addClickListener(removeListener); btnSendSMS.setStyleName(ValoTheme.BUTTON_TINY); btnSendSMS.addStyleName(ValoTheme.BUTTON_FRIENDLY); btnSendSMS.setImmediate(true); btnSendSMS.addClickListener(sendSMSBtnListener); searchTextField.setImmediate(true); searchTextField.addStyleName(ValoTheme.TEXTFIELD_TINY); searchTextField.addTextChangeListener(filterChangeListener); Label lbSearch = new Label("Search"); lbSearch.addStyleName(ValoTheme.LABEL_TINY); lbSearch.setSizeUndefined(); layoutButtons.addComponents(lbSearch, searchTextField, addBtn, deleteBtn, btnSendSMS); layoutButtons.setComponentAlignment(lbSearch, Alignment.MIDDLE_LEFT); layoutButtons.setComponentAlignment(searchTextField, Alignment.BOTTOM_LEFT); layoutButtons.setComponentAlignment(addBtn, Alignment.BOTTOM_RIGHT); layoutButtons.setComponentAlignment(deleteBtn, Alignment.BOTTOM_RIGHT); layoutButtons.setComponentAlignment(btnSendSMS, Alignment.BOTTOM_RIGHT); layoutButtons.setExpandRatio(addBtn, 3); addComponent(layoutTitle); addComponent(layoutTable); layoutTable.addComponent(layoutButtons); layoutTable.setExpandRatio(table, 3); setComponentAlignment(layoutTitle, Alignment.TOP_CENTER); setComponentAlignment(layoutTable, Alignment.TOP_CENTER); setExpandRatio(layoutTable, 3); setSpacing(true); setMargin(true); }
From source file:com.mechanicshop.components.TableLayout.java
public void createCustomMessage() { final TextArea textArea = new TextArea(); textArea.setImmediate(true);/* w w w.j a v a 2 s.c o m*/ textArea.setColumns(30); textArea.setRows(10); textArea.addStyleName(ValoTheme.TEXTAREA_SMALL); textArea.setRequired(true); final Window subWindow = new Window(); subWindow.setModal(true); subWindow.setHeight("350px"); subWindow.setWidth("500px"); subWindow.setCaption("Insert Message"); subWindow.setStyleName(ValoTheme.WINDOW_TOP_TOOLBAR); subWindow.setClosable(false); subWindow.setResizable(false); HorizontalLayout layoutButtons = new HorizontalLayout(); layoutButtons.setMargin(false); Button sendBtn = new Button("Send"); sendBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { textArea.validate(); String message = textArea.getValue(); smsSenderService.sendMessageMassive(message); subWindow.close(); Notification.show("Message Sent"); } catch (Exception e) { } } }); sendBtn.setImmediate(true); sendBtn.setStyleName(ValoTheme.BUTTON_TINY); sendBtn.addStyleName(ValoTheme.BUTTON_FRIENDLY); Button cancelBtn = new Button("Cancel"); cancelBtn.setStyleName(ValoTheme.BUTTON_TINY); cancelBtn.addStyleName(ValoTheme.BUTTON_DANGER); cancelBtn.setImmediate(true); cancelBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { subWindow.close(); } }); layoutButtons.setSizeUndefined(); layoutButtons.setSpacing(true); layoutButtons.addComponents(cancelBtn, sendBtn); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); layout.addComponent(textArea); layout.addComponent(layoutButtons); layout.setComponentAlignment(textArea, Alignment.MIDDLE_CENTER); layout.setComponentAlignment(layoutButtons, Alignment.MIDDLE_RIGHT); layout.setExpandRatio(textArea, 3); layout.setSizeFull(); subWindow.setContent(layout); subWindow.center(); getUI().addWindow(subWindow); }
From source file:com.mycollab.module.crm.view.opportunity.ContactRoleEditViewImpl.java
License:Open Source License
@Override public void display(SimpleOpportunity opportunity) { this.opportunity = opportunity; this.removeAllComponents(); this.setMargin(new MarginInfo(false, true, true, true)); this.addStyleName("oppcontact-role-edit"); AddViewLayout2 previewLayout = new AddViewLayout2( UserUIContext.getMessage(ContactI18nEnum.OPT_ADD_EDIT_CONTACT_ROLES), CrmAssetsManager.getAsset(CrmTypeConstants.CONTACT)); this.addComponent(previewLayout); ComponentContainer actionControls = createButtonControls(); if (actionControls != null) { previewLayout.addControlButtons(actionControls); }/*from w w w . j ava 2 s . com*/ contactRoleList = new ContactOpportunityList(); previewLayout.addBody(contactRoleList); MButton addMoreContactRolesBtn = new MButton( UserUIContext.getMessage(ContactI18nEnum.ACTION_ADD_CONTACT_ROLES), clickEvent -> { SimpleContactOpportunityRel contactRole = new SimpleContactOpportunityRel(); ContactRoleRowComp row = new ContactRoleRowComp(contactRole); contactRoleList.addRow(row); }).withStyleName(WebThemes.BUTTON_ACTION); HorizontalLayout buttonControls = new HorizontalLayout(); buttonControls.addComponent(addMoreContactRolesBtn); buttonControls.setMargin(new MarginInfo(true, true, true, true)); previewLayout.addBody(buttonControls); }
From source file:com.mycompany.filmupo.Graficos.java
/** * Metodo de inicializacion de la clase// w ww .ja v a2 s.c o m * * @param vaadinRequest VaadinRequest */ @Override protected void init(VaadinRequest vaadinRequest) { try { HorizontalLayout v2h2 = new HorizontalLayout(); v2h2.setMargin(true); final VerticalLayout v2h1 = new VerticalLayout(); v2h1.setMargin(true); final VerticalSplitPanel v2 = new VerticalSplitPanel(); v2.addComponent(v2h2); v2.addComponent(v2h1); v2.setSplitPosition(22, Unit.PERCENTAGE); v2.setLocked(true); VerticalLayout v1 = new VerticalLayout(); v1.setMargin(true); HorizontalSplitPanel layout = new HorizontalSplitPanel(); layout.addComponent(v1); layout.addComponent(v2); layout.setSplitPosition(28, Unit.PERCENTAGE); setContent(layout); //Creamos los 3 links de navegacion de la aplicacion y loa aadimos al layout declarado al principio del codigo Link pri = new Link("Principal", new ExternalResource("/Principal")); Link est = new Link("Graficos", new ExternalResource("/Graficos")); Link adm = new Link("Administracin", new ExternalResource("/Admin")); v2h2.addComponent(pri); v2h2.addComponent(new Label(" / ")); v2h2.addComponent(est); v2h2.addComponent(new Label(" / ")); v2h2.addComponent(adm); final DAO dao = new DAO(); dao.abrirConexion(); final List<Pelicula> listaPeliculas = dao.consultarPeliculas(); final List<Director> listaDirectores = dao.consultarDirectores(); final List<Actor> listaActores = dao.consultarActores(); //Creamos un unico arbol que contiene el acceso a las 4 graficas que hemos creado: // - Peliculas segun su duracion // - Peliculas segun su genero // - Numero de peliculas segun actor // - Numero de peliculas segun director Tree tree = new Tree(""); String a = "Estadisticas"; tree.addItem(a); String aa = "Peliculas segn su duracin"; tree.addItem(aa); tree.setParent(aa, a); tree.setChildrenAllowed(aa, false); String ab = "Peliculas segn su gnero"; tree.addItem(ab); tree.setParent(ab, a); tree.setChildrenAllowed(ab, false); String ac = "Numero de peliculas segn actor"; tree.addItem(ac); tree.setParent(ac, a); tree.setChildrenAllowed(ac, false); String ad = "Numero de peliculas segn director"; tree.addItem(ad); tree.setParent(ad, a); tree.setChildrenAllowed(ad, false); tree.setSelectable(true); tree.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { v2h1.removeAllComponents(); //Grafica de las peliculas segun su duracion if (event.getProperty().getValue().toString().contains("duracin")) { Chart chart = new Chart(ChartType.PIE); Configuration conf = chart.getConfiguration(); conf.setTitle("Peliculas"); conf.setSubTitle("Segn su duracin en minutos"); PlotOptionsPie options = new PlotOptionsPie(); options.setInnerSize(0); options.setSize("75%"); options.setCenter("50%", "50%"); conf.setPlotOptions(options); DataSeries series = new DataSeries(); for (Pelicula p : listaPeliculas) { series.add(new DataSeriesItem(p.getTitulo(), p.getDuracion())); } conf.addSeries(series); v2h1.addComponent(chart); //Grafica de las peliculas segun su genero } else if (event.getProperty().getValue().toString().contains("gnero")) { Chart chart = new Chart(ChartType.COLUMN); chart.setWidth("400px"); chart.setHeight("300px"); Configuration conf = chart.getConfiguration(); conf.setTitle("Peliculas"); conf.setSubTitle("Agrupadas segn su gnero"); PlotOptionsLine plotOptions = new PlotOptionsLine(); plotOptions.setMarker(new Marker(false)); conf.setPlotOptions(plotOptions); ListSeries series = new ListSeries("Numero de peliculas"); int i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0; try { dao.abrirConexion(); i1 = dao.numGeneros("Accin"); i2 = dao.numGeneros("Ciencia Ficcin"); i3 = dao.numGeneros("Drama"); i4 = dao.numGeneros("Romance"); i5 = dao.numGeneros("Novela de Suspense"); } catch (IllegalAccessException ex) { Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex); } catch (InstantiationException ex) { Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex); } series.addData(i1); series.addData(i2); series.addData(i3); series.addData(i4); series.addData(i5); conf.addSeries(series); XAxis xaxis = new XAxis(); xaxis.setTitle("Gnero"); xaxis.setCategories("Accin", "Ciencia Ficcin", "Drama", "Romance", "Novela de suspense"); conf.addxAxis(xaxis); YAxis yayis = new YAxis(); yayis.setTitle("Nmero de peliculas"); conf.addyAxis(yayis); v2h1.addComponent(chart); //Grafica de las peliculas segun actor } else if (event.getProperty().getValue().toString().contains("actor")) { Chart chart = new Chart(ChartType.PIE); Configuration conf = chart.getConfiguration(); conf.setTitle("Actores"); conf.setSubTitle("Nmero de peliculas que tienen"); PlotOptionsPie options = new PlotOptionsPie(); options.setInnerSize(0); options.setSize("75%"); options.setCenter("50%", "50%"); conf.setPlotOptions(options); DataSeries series = new DataSeries(); for (Actor a : listaActores) { int i = 0; try { dao.abrirConexion(); i = dao.numPeliculasA(a.getIdActor()); } catch (InstantiationException ex) { Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex); } series.add(new DataSeriesItem(a.getNombreCompleto(), i)); } conf.addSeries(series); v2h1.addComponent(chart); //Grafica del numero de peliculas segun director } else if (event.getProperty().getValue().toString().contains("director")) { Chart chart = new Chart(ChartType.PIE); Configuration conf = chart.getConfiguration(); conf.setTitle("Directores"); conf.setSubTitle("Nmero de peliculas que tienen"); PlotOptionsPie options = new PlotOptionsPie(); options.setInnerSize(0); options.setSize("75%"); options.setCenter("50%", "50%"); conf.setPlotOptions(options); DataSeries series = new DataSeries(); for (Director d : listaDirectores) { int i = 0; try { dao.abrirConexion(); i = dao.numPeliculasD(d.getIdDirector()); } catch (InstantiationException ex) { Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex); } series.add(new DataSeriesItem(d.getNombreCompleto(), i)); } conf.addSeries(series); v2h1.addComponent(chart); } } }); v1.addComponent(tree); dao.cerrarConexion(); } catch (SQLException ex) { Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex); } catch (InstantiationException ex) { Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.tagging.components.SearchEngineMetaDescription.java
License:Open Source License
private Component createSEOProgressBar() { ProgressBar seoProgressBar = new ProgressBar(); seoProgressBar.setWidth("250px"); seoProgressBar.setValue(0.5f);/*from w w w.j ava 2 s. c o m*/ HorizontalLayout layout = new HorizontalLayout(); layout.addComponent(new Label("SEO Rating:")); layout.addComponent(seoProgressBar); layout.setSpacing(true); layout.setMargin(new MarginInfo(false, false, true, false)); NativeButton addUpdateButton = new NativeButton("", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { // do nothing } }); addUpdateButton.addStyleName("update-button"); addUpdateButton.setHeight("28px"); addUpdateButton.setCaption("Update"); addUpdateButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { updateMetaDescriptionPreview(textArea.getValue()); } }); layout.addComponent(addUpdateButton); return layout; }
From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.umbrellacontent.UmbrellaContentViewImpl.java
License:Open Source License
private Component createSEOProgressBar() { ProgressBar seoProgressBar = new ProgressBar(); seoProgressBar.setWidth("300px"); seoProgressBar.setValue(0.5f);//from w w w . jav a 2 s . c o m HorizontalLayout layout = new HorizontalLayout(); layout.addComponent(new Label("SEO Rating:")); layout.addComponent(seoProgressBar); layout.setSpacing(true); layout.setMargin(new MarginInfo(false, false, true, false)); return layout; }
From source file:com.oodrive.nuage.webui.component.VvrOperationComponent.java
License:Apache License
@Override public final AbstractComponent createComponent(final VvrModel model, final ModelCreator handler) { final HorizontalLayout operationLayout = new HorizontalLayout(); operationLayout.setMargin(true); operationLayout.setSpacing(true);// w w w .j a va2 s . c o m operationLayout.setWidth("100%"); // Start and description buttons // START/STOP final Button startStop = new Button(); startStop.setWidth(BUTTON_WIDTH); startStop.addStyleName(Runo.BUTTON_BIG); final Resource iconStartStop; final String description; if (!model.isVvrStarted()) { iconStartStop = WebUiResources.getStartIcon(); description = "Start"; } else { iconStartStop = WebUiResources.getStopIcon(); description = "Stop"; } startStop.setIcon(iconStartStop); startStop.setDescription(description); operationLayout.addComponent(startStop); operationLayout.setExpandRatio(startStop, 1f); operationLayout.setComponentAlignment(startStop, Alignment.MIDDLE_LEFT); final UUID vvrUuid = model.getItemUuid(); startStop.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { final boolean started = model.isVvrStarted(); // Start/Stop are done in background if (!started) { WaitingComponent.executeBackground(model, new Background() { @Override public void processing() { model.startVvr(); } @Override public void postProcessing() { startStop.setIcon(WebUiResources.getStopIcon()); startStop.setDescription("Stop"); Notification.show("VVR started ", vvrUuid.toString(), Notification.Type.TRAY_NOTIFICATION); } }); } else { WaitingComponent.executeBackground(model, new Background() { @Override public void processing() { model.stopVvr(); } @Override public void postProcessing() { startStop.setIcon(WebUiResources.getStartIcon()); startStop.setDescription("Start"); Notification.show("VVR stopped ", vvrUuid.toString(), Notification.Type.TRAY_NOTIFICATION); } }); } } }); // ATTRIBUTES final Button attributes = new Button(); attributes.addStyleName(Runo.BUTTON_BIG); attributes.setWidth(BUTTON_WIDTH); operationLayout.addComponent(attributes); operationLayout.setExpandRatio(attributes, 1f); operationLayout.setComponentAlignment(attributes, Alignment.MIDDLE_LEFT); attributes.setIcon(WebUiResources.getSettingsIcon()); attributes.setDescription("Settings"); attributes.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { final VvrAttributesWindow attributesWindow = new VvrAttributesWindow(vvrUuid); attributesWindow.add(model); } catch (final Exception e) { LOGGER.error("Can not get VVR attributes: ", e); final ErrorWindow err = new ErrorWindow("Can not display VVR Attributes: " + e.getMessage()); err.add(model); } } }); // DELETE final Button delete = new Button(); delete.addStyleName(Runo.BUTTON_BIG); delete.setWidth(BUTTON_WIDTH); delete.setIcon(WebUiResources.getTrashIcon()); delete.setDescription("Delete"); operationLayout.addComponent(delete); operationLayout.setExpandRatio(delete, 12f); operationLayout.setComponentAlignment(delete, Alignment.MIDDLE_RIGHT); delete.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { final VvrDeleteWindow deleteWindow = new VvrDeleteWindow(vvrUuid); deleteWindow.add(vvrManagerModel); } catch (final Exception e) { LOGGER.error("Can not delete VVR: ", e); final ErrorWindow err = new ErrorWindow("Can not delete VVR: " + e.getMessage()); err.add(model); } } }); return operationLayout; }
From source file:com.openhris.employee.EmployeeSummaryUI.java
public EmployeeSummaryUI(int branchId) { this.branchId = branchId; setSizeFull();/*w w w. ja va2s . c om*/ setSpacing(true); setMargin(new MarginInfo(true, true, false, false)); HorizontalLayout h = new HorizontalLayout(); h.setWidth("100%"); h.setMargin(true); h.setSpacing(true); final ComboBox employeeStatus = new ComboBox("Status: "); employeeStatus.setWidth("150px"); employeeStatus.setNullSelectionAllowed(false); employeeStatus.addItem("employed"); employeeStatus.addItem("resigned"); h.addComponent(employeeStatus); Button generateBtn = new Button("GENERATE EMPLOYEE SUMMARY"); generateBtn.setWidth("250px"); generateBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (employeeStatus.getValue() == null) { getWindow().showNotification("Employee Status!", Window.Notification.TYPE_WARNING_MESSAGE); return; } tradeId = cs.getTradeIdByBranchId(getBranchId()); corporateId = cs.getCorporateIdByTradeId(tradeId); summary.setContainerDataSource( new EmployeeSummaryDataContainer(corporateId, employeeStatus.getValue().toString())); } }); h.addComponent(generateBtn); h.setComponentAlignment(generateBtn, Alignment.BOTTOM_LEFT); Button exportTableToExcel = new Button("EXPORT TO EXCEL"); exportTableToExcel.setWidth("250px"); exportTableToExcel.addListener(new Button.ClickListener() { private static final long serialVersionUID = -73954695086117200L; private ExcelExport excelExport; @Override public void buttonClick(Button.ClickEvent event) { excelExport = new ExcelExport(summary, "EMPLOYEE SUMMARY"); excelExport.excludeCollapsedColumns(); excelExport.setReportTitle(cs.getCorporateById(corporateId).toUpperCase() + " Employee Summary"); excelExport.setExportFileName(cs.getCorporateById(corporateId).replace(",", " ").toUpperCase() + "-Employee-Summary-" + ".xls"); excelExport.export(); } }); h.addComponent(exportTableToExcel); h.setComponentAlignment(exportTableToExcel, Alignment.BOTTOM_LEFT); h.setExpandRatio(exportTableToExcel, 3); addComponent(h); addComponent(summary); setExpandRatio(summary, 2); }
From source file:com.openhris.payroll.contributions.AFLUI.java
public AFLUI(int branchId) { this.branchId = branchId; setSizeFull();//from w w w . j av a 2 s . co m setSpacing(true); setMargin(new MarginInfo(true, true, false, false)); HorizontalLayout h = new HorizontalLayout(); h.setWidth("100%"); h.setMargin(true); h.setSpacing(true); final PopupDateField payrollDateField = new HRISPopupDateField("Payroll Month and Year"); payrollDateField.setWidth("200px"); h.addComponent(payrollDateField); Button generateBtn = new Button("GENERATE AFL"); generateBtn.setWidth("200px"); generateBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { tradeId = cs.getTradeIdByBranchId(getBranchId()); corporateId = cs.getCorporateIdByTradeId(tradeId); afl.setContainerDataSource(new AFLContainer(corporateId, util.parsingDate(util.convertDateFormat(payrollDateField.getValue().toString())))); } }); h.addComponent(generateBtn); h.setComponentAlignment(generateBtn, Alignment.BOTTOM_LEFT); Button exportTableToExcel = new Button("EXPORT TO EXCEL"); exportTableToExcel.setWidth("200px"); exportTableToExcel.addListener(new Button.ClickListener() { private static final long serialVersionUID = -73954695086117200L; private ExcelExport excelExport; @Override public void buttonClick(Button.ClickEvent event) { excelExport = new ExcelExport(afl, "AFL Remitance"); excelExport.excludeCollapsedColumns(); excelExport.setReportTitle(cs.getCorporateById(corporateId).toUpperCase() + " AFL Remitances"); excelExport.setExportFileName( cs.getCorporateById(corporateId).replace(",", " ").toUpperCase() + "-AFL-Remitance-" + util.convertDateFormat(payrollDateField.getValue().toString()) + ".xls"); excelExport.export(); } }); h.addComponent(exportTableToExcel); h.setComponentAlignment(exportTableToExcel, Alignment.BOTTOM_LEFT); h.setExpandRatio(exportTableToExcel, 2); addComponent(h); addComponent(afl); setExpandRatio(afl, 2); }