Example usage for com.vaadin.server FileDownloader FileDownloader

List of usage examples for com.vaadin.server FileDownloader FileDownloader

Introduction

In this page you can find the example usage for com.vaadin.server FileDownloader FileDownloader.

Prototype

public FileDownloader(Resource resource) 

Source Link

Document

Creates a new file downloader for the given resource.

Usage

From source file:com.esofthead.mycollab.vaadin.web.ui.AttachmentDisplayComponent.java

License:Open Source License

public void addAttachmentRow(final Content attachment) {
    String docName = attachment.getPath();
    int lastIndex = docName.lastIndexOf("/");
    if (lastIndex != -1) {
        docName = docName.substring(lastIndex + 1, docName.length());
    }/*from w  w  w  .  j  a  v  a  2 s.  co m*/

    final AbsoluteLayout attachmentLayout = new AbsoluteLayout();
    attachmentLayout.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    attachmentLayout.setHeight(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_HEIGHT);
    attachmentLayout.setStyleName("attachment-block");

    CssLayout thumbnailWrap = new CssLayout();
    thumbnailWrap.setSizeFull();
    thumbnailWrap.setStyleName("thumbnail-wrap");

    Link thumbnail = new Link();
    if (StringUtils.isBlank(attachment.getThumbnail())) {
        thumbnail.setIcon(FileAssetsUtil.getFileIconResource(attachment.getName()));
    } else {
        thumbnail.setIcon(VaadinResourceFactory.getInstance().getResource(attachment.getThumbnail()));
    }

    if (MimeTypesUtil.isImageType(docName)) {
        thumbnail.setResource(VaadinResourceFactory.getInstance().getResource(attachment.getPath()));
        new Fancybox(thumbnail).setPadding(0).setVersion("2.1.5").setEnabled(true).setDebug(true);
    }

    Div contentTooltip = new Div().appendChild(new Span().appendText(docName).setStyle("font-weight:bold"));
    Ul ul = new Ul()
            .appendChild(new Li().appendText("Size: " + FileUtils.getVolumeDisplay(attachment.getSize())))
            .setStyle("line-height:1.5em");
    ul.appendChild(new Li().appendText(
            "Last modified: " + AppContext.formatPrettyTime(attachment.getLastModified().getTime())));
    contentTooltip.appendChild(ul);
    thumbnail.setDescription(contentTooltip.write());
    thumbnail.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    thumbnailWrap.addComponent(thumbnail);

    attachmentLayout.addComponent(thumbnailWrap, "top: 0px; left: 0px; bottom: 0px; right: 0px; z-index: 0;");

    CssLayout attachmentNameWrap = new CssLayout();
    attachmentNameWrap.setWidth(UIConstants.DEFAULT_ATTACHMENT_THUMBNAIL_WIDTH);
    attachmentNameWrap.setStyleName("attachment-name-wrap");

    Label attachmentName = new Label(StringUtils.trim(docName, 60, true));
    attachmentName.setStyleName("attachment-name");
    attachmentNameWrap.addComponent(attachmentName);
    attachmentLayout.addComponent(attachmentNameWrap, "bottom: 0px; left: 0px; right: 0px; z-index: 1;");

    Button trashBtn = new Button(null, new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            ConfirmDialogExt.show(UI.getCurrent(),
                    AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, AppContext.getSiteName()),
                    AppContext.getMessage(GenericI18Enum.CONFIRM_DELETE_ATTACHMENT),
                    AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                    AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClose(ConfirmDialog dialog) {
                            if (dialog.isConfirmed()) {
                                ResourceService attachmentService = AppContextUtil
                                        .getSpringBean(ResourceService.class);
                                attachmentService.removeResource(attachment.getPath(), AppContext.getUsername(),
                                        AppContext.getAccountId());
                                ((ComponentContainer) attachmentLayout.getParent())
                                        .removeComponent(attachmentLayout);
                            }
                        }
                    });

        }
    });
    trashBtn.setIcon(FontAwesome.TRASH_O);
    trashBtn.setStyleName("attachment-control");
    attachmentLayout.addComponent(trashBtn, "top: 9px; left: 9px; z-index: 1;");

    Button downloadBtn = new Button();
    FileDownloader fileDownloader = new FileDownloader(
            VaadinResourceFactory.getInstance().getStreamResource(attachment.getPath()));
    fileDownloader.extend(downloadBtn);

    downloadBtn.setIcon(FontAwesome.DOWNLOAD);
    downloadBtn.setStyleName("attachment-control");
    attachmentLayout.addComponent(downloadBtn, "right: 9px; top: 9px; z-index: 1;");
    this.addComponent(attachmentLayout);
}

