Example usage for com.vaadin.ui Panel setHeight

List of usage examples for com.vaadin.ui Panel setHeight

Introduction

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

Prototype

@Override
    public void setHeight(String height) 

Source Link

Usage

From source file:fi.semantum.strategia.Utils.java

License:Open Source License

public static void manage(final Main main) {

    final Database database = main.getDatabase();

    VerticalLayout content = new VerticalLayout();
    content.setSizeFull();// w w w  .  ja va  2  s  .com
    content.setSpacing(true);

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

    final ComboBox users = new ComboBox();
    users.setWidth("100%");
    users.setNullSelectionAllowed(false);
    users.addStyleName(ValoTheme.COMBOBOX_SMALL);
    users.setCaption("Valitse kyttj:");

    final Map<String, Account> accountMap = new HashMap<String, Account>();
    makeAccountCombo(main, accountMap, users);

    for (Account a : Account.enumerate(database)) {
        accountMap.put(a.getId(database), a);
        users.addItem(a.getId(database));
        users.select(a.getId(database));
    }

    final Table table = new Table();
    table.setSelectable(true);
    table.setMultiSelect(true);
    table.addStyleName(ValoTheme.TABLE_SMALL);
    table.addStyleName(ValoTheme.TABLE_SMALL);
    table.addStyleName(ValoTheme.TABLE_COMPACT);

    users.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 5036991262418844060L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            users.removeValueChangeListener(this);
            makeAccountCombo(main, accountMap, users);
            makeAccountTable(database, users, accountMap, table);
            users.addValueChangeListener(this);
        }

    });

    final TextField tf = new TextField();

    Validator nameValidator = new Validator() {

        private static final long serialVersionUID = -4779239111120669168L;

        @Override
        public void validate(Object value) throws InvalidValueException {
            String s = (String) value;
            if (s.isEmpty())
                throw new InvalidValueException("Nimi ei saa olla tyhj");
            if (accountMap.containsKey(s))
                throw new InvalidValueException("Nimi on jo kytss");
        }

    };

    final Button save = new Button("Luo", new Button.ClickListener() {

        private static final long serialVersionUID = -6053708137324681886L;

        public void buttonClick(ClickEvent event) {

            if (!tf.isValid())
                return;

            String pass = Long.toString(Math.abs(UUID.randomUUID().getLeastSignificantBits()), 36);
            Account.create(database, tf.getValue(), "", Utils.hash(pass));

            Updates.update(main, true);

            makeAccountCombo(main, accountMap, users);
            makeAccountTable(database, users, accountMap, table);

            Dialogs.infoDialog(main, "Uusi kyttj '" + tf.getValue() + "' luotu",
                    "Kyttjn salasana on " + pass + "", null);

        }

    });
    save.addStyleName(ValoTheme.BUTTON_SMALL);

    final Button remove = new Button("Poista", new Button.ClickListener() {

        private static final long serialVersionUID = -5359199320445328801L;

        public void buttonClick(ClickEvent event) {

            Object selection = users.getValue();
            Account state = accountMap.get(selection);

            // System cannot be removed
            if ("System".equals(state.getId(database)))
                return;

            state.remove(database);

            Updates.update(main, true);

            makeAccountCombo(main, accountMap, users);
            makeAccountTable(database, users, accountMap, table);

        }

    });
    remove.addStyleName(ValoTheme.BUTTON_SMALL);

    tf.setWidth("100%");
    tf.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    tf.setCaption("Luo uusi kyttj nimell:");
    tf.setValue(findFreshUserName(nameValidator));
    tf.setCursorPosition(tf.getValue().length());
    tf.setValidationVisible(true);
    tf.setInvalidCommitted(true);
    tf.setImmediate(true);
    tf.addTextChangeListener(new TextChangeListener() {

        private static final long serialVersionUID = -8274588731607481635L;

        @Override
        public void textChange(TextChangeEvent event) {
            tf.setValue(event.getText());
            try {
                tf.validate();
            } catch (InvalidValueException e) {
                save.setEnabled(false);
                return;
            }
            save.setEnabled(true);
        }

    });
    tf.addValidator(nameValidator);
    if (!tf.isValid())
        save.setEnabled(false);

    hl1.addComponent(users);
    hl1.setExpandRatio(users, 1.0f);
    hl1.setComponentAlignment(users, Alignment.BOTTOM_CENTER);

    hl1.addComponent(tf);
    hl1.setExpandRatio(tf, 1.0f);
    hl1.setComponentAlignment(tf, Alignment.BOTTOM_CENTER);

    hl1.addComponent(save);
    hl1.setExpandRatio(save, 0.0f);
    hl1.setComponentAlignment(save, Alignment.BOTTOM_CENTER);

    hl1.addComponent(remove);
    hl1.setExpandRatio(remove, 0.0f);
    hl1.setComponentAlignment(remove, Alignment.BOTTOM_CENTER);

    content.addComponent(hl1);
    content.setExpandRatio(hl1, 0.0f);

    table.addContainerProperty("Kartta", String.class, null);
    table.addContainerProperty("Oikeus", String.class, null);
    table.addContainerProperty("Laajuus", String.class, null);

    table.setWidth("100%");
    table.setHeight("100%");
    table.setNullSelectionAllowed(true);
    table.setMultiSelect(true);
    table.setCaption("Kyttjn oikeudet");

    makeAccountTable(database, users, accountMap, table);

    content.addComponent(table);
    content.setExpandRatio(table, 1.0f);

    final Button removeRights = new Button("Poista valitut rivit", new Button.ClickListener() {

        private static final long serialVersionUID = 4699670345358079045L;

        public void buttonClick(ClickEvent event) {

            Object user = users.getValue();
            Account state = accountMap.get(user);

            Object selection = table.getValue();
            Collection<?> sel = (Collection<?>) selection;

            List<Right> toRemove = new ArrayList<Right>();

            for (Object s : sel) {
                Integer index = (Integer) s;
                toRemove.add(state.rights.get(index - 1));
            }

            for (Right r : toRemove)
                state.rights.remove(r);

            Updates.update(main, true);

            makeAccountTable(database, users, accountMap, table);

        }

    });
    removeRights.addStyleName(ValoTheme.BUTTON_SMALL);

    table.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1188285609779556446L;

        @Override
        public void valueChange(ValueChangeEvent event) {

            Object selection = table.getValue();
            Collection<?> sel = (Collection<?>) selection;
            if (sel.isEmpty())
                removeRights.setEnabled(false);
            else
                removeRights.setEnabled(true);

        }

    });

    final ComboBox mapSelect = new ComboBox();
    mapSelect.setWidth("100%");
    mapSelect.setNullSelectionAllowed(false);
    mapSelect.addStyleName(ValoTheme.COMBOBOX_SMALL);
    mapSelect.setCaption("Valitse kartta:");
    for (Strategiakartta a : Strategiakartta.enumerate(database)) {
        mapSelect.addItem(a.uuid);
        mapSelect.setItemCaption(a.uuid, a.getText(database));
        mapSelect.select(a.uuid);
    }

    final ComboBox rightSelect = new ComboBox();
    rightSelect.setWidth("100px");
    rightSelect.setNullSelectionAllowed(false);
    rightSelect.addStyleName(ValoTheme.COMBOBOX_SMALL);
    rightSelect.setCaption("Valitse oikeus:");
    rightSelect.addItem("Muokkaus");
    rightSelect.addItem("Luku");
    rightSelect.select("Luku");

    final ComboBox propagateSelect = new ComboBox();
    propagateSelect.setWidth("130px");
    propagateSelect.setNullSelectionAllowed(false);
    propagateSelect.addStyleName(ValoTheme.COMBOBOX_SMALL);
    propagateSelect.setCaption("Valitse laajuus:");
    propagateSelect.addItem(VALITTU_KARTTA);
    propagateSelect.addItem(ALATASON_KARTAT);
    propagateSelect.select(VALITTU_KARTTA);

    final Button addRight = new Button("Lis rivi", new Button.ClickListener() {

        private static final long serialVersionUID = -4841787792917761055L;

        public void buttonClick(ClickEvent event) {

            Object user = users.getValue();
            Account state = accountMap.get(user);

            String mapUUID = (String) mapSelect.getValue();
            Strategiakartta map = database.find(mapUUID);
            String right = (String) rightSelect.getValue();
            String propagate = (String) propagateSelect.getValue();

            Right r = new Right(map, right.equals("Muokkaus"), propagate.equals(ALATASON_KARTAT));
            state.rights.add(r);

            Updates.update(main, true);

            makeAccountTable(database, users, accountMap, table);

        }

    });
    addRight.addStyleName(ValoTheme.BUTTON_SMALL);

    table.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 6439090862804667322L;

        @Override
        public void valueChange(ValueChangeEvent event) {

            Object selection = table.getValue();
            Collection<?> selected = (Collection<?>) selection;
            if (!selected.isEmpty()) {
                removeRights.setEnabled(true);
            } else {
                removeRights.setEnabled(false);
            }

        }

    });

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

    hl2.addComponent(removeRights);
    hl2.setComponentAlignment(removeRights, Alignment.TOP_LEFT);
    hl2.setExpandRatio(removeRights, 0.0f);

    hl2.addComponent(addRight);
    hl2.setComponentAlignment(addRight, Alignment.BOTTOM_LEFT);
    hl2.setExpandRatio(addRight, 0.0f);

    hl2.addComponent(mapSelect);
    hl2.setComponentAlignment(mapSelect, Alignment.BOTTOM_LEFT);
    hl2.setExpandRatio(mapSelect, 1.0f);

    hl2.addComponent(rightSelect);
    hl2.setComponentAlignment(rightSelect, Alignment.BOTTOM_LEFT);
    hl2.setExpandRatio(rightSelect, 0.0f);

    hl2.addComponent(propagateSelect);
    hl2.setComponentAlignment(propagateSelect, Alignment.BOTTOM_LEFT);
    hl2.setExpandRatio(propagateSelect, 0.0f);

    content.addComponent(hl2);
    content.setComponentAlignment(hl2, Alignment.BOTTOM_LEFT);
    content.setExpandRatio(hl2, 0.0f);

    final VerticalLayout vl = new VerticalLayout();

    final Panel p = new Panel();
    p.setWidth("100%");
    p.setHeight("200px");
    p.setContent(vl);

    final TimeConfiguration tc = TimeConfiguration.getInstance(database);

    final TextField tf2 = new TextField();
    tf2.setWidth("200px");
    tf2.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    tf2.setCaption("Strategiakartan mritysaika:");
    tf2.setValue(tc.getRange());
    tf2.setCursorPosition(tf.getValue().length());
    tf2.setValidationVisible(true);
    tf2.setInvalidCommitted(true);
    tf2.setImmediate(true);
    tf2.addTextChangeListener(new TextChangeListener() {

        private static final long serialVersionUID = -8274588731607481635L;

        @Override
        public void textChange(TextChangeEvent event) {
            tf2.setValue(event.getText());
            try {
                tf2.validate();
                tc.setRange(event.getText());
                updateYears(database, vl);
                Updates.update(main, true);
            } catch (InvalidValueException e) {
                return;
            }
        }

    });
    tf2.addValidator(new Validator() {

        private static final long serialVersionUID = -4779239111120669168L;

        @Override
        public void validate(Object value) throws InvalidValueException {
            String s = (String) value;
            TimeInterval ti = TimeInterval.parse(s);
            long start = ti.startYear;
            long end = ti.endYear;
            if (start < 2015)
                throw new InvalidValueException("Alkuvuosi ei voi olla aikaisempi kuin 2015.");
            if (end > 2025)
                throw new InvalidValueException("Pttymisvuosi ei voi olla myhisempi kuin 2025.");
            if (end - start > 9)
                throw new InvalidValueException("Strategiakartta ei tue yli 10 vuoden tarkasteluja.");
        }

    });

    content.addComponent(tf2);
    content.setComponentAlignment(tf2, Alignment.BOTTOM_LEFT);
    content.setExpandRatio(tf2, 0.0f);

    updateYears(database, vl);

    content.addComponent(p);
    content.setComponentAlignment(p, Alignment.BOTTOM_LEFT);
    content.setExpandRatio(p, 0.0f);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setMargin(false);

    Dialogs.makeDialog(main, main.dialogWidth(), main.dialogHeight(0.8), "Hallinnoi strategiakarttaa", "Sulje",
            content, buttons);

}

