Example usage for com.vaadin.ui CheckBox getValue

List of usage examples for com.vaadin.ui CheckBox getValue

Introduction

In this page you can find the example usage for com.vaadin.ui CheckBox getValue.

Prototype

@Override
    public Boolean getValue() 

Source Link

Usage

From source file:jp.primecloud.auto.ui.ServiceButtonsTop.java

License:Open Source License

private void stopAllButtonClick(ClickEvent event) {
    // ?/* ww  w.  ja v a  2 s.c o  m*/
    HorizontalLayout optionLayout = new HorizontalLayout();
    final CheckBox checkBox = new CheckBox(ViewMessages.getMessage("IUI-000033"), false);
    checkBox.setImmediate(true);
    optionLayout.addComponent(checkBox);

    // ?
    String message = ViewMessages.getMessage("IUI-000010");
    DialogConfirm dialog = new DialogConfirm(ViewProperties.getCaption("dialog.confirm"), message,
            Buttons.OKCancelConfirm, optionLayout);
    dialog.setCallback(new DialogConfirm.Callback() {
        @Override
        public void onDialogResult(Result result) {
            if (result != Result.OK) {
                return;
            }

            boolean stopInstance = (Boolean) checkBox.getValue();
            stopAll(stopInstance);
        }
    });
    getApplication().getMainWindow().addWindow(dialog);
}

From source file:jp.primecloud.auto.ui.ServiceTable.java

License:Open Source License

public void stopButtonClick(Button.ClickEvent event) {
    final ComponentDto dto = (ComponentDto) this.getValue();
    final int index = this.getCurrentPageFirstItemIndex();

    HorizontalLayout optionLayout = new HorizontalLayout();
    final CheckBox checkBox = new CheckBox(ViewMessages.getMessage("IUI-000033"), false);
    checkBox.setImmediate(true);// w  ww .  j  a  va 2s .  c om
    optionLayout.addComponent(checkBox);

    String message = ViewMessages.getMessage("IUI-000017", dto.getComponent().getComponentName());
    DialogConfirm dialog = new DialogConfirm(ViewProperties.getCaption("dialog.confirm"), message,
            Buttons.OKCancel, optionLayout);
    dialog.setCallback(new DialogConfirm.Callback() {
        @Override
        public void onDialogResult(Result result) {
            if (result != Result.OK) {
                return;
            }
            ProcessService processService = BeanContext.getBean(ProcessService.class);
            Long farmNo = ViewContext.getFarmNo();
            List<Long> list = new ArrayList<Long>();
            list.add(dto.getComponent().getComponentNo());
            boolean stopInstance = (Boolean) checkBox.getValue();
            processService.stopComponents(farmNo, list, stopInstance);
            sender.refreshTable();

            // ????????
            for (Object itemId : getItemIds()) {
                ComponentDto dto2 = (ComponentDto) itemId;
                if (dto.getComponent().getComponentNo().equals(dto2.getComponent().getComponentNo())) {
                    select(itemId);
                    setCurrentPageFirstItemIndex(index);
                    setButtonStatus(dto2);
                    break;
                }
            }
        }
    });
    getApplication().getMainWindow().addWindow(dialog);
}

From source file:life.qbic.components.PackageManagerTab.java

License:Open Source License

/**
 * adds the automatic price calculation to the grid
 * @param calculatePricesAutomatically: checkbox whether the prices should be automatically calculated or not
 * @param container: sql container for getting the currently selected row
 * @param packageGrid: grid showing the packages
 *///from  w w  w  .j a v a  2  s . com
