Example usage for com.vaadin.ui CheckBox CheckBox

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

Introduction

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

Prototype

public CheckBox(String caption) 

Source Link

Document

Creates a new checkbox with a set caption.

Usage

From source file:ru.codeinside.adm.ui.AdminApp.java

License:Mozilla Public License

private Panel buildPrintTemplatesPanel() {
    boolean isUseService = "true".equals(get(API.PRINT_TEMPLATES_USE_OUTER_SERVICE));

    final TextField serviceLocation = new TextField("?? ??");
    serviceLocation.setValue(get(API.PRINT_TEMPLATES_SERVICELOCATION));
    serviceLocation.setEnabled(isUseService);
    serviceLocation.setRequired(isUseService);
    serviceLocation.setWidth(370, Sizeable.UNITS_PIXELS);

    final CheckBox useOuterService = new CheckBox("?  ??");
    useOuterService.setValue(isUseService);
    useOuterService.setImmediate(true);/*from   w w  w. j  a  v  a2  s .c o m*/
    useOuterService.addListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            Boolean newValue = (Boolean) valueChangeEvent.getProperty().getValue();
            serviceLocation.setEnabled(newValue);
            serviceLocation.setRequired(newValue);
        }
    });

    final Form form = new Form();
    form.addField(API.PRINT_TEMPLATES_USE_OUTER_SERVICE, useOuterService);
    form.addField(API.PRINT_TEMPLATES_SERVICELOCATION, serviceLocation);
    form.setImmediate(true);
    form.setWriteThrough(false);
    form.setInvalidCommitted(false);

    Button commit = new Button("", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                form.commit();
                set(API.PRINT_TEMPLATES_USE_OUTER_SERVICE, useOuterService.getValue());
                set(API.PRINT_TEMPLATES_SERVICELOCATION, serviceLocation.getValue());
                event.getButton().getWindow().showNotification("?? ?",
                        Window.Notification.TYPE_HUMANIZED_MESSAGE);
            } catch (Validator.InvalidValueException ignore) {
            }
        }
    });

    Panel panel = new Panel(" ");
    panel.setSizeFull();
    panel.addComponent(form);
    panel.addComponent(commit);
    return panel;
}

From source file:ru.codeinside.adm.ui.LogSettings.java

License:Mozilla Public License