From source file:gov.va.ehtac.appsonfhir.ui.FHIRChart.java

private Panel getProblemList() {
    Panel panel = new Panel();
    panel.setCaption("Problem List");
    panel.setWidth("80%");
    panel.setHeight("100px");

    return panel;
}

From source file:gov.va.ehtac.appsonfhir.ui.FHIRChart.java

private Panel getMedications() {
    Panel panel = new Panel();
    panel.setStyleName(Runo.LAYOUT_DARKER);
    panel.setCaption("Medications");
    panel.setWidth("80%");
    panel.setHeight("100px");

    return panel;
}

From source file:gov.va.ehtac.appsonfhir.ui.FHIRChart.java

private Panel getEncounters() {
    Panel panel = new Panel();
    panel.setCaption("Encounters");
    panel.setWidth("80%");
    panel.setHeight("100px");

    return panel;
}

From source file:gov.va.ehtac.appsonfhir.ui.FHIRChart.java

private Panel getAllergies() {
    Panel panel = new Panel();
    panel.setCaption("Recent Test Results");
    panel.setWidth("80%");
    panel.setHeight("100px");

    return panel;
}

From source file:gov.va.ehtac.appsonfhir.ui.FHIRChart.java

private Panel getTests() {
    Panel panel = new Panel();
    panel.setCaption("Recent Results");
    panel.setWidth("100%");
    panel.setHeight("100px");

    return panel;
}