private static void addAutomaticPriceCalculation(CheckBox calculatePricesAutomatically, SQLContainer container,
        RefreshableGrid packageGrid) {

    // TODO: make this more efficient + not a workaround any more
    // add the automatic price calculation for the external academic and external commercial prices to the package.
    // Since vaadin doesn't provide a proper ValueChangeListener for the grid, we have to do it this way..
    // Note: this recalculates the prices whenever some package has been edited by the user, which is pretty bad,
    // but I couldn't find a better way (a ValueChangeListener for the editor field of the internal_price column did
    // work even worse, so I decided to stick with this..).
    packageGrid.getEditorFieldGroup().addCommitHandler(new FieldGroup.CommitHandler() {
        @Override
        public void preCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException {

        }

        @Override
        public void postCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException {

            if (calculatePricesAutomatically.getValue()) {

                // Get the internal package price from the selected row in the grid
                Object selected = ((Grid.SingleSelectionModel) packageGrid.getSelectionModel())
                        .getSelectedRow();
                if (selected == null) {
                    displayNotification("Price could not be automatically calculated", "Vaadin couldn't get "
                            + "the selected row, so the external prices have NOT been automatically calculated. If you wanted to "
                            + "update the prices, please select the row via left click and then try shift + enter to open the edit "
                            + "menu. Unfortunately this seems to be a little buggy..", "warning");
                    return;
                }
                Item selectedRow = container.getItem(selected);
                String packagePriceInternalString = selectedRow.getItemProperty("package_price_internal")
                        .getValue().toString();

                // get the internal price as BigDecimal to deal with floating point issues
                BigDecimal packagePriceInternal = new BigDecimal(packagePriceInternalString);

                // check if we have a package group for the current package
                Object packageGroupObject = selectedRow.getItemProperty("package_group").getValue();
                if (packageGroupObject == null) {
                    displayNotification("No package group", "Package has no package group associated with it. "
                            + "Thus an automatic calculation of the external packages is NOT possible. Please update the package group"
                            + "or disable the Auto-calculate external prices checkbox.", "warning");
                    return;
                }

                String packageGroup = packageGroupObject.toString();

                // based on the package group we have differnet price modifiers:
                Float packagePriceExternalAcademic;
                Float packagePriceExternalCommercial;
                switch (packageGroup) {
                case "Bioinformatics Analysis":
                case "Project Management":
                    // recalculate the two external prices (*1.3 and *2.0)
                    packagePriceExternalAcademic = packagePriceInternal.multiply(externalAcademicPriceModifier)
                            .floatValue();
                    packagePriceExternalCommercial = packagePriceInternal
                            .multiply(externalCommercialPriceModifier).floatValue();
                    break;
                case "Sequencing":
                case "Mass spectrometry":
                    // recalculate the two external prices (*1.1)
                    packagePriceExternalAcademic = packagePriceInternal.multiply(externalPriceModifier)
                            .floatValue();
                    packagePriceExternalCommercial = packagePriceInternal.multiply(externalPriceModifier)
                            .floatValue();
                    break;
                default: // package group is "Other"
                    displayNotification("Wrong package group", "Package has package group \"Other\" "
                            + "associated with it. Thus an automatic calculation of the external packages is NOT possible. "
                            + "Please change the package group or disable the Auto-calculate external prices checkbox.",
                            "warning");
                    return;
                }

                // set the respective fields in the grid, which also updates the database
                selectedRow.getItemProperty("package_price_external_academic")
                        .setValue(packagePriceExternalAcademic);
                selectedRow.getItemProperty("package_price_external_commercial")
                        .setValue(packagePriceExternalCommercial);
            }
        }
    });
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.ValidationManagerUI.java

License:Apache License

private void createRequirementSpecNodeMenu(ContextMenu menu) {
    MenuItem create = menu.addItem(TRANSLATOR.translate("create.requiremnet"), VaadinIcons.PLUS,
            (MenuItem selectedItem) -> {
                Requirement r = new Requirement();
                r.setRequirementSpecNode((RequirementSpecNode) tree.getValue());
                displayRequirement(r, true);
            });//from ww  w .ja  va 2 s . c o m
    create.setEnabled(checkRight("requirement.modify"));
    MenuItem edit = menu.addItem(TRANSLATOR.translate("edit.req.spec.node"), EDIT_ICON,
            (MenuItem selectedItem) -> {
                displayRequirementSpecNode((RequirementSpecNode) tree.getValue(), true);
            });
    edit.setEnabled(checkRight("requirement.modify"));
    MenuItem importRequirement = menu.addItem(TRANSLATOR.translate("import.requirement"), IMPORT_ICON,
            (MenuItem selectedItem) -> {// Create a sub-window and set the content
                Window subWindow = new VMWindow(TRANSLATOR.translate("import.requirement"));
                VerticalLayout subContent = new VerticalLayout();
                subWindow.setContent(subContent);

                //Add a checkbox to know if file has headers or not
                CheckBox cb = new CheckBox(TRANSLATOR.translate("file.has.header"));

                FileUploader receiver = new FileUploader();
                Upload upload = new Upload(TRANSLATOR.translate("upload.excel"), receiver);
                upload.addSucceededListener((Upload.SucceededEvent event1) -> {
                    try {
                        subWindow.close();
                        //TODO: Display the excel file (partially), map columns and import
                        //Process the file
                        RequirementImporter importer = new RequirementImporter(receiver.getFile(),
                                (RequirementSpecNode) tree.getValue());

                        importer.importFile(cb.getValue());
                        importer.processImport();
                        buildProjectTree(tree.getValue());
                        updateScreen();
                    } catch (RequirementImportException ex) {
                        LOG.log(Level.SEVERE, TRANSLATOR.translate("import.error"), ex);
                        Notification.show(TRANSLATOR.translate("import.unsuccessful"),
                                Notification.Type.ERROR_MESSAGE);
                    } catch (VMException ex) {
                        LOG.log(Level.SEVERE, null, ex);
                    }
                });
                upload.addFailedListener((Upload.FailedEvent event1) -> {
                    LOG.log(Level.SEVERE, "Upload unsuccessful!\n{0}", event1.getReason());
                    Notification.show(TRANSLATOR.translate("upload.unsuccessful"),
                            Notification.Type.ERROR_MESSAGE);
                    subWindow.close();
                });
                subContent.addComponent(cb);
                subContent.addComponent(upload);
                // Open it in the UI
                addWindow(subWindow);
            });
    importRequirement.setEnabled(checkRight("requirement.modify"));
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.ValidationManagerUI.java

License:Apache License

private void createTestCaseMenu(ContextMenu menu) {
    MenuItem create = menu.addItem(TRANSLATOR.translate("create.step"), VaadinIcons.PLUS,
            (MenuItem selectedItem) -> {
                TestCase tc = (TestCase) tree.getValue();
                Step s = new Step();
                s.setStepSequence(tc.getStepList().size() + 1);
                s.setTestCase(tc);/* w w  w.j a v  a  2s .c  om*/
                displayStep(s, true);
            });
    create.setEnabled(checkRight("requirement.modify"));
    MenuItem edit = menu.addItem(TRANSLATOR.translate("edit.test.case"), EDIT_ICON, (MenuItem selectedItem) -> {
        displayTestCase((TestCase) tree.getValue(), true);
    });
    edit.setEnabled(checkRight("testcase.modify"));
    MenuItem importSteps = menu.addItem(TRANSLATOR.translate("import.step"), IMPORT_ICON,
            (MenuItem selectedItem) -> { // Create a sub-window and set the content
                Window subWindow = new VMWindow(TRANSLATOR.translate("import.test.case.step"));
                VerticalLayout subContent = new VerticalLayout();
                subWindow.setContent(subContent);

                //Add a checkbox to know if file has headers or not
                CheckBox cb = new CheckBox(TRANSLATOR.translate("file.has.header"));

                FileUploader receiver = new FileUploader();
                Upload upload = new Upload(TRANSLATOR.translate("upload.excel"), receiver);
                upload.addSucceededListener((Upload.SucceededEvent event1) -> {
                    try {
                        subWindow.close();
                        //TODO: Display the excel file (partially), map columns and import
                        //Process the file
                        TestCase tc = (TestCase) tree.getValue();
                        StepImporter importer = new StepImporter(receiver.getFile(), tc);
                        importer.importFile(cb.getValue());
                        importer.processImport();
                        SortedMap<Integer, Step> map = new TreeMap<>();
                        tc.getStepList().forEach((s) -> {
                            map.put(s.getStepSequence(), s);
                        });
                        //Now update the sequence numbers
                        int count = 0;
                        for (Entry<Integer, Step> entry : map.entrySet()) {
                            entry.getValue().setStepSequence(++count);
                            try {
                                new StepJpaController(DataBaseManager.getEntityManagerFactory())
                                        .edit(entry.getValue());
                            } catch (Exception ex) {
                                LOG.log(Level.SEVERE, null, ex);
                            }
                        }
                        buildProjectTree(new TestCaseServer(tc.getTestCasePK()).getEntity());
                        updateScreen();
                    } catch (TestCaseImportException ex) {
                        LOG.log(Level.SEVERE, TRANSLATOR.translate("import.error"), ex);
                        Notification.show(TRANSLATOR.translate("import.unsuccessful"),
                                Notification.Type.ERROR_MESSAGE);
                    }
                });
                upload.addFailedListener((Upload.FailedEvent event1) -> {
                    LOG.log(Level.SEVERE, "Upload unsuccessful!\n{0}", event1.getReason());
                    Notification.show(TRANSLATOR.translate("upload.unsuccessful"),
                            Notification.Type.ERROR_MESSAGE);
                    subWindow.close();
                });
                subContent.addComponent(cb);
                subContent.addComponent(upload);
                // Open it in the UI
                addWindow(subWindow);
            });
    importSteps.setEnabled(checkRight("requirement.modify"));
    MenuItem export = menu.addItem(TRANSLATOR.translate("general.export"), VaadinIcons.DOWNLOAD,
            (MenuItem selectedItem) -> {
                TestCase tc = (TestCase) tree.getValue();
                UI.getCurrent().addWindow(TestCaseExporter.getTestCaseExporter(Arrays.asList(tc)));
            });
    export.setEnabled(checkRight("testcase.view"));
    addExecutionDashboard(menu);
}

From source file:org.activiti.explorer.ui.profile.AccountSelectionPopup.java

License:Apache License

protected void initImapComponent() {
    imapForm = new Form();
    imapForm.setDescription(i18nManager.getMessage(Messages.IMAP_DESCRIPTION));

    final TextField imapServer = new TextField(i18nManager.getMessage(Messages.IMAP_SERVER));
    imapForm.getLayout().addComponent(imapServer);

    final TextField imapPort = new TextField(i18nManager.getMessage(Messages.IMAP_PORT));
    imapPort.setWidth(30, UNITS_PIXELS);
    imapPort.setValue(143); // Default imap port (non-ssl)
    imapForm.getLayout().addComponent(imapPort);

    final CheckBox useSSL = new CheckBox(i18nManager.getMessage(Messages.IMAP_SSL));
    useSSL.setValue(false);// www  .ja  v  a2 s  .  c o m
    useSSL.setImmediate(true);
    imapForm.getLayout().addComponent(useSSL);
    useSSL.addListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            imapPort.setValue(((Boolean) useSSL.getValue()) ? 993 : 143);
        }
    });

    final TextField imapUserName = new TextField(i18nManager.getMessage(Messages.IMAP_USERNAME));
    imapForm.getLayout().addComponent(imapUserName);

    final PasswordField imapPassword = new PasswordField(i18nManager.getMessage(Messages.IMAP_PASSWORD));
    imapForm.getLayout().addComponent(imapPassword);

    // Matching listener
    imapClickListener = new ClickListener() {
        public void buttonClick(ClickEvent event) {
            Map<String, Object> accountDetails = createAccountDetails("imap",
                    imapUserName.getValue().toString(), imapPassword.getValue().toString(), "server",
                    imapServer.getValue().toString(), "port", imapPort.getValue().toString(), "ssl",
                    imapPort.getValue().toString());
            fireEvent(new SubmitEvent(AccountSelectionPopup.this, SubmitEvent.SUBMITTED, accountDetails));
        }
    };
}