LogSettings() {

    logErrors = new OptionGroup("? ? :", Arrays.asList(Status.FAILURE.name()));
    logErrors.setItemCaption(Status.FAILURE.name(), "");
    logErrors.setImmediate(true);//from w ww .ja va  2  s  .com
    logErrors.setMultiSelect(true);

    logStatus = new OptionGroup("?  ?  '':", statusKeys());
    logStatus.setItemCaption(Status.REQUEST.name(), "?");
    logStatus.setItemCaption(Status.RESULT.name(), "");
    logStatus.setItemCaption(Status.PING.name(), "?");
    logStatus.setMultiSelect(true);
    logStatus.setImmediate(true);

    ipSet = new TextArea("? IP ?:");
    ipSet.setWordwrap(true);
    ipSet.setNullRepresentation("");
    ipSet.setWidth(100f, UNITS_PERCENTAGE);
    ipSet.setRows(10);

    tf = new TextField(" , :");
    tf.setRequired(true);
    tf.addValidator(new Validator() {
        public void validate(Object value) throws InvalidValueException {
            if (!isValid(value)) {
                throw new InvalidValueException(
                        "  ? ");
            }
        }

        public boolean isValid(Object value) {
            return value instanceof String && ((String) value).matches("[1-9][0-9]*");
        }
    });

    b1 = new Block("") {

        @Override
        void onLayout(Layout layout) {
            layout.addComponent(logErrors);
            layout.addComponent(logStatus);
        }

        @Override
        void onChange() {
            logErrors.setReadOnly(false);
            logStatus.setReadOnly(false);
        }

        @Override
        void onRefresh() {
            boolean _logErrors = AdminServiceProvider.getBoolProperty(API.LOG_ERRORS);
            if (_logErrors) {
                logErrors.setReadOnly(false);
                logErrors.setValue(Arrays.asList(Status.FAILURE.name()));
            } else {
                logErrors.setValue(Collections.emptySet());
            }
            logErrors.setReadOnly(true);

            String _logStatus = AdminServiceProvider.get().getSystemProperty(API.LOG_STATUS);
            if (_logStatus != null) {
                Set<String> set = new HashSet<String>();
                for (String key : statusKeys()) {
                    if (_logStatus.contains(key)) {
                        set.add(key);
                    }
                }
                logStatus.setReadOnly(false);
                logStatus.setValue(set);
            } else {
                logStatus.setValue(Collections.emptySet());
            }
            logStatus.setReadOnly(true);
        }

        @Override
        void onApply() {
            Collection logErrorsValue = (Collection) logErrors.getValue();
            boolean errorsEnabled = logErrorsValue.contains(Status.FAILURE.name());
            AdminServiceProvider.get().saveSystemProperty(API.LOG_ERRORS, Boolean.toString(errorsEnabled));
            LogCustomizer.setShouldWriteServerLogErrors(errorsEnabled);

            Collection logStatusValue = (Collection) logStatus.getValue();

            Set<Status> statuses = new TreeSet<Status>();

            if (logStatusValue.contains(Status.REQUEST.name())) {
                statuses.add(Status.REQUEST);
                statuses.add(Status.ACCEPT);
                statuses.add(Status.CANCEL);
            }

            if (logStatusValue.contains(Status.RESULT.name())) {
                statuses.add(Status.RESULT);
                statuses.add(Status.REJECT);
                statuses.add(Status.STATE);
                statuses.add(Status.NOTIFY);
            }

            if (logStatusValue.contains(Status.PING.name())) {
                statuses.add(Status.PING);
                statuses.add(Status.PROCESS);
                statuses.add(Status.PACKET);
            }

            StringBuilder statusBuilder = new StringBuilder();
            for (Status status : statuses) {
                if (statusBuilder.length() > 0) {
                    statusBuilder.append(", ");
                }
                statusBuilder.append(status);
            }
            String status = statusBuilder.toString();

            AdminServiceProvider.get().saveSystemProperty(API.LOG_STATUS, status);
            LogCustomizer.setServerLogStatus(status);

            boolean enabled = !status.isEmpty();
            LogCustomizer.setShouldWriteServerLog(enabled);
            AdminServiceProvider.get().saveSystemProperty(API.ENABLE_CLIENT_LOG, Boolean.toString(enabled));
        }
    };

    b2 = new Block("? ") {
        @Override
        void onLayout(Layout layout) {
            layout.addComponent(ipSet);
        }

        @Override
        void onRefresh() {
            String ips = AdminServiceProvider.get().getSystemProperty(API.SKIP_LOG_IPS);
            ipSet.setReadOnly(false);
            ipSet.setValue(ips);
            ipSet.setReadOnly(true);
        }

        @Override
        void onChange() {
            ipSet.setReadOnly(false);
        }

        @Override
        void onApply() {
            String value = (String) ipSet.getValue();
            TreeSet<String> items = new TreeSet<String>();
            if (value != null) {
                for (String item : value.split("[,;\\s]+")) {
                    items.add(item);
                }
                StringBuilder sb = new StringBuilder();
                for (String item : items) {
                    if (sb.length() > 0) {
                        sb.append(", ");
                    }
                    sb.append(item);
                }
                value = sb.toString();
            }
            AdminServiceProvider.get().saveSystemProperty(API.SKIP_LOG_IPS, value);
            LogCustomizer.setIgnoreSet(items);
        }
    };

    b3 = new Block("?   ") {
        @Override
        void onButtons(Layout layout) {
            layout.addComponent(new Button("? ", new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    LogScheduler.cleanLog();
                    getWindow().showNotification("?? ",
                            Window.Notification.TYPE_HUMANIZED_MESSAGE);
                }
            }));
        }

        @Override
        void onLayout(Layout layout) {
            layout.addComponent(tf);
        }

        @Override
        void onRefresh() {
            String logDepth = AdminServiceProvider.get().getSystemProperty(API.LOG_DEPTH);
            tf.setReadOnly(false);
            if (logDepth != null && logDepth.matches("[1-9][0-9]*")) {
                tf.setValue(logDepth);
            } else {
                tf.setValue(String.valueOf(API.DEFAULT_LOG_DEPTH));
            }
            tf.setReadOnly(true);
        }

        @Override
        void onChange() {
            tf.setReadOnly(false);
        }

        @Override
        void onApply() {
            tf.validate();
            AdminServiceProvider.get().saveSystemProperty(API.LOG_DEPTH, tf.getValue().toString());
        }
    };

    final CheckBox logSpSign = new CheckBox(" ? ");
    logSpSign.setValue(Boolean.valueOf(AdminServiceProvider.get().getSystemProperty(API.LOG_SP_SIGN)));
    logSpSign.addListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            AdminServiceProvider.get().saveSystemProperty(API.LOG_SP_SIGN,
                    String.valueOf(valueChangeEvent.getProperty().getValue()));
            notifySuccess();
        }
    });
    logSpSign.setImmediate(true);

    final CheckBox logOvSign = new CheckBox(" ? ");
    logOvSign.setValue(Boolean.valueOf(AdminServiceProvider.get().getSystemProperty(API.LOG_OV_SIGN)));
    logOvSign.addListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            AdminServiceProvider.get().saveSystemProperty(API.LOG_OV_SIGN,
                    String.valueOf(valueChangeEvent.getProperty().getValue()));
            notifySuccess();
        }
    });
    logOvSign.setImmediate(true);

    Label userSignsLabel = new Label("? ?");
    userSignsLabel.addStyleName(Reindeer.LABEL_H2);

    VerticalLayout userSignsVl = new VerticalLayout();
    userSignsVl.setMargin(true);
    userSignsVl.setSpacing(true);
    userSignsVl.addComponent(userSignsLabel);
    userSignsVl.addComponent(logSpSign);
    userSignsVl.addComponent(logOvSign);

    Panel userSingsWrapper = new Panel();
    userSingsWrapper.setScrollable(true);
    userSingsWrapper.setContent(userSignsVl);
    userSingsWrapper.setSizeFull();

    VerticalLayout vl = new VerticalLayout();
    vl.addComponent(b1);
    vl.addComponent(userSingsWrapper);
    vl.setExpandRatio(b1, 0.7f);
    vl.setExpandRatio(userSingsWrapper, 0.3f);
    vl.setSizeFull();

    HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);
    layout.addComponent(vl);
    layout.addComponent(b2);
    layout.addComponent(b3);
    layout.setSizeFull();
    layout.setExpandRatio(vl, 0.333f);
    layout.setExpandRatio(b2, 0.333f);
    layout.setExpandRatio(b3, 0.333f);

    Panel wrapper = new Panel(" ", layout);
    wrapper.addStyleName(Reindeer.PANEL_LIGHT);
    wrapper.setSizeFull();

    setCompositionRoot(wrapper);
    setSizeFull();
}

