List of usage examples for com.vaadin.server ThemeResource ThemeResource
public ThemeResource(String resourceId)
From source file:edu.kit.dama.ui.simon.panel.SimonMainPanel.java
License:Apache License
/** * Return the theme resource (icon) for the provided status. * * @param pStatus The status of a probe. * * @return The resource for the provided status. */// ww w. ja v a 2 s .c o m private ThemeResource getResourceForStatus(AbstractProbe.PROBE_STATUS pStatus) { switch (pStatus) { case SUCCEEDED: return new ThemeResource("img/24x24/bullet_ball_glass_green.png"); case FAILED: return new ThemeResource("img/24x24/bullet_ball_glass_red.png"); case UNAVAILABLE: return new ThemeResource("img/24x24/bullet_ball_glass_grey.png"); case UPDATING: return new ThemeResource("img/24x24/refresh.png"); default: //unknown return new ThemeResource("img/24x24/help2.png"); } }
From source file:edu.kit.dama.ui.simon.panel.SimonMainPanel.java
License:Apache License
/** * Build the overview tab including the list of all categories and der * overall status./*from w ww . j a va 2 s . c o m*/ * * @param pCategories A list of all categories. * * @return The tab component. */ private Component buildOverviewTab(String[] pCategories) { AbsoluteLayout abLay = new AbsoluteLayout(); UIUtils7.GridLayoutBuilder layoutBuilder = new UIUtils7.GridLayoutBuilder(4, pCategories.length + 1); updateButton = new Button("Update Status"); updateButton.addClickListener(this); Embedded logo = new Embedded(null, new ThemeResource("img/simon.png")); abLay.addComponent(logo, "top:30px;left:30px;"); Label simonSaysLabel = new Label("", ContentMode.HTML); simonSaysLabel.setHeight("150px"); setSimonSaysContent(simonSaysLabel, "Everything is fine."); abLay.addComponent(simonSaysLabel, "top:30px;left:250px;"); int row = 0; for (String category : pCategories) { HorizontalLayout rowLayout = new HorizontalLayout(); Label name = new Label(category); name.setWidth("200px"); name.setHeight("24px"); List<AbstractProbe> probes = probesByCategory.get(category); Collections.sort(probes, new Comparator<AbstractProbe>() { @Override public int compare(AbstractProbe o1, AbstractProbe o2) { return o1.getCurrentStatus().compareTo(o2.getCurrentStatus()); } }); int failed = 0; int unknown = 0; int unavailable = 0; int charactersPerProbe = 100; if (probes.size() > 0) { charactersPerProbe = (int) Math.rint((700.0 / probes.size()) / 8.0); } for (AbstractProbe probe : probes) { Label probeLabel = new Label(StringUtils.abbreviate(probe.getName(), charactersPerProbe)); probeLabel.setHeight("24px"); switch (probe.getCurrentStatus()) { case UNKNOWN: probeLabel.setDescription(probe.getName() + ": UNKNOWN"); probeLabel.addStyleName("probe-unknown"); unknown++; break; case UPDATING: probeLabel.setDescription(probe.getName() + ": UPDATING"); probeLabel.addStyleName("probe-updating"); break; case UNAVAILABLE: probeLabel.setDescription(probe.getName() + ": UNAVAILABLE"); probeLabel.addStyleName("probe-unavailable"); unavailable++; break; case FAILED: probeLabel.setDescription(probe.getName() + ": FAILED"); probeLabel.addStyleName("probe-failed"); failed++; break; default: probeLabel.setDescription(probe.getName() + ": SUCCESS"); probeLabel.addStyleName("probe-success"); } probeLabel.addStyleName("probe"); rowLayout.addComponent(probeLabel); } if (failed != 0) { setSimonSaysContent(simonSaysLabel, "There are errors!"); } else { if (unknown != 0) { setSimonSaysContent(simonSaysLabel, "There are unknown states. Please select 'Update Status'."); } else { if (unavailable != 0) { setSimonSaysContent(simonSaysLabel, "Some probes are unavailable. Please check their configuration."); } } } rowLayout.setWidth("700px"); layoutBuilder.addComponent(name, Alignment.TOP_LEFT, 0, row, 1, 1).addComponent(rowLayout, Alignment.TOP_LEFT, 1, row, 3, 1); row++; } layoutBuilder.addComponent(updateButton, Alignment.BOTTOM_RIGHT, 3, row, 1, 1); GridLayout tabLayout = layoutBuilder.getLayout(); tabLayout.setSpacing(true); tabLayout.setMargin(true); Panel p = new Panel(); p.setContent(tabLayout); p.setWidth("1024px"); p.setHeight("400px"); abLay.addComponent(p, "top:160px;left:30px;"); abLay.setSizeFull(); return abLay; }
From source file:edu.vserver.exercises.videoMcq.QuestionWindow.java
License:Apache License
/** * Sets a Notification about the correctness of the given answer to the browser window. * /*w w w .ja v a2 s . com*/ * @param question latest answered question. */ private void informUser(Question question) { if (this.isInformative()) { Notification n; if (question.isCorrectAnswer()) { n = new Notification("CORRECT", Notification.Type.HUMANIZED_MESSAGE); n.setIcon(new ThemeResource(SPH_Theme.CORRECT_ICON_48PX)); n.setStyleName("correctAnswer"); } else { n = new Notification("INCORRECT", Notification.Type.HUMANIZED_MESSAGE); n.setIcon(new ThemeResource(SPH_Theme.INCORRECT_ICON_48PX)); n.setStyleName("incorrectAnswer"); } if (question.containsAnswerDescription()) { n.setDescription(question.getAnswerDescription()); n.setDelayMsec(Notification.DELAY_FOREVER); } else { n.setDelayMsec(500); } n.setPosition(com.vaadin.shared.Position.MIDDLE_CENTER); n.show(Page.getCurrent()); } }
From source file:es.mdef.clientmanager.ui.GestionClientesUI.java
License:Apache License
CssLayout buildMenu() { // Add items// ww w. j av a 2s .co m menuItems.put("common", "Common UI Elements"); menu.setSizeFull(); menu.addComponent(getMenuTitleComponent()); final MenuBar settings = new MenuBar(); settings.addStyleName("user-menu"); // TODO Actualizar nombre de usuario cuando se logee con exito final MenuBar.MenuItem userMenuItem = settings.addItem(getNombreUsuario(), new ThemeResource("icons/usuario.svg"), null); userMenuItem.addItem("Cambiar contrasea", new MenuBar.Command() { @Override public void menuSelected(MenuBar.MenuItem selectedItem) { ChangePasswordWindow changePasswordWindow = new ChangePasswordWindow(); changePasswordWindow.center(); addWindow(changePasswordWindow); } }); userMenuItem.addSeparator(); userMenuItem.addItem("Salir", new MenuBar.Command() { @Override public void menuSelected(MenuBar.MenuItem selectedItem) { SecurityContextHolder.clearContext(); //UI.getCurrent().close(); Navigator navigator = UI.getCurrent().getNavigator(); navigator.navigateTo(""); } }); menu.addComponent(settings); menuItemsLayout.setPrimaryStyleName("valo-menuitems"); menu.addComponent(menuItemsLayout); final Button clientesButton = new Button("Clientes", new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { navigator.navigateTo(CLIENT_LIST_VIEW); } }); clientesButton.setHtmlContentAllowed(true); clientesButton.setPrimaryStyleName("valo-menu-item"); clientesButton.setIcon(new ThemeResource("icons/clientes2.svg")); menuItemsLayout.addComponent(clientesButton); final Button budgetButton = new Button("Presupuesto", new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { navigator.navigateTo(BUDGETS_VIEW); } }); budgetButton.setHtmlContentAllowed(true); budgetButton.setPrimaryStyleName("valo-menu-item"); budgetButton.setIcon(new ThemeResource("icons/money.svg")); menuItemsLayout.addComponent(budgetButton); final Button subscripcionButton = new Button("Suscripciones", new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { navigator.navigateTo(PROVIDERS_VIEW); } }); subscripcionButton.setHtmlContentAllowed(true); subscripcionButton.setPrimaryStyleName("valo-menu-item"); subscripcionButton.setIcon(new ThemeResource("icons/suscripciones.svg")); menuItemsLayout.addComponent(subscripcionButton); return menu; }
From source file:eu.eco2clouds.portal.component.apwizard.SuggestionStep.java
License:Apache License
private void render() { this.removeAllComponents(); if (this.mainLayout != null && this.mainLayout.getMenu() != null && this.mainLayout.getMenu().getResourcesStep() != null && this.mainLayout.getMenu().getResourcesStep().getNewResourceTable() != null && this.mainLayout.getMenu().getGeneralStep().getDuration() != null && this.mainLayout.getMenu().getGeneralStep().getDuration().getValue() != null && !this.mainLayout.getMenu().getGeneralStep().getDuration().getValue().equals("")) { VerticalLayout vlCpuLoad = new VerticalLayout(); vlCpuLoad.setMargin(false);//www .ja v a 2s. c o m vlCpuLoad.setSpacing(true); Label lblCpuLoad = new Label("Average Cpu Load"); vlCpuLoad.addComponent(lblCpuLoad); this.sliderCpuLoad.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { updateChart(); } }); HorizontalLayout hl = new HorizontalLayout(); hl.setMargin(false); hl.setSpacing(true); hl.addComponent(new Label("min 0", ContentMode.HTML)); hl.addComponent(sliderCpuLoad); hl.addComponent(new Label("100 max", ContentMode.HTML)); vlCpuLoad.addComponent(hl); vlCpuLoad.setComponentAlignment(lblCpuLoad, Alignment.MIDDLE_LEFT); vlCpuLoad.setComponentAlignment(hl, Alignment.MIDDLE_LEFT); this.deploymentTable.setContainerDataSource(this.getCombination()); this.deploymentTable.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(final Property.ValueChangeEvent event) { DeploymentTableBean item = (DeploymentTableBean) deploymentTable.getValue(); System.out.println("item is " + item); int selected = item.getId() - 1; long duration = Long.parseLong(mainLayout.getMenu().getGeneralStep().getDuration().getValue()); System.out.println("selected " + selected); System.out.println("power fr" + power_fr[selected]); System.out.println("power uk" + power_uk[selected]); System.out.println("power de" + power_de[selected]); TrendWindow trendWindow = new TrendWindow(power_fr[selected], power_uk[selected], power_de[selected], duration); UI.getCurrent().addWindow(trendWindow); } }); this.deploymentTable.addGeneratedColumn("GEC", new ColumnGenerator() { @Override public Object generateCell(final Table source, final Object itemId, Object columnId) { ArrayList<String> locations = new ArrayList<String>(); String[] vms = ((DeploymentTableBean) itemId).getCombination().split(" "); for (int i = 0; i < vms.length; i++) { String vmName = vms[i].split("@")[0]; String vmLocation = vms[i].split("@")[1]; if (!locations.contains(vmLocation)) { locations.add(vmLocation); } } SourcePercentage sp = SchedulerManagerFactory.getInstance().getGEC(locations); return new Label(Double.toString(sp.getGEC())); } }); this.deploymentTable.addGeneratedColumn("", new ColumnGenerator() { @Override public Object generateCell(final Table source, final Object itemId, Object columnId) { Button button = new Button(""); button.setStyleName(Reindeer.BUTTON_LINK); button.setIcon(new ThemeResource("img/pie.png")); button.setDescription("GEC"); button.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { ArrayList<String> locations = new ArrayList<String>(); String[] vms = ((DeploymentTableBean) itemId).getCombination().split(" "); for (int i = 0; i < vms.length; i++) { String vmName = vms[i].split("@")[0]; String vmLocation = vms[i].split("@")[1]; if (!locations.contains(vmLocation)) { locations.add(vmLocation); } } SourcePercentage sp = SchedulerManagerFactory.getInstance().getGEC(locations); GECWindow gecWindow = new GECWindow(((DeploymentTableBean) itemId).getCombination(), sp); UI.getCurrent().addWindow(gecWindow); } }); return button; } }); this.deploymentTable.addGeneratedColumn(" ", new ColumnGenerator() { @Override public Object generateCell(final Table source, final Object itemId, Object columnId) { Button button = new Button(""); button.setStyleName(Reindeer.BUTTON_LINK); button.setIcon(new ThemeResource("img/trend.png")); button.setDescription("CO2 trend"); button.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { //DeploymentTableBean item = (DeploymentTableBean) deploymentTable.getValue(); System.out.println("item is " + itemId); int selected = ((DeploymentTableBean) itemId).getId() - 1; long duration = Long .parseLong(mainLayout.getMenu().getGeneralStep().getDuration().getValue()); System.out.println("selected " + selected); System.out.println("power fr" + power_fr[selected]); System.out.println("power uk" + power_uk[selected]); System.out.println("power de" + power_de[selected]); TrendWindow trendWindow = new TrendWindow(power_fr[selected], power_uk[selected], power_de[selected], duration); UI.getCurrent().addWindow(trendWindow); } }); return button; } }); vlCpuLoad.addComponent(deploymentTable); OptionGroup chartAspect = new OptionGroup("Chart aspect"); chartAspect.addItem(1); chartAspect.setItemCaption(1, "NORMAL"); chartAspect.addItem(2); chartAspect.setItemCaption(2, "PERCENTAGE"); chartAspect.select(1); chartAspect.setNullSelectionAllowed(false); chartAspect.setImmediate(true); chartAspect.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { //final String valueString = String.valueOf(event.getProperty() // .getValue()); if (co2CountryChart != null) { co2CountryChart.toggleAspect(); } } }); vlCpuLoad.addComponent(chartAspect); chartHl.addComponent(vlCpuLoad); this.compute(); this.co2CountryChart = new CO2CountryChart(sdf.format(new Date()), this.deploymentTable.getItemIds().size(), co2_fr, co2_uk, co2_de, this.sliderCpuLoad.getValue()); chartHl.addComponent(this.co2CountryChart); chartHl.setComponentAlignment(vlCpuLoad, Alignment.TOP_LEFT); chartHl.setComponentAlignment(this.co2CountryChart, Alignment.TOP_RIGHT); this.addComponent(chartHl); } else { Label lblEmpty = new Label("No resources defined."); this.addComponent(lblEmpty); } }
From source file:eu.eco2clouds.portal.component.Logo.java
License:Apache License
private void render() { this.setSource(new ThemeResource("img/logo_ECO_clouds.png")); this.setHeight("100px"); }
From source file:eu.eco2clouds.portal.component.MainMenu.java
License:Apache License
public MainMenu() { this.setHeight("50px"); this.setSpacing(true); this.setMargin(true); this.setWidth("100%"); Label spaceLabel = new Label(" "); this.addComponent(spaceLabel); Button homePageBtn = new Button(""); homePageBtn.setIcon(new ThemeResource("img/homepage.png")); homePageBtn.setDescription("Home page"); homePageBtn.setStyleName(Reindeer.BUTTON_LINK); homePageBtn.addClickListener(new Button.ClickListener() { @Override/* w w w .j av a2 s. c o m*/ public void buttonClick(ClickEvent event) { int status = ((E2CPortal) UI.getCurrent()).getSessionStatus().getStatus(); if (status != SessionStatus.HOME) { ((E2CPortal) UI.getCurrent()).getSessionStatus().setStatus(SessionStatus.HOME); ((E2CPortal) UI.getCurrent()).render(); } } }); this.addComponent(homePageBtn); Button addExperimentBtn = new Button(""); addExperimentBtn.setIcon(new ThemeResource("img/add.png")); addExperimentBtn.setDescription("Add new experiment"); addExperimentBtn.setStyleName(Reindeer.BUTTON_LINK); addExperimentBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { int status = ((E2CPortal) UI.getCurrent()).getSessionStatus().getStatus(); if (status != SessionStatus.SUBMITAP) { ((E2CPortal) UI.getCurrent()).getSessionStatus().setStatus(SessionStatus.SUBMITAP); ((E2CPortal) UI.getCurrent()).render(); } } }); this.addComponent(addExperimentBtn); Button notificationBtn = new Button("Notifications"); notificationBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { int status = ((E2CPortal) UI.getCurrent()).getSessionStatus().getStatus(); if (status != SessionStatus.NOTIFICATIONS) { ((E2CPortal) UI.getCurrent()).getSessionStatus().setStatus(SessionStatus.NOTIFICATIONS); ((E2CPortal) UI.getCurrent()).render(); } } }); //this.addComponent(notificationBtn); Button logoutBtn = new Button(""); logoutBtn.setIcon(new ThemeResource("img/logout.png")); logoutBtn.setDescription("Logout"); logoutBtn.setStyleName(Reindeer.BUTTON_LINK); logoutBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { ((E2CPortal) UI.getCurrent()).getSessionStatus().setStatus(SessionStatus.UNLOGGED); ((E2CPortal) UI.getCurrent()).render(); } }); this.addComponent(logoutBtn); /*Button refreshBtn = new Button(" "); if (Configuration.refreshUIActive) { refreshBtn.setCaption("Disable autorefresh"); } else { refreshBtn.setCaption("Enable autorefresh"); } refreshBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { ((E2CPortal) UI.getCurrent()).toggleRefresh(); Configuration.refreshUIActive = !Configuration.refreshUIActive; if (Configuration.refreshUIActive) { event.getButton().setCaption("Disable autorefresh"); } else { event.getButton().setCaption("Enable autorefresh"); } } }); this.addComponent(refreshBtn);*/ this.setExpandRatio(spaceLabel, 20.0f); this.setComponentAlignment(homePageBtn, Alignment.MIDDLE_RIGHT); this.setComponentAlignment(addExperimentBtn, Alignment.MIDDLE_RIGHT); //this.setComponentAlignment(notificationBtn, Alignment.MIDDLE_LEFT); this.setComponentAlignment(logoutBtn, Alignment.MIDDLE_RIGHT); //this.setComponentAlignment(refreshBtn, Alignment.MIDDLE_RIGHT); }
From source file:fi.jasoft.draganddrop.demos.DragDemo.java
License:Apache License
@Override protected Component getDemoContent() { HorizontalLayout hl = new HorizontalLayout(); hl.setSizeFull();//ww w. j a v a 2s. c o m // source-start // Create image Image image = new Image(null, new ThemeResource("graphics/bin.jpg")); // Enable dropping items on image DragAndDrop.enable(image, DragAndDropOperation.DROP) // Set custom drop handler .onDrop(new DropHandler<Image>() { @Override protected void onDrop(Component component) { // Restor trash bin getSource().setSource(new ThemeResource("graphics/bin.jpg")); // Remove item ((ComponentContainer) component.getParent()).removeComponent(component); } }) // Set custom over handler .onOver(new DragOverHandler<Image>() { @Override protected void onOver(Component component) { // Add color to trash bin getSource().setSource(new ThemeResource("graphics/bin2.jpg")); } }) // Set custom out handler .onOut(new DragOutHandler<Image>() { @Override protected void onOut(Component component) { // Restore trash bin getSource().setSource(new ThemeResource("graphics/bin.jpg")); } }); // source-end hl.addComponent(image); hl.setComponentAlignment(image, Alignment.TOP_CENTER); VerticalLayout vl = new VerticalLayout(); vl.setSizeUndefined(); vl.setSpacing(true); hl.addComponent(vl); hl.setComponentAlignment(vl, Alignment.TOP_CENTER); // source-start /* * Create item list to drag from */ for (int i = 0; i < 5; i++) { Label item = new Label("Item " + (i + 1)); item.setStyleName("item"); item.setSizeUndefined(); // Enable dragging the items DragAndDrop.enable(item, DragAndDropOperation.DRAG); vl.addComponent(item); } // source-end return hl; }
From source file:fi.racetrace.adminpanel.ui.columngenerator.DeviceIconGC.java
License:Open Source License
@Override public Object generateCell(Table source, Object itemId, Object columnId) { Component c = null;/*from w w w .ja va 2s. co m*/ if (source.isEditable() && itemId.equals(source.getValue())) { // TODO bindaus modeliin ComboBox cb = new ComboBox("Icon", new BeanItemContainer<fi.racetrace.adminpanel.data.DeviceIcon>( fi.racetrace.adminpanel.data.DeviceIcon.class, icons)); cb.setWidth(100, Unit.PIXELS); final Item sdItem = source.getItem(itemId); cb.setValue(sdItem.getItemProperty("icon")); cb.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { sdItem.getItemProperty("icon").setValue(event.getProperty().getValue()); } }); c = cb; } else { Item item = source.getItem(itemId); DeviceIcon di = ((DeviceIcon) item.getItemProperty("icon").getValue()); if (di != null) { String icon = di.getPath(); Embedded e = new Embedded("icon", new ThemeResource("img/" + icon)); c = e; } else { Label l = new Label("N/A"); c = l; } } return c; }
From source file:fi.semantum.strategia.Updates.java
License:Open Source License
private static void updateQueryGrid(final Main main, final FilterState state) { main.gridPanelLayout.removeAllComponents(); main.gridPanelLayout.setMargin(false); final List<String> keys = state.reportColumns; if (keys.isEmpty()) { Label l = new Label("Kysely ei tuottanut yhtn tulosta."); l.addStyleName(ValoTheme.LABEL_BOLD); l.addStyleName(ValoTheme.LABEL_HUGE); main.gridPanelLayout.addComponent(l); return;//from www .j av a 2 s . com } final IndexedContainer container = new IndexedContainer(); for (String key : keys) { container.addContainerProperty(key, String.class, ""); } rows: for (Map<String, ReportCell> map : state.report) { Object item = container.addItem(); for (String key : keys) if (map.get(key) == null) continue rows; for (Map.Entry<String, ReportCell> entry : map.entrySet()) { @SuppressWarnings("unchecked") com.vaadin.data.Property<String> p = container.getContainerProperty(item, entry.getKey()); p.setValue(entry.getValue().get()); } } HorizontalLayout hl = new HorizontalLayout(); hl.setWidth("100%"); final TextField filter = new TextField(); filter.addStyleName(ValoTheme.TEXTFIELD_TINY); filter.setInputPrompt("rajaa hakutuloksia - kirjoitetun sanan tulee lyty rivin teksteist"); filter.setWidth("100%"); final Image clipboard = new Image(); clipboard.setSource(new ThemeResource("page_white_excel.png")); clipboard.setHeight("24px"); clipboard.setWidth("24px"); hl.addComponent(filter); hl.setExpandRatio(filter, 1.0f); hl.setComponentAlignment(filter, Alignment.BOTTOM_CENTER); hl.addComponent(clipboard); hl.setComponentAlignment(clipboard, Alignment.BOTTOM_CENTER); hl.setExpandRatio(clipboard, 0.0f); main.gridPanelLayout.addComponent(hl); main.gridPanelLayout.setExpandRatio(hl, 0f); filter.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 3033918399018888150L; @Override public void valueChange(ValueChangeEvent event) { container.removeAllContainerFilters(); container.addContainerFilter(new QueryFilter(filter.getValue(), true, false)); } }); AbsoluteLayout abs = new AbsoluteLayout(); abs.setSizeFull(); final Grid queryGrid = new Grid(container); queryGrid.setSelectionMode(SelectionMode.NONE); queryGrid.setHeightMode(HeightMode.CSS); queryGrid.setHeight("100%"); queryGrid.setWidth("100%"); for (String key : keys) { Column col = queryGrid.getColumn(key); col.setExpandRatio(1); } abs.addComponent(queryGrid); OnDemandFileDownloader dl = new OnDemandFileDownloader(new OnDemandStreamSource() { private static final long serialVersionUID = 981769438054780731L; File f; Date date = new Date(); @Override public InputStream getStream() { String uuid = UUID.randomUUID().toString(); File printing = new File(Main.baseDirectory(), "printing"); f = new File(printing, uuid + ".xlsx"); Workbook w = new XSSFWorkbook(); Sheet sheet = w.createSheet("Sheet1"); Row header = sheet.createRow(0); for (int i = 0; i < keys.size(); i++) { Cell cell = header.createCell(i); cell.setCellValue(keys.get(i)); } int row = 1; rows: for (Map<String, ReportCell> map : state.report) { for (String key : keys) if (map.get(key) == null) continue rows; Row r = sheet.createRow(row++); int column = 0; for (int i = 0; i < keys.size(); i++) { Cell cell = r.createCell(column++); ReportCell rc = map.get(keys.get(i)); cell.setCellValue(rc.getLong()); } } try { FileOutputStream s = new FileOutputStream(f); w.write(s); s.close(); } catch (Exception e) { e.printStackTrace(); } try { return new FileInputStream(f); } catch (FileNotFoundException e) { e.printStackTrace(); } throw new IllegalStateException(); } @Override public void onRequest() { // TODO Auto-generated method stub } @Override public long getFileSize() { return f.length(); } @Override public String getFileName() { return "Strategiakartta_" + Utils.dateString(date) + ".xlsx"; } }); dl.getResource().setCacheTime(0); dl.extend(clipboard); main.gridPanelLayout.addComponent(abs); main.gridPanelLayout.setExpandRatio(abs, 1f); }