From source file:org.asi.ui.customcomponentdemo.demo.ExtFilteringTableDemo.java

private VerticalLayout loadPagedFilterTable() {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);/*w ww  .  j  a  va 2  s.  c  om*/
    layout.setSpacing(true);
    final ExtPagedFilterTable<IndexedContainer> pagedFilterTable = new ExtPagedFilterTable<IndexedContainer>();
    pagedFilterTable.setCaption("ExtPagedFilterTable");
    pagedFilterTable.setWidth("100%");
    pagedFilterTable.setFilterBarVisible(true);

    pagedFilterTable.setSelectable(true);
    pagedFilterTable.setImmediate(true);
    pagedFilterTable.setMultiSelect(true);
    pagedFilterTable.setPageLength(5);
    pagedFilterTable.setRowHeaderMode(RowHeaderMode.INDEX);

    pagedFilterTable.setColumnReorderingAllowed(true);

    pagedFilterTable.setContainerDataSource(phasedProjectionBean);

    pagedFilterTable.setVisibleColumns(Utils.viscolumnmore);
    pagedFilterTable.setColumnHeaders(Utils.visheadermore);
    pagedFilterTable.setDoubleHeaderVisible(true);
    pagedFilterTable.sinkItemPerPageWithPageLength(false);
    pagedFilterTable.setDoubleHeaderVisibleColumns(Utils.dviscolumnmore);
    pagedFilterTable.setDoubleHeaderColumnHeaders(Utils.dvisheadermore);
    pagedFilterTable.setDoubleHeaderMap(dMapVisibleColumnsMore);
    pagedFilterTable.setColumnIcon(Utils.viscolumnmore[3], Utils.logoimg);
    pagedFilterTable.setColumnCheckBox(Utils.viscolumnmore[2], true, true);
    pagedFilterTable.addColumnResizeListener(new ExtCustomTable.ColumnResizeListener() {

        @Override
        public void columnResize(ExtCustomTable.ColumnResizeEvent event) {
            Notification.show("Pro:" + event.getPropertyId() + "\n Pre:" + event.getPreviousWidth() + "\n Cur: "
                    + event.getCurrentWidth());
        }
    });
    pagedFilterTable.addDoubleHeaderColumnResizeListener(new ExtCustomTable.DoubleHeaderColumnResizeListener() {

        @Override
        public void doubleHeaderColumnResize(ExtCustomTable.DoubleHeaderColumnResizeEvent event) {
            Notification.show("Pro:" + event.getPropertyId() + "\n Pre:" + event.getPreviousWidth() + "\n Cur: "
                    + event.getCurrentWidth());
        }

    });
    pagedFilterTable.setEditable(true);
    pagedFilterTable.setImmediate(true);
    pagedFilterTable.setTableFieldFactory(new DefaultFieldFactory() {

        @Override
        public Field<?> createField(Container container, Object itemId, Object propertyId,
                Component uiContext) {
            if (propertyId.equals(Utils.viscolumnmore[2])) {
                TextField ob = new TextField();
                ob.setImmediate(true);
                return ob;
            }
            return null;
        }
    });
    layout.addComponent(pagedFilterTable);
    layout.addComponent(pagedFilterTable.createControls());
    final CheckBox sink = new CheckBox("Sink ItemPerPage With PageLength");
    sink.setImmediate(true);
    layout.addComponent(sink);
    sink.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            pagedFilterTable.sinkItemPerPageWithPageLength(sink.getValue());
        }
    });
    return layout;
}

