Search in sources :

Example 16 with Resource

use of com.vaadin.server.Resource in project cuba by cuba-platform.

the class WebAppMenu method createMenuItem.

@Override
public MenuItem createMenuItem(String id, String caption, @Nullable String icon, @Nullable Consumer<MenuItem> command) {
    checkNotNullArgument(id);
    checkItemIdDuplicate(id);
    MenuItemImpl menuItem = new MenuItemImpl(this, id);
    Resource iconResource = null;
    if (icon != null) {
        iconResource = AppBeans.get(IconResolver.class).getIconResource(icon);
    }
    MenuBar.MenuItem delegateItem = component.createMenuItem(caption, iconResource, null);
    if (command != null) {
        @SuppressWarnings("UnnecessaryLocalVariable") Consumer<MenuItem> nonnullCommand = command;
        delegateItem.setCommand(selectedItem -> nonnullCommand.accept(menuItem));
    }
    menuItem.setDelegateItem(delegateItem);
    menuItem.setCaption(caption);
    menuItem.setIcon(icon);
    menuItem.setCommand(command);
    return menuItem;
}
Also used : Resource(com.vaadin.server.Resource) MenuBar(com.vaadin.ui.MenuBar) CubaMenuBar(com.haulmont.cuba.web.widgets.CubaMenuBar)

Example 17 with Resource

use of com.vaadin.server.Resource in project cuba by cuba-platform.

the class WebPopupButton method setPopupButtonIcon.

protected void setPopupButtonIcon(Button button, String icon) {
    if (!StringUtils.isEmpty(icon)) {
        Resource iconResource = getIconResource(icon);
        button.setIcon(iconResource);
    } else {
        button.setIcon(null);
    }
}
Also used : Resource(com.vaadin.server.Resource)

Example 18 with Resource

use of com.vaadin.server.Resource in project VaadinUtils by rlsutton1.

the class JasperReportLayout method createEmailButton.

private void createEmailButton(String buttonHeight, HorizontalLayout buttonContainer) {
    emailButton = new Button();
    Resource emailButtonIcon = reportProperties.getEmailButtonIconResource();
    if (emailButtonIcon == null) {
        emailButtonIcon = new ExternalResource("images/seanau/Send Email_32.png");
    }
    emailButton.setIcon(emailButtonIcon);
    emailButton.setDescription("Email");
    emailButton.setWidth("" + BUTTON_WIDTH);
    emailButton.setHeight(buttonHeight);
    emailButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    emailButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    emailButton.addClickListener(new ClickEventLogged.ClickListener() {

        private static final long serialVersionUID = 7207441556779172217L;

        @Override
        public void clicked(ClickEvent event) {
            new JasperReportEmailWindow(reportProperties, builder.getReportParameters());
        }
    });
    buttonContainer.addComponent(emailButton);
}
Also used : ClickEventLogged(au.com.vaadinutils.listener.ClickEventLogged) Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) JasperReportEmailWindow(au.com.vaadinutils.jasper.scheduler.JasperReportEmailWindow) ExternalResource(com.vaadin.server.ExternalResource) StreamResource(com.vaadin.server.StreamResource) Resource(com.vaadin.server.Resource) ExternalResource(com.vaadin.server.ExternalResource)

Example 19 with Resource

use of com.vaadin.server.Resource in project VaadinUtils by rlsutton1.

the class JasperReportLayout method getOptionsPanel.