From source file:ru.codeinside.gses.webui.supervisor.TaskFilter.java

License:Mozilla Public License

private CheckBox getOverdueField(String comboBoxWidth) {
    CheckBox overdueBox = new CheckBox(" ? ?");
    overdueBox.setWidth(comboBoxWidth);// w w  w . j a  v  a2  s .  c o m
    return overdueBox;
}

From source file:ru.vist.stat.forms.register.SubSciption.java

public SubSciption(final Window window) {
    this.window = window;
    VerticalLayout layout = new VerticalLayout();
    setCaption("? ?");
    layout.setMargin(true);// w  w  w . j a va2 s  .  c o  m
    List<CView> list = SetSubsDb.getUserViews(Common.getUser()); //VistUI.getSubs().getList();
    for (CView cv : list) {
        CheckBox box = new CheckBox(cv.getName());
        box.setValue(Boolean.TRUE);
        layout.addComponent(box);
        boxes.add(box);
    }
    HorizontalLayout hl = new BasicHorizontalLayout();
    BasicButton btnSave = new BasicButton("",
            "?  ? ");
    btnSave.addClickListener(new SaveClickListener());
    hl.addComponent(btnSave);
    BasicButton btnCancel = new BasicButton("", " ");
    hl.addComponent(btnCancel);
    btnCancel.addClickListener(new CancelClickListener());
    layout.addComponent(hl);
    setContent(layout);
}

