Example usage for com.vaadin.ui Window setModal

List of usage examples for com.vaadin.ui Window setModal

Introduction

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

Prototype

public void setModal(boolean modal) 

Source Link

Document

Sets window modality.

Usage

From source file:uicomponents.MSSampleMultiplicationTable.java

License:Open Source License

protected void createEnzymeSelectionWindow(String row) {
    Window subWindow = new Window(" Enzyme selection");
    subWindow.setWidth("400px");

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);/*  w ww.  j a va  2 s  .c  om*/
    layout.setMargin(true);
    EnzymePanel pan = new EnzymePanel(enzymes);
    Button ok = new Button("Okay.");
    ok.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            List<String> enzymes = pan.getEnzymes();
            ComboBox b = parseBoxRow(row, "Enzyme");
            if (enzymes.isEmpty()) {
                Styles.notification("No enzymes selected", "Please select at least one enzyme!",
                        NotificationType.ERROR);
            } else if (enzymes.size() == 1) {
                b.setValue(enzymes.get(0));
                subWindow.close();
            } else {
                b.addItem("Custom");
                b.setValue("Custom");
                enzymeMap.put(row, enzymes);
                subWindow.close();
            }
        }
    });
    layout.addComponent(pan);
    layout.addComponent(ok);

    subWindow.setContent(layout);
    // Center it in the browser window
    subWindow.center();
    subWindow.setModal(true);
    subWindow.setIcon(FontAwesome.FLASK);
    subWindow.setResizable(false);
    ProjectwizardUI ui = (ProjectwizardUI) UI.getCurrent();
    ui.addWindow(subWindow);
}

From source file:views.MetadataUploadView.java

License:Open Source License

private void createNotRightTypeDialogue(String headline, String moreInfo, String barcode) {
    Window subWindow = new Window(" Wrong data type!");
    subWindow.setWidth("400px");

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);/*from   w w  w  . j  a  v  a 2  s .  co m*/
    layout.setMargin(true);
    Label preInfo = new Label(
            "Data of barcode " + barcode + " in this column doesn't fit the attribute type. " + moreInfo);
    layout.addComponent(preInfo);
    Button ok = new Button("Ignore Column.");
    Button no = new Button("Select different attribute.");
    ok.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            getActiveTable().removeContainerProperty(headline);
            subWindow.close();
        }
    });
    no.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            resetAttribute(headline);
            subWindow.close();
        }
    });
    layout.addComponent(ok);
    layout.addComponent(no);

    subWindow.setContent(layout);
    // Center it in the browser window
    subWindow.center();
    subWindow.setModal(true);
    subWindow.setIcon(FontAwesome.BOLT);
    subWindow.setResizable(false);
    ProjectwizardUI ui = (ProjectwizardUI) UI.getCurrent();
    ui.addWindow(subWindow);
}

From source file:views.MetadataUploadView.java

License:Open Source License

private void createDelimiterChangeDialogue(String headline) {
    Window subWindow = new Window(" Unexpected number format");
    subWindow.setWidth("400px");

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);/*from   w w w  .jav  a 2s . com*/
    layout.setMargin(true);
    Label preInfo = new Label("The decimal delimiter of this type needs to be replaced with '.'.");
    layout.addComponent(preInfo);
    Button ok = new Button("Change numbers in this column.");
    Button no = new Button("Select different attribute.");
    ok.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            changeDelimiterInCol(headline);
            subWindow.close();
        }
    });
    no.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            resetAttribute(headline);
            subWindow.close();
        }
    });
    layout.addComponent(ok);
    layout.addComponent(no);

    subWindow.setContent(layout);
    // Center it in the browser window
    subWindow.center();
    subWindow.setModal(true);
    subWindow.setIcon(FontAwesome.QUESTION);
    subWindow.setResizable(false);
    ProjectwizardUI ui = (ProjectwizardUI) UI.getCurrent();
    ui.addWindow(subWindow);
}