From source file:gov.va.ehtac.appsonfhir.ui.FHIRChart.java

private Panel getCarePlan() {
    Panel panel = new Panel();
    panel.setCaption("Care Plan");
    panel.setWidth("100%");
    panel.setHeight("100px");

    return panel;
}

From source file:gov.va.ehtac.myappsonfhir.ui.FitnessWellness.java

private GridLayout getChartLayout() {
    getChartData(-6);//from  w w  w . j a  v a2s  .com
    Button b1 = new Button("See More");
    Button b2 = new Button("See More");
    Button b3 = new Button("See More");
    Button b4 = new Button("See More");

    b1.setImmediate(true);
    b2.setImmediate(true);
    b3.setImmediate(true);
    b4.setImmediate(true);

    b1.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            dRequest = "raw";
            refresh();
        }
    });

    b2.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            dRequest = "raw";
            refresh();
        }
    });

    b3.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            dRequest = "raw";
            refresh();
        }
    });

    b4.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            dRequest = "raw";
            refresh();
        }
    });

    GridLayout grid = new GridLayout(2, 2);
    grid.setMargin(true);
    grid.setWidth("100%");

    Panel p1 = new Panel("Heart Rate Activity");
    p1.setHeight("100px");
    VerticalComponentGroup v = new VerticalComponentGroup();
    //v.addComponent(hChart.getChart());
    v.addComponent(hChart.getChart());
    v.addComponent(b1);
    grid.addComponent(v, 0, 0);

    Panel p2 = new Panel("Distance - Miles");
    p2.setHeight("100px");
    VerticalComponentGroup v2 = new VerticalComponentGroup();
    //v2.addComponent(dChart.getChart());
    v2.addComponent(dChart.getChart(results));
    v2.addComponent(b2);
    grid.addComponent(v2, 1, 0);

    Panel p3 = new Panel("Calories Burned");
    p3.setHeight("100px");
    VerticalComponentGroup v3 = new VerticalComponentGroup();
    //v3.addComponent(cChart.getChart());
    v3.addComponent(cChart.getChart(results));
    v3.addComponent(b3);
    grid.addComponent(v3, 0, 1);

    Panel p4 = new Panel("Steps Taken");
    p4.setHeight("100px");
    VerticalComponentGroup v4 = new VerticalComponentGroup();
    //v4.addComponent(sChart.getChart());
    v4.addComponent(sChart.getChart(results));
    v4.addComponent(b4);
    grid.addComponent(v4, 1, 1);
    return grid;
}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