From source file:org.asi.ui.customcomponentdemo.demo.ExtFilteringTableDemo.java

private VerticalLayout loadFreezePagedFilterTable() {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);//  www. j  a v a 2s .c o  m
    layout.setSpacing(true);
    final FreezePagedFilterTable<IndexedContainer> pagedFreezeFilterTable = new FreezePagedFilterTable<IndexedContainer>();

    pagedFreezeFilterTable.setCaption("FreezePagedFilterTable");
    pagedFreezeFilterTable.setSplitPosition(Utils.splitPosition, Unit.PIXELS);
    pagedFreezeFilterTable.setMinSplitPosition(Utils.minSplitPosition, Unit.PIXELS);
    pagedFreezeFilterTable.setMaxSplitPosition(Utils.maxSplitPosition, Unit.PIXELS);
    pagedFreezeFilterTable.setContainerDataSource(phasedProjectionBean);
    pagedFreezeFilterTable.setPageLength(6);

    //        pagedFilterTable.setHeight("210px");
    pagedFreezeFilterTable.setSelectable(true);
    final ExtPagedFilterTable leftTable = pagedFreezeFilterTable.getLeftFreezeAsTable();
    final ExtPagedFilterTable rightTable = pagedFreezeFilterTable.getRightFreezeAsTable();
    leftTable.setVisibleColumns(Utils.viscolumnless);
    leftTable.setColumnHeaders(Utils.visheaderless);
    rightTable.setVisibleColumns(Utils.viscolumnmore);
    rightTable.setColumnHeaders(Utils.visheadermore);
    pagedFreezeFilterTable.setDoubleHeaderVisible(true);
    pagedFreezeFilterTable.setFilterBarVisible(true);
    pagedFreezeFilterTable.setDoubleHeaderVisibleColumns(Utils.dviscolumnless, Utils.dviscolumnmore);
    pagedFreezeFilterTable.setDoubleHeaderColumnHeaders(Utils.dvisheaderless, Utils.dvisheadermore);
    pagedFreezeFilterTable.setDoubleHeaderMap(dMapVisibleColumnsLess, dMapVisibleColumnsMore);
    rightTable.setDoubleHeaderColumnCheckBox(Utils.dviscolumnmore[0], true, true);
    rightTable.setDoubleHeaderColumnIcon(Utils.dviscolumnmore[1], Utils.logoimg);
    rightTable.setColumnCheckBox(Utils.viscolumnmore[0], true, true);
    rightTable.setColumnIcon(Utils.viscolumnmore[2], Utils.logoimg);

    rightTable.setDoubleHeaderColumnCheckBox(Utils.dviscolumnmore[2], true, true);
    rightTable.setDoubleHeaderColumnIcon(Utils.dviscolumnmore[2], Utils.logoimg);
    rightTable.setColumnCheckBox(Utils.viscolumnmore[1], true, false);
    rightTable.setColumnIcon(Utils.viscolumnmore[1], Utils.logoimg);
    rightTable.setColumnIcon(Utils.viscolumnmore[3], Utils.logoimg);

    pagedFreezeFilterTable.sinkItemPerPageWithPageLength(false);
    //        rightTable.setSortEnabled(false);
    rightTable.addDoubleHeaderColumnCheckListener(new ExtCustomTable.DoubleHeaderColumnCheckListener() {
        @Override
        public void doubleHeaderColumnCheck(ExtCustomTable.DoubleHeaderColumnCheckEvent event) {
            Notification
                    .show("Current Value: " + event.isChecked() + "\nPrropertyId: " + event.getPropertyId());
        }
    });
    rightTable.addColumnCheckListener(new ExtCustomTable.ColumnCheckListener() {
        @Override
        public void columnCheck(ExtCustomTable.ColumnCheckEvent event) {
            Notification
                    .show("Current Value: " + event.isChecked() + "\nPrropertyId: " + event.getPropertyId());
        }
    });
    layout.addComponent(pagedFreezeFilterTable);
    layout.addComponent(pagedFreezeFilterTable.createControls());
    final CheckBox sink = new CheckBox("Sink ItemPerPage With PageLength");
    sink.setImmediate(true);
    layout.addComponent(sink);
    sink.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            pagedFreezeFilterTable.sinkItemPerPageWithPageLength(sink.getValue());
        }
    });
    return layout;
}