From source file:se.natusoft.osgi.aps.apsuseradminweb.vaadin.components.editors.RoleEditor.java

License:Open Source License

/**
 * Creates a new RoleEditor instance.//from  ww w .  ja v a2  s.  co m
 *
 * @param userServiceAdmin The user admin service for editing the role.
 */
public RoleEditor(APSSimpleUserServiceAdmin userServiceAdmin) {
    this.userServiceAdmin = userServiceAdmin;

    this.setStyleName(CSS.APS_EDITING_TEXT);

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setMargin(true);
    verticalLayout.setSpacing(true);
    verticalLayout.setStyleName(CSS.APS_EDITING_TEXT + " " + CSS.APS_CONTENT_PANEL);

    // Role id, master and description.
    {
        HorizontalLayout horizLayout = new HorizontalLayout();
        horizLayout.setSpacing(true);

        this.idTextField = new TextField("Role id");
        this.idTextField.setColumns(30);
        this.idTextField.setImmediate(false);
        this.idTextField.setEnabled(true);
        horizLayout.addComponent(this.idTextField);

        this.masterRole = new CheckBox("Master Role");
        this.masterRole.setImmediate(false);
        this.masterRole.setEnabled(true);
        horizLayout.addComponent(this.masterRole);

        verticalLayout.addComponent(horizLayout);

        this.descriptionTextArea = new TextArea("Description of role");
        this.descriptionTextArea.setRows(3);
        this.descriptionTextArea.setColumns(60);
        this.descriptionTextArea.setImmediate(false);
        this.descriptionTextArea.setEnabled(true);
        verticalLayout.addComponent(this.descriptionTextArea);
    }

    // Roles
    {
        HorizontalLayout rolesLayout = new HorizontalLayout();
        rolesLayout.setSizeFull();

        // Available
        this.availableRoles = new Table("Available roles");
        this.availableRoles.setImmediate(true);
        this.availableRoles.setPageLength(10);
        this.availableRoles.setSortAscending(true);
        this.availableRoles.setSizeFull();
        this.availableRoles.setDragMode(Table.TableDragMode.ROW);
        this.availableRoles.setDropHandler(new DropHandler() {
            @Override
            public void drop(DragAndDropEvent event) {
                DataBoundTransferable t = (DataBoundTransferable) event.getTransferable();
                Object itemId = t.getItemId();
                removeSubRole(itemId);
            }

            @Override
            public AcceptCriterion getAcceptCriterion() {
                return new RoleAcceptCriterion(RoleEditor.this.availableRoles);
            }
        });
        VerticalLayout availableRolesFrame = new VerticalLayout();
        availableRolesFrame.setMargin(false, true, false, false);
        availableRolesFrame.addComponent(this.availableRoles);
        rolesLayout.addComponent(availableRolesFrame);

        // Selected
        this.selectedRoles = new Table("Selected sub roles of the role");
        this.selectedRoles.setImmediate(true);
        this.selectedRoles.setPageLength(10);
        this.selectedRoles.setSortAscending(true);
        this.selectedRoles.setSizeFull();
        this.selectedRoles.setDragMode(Table.TableDragMode.ROW);
        this.selectedRoles.setDropHandler(new DropHandler() {
            @Override
            public void drop(DragAndDropEvent event) {
                DataBoundTransferable t = (DataBoundTransferable) event.getTransferable();
                Object itemId = t.getItemId();
                addSubRole(itemId);
            }

            @Override
            public AcceptCriterion getAcceptCriterion() {
                return new RoleAcceptCriterion(RoleEditor.this.selectedRoles);
            }
        });
        VerticalLayout selectedRolesFrame = new VerticalLayout();
        selectedRolesFrame.setMargin(false, false, false, true);
        selectedRolesFrame.addComponent(this.selectedRoles);
        rolesLayout.addComponent(selectedRolesFrame);

        rolesLayout.setExpandRatio(availableRolesFrame, 0.5f);
        rolesLayout.setExpandRatio(selectedRolesFrame, 0.5f);

        verticalLayout.addComponent(rolesLayout);

        /* Help text for the role tables. */
        HelpText roleHelptext = new HelpText(
                "Drag and drop roles back and forth to set or remove a role. Also note that it is fully possible to "
                        + "create circular role dependencies. Don't!");
        verticalLayout.addComponent(roleHelptext);
    }

    // Save / Cancel
    {
        HorizontalLayout horizontalLayout = new HorizontalLayout();
        verticalLayout.addComponent(horizontalLayout);
        horizontalLayout.setSpacing(true);

        Button saveButton = new Button("Save");
        saveButton.addListener(new Button.ClickListener() {
            /** Click handling. */
            @Override
            public void buttonClick(Button.ClickEvent event) {
                save();
            }
        });
        horizontalLayout.addComponent(saveButton);

        Button cancelButton = new Button("Cancel");
        cancelButton.addListener(new Button.ClickListener() {
            /** Click handling. */
            @Override
            public void buttonClick(Button.ClickEvent event) {
                cancel();
            }
        });
        horizontalLayout.addComponent(cancelButton);
    }

    setContent(verticalLayout);
}