From source file:com.foc.vaadin.gui.components.FVImageField.java

License:Apache License

public void reactToEditable() {
    if (isEditable()) {
        if (imageControlLayout != null) {
            imageControlLayout.setVisible(true);
        } else {/*from w w w .j ava  2s.c o m*/
            imageControlLayout = new HorizontalLayout();
            imageControlLayout.setSpacing(true);
            imageControlLayout.setWidth("100%");
            imageControlLayout.setHeight("-1px");
            addComponent(imageControlLayout);
            setComponentAlignment(imageControlLayout, Alignment.TOP_RIGHT);

            if (isEditable()) {
                FVUpload_Image uploader = new FVUpload_Image();
                uploader.setWidth("100px");
                imageControlLayout.addComponent(uploader);
                imageControlLayout.setComponentAlignment(uploader, Alignment.TOP_RIGHT);

                uploader.setImageReceiver(this);

                downloadButton = new Button("Download");//, FVIconFactory.getInstance().getFVIcon_24(FVIconFactory.ICON_DOWNLOAD));
                if (ConfigInfo.isArabic()) {
                    downloadButton.setCaption("");//To hide the default ugly button we should set this to null
                }
                //               downloadButton.setIcon(FontAwesome.DOWNLOAD);
                downloadButton.setWidth("100px");
                //             downloadButton.setCaption(null);
                //             downloadButton.setStyleName(BaseTheme.BUTTON_LINK);
                downloadButton.addStyleName(FocXMLGuiComponentStatic.STYLE_NO_PRINT);
                downloadButton.addStyleName(FocXMLGuiComponentStatic.STYLE_HAND_POINTER_ON_HOVER);
                imageControlLayout.addComponent(downloadButton);
                imageControlLayout.setComponentAlignment(downloadButton, Alignment.TOP_LEFT);

                resource = new GenericFileResource(getFocData());
                FileDownloader downloader = new FileDownloader(resource);
                downloader.extend(downloadButton);
            }
        }
    } else {
        if (imageControlLayout != null)
            imageControlLayout.setVisible(false);
    }
}

From source file:com.foc.web.modules.photoAlbum.PhotoAlbum_Table.java

License:Apache License

@Override
public ColumnGenerator table_getGeneratedColumn(String tableName, final FVTableColumn tableColumn) {
    ColumnGenerator columnGenerator = null;

    if (tableColumn.getName().equals("DOWNLOAD")) {
        columnGenerator = new ColumnGenerator() {
            public Object generateCell(Table source, Object itemId, Object columnId) {
                long objId = (Long) itemId;
                FVButton button = new FVButton("");
                Resource iconResource = FVIconFactory.getInstance().getFVIcon_24(FVIconFactory.ICON_DOWNLOAD);
                button.setStyleName(Runo.BUTTON_LINK);
                button.setWidth("-1px");
                button.setHeight("-1px");
                button.setIcon(iconResource);
                PhotoAlbumFileResource resource = getPhotoAlbumFileResource(objId);
                FileDownloader downloader = new FileDownloader(resource);
                downloader.extend(button);
                return button;
            }/*from w ww  .  j  av a  2s.c  o m*/
        };
    }
    return columnGenerator;
}

From source file:com.gnts.pem.txn.sbi.SBIBuilding.java