From source file:views.MetadataUploadView.java

License:Open Source License

private void showStatus() {
    boolean ready = true;
    for (Object colName : getActiveTable().getContainerPropertyIds()) {
        String selected = getSelectedProperty(colName);
        ready &= selected != null && !selected.isEmpty();
    }//  w  w  w . j a va2s.  c  om
    if (ready) {
        fillCollisionsList();
        if (collisions.size() > 0) {
            Window subWindow = new Window(" Collisions found!");
            subWindow.setWidth("400px");

            VerticalLayout layout = new VerticalLayout();
            layout.setSpacing(true);
            layout.setMargin(true);
            Label preInfo = new Label("The following entries exist and would need to be overwritten:");
            layout.addComponent(preInfo);
            TextArea tf = new TextArea();
            tf.setWidth("350px");
            tf.setValue(StringUtils.join(collisions, ""));
            tf.setStyleName(Styles.areaTheme);
            layout.addComponent(tf);
            String overwriteInfo = "In order to keep your data safe, you are not allowed to overwrite existing information by default. "
                    + "You can either remove the columns in question (choose 'ignore column') or contact QBiC.";
            if (overWriteAllowed)
                overwriteInfo = "You can either remove the columns in question (choose 'ignore column') "
                        + "before sending it to the Database or overwrite the metadata.";
            Label info = new Label(overwriteInfo);
            Button ok = new Button("Got it!");
            ok.addClickListener(new ClickListener() {

                @Override
                public void buttonClick(ClickEvent event) {
                    subWindow.close();
                }
            });
            layout.addComponent(info);
            layout.addComponent(ok);

            subWindow.setContent(layout);
            // Center it in the browser window
            subWindow.center();
            subWindow.setModal(true);
            subWindow.setIcon(FontAwesome.BOLT);
            subWindow.setResizable(false);
            ProjectwizardUI ui = (ProjectwizardUI) UI.getCurrent();
            ui.addWindow(subWindow);
        } else {
            Styles.notification("No collisions found!",
                    "You can update the metadata in our database without overwriting something. To do so press 'Send to Database'",
                    NotificationType.DEFAULT);
        }
        send.setEnabled(collisions.isEmpty() || overWriteAllowed);
    } else
        send.setEnabled(false);
}

From source file:views.MetadataUploadView.java

License:Open Source License

protected void createVocabularySelectWindow(ComboBox selected, String propName, List<Label> entries) {
    Window subWindow = new Window(" " + propName);
    subWindow.setWidth("300px");

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);/*from   w  ww .  j  a v a2 s.  c  o  m*/
    layout.setSpacing(true);

    // create combobox per unique value for this column to find a mapping to the source vocabulary
    Map<String, String> entriesToVocabValues = new HashMap<String, String>();
    Set<String> uniqueEntries = new HashSet<String>();
    // keep these old values in case user chooses different property afterwards
    List<String> oldEntries = new ArrayList<String>();
    ValueChangeListener resetSelectionListener = new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            // reset labels to what they were before
            for (int i = 0; i < entries.size(); i++) {
                entries.get(i).setValue(oldEntries.get(i));
            }
            // remove reset listener, it won't be needed until a vocabulary field is selected again
            selected.removeValueChangeListener(this);
        }
    };
    selected.addValueChangeListener(resetSelectionListener);

    List<ComboBox> boxes = new ArrayList<ComboBox>();
    Set<String> vocabOptions = propToVocabulary.get(propNameToCode.get(propName)).keySet();
    for (Label l : entries) {
        String val = l.getValue();
        oldEntries.add(val);
        if (!uniqueEntries.contains(val)) {
            ComboBox b = new ComboBox(val);
            b.addItems(vocabOptions);
            b.setNullSelectionAllowed(false);
            b.setStyleName(Styles.boxTheme);
            b.setFilteringMode(FilteringMode.CONTAINS);
            layout.addComponent(b);
            boxes.add(b);
            uniqueEntries.add(val);
            val = StringUtils.capitalize(val);
            if (vocabOptions.contains(val)) {
                b.setValue(val);
                b.setEnabled(false);
            }
        }
    }
    Button send = new Button("Ok");
    send.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            boolean valid = true;
            for (ComboBox b : boxes) {
                if (b.getValue() != null) {
                    String newVal = b.getValue().toString();
                    entriesToVocabValues.put(b.getCaption(), newVal);
                } else
                    valid = false;
            }
            if (valid) {
                for (Label l : entries) {
                    l.setValue(entriesToVocabValues.get(l.getValue()));
                }
                subWindow.close();

                // check for collisions now that values have changed
                reactToTableChange();
            } else {
                String error = "Please select a value for each entry.";
                Styles.notification("Missing Input", error, NotificationType.DEFAULT);
            }
        }
    });
    layout.addComponent(send);

    subWindow.setContent(layout);
    // Center it in the browser window
    subWindow.center();
    subWindow.setModal(true);
    subWindow.setIcon(FontAwesome.FLASK);
    subWindow.setResizable(false);

    ProjectwizardUI ui = (ProjectwizardUI) UI.getCurrent();
    ui.addWindow(subWindow);
}