From source file:steps.ExtractionStep.java

License:Open Source License

/**
 * Create a new Extraction step for the wizard
 * /*w  w  w. j  a va 2 s  . c om*/
 * @param tissueMap A map of available tissues (codes and labels)
 * @param cellLinesMap
 */
public ExtractionStep(Map<String, String> tissueMap, Map<String, String> cellLinesMap, Set<String> people) {
    main = new VerticalLayout();
    main.setMargin(true);
    main.setSpacing(true);
    Label header = new Label("Sample Extracts");
    main.addComponent(Styles.questionize(header,
            "Extracts are individual tissue or other samples taken from organisms and used in the experiment. "
                    + "You can input (optional) experimental variables, e.g. extraction times or treatments, that differ between different groups "
                    + "of extracts.",
            "Sample Extracts"));

    ArrayList<String> tissues = new ArrayList<String>();
    tissues.addAll(tissueMap.keySet());
    Collections.sort(tissues);
    tissue = new ComboBox("Tissue", tissues);
    tissue.setRequired(true);
    tissue.setStyleName(Styles.boxTheme);
    tissue.setFilteringMode(FilteringMode.CONTAINS);
    if (ProjectwizardUI.testMode)
        tissue.setValue("Blood");
    tissueNum = new OpenbisInfoTextField("How many different tissue types are there in this sample extraction?",
            "", "50px", "2");
    tissueNum.getInnerComponent().setVisible(false);
    tissueNum.getInnerComponent().setEnabled(false);

    expName = new TextField("Experimental Step Name");
    expName.setStyleName(Styles.fieldTheme);
    main.addComponent(expName);

    c = new ConditionsPanel(suggestions, emptyFactor, "Tissue", tissue, true, conditionsSet,
            (TextField) tissueNum.getInnerComponent());
    main.addComponent(c);

    isotopes = new CheckBox("Isotope Labeling");
    isotopes.setImmediate(true);
    main.addComponent(Styles.questionize(isotopes,
            "Are extracted cells labeled by isotope labeling (e.g. for Mass Spectrometry)?",
            "Isotope Labeling"));

    labelingMethods = initLabelingMethods();

    isotopeTypes = new ComboBox();
    isotopeTypes.setVisible(false);
    isotopeTypes.setImmediate(true);
    isotopeTypes.setStyleName(Styles.boxTheme);
    isotopeTypes.setNullSelectionAllowed(false);
    for (LabelingMethod l : labelingMethods)
        isotopeTypes.addItem(l.getName());
    main.addComponent(isotopeTypes);

    isotopes.addValueChangeListener(new ValueChangeListener() {

        /**
         * 
         */
        private static final long serialVersionUID = 6993706766195224898L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            isotopeTypes.setVisible(isotopes.getValue());
        }
    });
    main.addComponent(tissueNum.getInnerComponent());
    main.addComponent(tissue);

    tissue.addValueChangeListener(new ValueChangeListener() {

        /**
         * 
         */
        private static final long serialVersionUID = 1987640360028444299L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            cellLine.setVisible(tissue.getValue().equals("Cell Line"));
            otherTissue.setVisible(tissue.getValue().equals("Other"));
        }
    });
    ArrayList<String> cellLines = new ArrayList<String>();
    cellLines.addAll(cellLinesMap.keySet());
    Collections.sort(cellLines);
    cellLine = new ComboBox("Cell Line", cellLines);
    cellLine.setStyleName(Styles.boxTheme);
    cellLine.setImmediate(true);
    cellLine.setVisible(false);
    cellLine.setFilteringMode(FilteringMode.CONTAINS);
    main.addComponent(cellLine);
    otherTissue = new TextField("Tissue Information");
    otherTissue.setWidth("350px");
    otherTissue.setStyleName(Styles.fieldTheme);
    otherTissue.setVisible(false);
    main.addComponent(otherTissue);

    HorizontalLayout persBoxH = new HorizontalLayout();
    persBoxH.setCaption("Contact Person");
    person = new ComboBox();
    person.addItems(people);
    person.setFilteringMode(FilteringMode.CONTAINS);
    person.setStyleName(Styles.boxTheme);

    reloadPeople = new Button();
    Styles.iconButton(reloadPeople, FontAwesome.REFRESH);
    persBoxH.addComponent(person);
    persBoxH.addComponent(reloadPeople);

    main.addComponent(Styles.questionize(persBoxH, "Contact person responsible for tissue extraction.",
            "Contact Person"));

    extractReps = new OpenbisInfoTextField(
            "Extracted replicates per patient/animal/plant per experimental variable.",
            "Number of extractions per individual defined in the last step. "
                    + "Technical replicates are added later!",
            "50px", "1");
    main.addComponent(extractReps.getInnerComponent());
}