From source file:org.diretto.web.richwebclient.view.windows.UploadSettingsWindow.java

/**
 * Constructs an {@link UploadSettingsWindow}.
 * /*w  w w.  j  av  a 2  s .c o m*/
 * @param mainWindow The corresponding {@code MainWindow}
 * @param uploadSection The corresponding {@code UploadSection}
 * @param fileInfo The {@code FileInfo} object
 * @param mediaType The {@code MediaType} of the file
 * @param uploadSettings The corresponding {@code UploadSettings}
 * @param otherFiles The names of the other upload files
 */
public UploadSettingsWindow(final MainWindow mainWindow, final UploadSection uploadSection, FileInfo fileInfo,
        MediaType mediaType, UploadSettings uploadSettings, List<String> otherFiles) {
    super("Upload Settings");

    this.mainWindow = mainWindow;

    setModal(true);
    setStyleName(Reindeer.WINDOW_BLACK);
    setWidth("940px");
    setHeight((((int) mainWindow.getHeight()) - 160) + "px");
    setResizable(false);
    setClosable(false);
    setDraggable(false);
    setPositionX((int) (mainWindow.getWidth() / 2.0f) - 470);
    setPositionY(126);

    wrapperLayout = new HorizontalLayout();
    wrapperLayout.setSizeFull();
    wrapperLayout.setMargin(true, true, true, true);
    addComponent(wrapperLayout);

    mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();
    mainLayout.setSpacing(true);

    HorizontalLayout titleLayout = new HorizontalLayout();
    titleLayout.setWidth("100%");
    mainLayout.addComponent(titleLayout);

    HorizontalLayout leftTitleLayout = new HorizontalLayout();
    titleLayout.addComponent(leftTitleLayout);
    titleLayout.setComponentAlignment(leftTitleLayout, Alignment.MIDDLE_LEFT);

    Label fileNameLabel = StyleUtils.getLabelH2(fileInfo.getName());
    leftTitleLayout.addComponent(fileNameLabel);
    leftTitleLayout.setComponentAlignment(fileNameLabel, Alignment.MIDDLE_LEFT);

    Label bullLabel = StyleUtils.getLabelHTML(
            "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&bull;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    leftTitleLayout.addComponent(bullLabel);
    leftTitleLayout.setComponentAlignment(bullLabel, Alignment.MIDDLE_LEFT);

    Label titleLabel = StyleUtils.getLabelHTML("<b>Title</b>&nbsp;&nbsp;&nbsp;");
    leftTitleLayout.addComponent(titleLabel);
    leftTitleLayout.setComponentAlignment(titleLabel, Alignment.MIDDLE_LEFT);

    final TextField titleField = new TextField();
    titleField.setMaxLength(50);
    titleField.setWidth("100%");
    titleField.setImmediate(true);

    if (uploadSettings != null && uploadSettings.getTitle() != null) {
        titleField.setValue(uploadSettings.getTitle());
    }

    titleField.focus();
    titleField.setCursorPosition(((String) titleField.getValue()).length());

    titleLayout.addComponent(titleField);
    titleLayout.setComponentAlignment(titleField, Alignment.MIDDLE_RIGHT);

    titleLayout.setExpandRatio(leftTitleLayout, 0);
    titleLayout.setExpandRatio(titleField, 1);

    mainLayout.addComponent(StyleUtils.getHorizontalLine());

    GridLayout topGridLayout = new GridLayout(2, 3);
    topGridLayout.setColumnExpandRatio(0, 1.0f);
    topGridLayout.setColumnExpandRatio(1, 0.0f);
    topGridLayout.setWidth("100%");
    topGridLayout.setSpacing(true);
    mainLayout.addComponent(topGridLayout);

    Label descriptionLabel = StyleUtils.getLabelBold("Description");
    topGridLayout.addComponent(descriptionLabel, 0, 0);

    final TextArea descriptionArea = new TextArea();
    descriptionArea.setSizeFull();
    descriptionArea.setImmediate(true);

    if (uploadSettings != null && uploadSettings.getDescription() != null) {
        descriptionArea.setValue(uploadSettings.getDescription());
    }

    topGridLayout.addComponent(descriptionArea, 0, 1);

    VerticalLayout tagsWrapperLayout = new VerticalLayout();
    tagsWrapperLayout.setHeight("30px");
    tagsWrapperLayout.setSpacing(false);
    topGridLayout.addComponent(tagsWrapperLayout, 0, 2);

    HorizontalLayout tagsLayout = new HorizontalLayout();
    tagsLayout.setWidth("100%");
    tagsLayout.setSpacing(true);

    Label tagsLabel = StyleUtils.getLabelBoldHTML("Tags&nbsp;");
    tagsLabel.setSizeUndefined();
    tagsLayout.addComponent(tagsLabel);
    tagsLayout.setComponentAlignment(tagsLabel, Alignment.MIDDLE_LEFT);

    addTagField = new TextField();
    addTagField.setImmediate(true);
    addTagField.setInputPrompt("Enter new Tag");

    addTagField.addShortcutListener(new ShortcutListener(null, KeyCode.ENTER, new int[0]) {
        private static final long serialVersionUID = -4767515198819351723L;

        @Override
        public void handleAction(Object sender, Object target) {
            if (target == addTagField) {
                addTag();
            }
        }
    });

    tagsLayout.addComponent(addTagField);
    tagsLayout.setComponentAlignment(addTagField, Alignment.MIDDLE_LEFT);

    tabSheet = new TabSheet();

    tabSheet.setStyleName(Reindeer.TABSHEET_SMALL);
    tabSheet.addStyleName("view");

    tabSheet.addListener(new ComponentDetachListener() {
        private static final long serialVersionUID = -657657505471281795L;

        @Override
        public void componentDetachedFromContainer(ComponentDetachEvent event) {
            tags.remove(tabSheet.getTab(event.getDetachedComponent()).getCaption());
        }
    });

    Button addTagButton = new Button("Add", new Button.ClickListener() {
        private static final long serialVersionUID = 5914473126402594623L;

        @Override
        public void buttonClick(ClickEvent event) {
            addTag();
        }
    });

    addTagButton.setStyleName(Reindeer.BUTTON_DEFAULT);

    tagsLayout.addComponent(addTagButton);
    tagsLayout.setComponentAlignment(addTagButton, Alignment.MIDDLE_LEFT);

    Label spaceLabel = StyleUtils.getLabelHTML("");
    spaceLabel.setSizeUndefined();
    tagsLayout.addComponent(spaceLabel);
    tagsLayout.setComponentAlignment(spaceLabel, Alignment.MIDDLE_LEFT);

    tagsLayout.addComponent(tabSheet);
    tagsLayout.setComponentAlignment(tabSheet, Alignment.MIDDLE_LEFT);
    tagsLayout.setExpandRatio(tabSheet, 1.0f);

    tagsWrapperLayout.addComponent(tagsLayout);
    tagsWrapperLayout.setComponentAlignment(tagsLayout, Alignment.TOP_LEFT);

    if (uploadSettings != null && uploadSettings.getTags() != null && uploadSettings.getTags().size() > 0) {
        for (String tag : uploadSettings.getTags()) {
            addTagField.setValue(tag);

            addTag();
        }
    }

    Label presettingLabel = StyleUtils.getLabelBold("Presetting");
    topGridLayout.addComponent(presettingLabel, 1, 0);

    final TwinColSelect twinColSelect;

    if (otherFiles != null && otherFiles.size() > 0) {
        twinColSelect = new TwinColSelect(null, otherFiles);
    } else {
        twinColSelect = new TwinColSelect();
    }

    twinColSelect.setWidth("400px");
    twinColSelect.setRows(10);
    topGridLayout.addComponent(twinColSelect, 1, 1);
    topGridLayout.setComponentAlignment(twinColSelect, Alignment.TOP_RIGHT);

    Label otherFilesLabel = StyleUtils
            .getLabelSmallHTML("Select the files which should get the settings of this file as presetting.");
    otherFilesLabel.setSizeUndefined();
    topGridLayout.addComponent(otherFilesLabel, 1, 2);
    topGridLayout.setComponentAlignment(otherFilesLabel, Alignment.MIDDLE_CENTER);

    mainLayout.addComponent(StyleUtils.getHorizontalLine());

    final UploadGoogleMap googleMap;

    if (uploadSettings != null && uploadSettings.getTopographicPoint() != null) {
        googleMap = new UploadGoogleMap(mediaType, 12, uploadSettings.getTopographicPoint().getLatitude(),
                uploadSettings.getTopographicPoint().getLongitude(), MapType.HYBRID);
    } else {
        googleMap = new UploadGoogleMap(mediaType, 12, 48.42255269321401d, 9.956477880477905d, MapType.HYBRID);
    }

    googleMap.setWidth("100%");
    googleMap.setHeight("300px");
    mainLayout.addComponent(googleMap);

    mainLayout.addComponent(StyleUtils.getHorizontalLine());

    GridLayout bottomGridLayout = new GridLayout(3, 3);
    bottomGridLayout.setSizeFull();
    bottomGridLayout.setSpacing(true);
    mainLayout.addComponent(bottomGridLayout);

    Label licenseLabel = StyleUtils.getLabelBold("License");
    bottomGridLayout.addComponent(licenseLabel, 0, 0);

    final TextArea licenseArea = new TextArea();
    licenseArea.setWidth("320px");
    licenseArea.setHeight("175px");
    licenseArea.setImmediate(true);

    if (uploadSettings != null && uploadSettings.getLicense() != null) {
        licenseArea.setValue(uploadSettings.getLicense());
    }

    bottomGridLayout.addComponent(licenseArea, 0, 1);

    final Label startTimeLabel = StyleUtils.getLabelBold("Earliest possible Start Date");
    startTimeLabel.setSizeUndefined();
    bottomGridLayout.setComponentAlignment(startTimeLabel, Alignment.TOP_CENTER);
    bottomGridLayout.addComponent(startTimeLabel, 1, 0);

    final InlineDateField startTimeField = new InlineDateField();
    startTimeField.setImmediate(true);
    startTimeField.setResolution(InlineDateField.RESOLUTION_SEC);

    boolean currentTimeAdjusted = false;

    if (uploadSettings != null && uploadSettings.getTimeRange() != null
            && uploadSettings.getTimeRange().getStartDateTime() != null) {
        startTimeField.setValue(uploadSettings.getTimeRange().getStartDateTime().toDate());
    } else {
        currentTimeAdjusted = true;

        startTimeField.setValue(new Date());
    }

    bottomGridLayout.setComponentAlignment(startTimeField, Alignment.TOP_CENTER);
    bottomGridLayout.addComponent(startTimeField, 1, 1);

    final CheckBox exactTimeCheckBox = new CheckBox("This is the exact point in time.");
    exactTimeCheckBox.setImmediate(true);
    bottomGridLayout.setComponentAlignment(exactTimeCheckBox, Alignment.TOP_CENTER);
    bottomGridLayout.addComponent(exactTimeCheckBox, 1, 2);

    final Label endTimeLabel = StyleUtils.getLabelBold("Latest possible Start Date");
    endTimeLabel.setSizeUndefined();
    bottomGridLayout.setComponentAlignment(endTimeLabel, Alignment.TOP_CENTER);
    bottomGridLayout.addComponent(endTimeLabel, 2, 0);

    final InlineDateField endTimeField = new InlineDateField();
    endTimeField.setImmediate(true);
    endTimeField.setResolution(InlineDateField.RESOLUTION_SEC);

    if (uploadSettings != null && uploadSettings.getTimeRange() != null
            && uploadSettings.getTimeRange().getEndDateTime() != null) {
        endTimeField.setValue(uploadSettings.getTimeRange().getEndDateTime().toDate());
    } else {
        endTimeField.setValue(startTimeField.getValue());
    }

    bottomGridLayout.setComponentAlignment(endTimeField, Alignment.TOP_CENTER);
    bottomGridLayout.addComponent(endTimeField, 2, 1);

    if (!currentTimeAdjusted && ((Date) startTimeField.getValue()).equals((Date) endTimeField.getValue())) {
        exactTimeCheckBox.setValue(true);

        endTimeLabel.setEnabled(false);
        endTimeField.setEnabled(false);
    }

    exactTimeCheckBox.addListener(new ValueChangeListener() {
        private static final long serialVersionUID = 7193545421803538364L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            if ((Boolean) event.getProperty().getValue()) {
                endTimeLabel.setEnabled(false);
                endTimeField.setEnabled(false);
            } else {
                endTimeLabel.setEnabled(true);
                endTimeField.setEnabled(true);
            }
        }
    });

    mainLayout.addComponent(StyleUtils.getHorizontalLine());

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setMargin(true, false, false, false);
    buttonLayout.setSpacing(false);

    HorizontalLayout uploadButtonLayout = new HorizontalLayout();
    uploadButtonLayout.setMargin(false, true, false, false);

    uploadButton = new Button("Upload File", new Button.ClickListener() {
        private static final long serialVersionUID = 8013811216568950479L;

        @Override
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            String titleValue = titleField.getValue().toString().trim();
            Date startTimeValue = (Date) startTimeField.getValue();
            Date endTimeValue = (Date) endTimeField.getValue();
            boolean exactTimeValue = (Boolean) exactTimeCheckBox.getValue();

            if (titleValue.equals("")) {
                ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Title Field",
                        StyleUtils.getLabelHTML("A title entry is required."));

                mainWindow.addWindow(confirmWindow);
            } else if (titleValue.length() < 5 || titleValue.length() > 50) {
                ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Title Field", StyleUtils
                        .getLabelHTML("The number of characters of the title has to be between 5 and 50."));

                mainWindow.addWindow(confirmWindow);
            } else if (!exactTimeValue && startTimeValue.after(endTimeValue)) {
                ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Date Entries",
                        StyleUtils.getLabelHTML("The second date has to be after the first date."));

                mainWindow.addWindow(confirmWindow);
            } else if (startTimeValue.after(new Date())
                    || (!exactTimeValue && endTimeValue.after(new Date()))) {
                ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Date Entries",
                        StyleUtils.getLabelHTML("The dates are not allowed to be in the future."));

                mainWindow.addWindow(confirmWindow);
            } else {
                disableButtons();

                String descriptionValue = descriptionArea.getValue().toString().trim();
                String licenseValue = licenseArea.getValue().toString().trim();
                TopographicPoint topographicPointValue = googleMap.getMarkerPosition();
                Collection<String> presettingValues = (Collection<String>) twinColSelect.getValue();

                if (exactTimeValue) {
                    endTimeValue = startTimeValue;
                }

                TimeRange timeRange = new TimeRange(new DateTime(startTimeValue), new DateTime(endTimeValue));

                UploadSettings uploadSettings = new UploadSettings(titleValue, descriptionValue, licenseValue,
                        new Vector<String>(tags), topographicPointValue, timeRange);

                mainWindow.removeWindow(event.getButton().getWindow());

                requestRepaint();

                uploadSection.upload(uploadSettings, new Vector<String>(presettingValues));
            }
        }
    });

    uploadButton.setStyleName(Reindeer.BUTTON_DEFAULT);
    uploadButtonLayout.addComponent(uploadButton);
    buttonLayout.addComponent(uploadButtonLayout);

    HorizontalLayout cancelButtonLayout = new HorizontalLayout();
    cancelButtonLayout.setMargin(false, true, false, false);

    cancelButton = new Button("Cancel", new Button.ClickListener() {
        private static final long serialVersionUID = -2565870159504952913L;

        @Override
        public void buttonClick(ClickEvent event) {
            disableButtons();

            mainWindow.removeWindow(event.getButton().getWindow());

            requestRepaint();

            uploadSection.cancelUpload();
        }
    });

    cancelButton.setStyleName(Reindeer.BUTTON_DEFAULT);
    cancelButtonLayout.addComponent(cancelButton);
    buttonLayout.addComponent(cancelButtonLayout);

    cancelAllButton = new Button("Cancel All", new Button.ClickListener() {
        private static final long serialVersionUID = -8578124709201789182L;

        @Override
        public void buttonClick(ClickEvent event) {
            disableButtons();

            mainWindow.removeWindow(event.getButton().getWindow());

            requestRepaint();

            uploadSection.cancelAllUploads();
        }
    });

    cancelAllButton.setStyleName(Reindeer.BUTTON_DEFAULT);
    buttonLayout.addComponent(cancelAllButton);

    mainLayout.addComponent(buttonLayout);
    mainLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_CENTER);

    wrapperLayout.addComponent(mainLayout);
}

From source file:org.eclipse.hawkbit.ui.distributions.disttype.CreateUpdateDistSetTypeLayout.java

License:Open Source License

private static boolean isMandatoryModuleType(final Item item) {
    final CheckBox mandatoryCheckBox = (CheckBox) item.getItemProperty(DIST_TYPE_MANDATORY).getValue();
    return mandatoryCheckBox.getValue();
}