Example usage for com.vaadin.ui HorizontalLayout setCaption

List of usage examples for com.vaadin.ui HorizontalLayout setCaption

Introduction

In this page you can find the example usage for com.vaadin.ui HorizontalLayout setCaption.

Prototype

@Override
    public void setCaption(String caption) 

Source Link

Usage

From source file:com.save.reports.reimbursement.ReimbursementReportUI.java

private Window filterReport() {
    Window sub = new Window("FILTER REPORT");
    sub.setWidth("400px");
    sub.setModal(true);/*  w  w w . j  a v  a 2s  . c  o m*/
    sub.center();

    FormLayout f = new FormLayout();
    f.setWidth("100%");
    f.setMargin(true);
    f.setSpacing(true);

    CheckBox employeeCheckBox = new CheckBox("Filter by Employee");
    f.addComponent(employeeCheckBox);

    CheckBox amountCheckBox = new CheckBox("Filter by Amount");
    f.addComponent(amountCheckBox);

    CheckBox dateCheckBox = new CheckBox("Filter by Date");
    f.addComponent(dateCheckBox);

    ComboBox employeeComboBox = CommonComboBox.getAllEmpployees(null);
    employeeComboBox.setEnabled(false);
    f.addComponent(employeeComboBox);
    employeeCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> {
        employeeComboBox.setEnabled((boolean) e.getProperty().getValue());
        isEmployee = (boolean) e.getProperty().getValue();
    });

    TextField amountField = new CommonTextField("Amount: ");
    amountField.addStyleName("align-right");
    amountField.setEnabled(false);
    f.addComponent(amountField);
    amountCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> {
        amountField.setEnabled((boolean) e.getProperty().getValue());
        isAmount = (boolean) e.getProperty().getValue();
    });

    HorizontalLayout h = new HorizontalLayout();
    h.setCaption("Date: ");
    h.setWidth("100%");
    h.setSpacing(true);

    DateField from = new DateField();
    from.setWidth("100%");
    from.setEnabled(false);
    h.addComponent(from);

    DateField to = new DateField();
    to.setWidth("100%");
    to.setEnabled(false);
    h.addComponent(to);

    dateCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> {
        from.setEnabled((boolean) e.getProperty().getValue());
        to.setEnabled((boolean) e.getProperty().getValue());
        isDate = (boolean) e.getProperty().getValue();
    });

    f.addComponent(h);

    Button generate = new CommonButton("Generate Report");
    generate.addClickListener((Button.ClickEvent e) -> {
        if (!isEmployee && !isAmount && !isDate) {
            mrDataGrid.setContainerDataSource(new ReimbursementDataContainer());
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isEmployee && !isAmount && !isDate) {
            if (employeeComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(
                    new ReimbursementDataContainer(employeeComboBox.getValue().toString()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (!isEmployee && isAmount && !isDate) {
            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            mrDataGrid.setContainerDataSource(new ReimbursementDataContainer(
                    CommonUtilities.convertStringToDouble(amountField.getValue().trim())));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (!isEmployee && !isAmount && isDate) {
            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(new ReimbursementDataContainer(from.getValue(), to.getValue()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isEmployee && isAmount && !isDate) {
            if (employeeComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            mrDataGrid.setContainerDataSource(
                    new ReimbursementDataContainer(employeeComboBox.getValue().toString(),
                            CommonUtilities.convertStringToDouble(amountField.getValue().trim())));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isEmployee && !isAmount && isDate) {
            if (employeeComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(new ReimbursementDataContainer(
                    employeeComboBox.getValue().toString(), from.getValue(), to.getValue()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (!isEmployee && isAmount && isDate) {
            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(new ReimbursementDataContainer(
                    CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(),
                    to.getValue()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isEmployee && isAmount && isDate) {
            if (employeeComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(
                    new ReimbursementDataContainer(employeeComboBox.getValue().toString(),
                            CommonUtilities.convertStringToDouble(amountField.getValue().trim()),
                            from.getValue(), to.getValue()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        sub.close();
    });
    f.addComponent(generate);

    sub.setContent(f);
    sub.getContent().setHeightUndefined();

    return sub;
}

From source file:com.terralcode.gestion.frontend.view.widgets.appointment.AppointmentView.java

private void buildContactInfo() {
    contactInfo = new ComboBox();
    contactInfo.setContainerDataSource(containerContacts);
    contactInfo.setTextInputAllowed(false);
    contactInfo.setInputPrompt("Seleccione un contacto...");
    contactInfo.setWidth("100%");
    rootLayout.addComponent(contactInfo);

    contactInfoDetails = new Button(FontAwesome.PHONE);
    contactInfoDetails.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    contactInfoDetails.addClickListener(new Button.ClickListener() {
        @Override//w  ww .  jav a  2 s.co m
        public void buttonClick(Button.ClickEvent event) {
            if (appointment.getContactInfo() != null) {
                Notification.show("Funcionalidad en desarrollo.", Notification.Type.ASSISTIVE_NOTIFICATION);
                //customerView.open(appointment.getCustomer());
            }
        }
    });

    HorizontalLayout wrapper = new HorizontalLayout();
    wrapper.setCaption("Contacto");
    wrapper.addComponent(contactInfo);
    wrapper.addComponent(contactInfoDetails);
    wrapper.setWidth("100%");
    wrapper.setExpandRatio(contactInfo, 1);
    rootLayout.addComponent(wrapper);
}

From source file:com.terralcode.gestion.frontend.view.widgets.appointment.AppointmentView.java

private void buildAddress() {
    address = new ComboBox();
    address.setContainerDataSource(containerAddresses);
    address.setTextInputAllowed(false);//w w w . ja va  2  s . c om
    address.setInputPrompt("Seleccione una direccin...");
    address.setWidth("100%");
    rootLayout.addComponent(address);

    addressDetails = new Button(FontAwesome.MAP_MARKER);
    addressDetails.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    addressDetails.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (appointment.getAddress() != null) {
                Notification.show("Funcionalidad en desarrollo.", Notification.Type.ASSISTIVE_NOTIFICATION);
                //customerView.open(appointment.getCustomer());
            }
        }
    });

    HorizontalLayout wrapper = new HorizontalLayout();
    wrapper.setCaption("Direccin");
    wrapper.addComponent(address);
    wrapper.addComponent(addressDetails);
    wrapper.setWidth("100%");
    wrapper.setExpandRatio(address, 1);
    rootLayout.addComponent(wrapper);
}

From source file:com.terralcode.gestion.frontend.view.widgets.appointment.AppointmentView.java

private void buildCustomer() {
    customer = new ComboBox();
    customer.setContainerDataSource(containerCustomers);
    customer.setFilteringMode(FilteringMode.CONTAINS);
    customer.setInputPrompt("Seleccione un cliente...");
    customer.setWidth("100%");
    //<editor-fold defaultstate="collapsed" desc="Adjust ContactInfo and Addresses according to the selected Customer">
    customer.addValueChangeListener(new ValueChangeListener() {

        @Override//ww  w . j a va2 s  . c  om
        public void valueChange(Property.ValueChangeEvent event) {
            updateCustomerCombos((CustomerCRM) event.getProperty().getValue());
        }

        private void updateCustomerCombos(CustomerCRM customerCRM) {
            if (customerCRM != null) {
                containerAddresses.removeAllItems();
                address.setValue(null);
                containerAddresses.addAll(customerCRMService.find(customerCRM.getId()).getAddressList());
                if (containerAddresses.size() > 0) {
                    address.select(containerAddresses.getIdByIndex(0));
                }

                containerContacts.removeAllItems();
                contactInfo.setValue(null);
                containerContacts.addAll(customerCRMService.find(customerCRM.getId()).getContactInfoList());
                if (containerContacts.size() > 0) {
                    contactInfo.select(containerContacts.getIdByIndex(0));
                }
            } else {
                containerAddresses.removeAllItems();
                address.setValue(null);

                containerContacts.removeAllItems();
                contactInfo.setValue(null);
            }
        }
    });
    //</editor-fold>

    customerDetails = new Button(FontAwesome.EYE);
    customerDetails.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    customerDetails.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (appointment.getCustomer() != null) {
                customerView.open(appointment.getCustomer());
            }
        }
    });

    HorizontalLayout customerWrapper = new HorizontalLayout();
    customerWrapper.setCaption("Cliente");
    customerWrapper.addComponent(customer);
    customerWrapper.addComponent(customerDetails);
    customerWrapper.setWidth("100%");
    customerWrapper.setExpandRatio(customer, 1);
    rootLayout.addComponent(customerWrapper);

    //<editor-fold defaultstate="collapsed" desc="Antiguo buscador de clientes">
    //        Button searchCustomerBtn = new Button("Busca!");
    //        searchCustomerBtn.addClickListener(new Button.ClickListener() {
    //
    //            @Override
    //            public void buttonClick(Button.ClickEvent event) {
    //                CustomerFinderDialogWindow dlgWin = new CustomerFinderDialogWindow(appointment.getCustomer(), customerCRMService){
    //
    //                    @Override
    //                    protected void onButtonCancelClicked() {
    //                        this.close();
    //                    }
    //
    //                    @Override
    //                    protected void onButtonOKClicked() {
    //                        //appointment.setCustomer(this.getSelectedCustomer());
    //                        customer.setValue(this.getSelectedCustomer());
    //                        //updateCustomerCombos(appointment.getCustomer());
    //                        this.close();
    //                    }
    //
    //
    //
    //                };
    //                UI.getCurrent().addWindow(dlgWin);
    //                dlgWin.focus();
    //            }
    //        });
    //        rootLayout.addComponent(searchCustomerBtn);
    //</editor-fold>    
}

From source file:com.terralcode.gestion.frontend.view.widgets.appointment.AppointmentView.java

private void buildAppointmentStatus() {
    Label section = new Label("Estado");
    section.addStyleName(ValoTheme.LABEL_H4);
    section.addStyleName(ValoTheme.LABEL_COLORED);
    rootLayout.addComponent(section);//from  w  ww. j av a  2  s .c o m

    status = new ComboBox();
    status.setContainerDataSource(containerStatuses);
    status.setWidth("100%");
    status.setTextInputAllowed(false);
    status.setNullSelectionAllowed(false);

    notifyChanges = new CheckBox();
    notifyChanges.setIcon(FontAwesome.BELL);
    notifyChanges.setImmediate(true);

    HorizontalLayout statusWrapper = new HorizontalLayout();
    statusWrapper.setCaption("Estado");
    statusWrapper.addComponent(status);
    statusWrapper.addComponent(notifyChanges);
    statusWrapper.setWidth("100%");
    statusWrapper.setExpandRatio(status, 1);
    rootLayout.addComponent(statusWrapper);

    statusNotes = new TextArea("Notas de estado");
    statusNotes.setWidth("100%");
    statusNotes.setInputPrompt("Anotaciones del estado...");
    rootLayout.addComponent(statusNotes);
}

From source file:com.zklogtool.web.components.OpenSnapshotFileDialog.java

License:Apache License

public OpenSnapshotFileDialog(final TabSheet displayTabSheet, final Window windowHandle) {

    buildMainLayout();/*w  ww. ja  v  a2 s.  c o  m*/
    setCompositionRoot(mainLayout);

    openButton.addClickListener(new ClickListener() {

        DataState dataState;

        @Override
        public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {

            File snapshot = new File(snapshotFileLabel.getValue());

            SnapshotFileReader snapReader = new SnapshotFileReader(snapshot, 0);

            SnapshotView snapshotView;

            if (!validateInputs()) {
                return;
            }

            try {

                dataState = snapReader.readFuzzySnapshot();

                snapshotView = new SnapshotView(dataState);

            } catch (CRCValidationException e) {

                snapshotFileLabel
                        .setComponentError(new UserError("CRC validation problem. File is probably corrupted"));
                return;

            } catch (IOException e) {

                snapshotFileLabel.setComponentError(new UserError("IO problem with file"));
                return;

            }

            HorizontalLayout horizontalLayout = new HorizontalLayout();
            horizontalLayout.setCaption(tabNameLabel.getValue());
            horizontalLayout.addComponent(snapshotView);
            horizontalLayout.setWidth("100%");
            horizontalLayout.setHeight("100%");
            Tab snapshotTab = displayTabSheet.addTab(horizontalLayout);
            snapshotTab.setClosable(true);
            displayTabSheet.setSelectedTab(snapshotTab);

            windowHandle.close();

        }

    });

}

From source file:com.zklogtool.web.components.OpenTransactionLogFileDialog.java

License:Apache License

public OpenTransactionLogFileDialog(final TabSheet displayTabSheet, final Window windowHandle) {
    buildMainLayout();//from w ww .j a  v  a2  s  . c om
    setCompositionRoot(mainLayout);

    openButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {

            File transactionLogFile = new File(transactionLogFileLabel.getValue());
            File snapshotDir = new File(snapshotDirectoryLabel.getValue());

            if (!transactionLogFile.isFile() && !transactionLogFile.isDirectory()) {

                transactionLogFileLabel.setComponentError(new UserError("IO problem"));
                return;

            }

            if (snapshotDirectoryLabel.getValue() != null && !snapshotDirectoryLabel.getValue().isEmpty()
                    && !snapshotDir.isDirectory()) {

                snapshotDirectoryLabel.setComponentError(new UserError("IO problem"));
                return;

            }

            TransactionLogView transactionLogView = new TransactionLogView(transactionLogFile, snapshotDir,
                    followCheckbox.getValue(), startFromLastCheckbox.getValue(), displayTabSheet,
                    nameLabel.getValue());

            HorizontalLayout horizontalLayout = new HorizontalLayout();
            horizontalLayout.setCaption(nameLabel.getValue());
            horizontalLayout.addComponent(transactionLogView);
            horizontalLayout.setWidth("100%");
            horizontalLayout.setHeight("100%");
            Tab transactionLogTab = displayTabSheet.addTab(horizontalLayout);
            transactionLogTab.setClosable(true);
            displayTabSheet.setSelectedTab(transactionLogTab);

            windowHandle.close();

        }

    });

}

From source file:com.zklogtool.web.components.TransactionLogView.java

License:Apache License

public TransactionLogView(final File transactionLogFile, final File snapshotDir, final boolean follow,
        final boolean startFromLast, final TabSheet displayTabSheet, final String name) {
    buildMainLayout();//from w w w .  ja  va 2 s.c om
    setCompositionRoot(mainLayout);

    descriptionLabel.setContentMode(ContentMode.PREFORMATTED);

    final Container container = new IndexedContainer();
    container.addContainerProperty("zxid", String.class, 0);
    container.addContainerProperty("cxid", String.class, 0);
    container.addContainerProperty("client id", String.class, 0);
    //container.addContainerProperty("time", Date.class, 0);
    container.addContainerProperty("operation", ZkOperations.class, "");
    container.addContainerProperty("path", String.class, "");

    reconstructDataTreeButton.setVisible(false);
    filterTable.setContainerDataSource(container);
    filterTable.setFilterBarVisible(true);
    filterTable.setFilterDecorator(new TransactionFilterDecoder());
    filterTable.setSelectable(true);
    filterTable.setImmediate(true);

    final TransactionLog transactionLog;
    final Iterator<Transaction> iterator;
    final Map<String, Transaction> transactionMap = new HashMap<String, Transaction>();

    filterTable.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {

            if (filterTable.getValue() == null)
                return;

            StringBuilder description = new StringBuilder();

            TransactionPrinter printer = new TransactionPrinter(description, new UnicodeDecoder());

            printer.print(transactionMap.get("0x" + filterTable.getValue().toString()));

            descriptionLabel.setValue(description.toString());

            if (snapshotDir != null && transactionLogFile.isDirectory()) {

                reconstructDataTreeButton.setVisible(true);

            }

        }
    });

    if (transactionLogFile.isFile()) {

        transactionLog = new TransactionLog(transactionLogFile, new TransactionLogReaderFactory());
    } else {

        transactionLog = new TransactionLog(new DataDirTransactionLogFileList(transactionLogFile),
                new TransactionLogReaderFactory());
    }

    iterator = transactionLog.iterator();

    if (startFromLast) {

        while (iterator.hasNext()) {

            iterator.next();
        }
    }

    final Runnable fillData = new Runnable() {

        @Override
        public void run() {
            // TODO Auto-generated method stub

            while (iterator.hasNext()) {

                Transaction t = iterator.next();

                transactionMap.put(Util.longToHexString(t.getTxnHeader().getZxid()), t);

                Item item = container.addItem(Long.toHexString(t.getTxnHeader().getZxid()));
                item.getItemProperty("zxid").setValue(Util.longToHexString(t.getTxnHeader().getZxid()));

                item.getItemProperty("cxid").setValue(Util.longToHexString(t.getTxnHeader().getCxid()));

                item.getItemProperty("client id")
                        .setValue(Util.longToHexString(t.getTxnHeader().getClientId()));

                /*item.getItemProperty("time").setValue(
                 new Date(t.getTxnHeader().getTime()));*/
                switch (t.getTxnHeader().getType()) {

                case OpCode.create:
                    CreateTxn createTxn = (CreateTxn) t.getTxnRecord();
                    item.getItemProperty("operation").setValue(ZkOperations.CREATE);
                    item.getItemProperty("path").setValue(createTxn.getPath());
                    break;

                case OpCode.delete:
                    DeleteTxn deleteTxn = (DeleteTxn) t.getTxnRecord();
                    item.getItemProperty("operation").setValue(ZkOperations.DELTE);
                    item.getItemProperty("path").setValue(deleteTxn.getPath());
                    break;

                case OpCode.setData:
                    SetDataTxn setDataTxn = (SetDataTxn) t.getTxnRecord();
                    item.getItemProperty("operation").setValue(ZkOperations.SET_DATA);
                    item.getItemProperty("path").setValue(setDataTxn.getPath());
                    break;

                case OpCode.setACL:
                    SetACLTxn setACLTxn = (SetACLTxn) t.getTxnRecord();
                    item.getItemProperty("operation").setValue(ZkOperations.SET_ACL);
                    item.getItemProperty("path").setValue(setACLTxn.getPath());
                    break;

                case OpCode.check:
                    CheckVersionTxn checkVersionTxn = (CheckVersionTxn) t.getTxnRecord();
                    item.getItemProperty("operation").setValue(ZkOperations.CHECK);
                    item.getItemProperty("path").setValue(checkVersionTxn.getPath());
                    break;

                case OpCode.multi:
                    item.getItemProperty("operation").setValue(ZkOperations.MULTI);
                    break;

                case OpCode.createSession:
                    item.getItemProperty("operation").setValue(ZkOperations.CREATE_SESSION);
                    break;

                case OpCode.closeSession:
                    item.getItemProperty("operation").setValue(ZkOperations.CLOSE_SESSION);
                    break;

                case OpCode.error:
                    item.getItemProperty("operation").setValue(ZkOperations.ERROR);
                    break;

                }

            }
        }

    };

    fillData.run();

    Thread monitorThread = new Thread(new Runnable() {

        @Override
        public void run() {

            while (true) {
                //push UI
                UI.getCurrent().access(fillData);

                try {
                    Thread.sleep(250);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }

    });

    if (follow) {
        monitorThread.start();

    }

    reconstructDataTreeButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {

            DataDirHelper dataDirHelper = new DataDirHelper(transactionLogFile, snapshotDir);
            List<File> snapshots = dataDirHelper.getSortedSnapshotList();
            DataDirTransactionLogFileList l = new DataDirTransactionLogFileList(transactionLogFile);
            TransactionLog transactionLog = new TransactionLog(l, new TransactionLogReaderFactory());

            File snapFile = null;
            DataState dataState = null;

            long currentZxid = Long.parseLong(filterTable.getValue().toString(), 16);

            int i = snapshots.size() - 1;
            while (i >= 0) {

                long snapZxid = Util.getZxidFromName(snapshots.get(i).getName());

                if (snapZxid <= currentZxid) {

                    if (i == 0) {
                        snapFile = snapshots.get(0);
                    } else {
                        snapFile = snapshots.get(i - 1);
                    }

                    break;

                }

                i--;

            }

            if (snapFile == null) {
                dispalyNotEnoughDataErrorMessage();
                return;
            }

            long TS = Util.getZxidFromName(snapFile.getName());

            //catch this exception and print error
            SnapshotFileReader snapReader = new SnapshotFileReader(snapFile, TS);

            try {
                dataState = snapReader.restoreDataState(transactionLog.iterator());
            } catch (Exception ex) {
                //dispay error dialog
                //not enough information
                dispalyNotEnoughDataErrorMessage();
                return;
            }

            //set iterator to last zxid
            TransactionIterator iterator = transactionLog.iterator();
            Transaction t;

            do {

                t = iterator.next();

            } while (t.getTxnHeader().getZxid() < TS);

            while (iterator.nextTransactionState() == TransactionState.OK
                    && dataState.getLastZxid() < currentZxid) {
                dataState.processTransaction(iterator.next());
            }

            HorizontalLayout horizontalLayout = new HorizontalLayout();
            horizontalLayout.setCaption(name + " at zxid 0x" + Long.toString(currentZxid, 16));
            horizontalLayout.addComponent(new SnapshotView(dataState));
            horizontalLayout.setWidth("100%");
            horizontalLayout.setHeight("100%");
            Tab snapshotTab = displayTabSheet.addTab(horizontalLayout);
            snapshotTab.setClosable(true);
            displayTabSheet.setSelectedTab(snapshotTab);

        }

        void dispalyNotEnoughDataErrorMessage() {

            final Window window = new Window("Error");
            window.setModal(true);

            final VerticalLayout verticalLayout = new VerticalLayout();
            verticalLayout.setMargin(true);
            verticalLayout.addComponent(new Label("Not enough data to reconstruct data tree"));

            window.setContent(verticalLayout);
            UI.getCurrent().addWindow(window);

        }

    });

}

From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultRowEditingFormView.java

License:Apache License

private void addFieldToLayout(Field<?> field) {
    if (field instanceof CheckBox) {
        HorizontalLayout checkboxLayout = new HorizontalLayout();
        checkboxLayout.setCaption(field.getCaption());
        field.setCaption(null);//from w w w.ja v  a 2s .  c  o  m
        checkboxLayout.addComponent(field);

        fieldLayout.addComponent(checkboxLayout);
    } else {
        fieldLayout.addComponent(field);
    }
}

From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultRowEditingFormView.java

License:Apache License

@Override
public void addBlobField(ContainerRow row, TableColumn tableColumn, final ContainerBlob containerBlob,
        boolean readonly) {

    HorizontalLayout blobField = new HorizontalLayout();
    if (tableColumn.getTitle() != null) {
        blobField.setCaption(tableColumn.getTitle());
    } else {/*from  w  w w .ja v  a2s.c om*/
        blobField.setCaption(tableColumn.getName());
    }

    blobField.setSpacing(true);

    final FileMetadata metadata = tableColumn.getFileMetadata();
    Assert.notNull(metadata, "Missing file metadata for field '" + tableColumn.getName() + "'");

    Link downloadLink = new Link();
    downloadLink.setVisible(false);
    blobField.addComponent(downloadLink);
    blobField.setComponentAlignment(downloadLink, Alignment.MIDDLE_LEFT);

    updateDownloadLink(row, containerBlob, metadata, downloadLink);

    if (!readonly) {
        Upload upload = buildUpload(row, containerBlob, metadata, downloadLink);
        blobField.addComponent(upload);
    }
    fieldLayout.addComponent(blobField);
}