private Component getBennuInterface() {
    GridSystemLayout gsl = new GridSystemLayout();
    gsl.setMargin(false);//from  w  ww. j a  v a 2s.c  om

    Label lblBigTitle = new Label("A Big Title (H1)", Label.CONTENT_TEXT);
    lblBigTitle.setStyleName(BennuTheme.LABEL_H1);

    Label lblBigText = new Label(LOREM_TEXT_LARGE, Label.CONTENT_TEXT);

    gsl.setCell("big_title", 16, lblBigTitle);
    gsl.setCell("big_text", 16, lblBigText);

    Label lblOneLink = new Label(
            "<a href='http://www.google.com'>Label Link : One link a day keeps the doctor away</a>",
            Label.CONTENT_XHTML);
    gsl.setCell("label_one_link", 16, lblOneLink);

    Button btOneLink = new Button("Button Link: One link a day keeps the doctor away", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            event.getButton().getWindow().showNotification("You just clicked a button link!");
        }
    });

    btOneLink.setStyleName(BaseTheme.BUTTON_LINK);
    gsl.setCell("button_one_link", 16, btOneLink);

    Label lblTitleH2 = new Label("A Not So Big Title (H2)", Label.CONTENT_TEXT);
    lblTitleH2.setStyleName(BennuTheme.LABEL_H2);
    gsl.setCell("not_so_big_title", 16, lblTitleH2);

    Label lblSmallText = new Label(LOREM_TEXT_SMALL, Label.CONTENT_TEXT);
    gsl.setCell("small_text", 16, lblSmallText);

    Table table = new Table();
    table.setSizeFull();
    table.setPageLength(0);
    table.addContainerProperty("Name", String.class, "");
    table.addContainerProperty("Age", Integer.class, "");
    table.addContainerProperty("Nickname", String.class, "");

    table.addItem(new Object[] { "Giacomo Guilizzoni", 34, "Peidi" }, 1);
    table.addItem(new Object[] { "Giodp Jack Guilizzoni", 4, "The Guids" }, 2);
    table.addItem(new Object[] { "Marco Botton", 31, "" }, 3);
    table.addItem(new Object[] { "Mariah Maciachlan", 35, "Patata" }, 4);
    table.addItem(new Object[] { "Valerie Libery WOW! Division", 23, "Val" }, 5);
    table.addItem(new Object[] { "Guido Master lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum", 99,
            "Booya Master" }, 6);

    gsl.setCell("table", 16, table);

    Label lblTitleH3 = new Label("A Getting Smaller Title (H3)", Label.CONTENT_TEXT);
    lblTitleH3.setStyleName(BennuTheme.LABEL_H3);
    gsl.setCell("getting_smaller_title", 16, lblTitleH3);

    Panel panelLeft = new Panel();
    panelLeft.setScrollable(true);
    panelLeft.setSizeFull();
    panelLeft.setHeight("145px");
    panelLeft.addComponent(new Label(LOREM_TEXT_ALL));

    Panel panelRight = new Panel();
    panelRight.addComponent(new Label(LOREM_TEXT_LARGE));

    gsl.setCell("panel_left", 8, panelLeft);
    gsl.setCell("panel_right", 8, panelRight);

    Label lblTitleH4 = new Label("A Smaller Title (H4)", Label.CONTENT_TEXT);
    lblTitleH4.setStyleName(BennuTheme.LABEL_H4);
    gsl.setCell("smaller_title", 16, lblTitleH4);

    Label lblTextb4Form = new Label(LOREM_TEXT_SMALL, Label.CONTENT_TEXT);
    gsl.setCell("txtB4Form", 0, 8, 8, lblTextb4Form);

    Form form = new Form();
    form.setSizeFull();
    form.addField("form_label", new TextField("Form Label"));
    form.addField("large_form_label", new DateField("Large Form Label"));
    form.addField("much_larger_form_label", new Select("Much Larger Form Label"));
    form.addField("something_diff", new TextArea("And now for something completely different"));

    final OptionGroup checkboxes = new OptionGroup("Checkboxes fun");
    checkboxes.setMultiSelect(true);
    checkboxes.addItem("not selected");
    checkboxes.addItem("selected");
    checkboxes.select("selected");
    checkboxes.addItem("disabled");
    checkboxes.setItemEnabled("disabled", false);
    checkboxes.addItem("disabled selected");
    checkboxes.select("disabled selected");
    checkboxes.setItemEnabled("disabled selected", false);

    form.addField("checkboxes", checkboxes);

    final OptionGroup radiobuttons = new OptionGroup("Radio on/off");
    radiobuttons.addItem("option 1(selected)");
    radiobuttons.select("option 1(selected)");
    radiobuttons.addItem("option 2");
    radiobuttons.addItem("option 3 (disabled)");
    radiobuttons.setItemEnabled("option 3 (disabled)", false);

    radiobuttons.addItem("option 4 (disabled and selected)");
    radiobuttons.select("option 4 (disabled and selected)");
    radiobuttons.setItemEnabled("option 4 (disabled and selected)", false);

    form.addField("radiobuttons", radiobuttons);

    form.getFooter().addComponent(new Button("Submit the info"));
    form.getFooter().addComponent(new Button("Cancel the info"));

    final Panel rightFormPanel = new Panel();
    rightFormPanel.setScrollable(true);
    rightFormPanel.setSizeFull();
    rightFormPanel.setHeight("400px");
    rightFormPanel.addComponent(new Label(LOREM_TEXT_ALL, Label.CONTENT_TEXT));

    gsl.setCell("form", 12, form);
    gsl.setCell("rightFormPanel", 4, rightFormPanel);

    return gsl;
}