From source file:views.MetadataUploadView.java

License:Open Source License

protected void createConditionWindow(ComboBox selectionBox) {
    String val = (String) selectionBox.getValue();

    // val.equals("[Experimental Condition]")
    String header = " Experimental Condition Name";
    String prefix = "Condition";
    Resource icon = FontAwesome.FLASK;

    if (val.equals("[Other Property]")) {
        header = " Property Name";
        prefix = "Property";
        icon = FontAwesome.FILE_TEXT;/*from ww  w .j  a  va  2 s  .  com*/
    }
    final String category = prefix;

    Window subWindow = new Window(header);
    subWindow.setWidth("300px");

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    TextField label = new TextField();
    label.setRequired(true);
    label.setStyleName(Styles.fieldTheme);
    RegexpValidator factorLabelValidator = new RegexpValidator("([a-z]+_?[a-z]*)+([a-z]|[0-9]*)",
            "Name must start with a lower case letter and contain only lower case letter words, which can be connected by underscores ('_'). It can end with one or more numbers.");
    label.addValidator(factorLabelValidator);
    label.setValidationVisible(true);
    label.setImmediate(true);

    ComboBox unitSelect = new ComboBox("Unit");
    unitSelect.setNullSelectionAllowed(false);
    unitSelect.addItems(properties.Unit.values());
    String nullItem = "[None]";
    unitSelect.addItem(nullItem);
    unitSelect.select(nullItem);
    unitSelect.setStyleName(Styles.boxTheme);
    unitSelect.setImmediate(true);

    Button send = new Button("Ok");
    send.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (label.isValid()) {
                String unit = "";
                if (!unitSelect.getValue().equals(nullItem))
                    unit = " [" + unitSelect.getValue() + "]";
                String name = category + ": " + label.getValue() + unit;
                selectionBox.addItem(name);
                selectionBox.select(name);
                subWindow.close();
            } else {
                String error = "Please input a name for this " + category + ".";
                if (!label.isEmpty())
                    error = factorLabelValidator.getErrorMessage();
                Styles.notification("Missing Input", error, NotificationType.DEFAULT);
            }
        }
    });
    layout.addComponent(label);
    layout.addComponent(unitSelect);
    layout.addComponent(send);

    subWindow.setContent(layout);
    // Center it in the browser window
    subWindow.center();
    subWindow.setModal(true);
    subWindow.setIcon(icon);
    subWindow.setResizable(false);
    ProjectwizardUI ui = (ProjectwizardUI) UI.getCurrent();
    ui.addWindow(subWindow);
}