From source file:steps.FinishStep.java

License:Open Source License

public FinishStep(final Wizard w, AttachmentConfig attachmentConfig) {
    this.w = w;// w w w .  ja v  a2 s.com
    this.attachConfig = attachmentConfig;

    main = new VerticalLayout();
    main.setMargin(true);
    main.setSpacing(true);
    Label header = new Label("Summary and File Upload");
    main.addComponent(Styles.questionize(header,
            "Here you can download spreadsheets of the samples in your experiment "
                    + "and upload informative files belonging to your project, e.g. treatment information. "
                    + "It might take a few minutes for your files to show up in our project browser.",
            "Last Step"));
    summary = new Label();
    summary.setContentMode(ContentMode.PREFORMATTED);
    Panel summaryPane = new Panel();
    summaryPane.setContent(summary);
    summaryPane.setWidth("550px");
    main.addComponent(summaryPane);

    downloads = new VerticalLayout();
    downloads.setCaption("Download Spreadsheets:");
    downloads.setSpacing(true);
    dlEntities = new Button("Sample Sources");
    dlExtracts = new Button("Sample Extracts");
    dlPreps = new Button("Sample Preparations");
    dlEntities.setEnabled(false);
    dlExtracts.setEnabled(false);
    dlPreps.setEnabled(false);
    downloads.addComponent(dlEntities);
    downloads.addComponent(dlExtracts);
    downloads.addComponent(dlPreps);

    this.bar = new ProgressBar();
    this.info = new Label();
    info.setCaption("Preparing Spreadsheets");
    main.addComponent(bar);
    main.addComponent(info);
    main.addComponent(downloads);

    browserLink = new Button("Show in Project Browser");
    main.addComponent(browserLink);

    attach = new CheckBox("Upload Additional Files");
    // attach.setVisible(false);
    attach.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            uploads.setVisible(attach.getValue());
            w.getFinishButton().setVisible(!attach.getValue());
        }
    });
    main.addComponent(Styles.questionize(attach,
            "Upload one or more small files pertaining to the experimental design of this project.",
            "Upload Attachments"));
}