From source file:org.activiti.kickstart.ui.popup.ProcessImagePopupWindow.java

License:Apache License

protected void initUi() {
    setModal(true);/* w  w  w . j av  a  2 s .c  o m*/
    setHeight("80%");
    setWidth("80%");
    center();
    setCaption(TITLE);

    StreamResource.StreamSource streamSource = null;
    if (processDefinitionId != null) {
        streamSource = new StreamSource() {

            private static final long serialVersionUID = -8875067466181823014L;

            public InputStream getStream() {
                return adhocWorkflowService.getProcessImage(processDefinitionId);
            }
        };
    } else if (adhocWorkflow != null) {
        final ProcessDiagramGenerator converter = new ProcessDiagramGenerator(adhocWorkflow);
        streamSource = new StreamSource() {

            private static final long serialVersionUID = 239500411112658830L;

            public InputStream getStream() {
                return converter.execute();
            }
        };
    }

    // resource must have unique id!
    StreamResource imageresource = new StreamResource(streamSource, UUID.randomUUID() + ".png",
            viewManager.getApplication());
    Panel panel = new Panel();
    panel.setContent(new HorizontalLayout());
    panel.setStyleName(Reindeer.PANEL_LIGHT);
    panel.setHeight("95%");
    Embedded embedded = new Embedded("", imageresource);
    embedded.setType(Embedded.TYPE_IMAGE);
    panel.addComponent(embedded);
    addComponent(panel);
}