@SuppressWarnings("deprecation")
void populateAndConfig(boolean search) {
    try {// w w  w .  j  a  v  a  2 s .  c o m
        tblEvalDetails.removeAllItems();
        tblEvalDetails.setImmediate(true);
        List<TPemCmEvalDetails> evalList = null;
        evalList = new ArrayList<TPemCmEvalDetails>();
        if (search) {
            String evalno = tfSearchEvalNumber.getValue();
            String customer = tfSearchCustomer.getValue();
            String bankbranch = (String) slSearchBankbranch.getValue();
            evalList = beanEvaluation.getSearchEvalDetailnList(null, evalno, null, customer, bankbranch,
                    selectedBankid, selectCompanyid, null);
            total = evalList.size();

            if (total == 0) {
                lblNotificationIcon.setIcon(new ThemeResource("img/msg_info.png"));
                lblSaveNotification.setValue("No Records found");
            } else {
                lblNotificationIcon.setIcon(null);
                lblSaveNotification.setValue("");
            }
        } else {

            evalList = beanEvaluation.getSearchEvalDetailnList(selectedFormName, null, null, null, null,
                    selectedBankid, selectCompanyid, null);
            total = evalList.size();
        }
        lblNoofRecords.setValue(
                "<font size=\"2\" color=\"black\">No.of Records:</font> <font size=\"2\" color=\"#1E90FF\"> "
                        + total + "</font>");

        beans = new BeanItemContainer<TPemCmEvalDetails>(TPemCmEvalDetails.class);
        beans.addAll(evalList);
        btnEdit.setEnabled(false);
        tblEvalDetails.setContainerDataSource(beans);
        tblEvalDetails.setSelectable(true);
        tblEvalDetails.setColumnFooter("lastUpdateDt", "No. of Records:" + total);
        tblEvalDetails.setVisibleColumns(new Object[] { "evalNo", "docDate", "bankBranch", "custName",
                "docStatus", "lastUpdtedBy", "lastUpdateDt" });
        tblEvalDetails.setColumnHeaders(new String[] { "Evaluation Number", "Evaluation Date", "Bank Branch",
                "Customer Name", "Status", "Last Updated By", "Last Updated Date" });
        tblEvalDetails.addValueChangeListener(new Property.ValueChangeListener() {
            /**
            * 
            */
            private static final long serialVersionUID = 3729824796823933688L;

            @Override
            public void valueChange(ValueChangeEvent event) {
                StreamResource sr = getPDFStream();

                if (sr != null) {

                    if (filedownloader == null) {
                        filedownloader = new FileDownloader(getPDFStream());
                        filedownloader.extend(btnView);
                    } else {
                        filedownloader.setFileDownloadResource(sr);
                    }
                } else {
                    lblNotificationIcon.setIcon(new ThemeResource("img/msg_info.png"));
                    lblSaveNotification.setValue("No document is there");
                    //   notif.show(Page.getCurrent());
                    if (filedownloader != null) {
                        filedownloader.setFileDownloadResource(null); // reset
                    }

                }

                TPemCmEvalDetails syncList = (TPemCmEvalDetails) event.getProperty().getValue();
                if (syncList != null) {

                    if (syncList.getDocStatus().equals("Draft") || syncList.getDocStatus().equals("Rejected")) {
                        btnEdit.setEnabled(true);
                        btnView.setEnabled(false);
                    } else {
                        btnEdit.setEnabled(false);
                        btnView.setEnabled(true);

                    }
                    btnAdd.setEnabled(false);
                } else {
                    btnEdit.setEnabled(false);
                    btnAdd.setEnabled(true);
                }
            }

        });
        tblEvalDetails.setImmediate(true);
        tblEvalDetails.addItemClickListener(new ItemClickListener() {

            @Override
            public void itemClick(ItemClickEvent event) {
                // TODO Auto-generated method stub
                if (tblEvalDetails.isSelected(event.getItemId())) {

                    btnView.setEnabled(false);
                } else {

                    btnView.setEnabled(true);
                }
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
        logger.info("Error-->" + e);
    }
    getExportTableDetails();
}

From source file:com.gnts.pem.txn.sbi.SBIConstruction.java

@SuppressWarnings("deprecation")
void populateAndConfig(boolean search) {
    try {//from  w  w w. j  av  a 2 s . com
        tblEvalDetails.removeAllItems();
        tblEvalDetails.setImmediate(true);
        List<TPemCmEvalDetails> evalList = null;
        evalList = new ArrayList<TPemCmEvalDetails>();
        if (search) {
            String evalno = tfSearchEvalNumber.getValue();
            String customer = tfSearchCustomer.getValue();
            String bankbranch = (String) slSearchBankbranch.getValue();
            evalList = beanEvaluation.getSearchEvalDetailnList(null, evalno, null, customer, bankbranch,
                    selectedBankid, selectCompanyid, null);
            total = evalList.size();
            if (total == 0) {
                lblNotificationIcon.setIcon(new ThemeResource("img/msg_info.png"));
                lblSaveNotification.setValue("No Records found");
            } else {
                lblNotificationIcon.setIcon(null);
                lblSaveNotification.setValue("");
            }
        } else {

            evalList = beanEvaluation.getSearchEvalDetailnList(SelectedFormName, null, null, null, null,
                    selectedBankid, selectCompanyid, null);
            total = evalList.size();
        }
        lblNoofRecords.setValue(
                "<font size=\"2\" color=\"black\">No.of Records:</font> <font size=\"2\" color=\"#1E90FF\"> "
                        + total + "</font>");
        beans = new BeanItemContainer<TPemCmEvalDetails>(TPemCmEvalDetails.class);
        beans.addAll(evalList);
        btnEdit.setEnabled(false);
        tblEvalDetails.setContainerDataSource(beans);
        tblEvalDetails.setSelectable(true);
        tblEvalDetails.setColumnFooter("lastUpdateDt", "No. of Records:" + total);
        tblEvalDetails.setVisibleColumns(new Object[] { "evalNo", "docDate", "bankBranch", "custName",
                "docStatus", "lastUpdtedBy", "lastUpdateDt" });
        tblEvalDetails.setColumnHeaders(new String[] { "Evaluation Number", "Evaluation Date", "Bank Branch",
                "Customer Name", "Status", "Last Updated By", "Last Updated Date" });
        tblEvalDetails.addValueChangeListener(new Property.ValueChangeListener() {
            /**
            * 
            */
            private static final long serialVersionUID = 3729824796823933688L;

            @Override
            public void valueChange(ValueChangeEvent event) {

                StreamResource sr = getPDFStream();

                if (sr != null) {

                    if (filedownloader == null) {
                        filedownloader = new FileDownloader(getPDFStream());
                        filedownloader.extend(btnView);
                    } else {
                        filedownloader.setFileDownloadResource(sr);
                    }
                } else {
                    lblNotificationIcon.setIcon(new ThemeResource("img/msg_info.png"));
                    lblSaveNotification.setValue("No document is there");
                    //   notif.show(Page.getCurrent());
                    if (filedownloader != null) {
                        filedownloader.setFileDownloadResource(null); // reset
                    }

                }
                TPemCmEvalDetails syncList = (TPemCmEvalDetails) event.getProperty().getValue();
                if (syncList != null) {

                    if (syncList.getDocStatus().equals("Draft") || syncList.getDocStatus().equals("Rejected")) {
                        btnEdit.setEnabled(true);
                        btnView.setEnabled(false);
                    } else {
                        btnEdit.setEnabled(false);
                        btnView.setEnabled(true);

                    }
                    btnAdd.setEnabled(false);
                } else {
                    btnEdit.setEnabled(false);
                    btnAdd.setEnabled(true);
                }
            }

        });
        tblEvalDetails.setImmediate(true);
        tblEvalDetails.addItemClickListener(new ItemClickListener() {

            @Override
            public void itemClick(ItemClickEvent event) {
                // TODO Auto-generated method stub
                if (tblEvalDetails.isSelected(event.getItemId())) {

                    btnView.setEnabled(false);
                } else {

                    btnView.setEnabled(true);
                }
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
        logger.info("Error-->" + e);
    }
    getExportTableDetails();
}

From source file:com.gnts.pem.txn.sbi.SBIConstructionBuilding.java

@SuppressWarnings("deprecation")
void populateAndConfig(boolean search) {
    try {/*from w  w w  .ja  v  a  2s .  c  o m*/
        tblEvalDetails.removeAllItems();
        tblEvalDetails.setImmediate(true);
        List<TPemCmEvalDetails> evalList = null;
        evalList = new ArrayList<TPemCmEvalDetails>();
        if (search) {
            String evalno = tfSearchEvalNumber.getValue();
            String customer = tfSearchCustomer.getValue();
            String bankbranch = (String) tfSearchBankbranch.getValue();
            evalList = beanEvaluation.getSearchEvalDetailnList(null, evalno, null, customer, bankbranch,
                    selectedBankid, selectCompanyid, null);
            total = evalList.size();
            if (total == 0) {
                lblNotificationIcon.setIcon(new ThemeResource("img/msg_info.png"));
                lblSaveNotification.setValue("No Records found");
            } else {
                lblNotificationIcon.setIcon(null);
                lblSaveNotification.setValue("");
            }
        } else {

            evalList = beanEvaluation.getSearchEvalDetailnList(selectedFormName, null, null, null, null,
                    selectedBankid, selectCompanyid, null);
            total = evalList.size();
        }
        lblNoofRecords.setValue(
                "<font size=\"2\" color=\"black\">No.of Records:</font> <font size=\"2\" color=\"#1E90FF\"> "
                        + total + "</font>");
        beans = new BeanItemContainer<TPemCmEvalDetails>(TPemCmEvalDetails.class);
        beans.addAll(evalList);
        btnEdit.setEnabled(false);
        tblEvalDetails.setContainerDataSource(beans);
        tblEvalDetails.setSelectable(true);
        tblEvalDetails.setColumnFooter("lastUpdateDt", "No. of Records:" + total);
        tblEvalDetails.setVisibleColumns(new Object[] { "evalNo", "docDate", "bankBranch", "custName",
                "docStatus", "lastUpdtedBy", "lastUpdateDt" });
        tblEvalDetails.setColumnHeaders(new String[] { "Evaluation Number", "Evaluation Date", "Bank Branch",
                "Customer Name", "Status", "Last Updated By", "Last Updated Date" });
        tblEvalDetails.addValueChangeListener(new Property.ValueChangeListener() {
            /**
            * 
            */
            private static final long serialVersionUID = 3729824796823933688L;

            @Override
            public void valueChange(ValueChangeEvent event) {

                StreamResource sr = getPDFStream();

                if (sr != null) {

                    if (filedownloader == null) {
                        filedownloader = new FileDownloader(getPDFStream());
                        filedownloader.extend(btnView);
                    } else {
                        filedownloader.setFileDownloadResource(sr);
                    }
                } else {
                    lblNotificationIcon.setIcon(new ThemeResource("img/msg_info.png"));
                    lblSaveNotification.setValue("No document is there");
                    //   notif.show(Page.getCurrent());
                    if (filedownloader != null) {
                        filedownloader.setFileDownloadResource(null); // reset
                    }

                }
                TPemCmEvalDetails syncList = (TPemCmEvalDetails) event.getProperty().getValue();
                if (syncList != null) {

                    if (syncList.getDocStatus().equals("Draft") || syncList.getDocStatus().equals("Rejected")) {
                        btnEdit.setEnabled(true);
                        btnView.setEnabled(false);
                    } else {
                        btnEdit.setEnabled(false);
                        btnView.setEnabled(true);

                    }
                    btnAdd.setEnabled(false);
                } else {
                    btnEdit.setEnabled(false);
                    btnAdd.setEnabled(true);
                }
            }

        });
        tblEvalDetails.setImmediate(true);
        tblEvalDetails.addItemClickListener(new ItemClickListener() {

            @Override
            public void itemClick(ItemClickEvent event) {
                // TODO Auto-generated method stub
                if (tblEvalDetails.isSelected(event.getItemId())) {

                    btnView.setEnabled(false);
                } else {

                    btnView.setEnabled(true);
                }
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
        logger.info("Error-->" + e);
    }
    getExportTableDetails();
}

From source file:com.gnts.pem.txn.sbi.SBIFlat.java

@SuppressWarnings("deprecation")
void populateAndConfig(boolean search) {
    try {/*  ww  w.  java2 s.c o m*/
        tblEvalDetails.removeAllItems();
        tblEvalDetails.setImmediate(true);
        List<TPemCmEvalDetails> evalList = null;
        evalList = new ArrayList<TPemCmEvalDetails>();
        if (search) {
            String evalno = tfSearchEvalNumber.getValue();
            String customer = tfSearchCustomer.getValue();
            String bankbranch = (String) slSearchBankbranch.getValue();
            evalList = beanEvaluation.getSearchEvalDetailnList(null, evalno, null, customer, bankbranch,
                    selectedBankid, selectCompanyid, null);
        } else {

            evalList = beanEvaluation.getSearchEvalDetailnList(selectedFormName, null, null, null, null,
                    selectedBankid, selectCompanyid, null);
            total = evalList.size();
        }
        if (total == 0) {
            lblNotificationIcon.setIcon(new ThemeResource("img/msg_info.png"));
            lblSaveNotification.setValue("No Records found");
        } else {
            lblNotificationIcon.setIcon(null);
            lblSaveNotification.setValue("");
        }
        lblNoofRecords.setValue(
                "<font size=\"2\" color=\"black\">No.of Records:</font> <font size=\"2\" color=\"#1E90FF\"> "
                        + total + "</font>");

        beans = new BeanItemContainer<TPemCmEvalDetails>(TPemCmEvalDetails.class);
        beans.addAll(evalList);
        btnEdit.setEnabled(false);
        tblEvalDetails.setContainerDataSource(beans);
        tblEvalDetails.setSelectable(true);
        tblEvalDetails.setColumnFooter("lastUpdateDt", "No. of Records:" + total);
        tblEvalDetails.setVisibleColumns(new Object[] { "evalNo", "docDate", "bankBranch", "custName",
                "docStatus", "lastUpdtedBy", "lastUpdateDt" });
        tblEvalDetails.setColumnHeaders(new String[] { "Evaluation Number", "Evaluation Date", "Bank Branch",
                "Customer Name", "Status", "Last Updated By", "Last Updated Date" });
        tblEvalDetails.addValueChangeListener(new Property.ValueChangeListener() {
            /**
            * 
            */
            private static final long serialVersionUID = 3729824796823933688L;

            @Override
            public void valueChange(ValueChangeEvent event) {
                StreamResource sr = getPDFStream();

                if (sr != null) {

                    if (filedownloader == null) {
                        filedownloader = new FileDownloader(getPDFStream());
                        filedownloader.extend(btnView);

                    } else {
                        filedownloader.setFileDownloadResource(sr);
                    }
                } else {
                    lblNotificationIcon.setIcon(new ThemeResource("img/msg_info.png"));
                    lblSaveNotification.setValue("No document is there");
                    //   notif.show(Page.getCurrent());
                    if (filedownloader != null) {
                        filedownloader.setFileDownloadResource(null); // reset
                    }

                }

                TPemCmEvalDetails syncList = (TPemCmEvalDetails) event.getProperty().getValue();
                if (syncList != null) {

                    if (syncList.getDocStatus().equals("Draft") || syncList.getDocStatus().equals("Rejected")) {
                        btnEdit.setEnabled(true);
                        btnView.setEnabled(false);
                    } else {
                        btnEdit.setEnabled(false);
                        btnView.setEnabled(true);

                    }

                    btnAdd.setEnabled(false);
                } else {
                    btnEdit.setEnabled(false);
                    btnAdd.setEnabled(true);
                }
            }

        });
        tblEvalDetails.setImmediate(true);
        tblEvalDetails.addItemClickListener(new ItemClickListener() {

            @Override
            public void itemClick(ItemClickEvent event) {
                // TODO Auto-generated method stub
                if (tblEvalDetails.isSelected(event.getItemId())) {

                    btnView.setEnabled(false);
                } else {

                    btnView.setEnabled(true);
                }
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
        logger.info("Error-->" + e);
    }
    getExportTableDetails();
}

From source file:com.gnts.pem.txn.sbi.SBILand.java

@SuppressWarnings("deprecation")
void populateAndConfig(boolean search) {
    try {/* w ww .  j a v a  2 s  . co m*/
        tblEvalDetails.removeAllItems();
        tblEvalDetails.setImmediate(true);
        List<TPemCmEvalDetails> evalList = null;
        evalList = new ArrayList<TPemCmEvalDetails>();
        if (search) {
            String evalno = tfSearchEvalNumber.getValue();
            String customer = tfSearchCustomer.getValue();
            String bankbranch = (String) slSearchBankbranch.getValue();
            evalList = beanEvaluation.getSearchEvalDetailnList(null, evalno, null, customer, bankbranch,
                    selectedBankid, selectCompanyid, null);
        } else {

            evalList = beanEvaluation.getSearchEvalDetailnList(selectedFormName, null, null, null, null,
                    selectedBankid, selectCompanyid, null);
            total = evalList.size();
        }
        if (total == 0) {
            lblNotificationIcon.setIcon(new ThemeResource("img/msg_info.png"));
            lblSaveNotification.setValue("No Records found");
        } else {
            lblNotificationIcon.setIcon(null);
            lblSaveNotification.setValue("");
        }
        lblNoofRecords.setValue(
                "<font size=\"2\" color=\"black\">No.of Records:</font> <font size=\"2\" color=\"#1E90FF\"> "
                        + total + "</font>");

        beans = new BeanItemContainer<TPemCmEvalDetails>(TPemCmEvalDetails.class);
        beans.addAll(evalList);
        btnEdit.setEnabled(false);
        tblEvalDetails.setContainerDataSource(beans);
        tblEvalDetails.setSelectable(true);
        tblEvalDetails.setColumnFooter("lastUpdateDt", "No. of Records:" + total);
        tblEvalDetails.setVisibleColumns(new Object[] { "evalNo", "docDate", "bankBranch", "custName",
                "docStatus", "lastUpdtedBy", "lastUpdateDt" });
        tblEvalDetails.setColumnHeaders(new String[] { "Evaluation Number", "Evaluation Date", "Bank Branch",
                "Customer Name", "Status", "Last Updated By", "Last Updated Date" });
        /*      tblEvalDetails.addListener(new ItemClickListener() {
                 private static final long serialVersionUID = 1L;
                
                 public void itemClick(ItemClickEvent event) {
                    if (tblEvalDetails.isSelected(event.getItemId())) {
          btnEdit.setEnabled(false);
          btnAdd.setEnabled(true);
                
                    } else {
          btnEdit.setEnabled(true);
          btnAdd.setEnabled(false);
                
                    }
                
                 }
              });
              */
        tblEvalDetails.addValueChangeListener(new Property.ValueChangeListener() {
            /**
            * 
            */
            private static final long serialVersionUID = 3729824796823933688L;

            @Override
            public void valueChange(ValueChangeEvent event) {

                StreamResource sr = getPDFStream();

                if (sr != null) {

                    if (filedownloader == null) {
                        filedownloader = new FileDownloader(getPDFStream());
                        filedownloader.extend(btnView);
                    } else {
                        filedownloader.setFileDownloadResource(sr);
                    }
                } else {

                    //   notif.show(Page.getCurrent());
                    if (filedownloader != null) {
                        filedownloader.setFileDownloadResource(null); // reset
                    }

                }
                TPemCmEvalDetails syncList = (TPemCmEvalDetails) event.getProperty().getValue();
                if (syncList != null) {

                    if (syncList.getDocStatus().equals("Draft") || syncList.getDocStatus().equals("Rejected")) {
                        btnEdit.setEnabled(true);
                        btnView.setEnabled(false);
                    } else {
                        btnEdit.setEnabled(false);
                        btnView.setEnabled(true);

                    }
                    btnAdd.setEnabled(false);

                } else {
                    btnEdit.setEnabled(false);
                    btnAdd.setEnabled(true);

                }
            }

        });
        tblEvalDetails.setImmediate(true);
        tblEvalDetails.addItemClickListener(new ItemClickListener() {

            @Override
            public void itemClick(ItemClickEvent event) {
                // TODO Auto-generated method stub
                if (tblEvalDetails.isSelected(event.getItemId())) {

                    btnView.setEnabled(false);
                } else {

                    btnView.setEnabled(true);
                }
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
        logger.info("Error-->" + e);
    }
    getExportTableDetails();
}

From source file:com.gnts.pem.txn.sbi.SBILand.java

void editPropertyImageDetails() {
    try {/*from  w  w  w.j  av a  2 s .  co  m*/
        List<TPemCmPropImage> imageList = beanPropImage.getPropImageList(headerid);
        TPemCmPropImage propObj = imageList.get(0);
        if (propObj.getPropimage1() != null) {
            byte[] myimage = (byte[]) propObj.getPropimage1();

            UploadUI test = new UploadUI(hlImageLayout1);
            hlImageLayout1.addComponent(btnImgDownload);
            test.dispayImage(myimage);
        } else {

            try {
                new UploadUI(hlImageLayout1);
            } catch (Exception e) {

            }
        }

        if (propObj.getPropimage2() != null) {
            byte[] myimage1 = (byte[]) propObj.getPropimage2();

            UploadUI2 test = new UploadUI2(hlImageLayout2);
            hlImageLayout2.addComponent(btnImg1Download);
            test.dispayImage(myimage1);
        } else {

            try {
                new UploadUI2(hlImageLayout2);
            } catch (Exception e) {

            }
        }

        StreamResource sr = getImgStream();
        FileDownloader fileDownloader = new FileDownloader(sr);
        fileDownloader.extend(btnImgDownload);

        StreamResource sr1 = getImgStream1();
        FileDownloader fileDownloader1 = new FileDownloader(sr1);
        fileDownloader1.extend(btnImg1Download);

    } catch (Exception e) {

    }
}

From source file:com.gnts.pem.txn.synd.SyndBuilding.java

License:Open Source License

@SuppressWarnings("deprecation")
void populateAndConfig(boolean search) {
    try {/*from w  w  w  .  j a v a  2  s.  c om*/
        tblEvalDetails.removeAllItems();
        tblEvalDetails.setImmediate(true);
        List<TPemCmEvalDetails> evalList = null;
        evalList = new ArrayList<TPemCmEvalDetails>();
        if (search) {
            String evalno = tfSearchEvalNumber.getValue();
            String customer = tfSearchCustomer.getValue();
            String bankbranch = (String) tfSearchBankbranch.getValue();
            evalList = beanEvaluation.getSearchEvalDetailnList(null, evalno, null, customer, bankbranch,
                    selectedBankid, selectCompanyid, null);
        } else {

            evalList = beanEvaluation.getSearchEvalDetailnList(SelectedFormName, null, null, null, null,
                    selectedBankid, selectCompanyid, null);
            total = evalList.size();
        }
        if (total == 0) {
            lblNotificationIcon.setIcon(new ThemeResource("img/msg_info.png"));
            lblSaveNotification.setValue("No Records found");
        } else {
            lblNotificationIcon.setIcon(null);
            lblSaveNotification.setValue("");
        }
        lblNoofRecords.setValue(
                "<font size=\"2\" color=\"black\">No.of Records:</font> <font size=\"2\" color=\"#1E90FF\"> "
                        + total + "</font>");

        beans = new BeanItemContainer<TPemCmEvalDetails>(TPemCmEvalDetails.class);
        beans.addAll(evalList);
        btnEdit.setEnabled(false);
        tblEvalDetails.setContainerDataSource(beans);
        tblEvalDetails.setSelectable(true);
        tblEvalDetails.setColumnFooter("lastUpdateDt", "No. of Records:" + total);
        tblEvalDetails.setVisibleColumns(new Object[] { "evalNo", "docDate", "bankBranch", "custName",
                "docStatus", "lastUpdtedBy", "lastUpdateDt" });
        tblEvalDetails.setColumnHeaders(new String[] { "Evaluation Number", "Evaluation Date", "Bank Branch",
                "Customer Name", "Status", "Last Updated By", "Last Updated Date" });
        tblEvalDetails.addValueChangeListener(new Property.ValueChangeListener() {
            /**
            * 
            */
            private static final long serialVersionUID = 3729824796823933688L;

            @Override
            public void valueChange(ValueChangeEvent event) {

                StreamResource sr = getPDFStream();

                if (sr != null) {

                    if (filedownloader == null) {
                        filedownloader = new FileDownloader(getPDFStream());
                        filedownloader.extend(btnView);
                    } else {
                        filedownloader.setFileDownloadResource(sr);
                    }
                } else {
                    lblNotificationIcon.setIcon(new ThemeResource("img/msg_info.png"));
                    lblSaveNotification.setValue("No document is there");
                    //   notif.show(Page.getCurrent());
                    if (filedownloader != null) {
                        filedownloader.setFileDownloadResource(null); // reset
                    }

                }
                TPemCmEvalDetails syncList = (TPemCmEvalDetails) event.getProperty().getValue();
                if (syncList != null) {

                    if (syncList.getDocStatus().equals("Draft") || syncList.getDocStatus().equals("Rejected")) {
                        btnEdit.setEnabled(true);
                        btnView.setEnabled(false);
                    } else {
                        btnEdit.setEnabled(false);
                        btnView.setEnabled(true);

                    }
                    btnAdd.setEnabled(false);
                } else {
                    btnEdit.setEnabled(false);
                    btnAdd.setEnabled(true);
                }
            }

        });
        tblEvalDetails.setImmediate(true);
        tblEvalDetails.addItemClickListener(new ItemClickListener() {

            @Override
            public void itemClick(ItemClickEvent event) {
                // TODO Auto-generated method stub
                if (tblEvalDetails.isSelected(event.getItemId())) {

                    btnView.setEnabled(false);
                } else {

                    btnView.setEnabled(true);
                }
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
        logger.info("Error-->" + e);
    }
    getExportTableDetails();
}