From source file:steps.ProjectContextStep.java

License:Open Source License

/**
 * Create a new Context Step for the wizard
 * //from  ww  w .ja v a2s.c  om
 * @param newProjectCode
 */
public ProjectContextStep(ProjectInformationComponent projSelect) {
    main = new VerticalLayout();
    main.setMargin(true);
    main.setSpacing(true);
    main.setSizeUndefined();

    projectInfoComponent = projSelect;
    projectInfoComponent.setImmediate(true);
    projectInfoComponent.setVisible(true);

    projectContext = new CustomVisibilityComponent(new OptionGroup("", contextOptions));
    projectContext.setVisible(false);

    disableContextOptions();

    experimentTable = new Table("Applicable Experiments");
    experimentTable.setColumnHeader("experiment_type", "Experimental Step");
    experimentTable.setColumnHeader("samples", "Samples");
    experimentTable.setColumnHeader("date", "Date");
    experimentTable.setColumnHeader("code", "Code");
    experimentTable.setStyleName(ValoTheme.TABLE_SMALL);
    experimentTable.setPageLength(1);
    experimentTable.setContainerDataSource(new BeanItemContainer<ExperimentBean>(ExperimentBean.class));
    experimentTable.setSelectable(true);
    experimentTable.setVisible(false);

    samples = new Table("Sample Overview");
    samples.setStyleName(ValoTheme.TABLE_SMALL);
    samples.setColumnHeader("code", "Code");
    samples.setColumnHeader("secondary_Name", "Secondary Name");
    samples.setVisible(false);
    samples.setPageLength(1);
    samples.setContainerDataSource(new BeanItemContainer<NewSampleModelBean>(NewSampleModelBean.class));

    grid = new GridLayout(2, 4);
    grid.setSpacing(true);
    grid.setMargin(true);
    grid.addComponent(projectInfoComponent, 0, 0);
    Component context = Styles.questionize(projectContext, "If this experiment's organisms or "
            + "tissue extracts are already registered at QBiC from an earlier experiment, you can chose the second "
            + "option (new tissue extracts from old organism) or the third (new measurements from old tissue extracts). "
            + "You can also create a preliminary sub-project and add samples later or "
            + "download existing sample information by choosing the last option.", "Project Context");
    grid.addComponent(context, 0, 1);
    grid.addComponent(experimentTable, 0, 2);
    grid.addComponent(samples, 1, 1, 1, 2);

    pilotBox = new CheckBox("Pilot Project");

    pilot = new CustomVisibilityComponent(pilotBox);
    pilot.setVisible(false);
    grid.addComponent(Styles.questionize(pilot,
            "Select if the samples you want to add belong to a pilot project. "
                    + "You can derive non-pilot samples from existing pilot experiments, but not the other way around.",
            "Pilot Experiment"), 0, 3);

    main.addComponent(grid);

    initListeners();
}

From source file:tad.grupo7.ccamistadeslargas.EventosLayout.java

/**
 * Muestra el formulario para aadir un gasto al evento.
 *
 * @param e Evento al que aadir el gasto.
 *//* w  w w.j  a va2  s  . co  m*/