private Component getOptionsPanel() {
    VerticalLayout layout = new VerticalLayout();
    layout.setId("OptionsPanel");
    // layout.setMargin(new MarginInfo(false, false, false, false));
    // layout.setSpacing(true);
    layout.setSizeFull();
    String buttonHeight = "" + BUTTON_WIDTH;
    HorizontalLayout buttonBar = new HorizontalLayout();
    buttonBar.setStyleName("njadmin-grey-colour");
    buttonBar.setSpacing(true);
    // buttonBar.setStyleName(Reindeer.LAYOUT_BLUE);
    buttonBar.setWidth("100%");
    buttonBar.setHeight("" + (BUTTON_WIDTH));
    buttonBar.setMargin(new MarginInfo(false, false, false, false));
    HorizontalLayout buttonContainer = new HorizontalLayout();
    buttonContainer.setSizeFull();
    buttonContainer.setWidth("280");
    showButton = new Button();
    Resource previewButtonIcon = reportProperties.getPreviewButtonIconResource();
    if (previewButtonIcon == null) {
        previewButtonIcon = new ExternalResource("images/seanau/Print preview.png");
    }
    showButton.setIcon(previewButtonIcon);
    showButton.setDescription("Preview");
    showButton.setWidth("" + BUTTON_WIDTH);
    showButton.setHeight(buttonHeight);
    showButton.setDisableOnClick(true);
    showButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    showButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    addButtonListener(showButton, OutputFormat.HTML);
    buttonContainer.addComponent(showButton);
    printButton = new Button();
    Resource pdfButtonIcon = reportProperties.getPdfButtonIconResource();
    if (pdfButtonIcon == null) {
        pdfButtonIcon = new ExternalResource("images/seanau/Print_32.png");
    }
    printButton.setIcon(pdfButtonIcon);
    printButton.setDescription("Print (PDF)");
    printButton.setWidth("" + BUTTON_WIDTH);
    printButton.setHeight(buttonHeight);
    printButton.setDisableOnClick(true);
    printButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    printButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    addButtonListener(printButton, OutputFormat.PDF);
    buttonContainer.addComponent(printButton);
    exportButton = new Button();
    Resource exportButtonIcon = reportProperties.getExportButtonIconResource();
    if (exportButtonIcon == null) {
        exportButtonIcon = new ExternalResource("images/exporttoexcel.png");
    }
    exportButton.setDescription("Export (Excel - CSV)");
    exportButton.setIcon(exportButtonIcon);
    exportButton.setWidth("" + BUTTON_WIDTH);
    exportButton.setDisableOnClick(true);
    exportButton.setHeight(buttonHeight);
    exportButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    exportButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    addButtonListener(exportButton, OutputFormat.CSV);
    buttonContainer.addComponent(exportButton);
    createFavouriteButton(buttonHeight, buttonContainer);
    createEmailButton(buttonHeight, buttonContainer);
    createScheduleButton(buttonHeight, buttonContainer);
    if (reportProperties instanceof JasperReportPopUp) {
        // This is disabled because there are serious problems with
        // transient (JasperReportProperties is not aware of them)
        // parameters in drill
        // downs, these can not currently be save or represented in the
        // ReportEmailSchedule
        emailButton.setEnabled(false);
        scheduleButton.setEnabled(false);
    }
    buttonBar.addComponent(buttonContainer);
    layout.addComponent(buttonBar);
    components = builder.buildLayout(false);
    if (components.size() > 0) {
        VerticalLayout filterPanel = new VerticalLayout();
        filterPanel.setMargin(new MarginInfo(false, false, true, false));
        filterPanel.setSpacing(true);
        filterPanel.setSizeFull();
        Label filterLabel = new Label("<b>Filters</b>");
        filterLabel.setStyleName(Reindeer.LABEL_H2);
        filterLabel.setContentMode(ContentMode.HTML);
        filterPanel.addComponent(filterLabel);
        for (ExpanderComponent componet : components) {
            filterPanel.addComponent(componet.getComponent());
            if (componet.shouldExpand()) {
                filterPanel.setExpandRatio(componet.getComponent(), 1);
            }
        }
        layout.addComponent(filterPanel);
        layout.setExpandRatio(filterPanel, 1.0f);
        try {
            ReportSave reportSave = UI.getCurrent().getSession().getAttribute(ReportSave.class);
            if (reportSave != null) {
                for (ReportParameter<?> rp : builder.getReportParameters()) {
                    for (String paramterName : rp.getParameterNames()) {
                        for (ReportSaveParameter saved : reportSave.getParameters()) {
                            if (saved.getParameterName().equals(rp.getLabel(paramterName))) {
                                try {
                                    if (StringUtils.isNotBlank(saved.getMetaData())) {
                                        rp.applySaveMetaData(saved.getMetaData());
                                    } else {
                                        rp.setValueAsString(saved.getParameterValue(), paramterName);
                                    }
                                } catch (ReadOnlyException | ConversionException | ParseException e) {
                                    ErrorWindow.showErrorWindow(e);
                                }
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            logger.error(e, e);
        }
    }
    // hidden frame for downloading csv
    csv = new BrowserFrame();
    csv.setVisible(true);
    csv.setHeight("1");
    csv.setWidth("1");
    csv.setImmediate(true);
    layout.addComponent(csv);
    return layout;
}
Also used : ConversionException(com.vaadin.data.util.converter.Converter.ConversionException) ExpanderComponent(au.com.vaadinutils.jasper.filter.ExpanderComponent) BrowserFrame(com.vaadin.ui.BrowserFrame) ExternalResource(com.vaadin.server.ExternalResource) StreamResource(com.vaadin.server.StreamResource) Resource(com.vaadin.server.Resource) Label(com.vaadin.ui.Label) ExternalResource(com.vaadin.server.ExternalResource) ParseException(java.text.ParseException) ConversionException(com.vaadin.data.util.converter.Converter.ConversionException) ReadOnlyException(com.vaadin.data.Property.ReadOnlyException) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Button(com.vaadin.ui.Button) MarginInfo(com.vaadin.shared.ui.MarginInfo) VerticalLayout(com.vaadin.ui.VerticalLayout) ParseException(java.text.ParseException) ReportSave(au.com.vaadinutils.jasper.scheduler.entities.ReportSave) ReportSaveParameter(au.com.vaadinutils.jasper.scheduler.entities.ReportSaveParameter) ReadOnlyException(com.vaadin.data.Property.ReadOnlyException)

Aggregations

Resource (com.vaadin.server.Resource)19 ExternalResource (com.vaadin.server.ExternalResource)5 StreamResource (com.vaadin.server.StreamResource)4 Button (com.vaadin.ui.Button)4 ClickEvent (com.vaadin.ui.Button.ClickEvent)3 ReportSave (au.com.vaadinutils.jasper.scheduler.entities.ReportSave)2 ReportSaveParameter (au.com.vaadinutils.jasper.scheduler.entities.ReportSaveParameter)2 ClickEventLogged (au.com.vaadinutils.listener.ClickEventLogged)2 Configuration (com.haulmont.cuba.core.global.Configuration)2 ThemeConstants (com.haulmont.cuba.gui.theme.ThemeConstants)2 WebConfig (com.haulmont.cuba.web.WebConfig)2 VersionedThemeResource (com.haulmont.cuba.web.toolkit.VersionedThemeResource)2 FileResource (com.vaadin.server.FileResource)2 BrowserFrame (com.vaadin.ui.BrowserFrame)2 InputDialog (au.com.vaadinutils.editors.InputDialog)1 Recipient (au.com.vaadinutils.editors.Recipient)1 ExpanderComponent (au.com.vaadinutils.jasper.filter.ExpanderComponent)1 ReportParameter (au.com.vaadinutils.jasper.parameter.ReportParameter)1 JasperReportEmailWindow (au.com.vaadinutils.jasper.scheduler.JasperReportEmailWindow)1 JasperReportSchedulerWindow (au.com.vaadinutils.jasper.scheduler.JasperReportSchedulerWindow)1