private void mostrarFormularioAddGasto(Evento e) {
    //T?TULO
    CssLayout labels = new CssLayout();
    labels.addStyleName("labels");
    Label l = new Label("Aadir Gasto");
    l.setSizeUndefined();
    l.addStyleName(ValoTheme.LABEL_H2);
    l.addStyleName(ValoTheme.LABEL_COLORED);
    //FORMULARIO
    TextField titulo = new TextField("Ttulo");
    titulo.setRequired(true);
    TextField precio = new TextField("Precio");
    precio.setRequired(true);
    List<Participante> participantes = ParticipanteDAO.readAllFromEvento(e.getId());
    ComboBox pagador = new ComboBox("Pagador");
    List<Participante> deudores = new ArrayList<>();
    Label d = new Label("Deudores");
    FormLayout form = new FormLayout(l, titulo, precio, pagador, d);
    for (Participante p : participantes) {
        pagador.addItem(p.getNombre());
        CheckBox c = new CheckBox(p.getNombre());
        c.addValueChangeListener(evento -> {
            deudores.add(p);
        });
        form.addComponent(c);
    }
    final Button add = new Button("Aadir Gasto");
    add.addStyleName(ValoTheme.BUTTON_PRIMARY);
    add.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    //SI SE CLICA EN AADIR PAGO SE CREA EL PAGO A LA VEZ QUE SE CIERRA LA VENTANA
    add.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                titulo.validate();
                precio.validate();
                pagador.validate();
                GastoDAO.create(titulo.getValue(), Double.valueOf(precio.getValue()), e.getId(),
                        ParticipanteDAO.read(pagador.getValue().toString(), usuario.getId()).getId(), deudores);
                mostrarEvento(e);
            } catch (Validator.InvalidValueException ex) {
                Notification n = new Notification("Rellena todos los campos",
                        Notification.Type.WARNING_MESSAGE);
                n.setPosition(Position.TOP_CENTER);
                n.show(Page.getCurrent());
            }
        }
    });
    //AADIMOS LOS COMPONENTES
    form.addComponent(add);
    setSecondComponent(form);
}

From source file:trader.LoginUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    setLocale(Locale.ENGLISH);/* w  w  w  .ja  v  a2 s .c  o m*/

    FormLayout loginForm = new FormLayout();
    loginForm.setSizeUndefined();

    loginForm.addComponent(userName = new TextField("Username"));
    loginForm.addComponent(passwordField = new PasswordField("Password"));
    loginForm.addComponent(rememberMe = new CheckBox("Remember me"));
    loginForm.addComponent(login = new Button("Login"));
    login.addStyleName(ValoTheme.BUTTON_PRIMARY);
    login.setDisableOnClick(true);
    login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    login.addClickListener(new Button.ClickListener() {
        /**
        * 
        */
        private static final long serialVersionUID = 7813011112417170727L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            login();
        }
    });

    VerticalLayout loginLayout = new VerticalLayout();
    loginLayout.setSpacing(true);
    loginLayout.setSizeUndefined();

    if (request.getParameter("logout") != null) {
        loggedOutLabel = new Label("You have been logged out!");
        loggedOutLabel.addStyleName(ValoTheme.LABEL_SUCCESS);
        loggedOutLabel.setSizeUndefined();
        loginLayout.addComponent(loggedOutLabel);
        loginLayout.setComponentAlignment(loggedOutLabel, Alignment.BOTTOM_CENTER);
    }

    loginLayout.addComponent(loginFailedLabel = new Label());
    loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER);
    loginFailedLabel.setSizeUndefined();
    loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE);
    loginFailedLabel.setVisible(false);

    loginLayout.addComponent(loginForm);
    loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER);

    VerticalLayout rootLayout = new VerticalLayout(loginLayout);
    rootLayout.setSizeFull();
    rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER);
    setContent(rootLayout);
    setSizeFull();
}