Example usage for com.vaadin.ui HorizontalLayout setMargin

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

Introduction

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

Prototype

@Override
    public void setMargin(boolean enabled) 

Source Link

Usage

From source file:annis.gui.frequency.FrequencyQueryPanel.java

License:Apache License

public FrequencyQueryPanel(final QueryController controller, QueryUIState state) {
    this.controller = controller;
    this.state = state;

    setWidth("99%");
    setHeight("99%");
    setMargin(true);/*from  w  w w  .  j  av a 2 s .c o m*/

    queryLayout = new VerticalLayout();
    queryLayout.setWidth("100%");
    queryLayout.setHeight("100%");

    HorizontalLayout queryDescriptionLayout = new HorizontalLayout();
    queryDescriptionLayout.setSpacing(true);
    queryDescriptionLayout.setWidth("100%");
    queryDescriptionLayout.setHeight("-1px");
    queryLayout.addComponent(queryDescriptionLayout);

    lblCorpusList = new Label("");
    lblCorpusList.setCaption("selected corpora:");
    lblCorpusList.setWidth("100%");

    lblAQL = new Label("");
    lblAQL.setCaption("query to analyze:");
    lblAQL.setWidth("100%");
    lblAQL.addStyleName(Helper.CORPUS_FONT_FORCE);

    queryDescriptionLayout.addComponent(lblCorpusList);
    queryDescriptionLayout.addComponent(lblAQL);

    queryDescriptionLayout.setComponentAlignment(lblCorpusList, Alignment.MIDDLE_LEFT);
    queryDescriptionLayout.setComponentAlignment(lblAQL, Alignment.MIDDLE_RIGHT);

    tblFrequencyDefinition = new Table();
    tblFrequencyDefinition.setImmediate(true);
    tblFrequencyDefinition.setSortEnabled(false);
    tblFrequencyDefinition.setSelectable(true);
    tblFrequencyDefinition.setMultiSelect(true);
    tblFrequencyDefinition.setTableFieldFactory(new FieldFactory());
    tblFrequencyDefinition.setEditable(true);
    tblFrequencyDefinition.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            if (tblFrequencyDefinition.getValue() == null
                    || ((Set<Object>) tblFrequencyDefinition.getValue()).isEmpty()) {
                btDeleteRow.setEnabled(false);
            } else {
                btDeleteRow.setEnabled(true);
            }
        }
    });

    lblErrorOrMsg = new Label("No node with explicit name in OR expression found! "
            + "When using OR expression you need to explicitly name the nodes "
            + "you want to include in the frequency analysis with \"#\", " + "like e.g. in <br />" + "<pre>"
            + "(n1#tok=\"fun\" | n1#tok=\"severity\")" + "</pre>");
    lblErrorOrMsg.setContentMode(ContentMode.HTML);
    lblErrorOrMsg.addStyleName("embedded-warning");
    lblErrorOrMsg.setWidth("100%");
    lblErrorOrMsg.setVisible(false);
    queryLayout.addComponent(lblErrorOrMsg);

    tblFrequencyDefinition.setWidth("100%");
    tblFrequencyDefinition.setHeight("100%");

    tblFrequencyDefinition.setContainerDataSource(state.getFrequencyTableDefinition());

    tblFrequencyDefinition.setColumnHeader("nr", "Node number/name");
    tblFrequencyDefinition.setColumnHeader("annotation", "Selected annotation of node");
    tblFrequencyDefinition.setColumnHeader("comment", "Comment");

    tblFrequencyDefinition.addStyleName(Helper.CORPUS_FONT_FORCE);

    tblFrequencyDefinition.setRowHeaderMode(Table.RowHeaderMode.INDEX);

    tblFrequencyDefinition.setColumnExpandRatio("nr", 0.15f);
    tblFrequencyDefinition.setColumnExpandRatio("annotation", 0.35f);
    tblFrequencyDefinition.setColumnExpandRatio("comment", 0.5f);
    tblFrequencyDefinition.setVisibleColumns("nr", "annotation", "comment");

    queryLayout.addComponent(tblFrequencyDefinition);

    metaNamesContainer = new IndexedContainer();
    PopupTwinColumnSelect metaSelect = new PopupTwinColumnSelect();
    metaSelect.setSelectableContainer(metaNamesContainer);
    metaSelect.setPropertyDataSource(state.getFrequencyMetaData());
    metaSelect.setCaption("Metadata");

    queryLayout.addComponent(metaSelect);

    if (controller != null) {
        createAutomaticEntriesForQuery(state.getAql().getValue());
        updateQueryInfo(state.getAql().getValue());
    }

    HorizontalLayout layoutButtons = new HorizontalLayout();

    btAdd = new Button("Add");
    btAdd.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            cbAutomaticMode.setValue(Boolean.FALSE);

            int nr = 1;
            // get the highest number of values from the existing defitions
            for (Object id : tblFrequencyDefinition.getItemIds()) {
                String textNr = (String) tblFrequencyDefinition.getItem(id).getItemProperty("nr").getValue();
                try {
                    nr = Math.max(nr, Integer.parseInt(textNr));
                } catch (NumberFormatException ex) {
                    // was not a number but a named node
                }
            }
            if (controller != null) {
                List<QueryNode> nodes = parseQuery(FrequencyQueryPanel.this.state.getAql().getValue());
                nr = Math.min(nr, nodes.size() - 1);
                int id = counter++;
                UserGeneratedFrequencyEntry entry = new UserGeneratedFrequencyEntry();
                entry.setAnnotation("tok");
                entry.setComment("");
                entry.setNr("" + (nr + 1));
                FrequencyQueryPanel.this.state.getFrequencyTableDefinition().addItem(id, entry);
            }
        }
    });
    layoutButtons.addComponent(btAdd);

    btDeleteRow = new Button("Delete selected row(s)");
    btDeleteRow.setEnabled(false);
    btDeleteRow.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Set<Object> selected = new HashSet((Set<Object>) tblFrequencyDefinition.getValue());
            for (Object o : selected) {
                cbAutomaticMode.setValue(Boolean.FALSE);
                tblFrequencyDefinition.removeItem(o);

            }
        }
    });
    layoutButtons.addComponent(btDeleteRow);

    cbAutomaticMode = new CheckBox("Automatic mode", true);
    cbAutomaticMode.setImmediate(true);
    cbAutomaticMode.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            btShowFrequencies.setEnabled(true);
            if (cbAutomaticMode.getValue()) {
                tblFrequencyDefinition.removeAllItems();
                if (controller != null) {
                    createAutomaticEntriesForQuery(FrequencyQueryPanel.this.state.getAql().getValue());
                }
            }
        }
    });
    layoutButtons.addComponent(cbAutomaticMode);

    btReset = new Button("Reset to default");
    btReset.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            cbAutomaticMode.setValue(Boolean.TRUE);
            btShowFrequencies.setEnabled(true);
            tblFrequencyDefinition.removeAllItems();
            if (controller != null) {
                createAutomaticEntriesForQuery(FrequencyQueryPanel.this.state.getAql().getValue());
            }
        }
    });
    //layoutButtons.addComponent(btReset);

    layoutButtons.setComponentAlignment(btAdd, Alignment.MIDDLE_LEFT);
    layoutButtons.setComponentAlignment(btDeleteRow, Alignment.MIDDLE_LEFT);
    layoutButtons.setComponentAlignment(cbAutomaticMode, Alignment.MIDDLE_RIGHT);
    layoutButtons.setExpandRatio(btAdd, 0.0f);
    layoutButtons.setExpandRatio(btDeleteRow, 0.0f);
    layoutButtons.setExpandRatio(cbAutomaticMode, 1.0f);

    layoutButtons.setMargin(true);
    layoutButtons.setSpacing(true);
    layoutButtons.setHeight("-1px");
    layoutButtons.setWidth("100%");

    queryLayout.addComponent(layoutButtons);

    btShowFrequencies = new Button("Perform frequency analysis");
    btShowFrequencies.setDisableOnClick(true);
    btShowFrequencies.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {

            if (controller != null) {
                try {
                    if (resultPanel != null) {
                        removeComponent(resultPanel);
                    }
                    queryLayout.setVisible(false);

                    pbQuery.setCaption("Please wait, the frequencies analysis can take some time");
                    pbQuery.setIndeterminate(true);
                    pbQuery.setEnabled(true);
                    pbQuery.setVisible(true);

                    controller.executeFrequency(FrequencyQueryPanel.this);
                } catch (Exception ex) {
                    btShowFrequencies.setEnabled(true);
                }
            }

        }
    });
    queryLayout.addComponent(btShowFrequencies);

    queryLayout.setComponentAlignment(tblFrequencyDefinition, Alignment.TOP_CENTER);
    queryLayout.setComponentAlignment(layoutButtons, Alignment.TOP_CENTER);
    queryLayout.setComponentAlignment(btShowFrequencies, Alignment.TOP_CENTER);

    queryLayout.setExpandRatio(tblFrequencyDefinition, 1.0f);
    queryLayout.setExpandRatio(layoutButtons, 0.0f);
    queryLayout.setExpandRatio(btShowFrequencies, 0.0f);

    queryLayout.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {
        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            Component c = event.getClickedComponent();
            if (c instanceof Field) {
                Object itemID = getField2ItemID().get((Field) c);
                if (itemID != null) {
                    if (!event.isCtrlKey() && !event.isShiftKey()) {
                        // deselect everything else if no modifier key was clicked
                        tblFrequencyDefinition.setValue(null);
                    }
                    // select the item
                    tblFrequencyDefinition.select(itemID);
                }
            }
        }
    });

    btShowQuery = new Button("New Analysis", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            showQueryDefinitionPanel();
        }
    });
    btShowQuery.setVisible(false);

    pbQuery.setVisible(false);
    addComponent(pbQuery);

    addComponent(queryLayout);
    addComponent(btShowQuery);

    setComponentAlignment(btShowQuery, Alignment.TOP_CENTER);
    setComponentAlignment(pbQuery, Alignment.TOP_CENTER);

    if (controller != null) {
        state.getSelectedCorpora().addValueChangeListener(new Property.ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                if (cbAutomaticMode.getValue()) {
                    createAutomaticEntriesForQuery(FrequencyQueryPanel.this.state.getAql().getValue());
                }
                updateQueryInfo(FrequencyQueryPanel.this.state.getAql().getValue());
            }
        });
    }
}

From source file:annis.gui.HelpUsWindow.java

License:Apache License

public HelpUsWindow() {
    setSizeFull();// w w  w . j a  va  2 s  .  com
    layout = new VerticalLayout();
    setContent(layout);

    layout.setSizeFull();
    layout.setMargin(new MarginInfo(false, false, true, false));

    HorizontalLayout hLayout = new HorizontalLayout();
    hLayout.setSizeFull();
    hLayout.setMargin(false);

    VerticalLayout labelLayout = new VerticalLayout();
    labelLayout.setMargin(true);
    labelLayout.setSizeFull();

    Label lblOpenSource = new Label();

    lblOpenSource.setValue("<h1>ANNIS is <a href=\"http://opensource.org/osd\">Open Source</a> "
            + "software.</h1>" + "<p>This means you are free to download the source code and add new "
            + "features or make other adjustments to ANNIS on your own.<p/>"
            + "Here are some examples how you can help ANNIS:" + "<ul>"
            + "<li>Fix or report problems (bugs) you encounter when using the ANNIS software.</li>"
            + "<li>Add new features.</li>" + "<li>Enhance the documentation</li>" + "</ul>"
            + "<p>Feel free to visit our GitHub page for more information: <a href=\"https://github.com/korpling/ANNIS\" target=\"_blank\">https://github.com/korpling/ANNIS</a></p>");
    lblOpenSource.setContentMode(ContentMode.HTML);
    lblOpenSource.setStyleName("opensource");
    lblOpenSource.setWidth("100%");
    lblOpenSource.setHeight("-1px");
    labelLayout.addComponent(lblOpenSource);

    Link lnkFork = new Link();
    lnkFork.setResource(new ExternalResource("https://github.com/korpling/ANNIS"));
    lnkFork.setIcon(
            new ExternalResource("https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png"));
    lnkFork.setTargetName("_blank");

    hLayout.addComponent(labelLayout);
    hLayout.addComponent(lnkFork);
    hLayout.setComponentAlignment(labelLayout, Alignment.TOP_LEFT);
    hLayout.setComponentAlignment(lnkFork, Alignment.TOP_RIGHT);
    hLayout.setExpandRatio(labelLayout, 1.0f);

    layout.addComponent(hLayout);

    final HelpUsWindow finalThis = this;

    btClose = new Button("Close");
    btClose.addClickListener(new OkClickListener(finalThis));
    layout.addComponent(btClose);

    layout.setComponentAlignment(hLayout, Alignment.MIDDLE_CENTER);
    layout.setComponentAlignment(btClose, Alignment.MIDDLE_CENTER);
    layout.setExpandRatio(hLayout, 1.0f);
}

From source file:at.peppol.webgui.app.components.InvoiceTabForm.java

License:Mozilla Public License

private void initElements() {
    supplierForm = new PartyDetailForm("Supplier", supplier.getParty());
    supplierForm.setImmediate(true);/*from   w  ww  .  j  a  v a 2  s.c  o m*/
    customerForm = new PartyDetailForm("Customer", customer.getParty());
    customerForm.setImmediate(true);
    //supplierForm.setSizeFull ();
    //customerForm.setSizeFull ();

    final HorizontalLayout footerLayout = new HorizontalLayout();
    footerLayout.setSpacing(true);
    footerLayout.setMargin(true);
    footerLayout.addComponent(new Button("Save Invoice", new Button.ClickListener() {

        @Override
        public void buttonClick(final Button.ClickEvent event) {
            SetCommonCurrency();
            ValidatorHandler vh = new ValidatorHandler(footerLayout);
            AbstractUBLDocumentMarshaller.setGlobalValidationEventHandler(vh);
            vh.clearErrors();
            clearTabErrorStyles();
            boolean invoiceHasErrors = false;

            List<ValidationError> errors = GlobalValidationsRegistry.runAll();
            if (errors.size() > 0) {
                invoiceHasErrors = true;
                Window errorWindow = new Window("Errors");
                //position and size of the window
                errorWindow.setPositionX(200);
                errorWindow.setPositionY(200);
                errorWindow.setWidth("600px");
                errorWindow.setHeight("300px");

                //add the error messages
                String errorMessage = "<ol>";
                for (int i = 0; i < errors.size(); i++) {
                    errorMessage += "<li style=\"margin-top: 4px;\"><b>" + errors.get(i).getRuleID() + "</b>: "
                            + errors.get(i).getErrorInfo() + "</li>";
                    //mark the appropriate Tab as error
                    Tab tab = invTabSheet.getTab(errors.get(i).getMainComponent());
                    if (tab != null)
                        tab.setStyleName("test111");
                }
                errorMessage += "</ol>";
                errorWindow.addComponent(new Label(errorMessage, Label.CONTENT_XHTML));

                //show the error window
                getParent().getWindow().addWindow(errorWindow);
                errors.clear();
            }

            ValidatorsList.validateListenersNotify();
            if (ValidatorsList.validateListeners() == false) {
                invoiceHasErrors = true;
            }

            if (invoiceHasErrors) {
                getWindow().showNotification("Validation error. Could not save invoice",
                        Notification.TYPE_TRAY_NOTIFICATION);
            } else {
                try {
                    if (invoiceFilePath.equals("")) {
                        UBL20DocumentMarshaller.writeInvoice(invoice,
                                new StreamResult(new File(um.getDrafts().getFolder().toString()
                                        + System.getProperty("file.separator") + "invoice"
                                        + System.currentTimeMillis() + ".xml")));
                        invoiceFilePath = um.getDrafts().getFolder().toString()
                                + System.getProperty("file.separator") + "invoice" + System.currentTimeMillis()
                                + ".xml";
                    } else {
                        UBL20DocumentMarshaller.writeInvoice(invoice,
                                new StreamResult(new File(invoiceFilePath)));
                    }
                    getWindow()
                            .showNotification(
                                    "Validation passed. Invoice saved in "
                                            + um.getDrafts().getName().toUpperCase() + " folder",
                                    Notification.TYPE_TRAY_NOTIFICATION);
                } catch (Exception e) {
                    getWindow().showNotification("Disk access error. Could not save invoice",
                            Notification.TYPE_ERROR_MESSAGE);
                }
            }

            /*PEPPOL validation
             * final ValidationPyramid vp = new ValidationPyramid (EValidationDocumentType.INVOICE,
                    ValidationTransaction.createUBLTransaction (ETransaction.T10));
             final List <ValidationPyramidResultLayer> aResults = vp.applyValidation (new FileSystemResource ("invoice.xml"))
                   .getAllValidationResultLayers ();
             if (aResults.isEmpty ())
               System.out.println ("  The document is valid!");
             else
               for (final ValidationPyramidResultLayer aResultLayer : aResults)
                 for (final IResourceError aError : aResultLayer.getValidationErrors ())
                   System.out.println ("  " + aResultLayer.getValidationLevel () + " " + aError.getAsString (Locale.US));
            */
            /*ValidatorsList.validateListenersNotify();
            if (ValidatorsList.validateListeners() == false) {
               getParent().getWindow().showNotification("Validation error... ",Notification.TYPE_TRAY_NOTIFICATION);
            }
            else
               getParent().getWindow().showNotification("Validation passed! ",Notification.TYPE_TRAY_NOTIFICATION);
            */

        }
    }));

    /*    footerLayout.addComponent (new Button ("Save Invoice", new Button.ClickListener () {
            
          @Override
          public void buttonClick (final Button.ClickEvent event) {
            try {
              SetCommonCurrency ();          
              System.out.println (invoice.getDelivery ().get (0).getDeliveryAddress ().getStreetName ().getValue ());
            }
            catch (final Exception ex) {
              LOGGER.error ("Error creating files. ", ex);
            }
          }
        }));
    */
    footerLayout.addComponent(new Button("Read Invoice from disk", new Button.ClickListener() {

        @Override
        public void buttonClick(final Button.ClickEvent event) {
            try {
                SetCommonCurrency();
                InvoiceType inv = UBL20DocumentMarshaller
                        .readInvoice(new StreamSource(new FileInputStream(new File("invoice.xml"))));
            } catch (final Exception ex) {
                LOGGER.error("Error creating files. ", ex);
            }
        }
    }));

    getFooter().addComponent(footerLayout);

}

From source file:at.peppol.webgui.app.components.TabInvoiceLine.java

License:Mozilla Public License

private void initElements() {
    invoiceLineList = parent.getInvoice().getInvoiceLine();

    final GridLayout grid = new GridLayout(4, 4);
    final VerticalLayout outerLayout = new VerticalLayout();
    hiddenContent = new VerticalLayout();
    hiddenContent.setSpacing(true);/*from   w w  w.j ava 2 s  .c o m*/
    hiddenContent.setMargin(true);

    table = new InvoiceLineTable(parent.getInvoice().getInvoiceLine());
    table.setSelectable(true);
    table.setImmediate(true);
    table.setNullSelectionAllowed(false);
    table.setHeight(150, UNITS_PIXELS);
    table.setFooterVisible(false);
    table.addStyleName("striped strong");

    //table.addListener(parent.new LinesTotalAmountListener());
    //table.addListener(parent.new TaxExclusiveAmountListener());

    final VerticalLayout tableContainer = new VerticalLayout();
    tableContainer.addComponent(table);
    tableContainer.setMargin(false, true, false, false);

    // buttons Add, Edit, Delete
    final Button addBtn = new Button("Add new");
    final Button editBtn = new Button("Edit selected");
    final Button deleteBtn = new Button("Delete Selected");

    addBtn.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            addBtn.setEnabled(false);
            editBtn.setEnabled(false);
            deleteBtn.setEnabled(false);
            //addMode = true;
            hiddenContent.removeAllComponents();
            invoiceLineItem = createInvoiceLineItem();

            final Label formLabel = new Label("<h3>Adding new invoice line</h3>", Label.CONTENT_XHTML);

            hiddenContent.addComponent(formLabel);
            final Form form = createInvoiceLineMainForm();
            hiddenContent.addComponent(form);

            HorizontalLayout h1 = new HorizontalLayout();
            h1.setSpacing(true);
            h1.setMargin(true);

            // Set invoiceLine 0..N cardinality panels
            //final Panel itemPropertyPanel = new ItemPropertyForm ("Additional",
            //                                                      invoiceLineItem.getInvLineAdditionalItemPropertyList ());
            final ItemPropertyForm itemPropertyPanel = new ItemPropertyForm("Additional",
                    invoiceLineItem.getInvLineAdditionalItemPropertyList());
            h1.addComponent(itemPropertyPanel);

            //add the allowance/charge indicator 0..N cardinality
            final InvoiceLineAllowanceChargeForm lineAllowanceChargePanel = new InvoiceLineAllowanceChargeForm(
                    "", invoiceLineItem.getAllowanceCharge(), parent.getInvoice());

            //add the listeners for line extension amount calculation
            BIIRULE_T10_R018 biirule_t10_r018 = new BIIRULE_T10_R018(invoiceLineItem, form);
            form.getField("Price Amount").addListener(biirule_t10_r018);
            form.getField("Base Quantity").addListener(biirule_t10_r018);
            form.getField("Invoiced Quantity").addListener(biirule_t10_r018);
            lineAllowanceChargePanel.getTable().addListener((ItemSetChangeListener) biirule_t10_r018);

            //add the listeners for VAT AE tax total amount
            EUGEN_T10_R018 eugen_t10_r018 = new EUGEN_T10_R018(form, "Tax Scheme ID", "Tax Category ID",
                    "Tax Total Amount");
            form.getField("Tax Scheme ID").addListener(eugen_t10_r018);
            form.getField("Tax Category ID").addListener(eugen_t10_r018);

            h1.addComponent(lineAllowanceChargePanel);

            HorizontalLayout h2 = new HorizontalLayout();
            h2.setSpacing(true);
            h2.setMargin(true);

            final Panel lineOrderPanel = new InvoiceLineOrderForm("", invoiceLineItem.getInvLineOrderList());

            h2.addComponent(lineOrderPanel);

            final Panel lineCommodityPanel = new InvoiceLineCommodityClassificationForm("",
                    invoiceLineItem.getInvLineCommodityClassificationList());

            h2.addComponent(lineCommodityPanel);

            hiddenContent.addComponent(h1);
            hiddenContent.addComponent(h2);

            // Save new line button
            final HorizontalLayout buttonLayout = new HorizontalLayout();
            buttonLayout.setSpacing(true);
            buttonLayout.addComponent(new Button("Save invoice line", new Button.ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    AbstractTextField itemName = (AbstractTextField) form.getField("Item Name");
                    itemName.setMaxLength(50);

                    if (itemName.getValue().toString().length() > 50) {
                        //itemName.setComponentError(new UserError("Item Name should not be more than 50 characters"));
                        itemName.setValue(itemName.getValue().toString().substring(0, 49));
                        getWindow().showNotification("Item Name truncated to 50 chars",
                                Notification.TYPE_TRAY_NOTIFICATION);
                    }

                    try {
                        /*Collection<String> props = (Collection<String>) form.getItemPropertyIds();
                        List<Field> fields = new ArrayList<Field>();
                        for (String property : props) {
                           fields.add(form.getField(property));
                        }
                        List<BlurListener> listeners = new ArrayList<BlurListener>();
                        for (Field f : fields) {
                           if (f instanceof AbstractTextField) {
                              AbstractTextField ff = (AbstractTextField)f;
                              listeners.addAll((Collection<BlurListener>) ff.getListeners(BlurEvent.class));
                           }
                        }
                        ValidatorsList.validateListenersNotify(listeners);
                        form.validate();*/
                        Utils.validateFormFields(form);
                        //form.commit();
                        // update table (and consequently add new item to invoiceList list)
                        table.addLine(invoiceLineItem);
                        //hide form
                        hiddenContent.setVisible(false);
                        //addMode = false;
                        addBtn.setEnabled(true);
                        editBtn.setEnabled(true);
                        deleteBtn.setEnabled(true);
                        //itemName.setComponentError(null);
                    } catch (InvalidValueException e) {
                        getWindow().showNotification("Invoice line has errors",
                                Notification.TYPE_TRAY_NOTIFICATION);
                    }

                }
            }));
            buttonLayout.addComponent(new Button("Cancel", new Button.ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    addBtn.setEnabled(true);
                    editBtn.setEnabled(true);
                    deleteBtn.setEnabled(true);
                    hiddenContent.removeAllComponents();
                    // hide form
                    hiddenContent.setVisible(false);
                    addMode = false;
                }
            }));

            hiddenContent.addComponent(buttonLayout);

            // hiddenContent.setVisible(!hiddenContent.isVisible());
            hiddenContent.setVisible(true);
        }
    });

    editBtn.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            final Object rowId = table.getValue(); // get the selected rows id
            if (rowId != null) {
                addBtn.setEnabled(true);
                editBtn.setEnabled(true);
                deleteBtn.setEnabled(true);

                final String sid = (String) table.getContainerProperty(rowId, "ID.value").getValue();
                // TODO: PUT THIS IN FUNCTION BEGINS
                editMode = true;
                hiddenContent.removeAllComponents();

                // get selected item
                invoiceLineItem = (InvoiceLineAdapter) invoiceLineList.get(table.getIndexFromID(sid));
                // clone it to original item
                originalItem = new InvoiceLineAdapter();
                cloneInvoiceLineItem(invoiceLineItem, originalItem);

                final Label formLabel = new Label("<h3>Editing invoice line</h3>", Label.CONTENT_XHTML);

                hiddenContent.addComponent(formLabel);
                final Form form = createInvoiceLineMainForm();
                hiddenContent.addComponent(form);

                HorizontalLayout h1 = new HorizontalLayout();
                h1.setSpacing(true);
                h1.setMargin(true);
                // Set invoiceLine 0..N cardinality panels
                final ItemPropertyForm itemPropertyPanel = new ItemPropertyForm("Additional",
                        invoiceLineItem.getInvLineAdditionalItemPropertyList());
                h1.addComponent(itemPropertyPanel);

                //add the allowance/charge indicator 0..N cardinality
                final InvoiceLineAllowanceChargeForm lineAllowanceChargePanel = new InvoiceLineAllowanceChargeForm(
                        "", invoiceLineItem.getAllowanceCharge(), parent.getInvoice());

                //add the listeners for line extension amount calculation
                BIIRULE_T10_R018 biirule_t10_r018 = new BIIRULE_T10_R018(invoiceLineItem, form);
                form.getField("Price Amount").addListener(biirule_t10_r018);
                form.getField("Base Quantity").addListener(biirule_t10_r018);
                lineAllowanceChargePanel.getTable().addListener((ItemSetChangeListener) biirule_t10_r018);

                //add the listeners for VAT AE tax total amount
                EUGEN_T10_R018 eugen_t10_r018 = new EUGEN_T10_R018(form, "Tax Scheme ID", "Tax Category ID",
                        "Tax Total Amount");
                form.getField("Tax Scheme ID").addListener(eugen_t10_r018);
                form.getField("Tax Category ID").addListener(eugen_t10_r018);

                h1.addComponent(lineAllowanceChargePanel);

                HorizontalLayout h2 = new HorizontalLayout();
                h2.setSpacing(true);
                h2.setMargin(true);

                final Panel lineOrderPanel = new InvoiceLineOrderForm("",
                        invoiceLineItem.getInvLineOrderList());
                h2.addComponent(lineOrderPanel);

                final Panel lineCommodityPanel = new InvoiceLineCommodityClassificationForm("",
                        invoiceLineItem.getInvLineCommodityClassificationList());
                h2.addComponent(lineCommodityPanel);

                hiddenContent.addComponent(h1);
                hiddenContent.addComponent(h2);

                /*// Set invoiceLine 0..N cardinalily panels
                final Panel itemPropertyPanel = new ItemPropertyForm ("Additional",
                                                        invoiceLineItem.getInvLineAdditionalItemPropertyList ());
                hiddenContent.addComponent (itemPropertyPanel);*/

                // Save new line button
                final HorizontalLayout buttonLayout = new HorizontalLayout();
                buttonLayout.setSpacing(true);
                buttonLayout.addComponent(new Button("Save changes", new Button.ClickListener() {
                    @Override
                    public void buttonClick(final ClickEvent event) {
                        // update table (and consequently edit item to allowanceChargeList
                        // list)
                        AbstractTextField itemName = (AbstractTextField) form.getField("Item Name");
                        itemName.setMaxLength(50);

                        if (itemName.getValue().toString().length() > 50) {
                            //itemName.setComponentError(new UserError("Item Name should not be more than 50 characters"));
                            itemName.setValue(itemName.getValue().toString().substring(0, 49));
                            getWindow().showNotification("Item Name truncated to 50 chars",
                                    Notification.TYPE_TRAY_NOTIFICATION);
                        }

                        try {
                            /*Collection<String> props = (Collection<String>) form.getItemPropertyIds();
                            List<Field> fields = new ArrayList<Field>();
                            for (String property : props) {
                               fields.add(form.getField(property));
                            }
                            List<BlurListener> listeners = new ArrayList<BlurListener>();
                            for (Field f : fields) {
                               if (f instanceof AbstractTextField) {
                                  AbstractTextField ff = (AbstractTextField)f;
                                  listeners.addAll((Collection<BlurListener>) ff.getListeners(BlurEvent.class));
                               }
                            }
                            ValidatorsList.validateListenersNotify(listeners);
                            form.validate();*/
                            Utils.validateFormFields(form);
                            //table.setInvoiceLine (sid, invoiceLineItem);
                            table.setLine(sid, invoiceLineItem);
                            addBtn.setEnabled(true);
                            editBtn.setEnabled(true);
                            deleteBtn.setEnabled(true);
                            //    hide form
                            hiddenContent.setVisible(false);
                            editMode = false;
                        } catch (InvalidValueException e) {
                            getWindow().showNotification("Invoice line has errors",
                                    Notification.TYPE_TRAY_NOTIFICATION);
                        }
                    }
                }));
                buttonLayout.addComponent(new Button("Cancel editing", new Button.ClickListener() {
                    @Override
                    public void buttonClick(final ClickEvent event) {
                        hiddenContent.removeAllComponents();
                        addBtn.setEnabled(true);
                        editBtn.setEnabled(true);
                        deleteBtn.setEnabled(true);
                        //table.setInvoiceLine (sid, originalItem);
                        table.setLine(sid, originalItem);
                        // hide form
                        hiddenContent.setVisible(false);
                        editMode = false;
                    }
                }));

                hiddenContent.addComponent(buttonLayout);

                // hiddenContent.setVisible(!hiddenContent.isVisible());
                hiddenContent.setVisible(true);
                // TODO: PUT THIS IN FUNCTION ENDS
            } else {
                parent.getWindow().showNotification("Info", "No table line is selected",
                        Window.Notification.TYPE_HUMANIZED_MESSAGE);
            }

        }
    });

    deleteBtn.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            final Object rowId = table.getValue(); // get the selected rows id
            if (rowId != null) {
                if (table.getContainerProperty(rowId, "ID.value").getValue() != null) {
                    final String sid = (String) table.getContainerProperty(rowId, "ID.value").getValue();
                    //table.removeInvoiceLine (sid);
                    table.removeLine(sid);
                }
            } else {
                parent.getWindow().showNotification("Info", "No table line is selected",
                        Window.Notification.TYPE_HUMANIZED_MESSAGE);

            }
        }
    });

    final VerticalLayout buttonsContainer = new VerticalLayout();
    buttonsContainer.setSpacing(true);
    buttonsContainer.addComponent(addBtn);
    buttonsContainer.addComponent(editBtn);
    buttonsContainer.addComponent(deleteBtn);

    final Panel outerPanel = new Panel("Invoice Line");

    grid.addComponent(tableContainer, 0, 0);
    grid.addComponent(buttonsContainer, 1, 0);

    outerPanel.addComponent(grid);
    outerLayout.addComponent(outerPanel);

    // ---- HIDDEN FORM BEGINS -----
    final VerticalLayout formLayout = new VerticalLayout();
    formLayout.addComponent(hiddenContent);
    hiddenContent.setVisible(false);
    outerLayout.addComponent(formLayout);
    // ---- HIDDEN FORM ENDS -----

    setLayout(outerLayout);
    grid.setSizeUndefined();
    outerPanel.requestRepaintAll();
}

From source file:br.com.anteros.mobileserver.app.form.ExecuteForm.java

License:Apache License

private void createForm() {
    if (actionSynchronism.getItems() != null) {

        Label lblTitle = new Label("Parmetros de execuo Ao " + actionSynchronism.getName() + " ("
                + actionSynchronism.getId() + ")");
        lblTitle.setStyleName("h2 color");
        lblTitle.setImmediate(false);//w  ww .j  av  a 2  s . c om
        addComponent(lblTitle);
        setComponentAlignment(lblTitle, Alignment.TOP_LEFT);

        Synchronism synchronism = actionSynchronism.getItems().iterator().next();
        executeForm = new Form();
        fields.clear();
        ParameterSynchronism[] parameters = null;
        if (synchronism instanceof TableSynchronism)
            parameters = ((TableSynchronism) synchronism).getParameters();
        if (synchronism instanceof ProcedureSynchronism)
            parameters = ((ProcedureSynchronism) synchronism).getParameters();
        for (ParameterSynchronism param : parameters) {
            if (param.getParameterType().intValue() == ParameterSynchronism.INPUT
                    || param.getParameterType().intValue() == ParameterSynchronism.SUBSTITUITION) {
                String value = FieldTypes.getFieldTypes().get(param.getParameterDataType().intValue() + "");
                if (value != null) {
                    if (FieldTypes.UNKNOW.equalsIgnoreCase(value)) {
                        TextField field = new TextField();
                        field.setCaption(param.getName());
                        field.setWidth("400px");
                        executeForm.addField(param.getName(), field);
                        fields.add(field);
                    } else if (FieldTypes.INTEGER.equalsIgnoreCase(value)) {
                        TextField field = new TextField();
                        field.setCaption(param.getName());
                        field.setWidth("150px");
                        field.setRequired(true);
                        field.setRequiredError("Informe o valor para o campo " + param.getName());
                        executeForm.addField(param.getName(), field);
                        fields.add(field);
                    } else if (FieldTypes.VARCHAR.equalsIgnoreCase(value)) {
                        TextField field = new TextField();
                        field.setCaption(param.getName());
                        field.setWidth("400px");
                        field.setRequired(true);
                        field.setRequiredError("Informe o valor para o campo " + param.getName());
                        executeForm.addField(param.getName(), field);
                        fields.add(field);
                    } else if (FieldTypes.FLOAT.equalsIgnoreCase(value)) {
                        TextField field = new TextField();
                        field.setCaption(param.getName());
                        field.setWidth("150px");
                        field.setRequired(true);
                        field.setRequiredError("Informe o valor para o campo " + param.getName());
                        executeForm.addField(param.getName(), field);
                        fields.add(field);
                    } else if (FieldTypes.NUMERIC.equalsIgnoreCase(value)) {
                        TextField field = new TextField();
                        field.setCaption(param.getName());
                        field.setWidth("150px");
                        field.setRequired(true);
                        field.setRequiredError("Informe o valor para o campo " + param.getName());
                        executeForm.addField(param.getName(), field);
                        fields.add(field);
                    } else if (FieldTypes.DATE.equalsIgnoreCase(value)) {
                        PopupDateField field = new PopupDateField();
                        field.setCaption(param.getName());
                        field.setWidth("150px");
                        field.setRequired(true);
                        field.setRequiredError("Informe o valor para o campo " + param.getName());
                        field.setResolution(PopupDateField.RESOLUTION_DAY);
                        executeForm.addField(param.getName(), field);
                        fields.add(field);
                    } else if (FieldTypes.TIME.equalsIgnoreCase(value)) {
                        TextField field = new TextField();
                        field.setCaption(param.getName());
                        field.setWidth("150px");
                        field.setRequired(true);
                        field.setRequiredError("Informe o valor para o campo " + param.getName());
                        executeForm.addField(param.getName(), field);
                        fields.add(field);
                    } else if (FieldTypes.TIMESTAMP.equalsIgnoreCase(value)) {
                        TextField field = new TextField();
                        field.setCaption(param.getName());
                        field.setWidth("150px");
                        field.setRequired(true);
                        field.setRequiredError("Informe o valor para o campo " + param.getName());
                        executeForm.addField(param.getName(), field);
                        fields.add(field);
                    }
                }
            }
        }

        panelForm = new Panel();
        panelForm.setHeight("100%");
        panelForm.setWidth("100%");
        panelForm.setScrollable(true);
        addComponent(panelForm);
        executeForm.setImmediate(true);
        executeForm.setWidth("100%");
        panelForm.addComponent(executeForm);

        executeCommit = new CheckBox("Executar COMMIT no final do processo?");
        addComponent(executeCommit);

        HorizontalLayout buttons = new HorizontalLayout();
        buttons.setImmediate(false);
        buttons.setWidth("600px");
        buttons.setHeight("-1px");
        buttons.setMargin(false);
        buttons.setSpacing(true);
        addComponent(buttons);

        btnExecute = new Button();
        btnExecute.setCaption("Executar");
        btnExecute.setIcon(new ThemeResource("icons/16/run.png"));
        btnExecute.addListener(clickListener);
        buttons.addComponent(btnExecute);
        buttons.setComponentAlignment(btnExecute, Alignment.MIDDLE_RIGHT);
        buttons.setExpandRatio(btnExecute, 1);

        btnClose = new Button();
        btnClose.setCaption("Fechar");
        btnClose.setIcon(new ThemeResource("icons/16/doorOut.png"));
        btnClose.addListener(clickListener);
        buttons.addComponent(btnClose);

        buttons.setComponentAlignment(btnClose, Alignment.MIDDLE_RIGHT);
        buttons.setMargin(true, false, true, false);
        addComponent(buttons);

        pageControl = new TabSheet();
        pageControl.setImmediate(true);
        pageControl.setWidth("100.0%");
        pageControl.setHeight("100.0%");

        textPanel = new Panel();
        textPanel.setImmediate(true);
        textPanel.setWidth("100%");
        textPanel.setHeight("100%");
        pageControl.addTab(textPanel, "Resultado", null);
        addComponent(pageControl);
        setExpandRatio(pageControl, 1.0f);
    }
}

From source file:br.com.anteros.mobileserver.util.UserMessages.java

License:Apache License

public Window confirm(String title, String message, String okTitle, String cancelTitle,
        Button.ClickListener listener) {

    if (title == null) {
        title = CONFIRM_OK_TITLE;/*from w ww .j  a v a2  s . co  m*/
    }
    if (cancelTitle == null) {
        cancelTitle = CONFIRM_CANCEL_TITLE;
    }
    if (okTitle == null) {
        okTitle = CONFIRM_OK_TITLE;
    }

    final Window confirm = new Window(title);
    this.confirm = confirm;
    win.addWindow(confirm);

    confirm.addListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1971800928047045825L;

        public void windowClose(CloseEvent ce) {
            Object data = ce.getWindow().getData();
            if (data != null) {
                try {
                } catch (Exception exception) {
                    error("Unhandled Exception", exception);
                }
            }
        }
    });

    int chrW = 5;
    int chrH = 15;
    int txtWidth = Math.max(250, Math.min(350, message.length() * chrW));
    int btnHeight = 25;
    int vmargin = 100;
    int hmargin = 40;

    int txtHeight = 2 * chrH * (message.length() * chrW) / txtWidth;

    confirm.setWidth((txtWidth + hmargin) + "px");
    confirm.setHeight((vmargin + txtHeight + btnHeight) + "px");
    confirm.getContent().setSizeFull();

    confirm.center();
    confirm.setModal(true);

    Label text = new Label(message);
    text.setWidth("100%");
    text.setHeight("100%");

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setHeight(btnHeight + 5 + "px");
    buttons.setWidth("100%");
    buttons.setSpacing(true);
    buttons.setMargin(false);

    Button cancel = new Button(cancelTitle, listener);
    cancel.setIcon(new ThemeResource("icons/16/no.png"));
    cancel.setData(USER_CONFIRM_CANCEL);
    cancel.setClickShortcut(KeyCode.ESCAPE);
    Button ok = new Button(okTitle, listener);
    ok.setIcon(new ThemeResource("icons/16/yes.png"));
    ok.setData(USER_CONFIRM_OK);
    ok.setClickShortcut(KeyCode.ENTER);
    buttons.addComponent(ok);
    buttons.setExpandRatio(ok, 1);
    buttons.setComponentAlignment(ok, Alignment.MIDDLE_RIGHT);

    buttons.addComponent(cancel);
    buttons.setComponentAlignment(cancel, Alignment.MIDDLE_RIGHT);

    confirm.addComponent(text);
    confirm.addComponent(buttons);
    ((VerticalLayout) confirm.getContent()).setExpandRatio(text, 1f);
    confirm.setResizable(false);
    return confirm;
}

From source file:ch.bfh.ti.soed.hs16.srs.white.view.LogInView.java

License:Open Source License

@Override
public Component load() {
    final VerticalLayout formContainer = new VerticalLayout();
    formContainer.setStyleName("login-form");
    formContainer.setWidthUndefined();//from   w w w  .  j a  v  a2s.c  om

    fieldMail.setCaption("Type your mail here:");
    fieldMail.setStyleName("textfield-form");
    fieldMail.setTabIndex(1);
    fieldMail.focus();

    fieldPassword.setCaption("Type your password here:");
    fieldPassword.setTabIndex(2);
    fieldPassword.setStyleName("textfield-form");

    btnLogin.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    btnLogin.setTabIndex(3);
    btnLogin.addClickListener(e -> {
        switch (logInController.login()) {
        case ADMIN:
            AbstractView adminView = new AdminView();
            ApplicationController appController = ApplicationController.getInstance();
            appController.loadView(adminView);
            break;
        case USER:
            // Load the user view here
        default:
            break;
        }
    });

    btnLogin.setStyleName("button-center");
    btnLogin.setTabIndex(4);
    btnLogin.setWidth("91px");

    btnRegister.addClickListener(e -> {
        RegistrationView rView = new RegistrationView(this);
        ApplicationController applicationController = ApplicationController.getInstance();
        applicationController.loadView(rView);
    });
    btnRegister.setStyleName("button-center");
    btnRegister.setWidth("91px");

    labelMessage.setStyleName("horizontal-center");
    labelMessage.setSizeUndefined();

    final HorizontalLayout layoutButtons = new HorizontalLayout();

    layoutButtons.addComponents(btnLogin, btnRegister);
    layoutButtons.setStyleName("horizontal-center");
    layoutButtons.setMargin(true);
    layoutButtons.setSpacing(true);

    formContainer.addComponents(fieldMail, fieldPassword, layoutButtons, labelMessage);
    formContainer.setMargin(true);
    formContainer.setSpacing(true);

    Responsive.makeResponsive(formContainer);

    return formContainer;
}

From source file:ch.bfh.ti.soed.hs16.srs.white.view.RegistrationView.java

License:Open Source License

@Override
public Component load() {
    final VerticalLayout layout = new VerticalLayout();
    layout.setStyleName("registration-form");

    fieldFirstName.setStyleName("textfield-form");
    fieldLastName.setStyleName("textfield-form");
    fieldEmail.setStyleName("textfield-form");
    fieldConfirmEmail.setStyleName("textfield-form");
    fieldPassword.setStyleName("textfield-form");
    fieldConfirmPassword.setStyleName("textfield-form");

    btnSubmit.setStyleName("button-center");
    btnSubmit.setWidth("91px");
    btnSubmit.addClickListener(e -> registrationController.register());

    btnCancel.setStyleName("button-center");
    btnCancel.setWidth("91px");
    btnCancel.addClickListener(e -> registrationController.goBack(getLastView()));

    final HorizontalLayout layoutButtons = new HorizontalLayout();
    layoutButtons.addComponents(btnSubmit, btnCancel);
    layoutButtons.setStyleName("horizontal-center");
    layoutButtons.setMargin(true);
    layoutButtons.setSpacing(true);// w w  w .j  a va2  s  .com

    labelMessage.setStyleName("horizontal-center");
    labelMessage.setSizeUndefined();

    layout.addComponents(fieldFirstName, fieldLastName, fieldEmail, fieldConfirmEmail, fieldPassword,
            fieldConfirmPassword, layoutButtons, labelMessage);

    return layout;
}

From source file:com.cavisson.gui.dashboard.components.controls.Forms.java

License:Apache License

public Forms() {
    setSpacing(true);//w w  w.j  a v a2 s .  c  om
    setMargin(true);

    Label title = new Label("Forms");
    title.addStyleName("h1");
    addComponent(title);

    final FormLayout form = new FormLayout();
    form.setMargin(false);
    form.setWidth("800px");
    form.addStyleName("light");
    addComponent(form);

    Label section = new Label("Personal Info");
    section.addStyleName("h2");
    section.addStyleName("colored");
    form.addComponent(section);
    StringGenerator sg = new StringGenerator();

    TextField name = new TextField("Name");
    name.setValue(sg.nextString(true) + " " + sg.nextString(true));
    name.setWidth("50%");
    form.addComponent(name);

    DateField birthday = new DateField("Birthday");
    birthday.setValue(new Date(80, 0, 31));
    form.addComponent(birthday);

    TextField username = new TextField("Username");
    username.setValue(sg.nextString(false) + sg.nextString(false));
    username.setRequired(true);
    form.addComponent(username);

    OptionGroup sex = new OptionGroup("Sex");
    sex.addItem("Female");
    sex.addItem("Male");
    sex.select("Male");
    sex.addStyleName("horizontal");
    form.addComponent(sex);

    section = new Label("Contact Info");
    section.addStyleName("h3");
    section.addStyleName("colored");
    form.addComponent(section);

    TextField email = new TextField("Email");
    email.setValue(sg.nextString(false) + "@" + sg.nextString(false) + ".com");
    email.setWidth("50%");
    email.setRequired(true);
    form.addComponent(email);

    TextField location = new TextField("Location");
    location.setValue(sg.nextString(true) + ", " + sg.nextString(true));
    location.setWidth("50%");
    location.setComponentError(new UserError("This address doesn't exist"));
    form.addComponent(location);

    TextField phone = new TextField("Phone");
    phone.setWidth("50%");
    form.addComponent(phone);

    HorizontalLayout wrap = new HorizontalLayout();
    wrap.setSpacing(true);
    wrap.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    wrap.setCaption("Newsletter");
    CheckBox newsletter = new CheckBox("Subscribe to newsletter", true);
    wrap.addComponent(newsletter);

    ComboBox period = new ComboBox();
    period.setTextInputAllowed(false);
    period.addItem("Daily");
    period.addItem("Weekly");
    period.addItem("Montly");
    period.setNullSelectionAllowed(false);
    period.select("Weekly");
    period.addStyleName("small");
    period.setWidth("10em");
    wrap.addComponent(period);
    form.addComponent(wrap);

    section = new Label("Additional Info");
    section.addStyleName("h4");
    section.addStyleName("colored");
    form.addComponent(section);

    TextField website = new TextField("Website");
    website.setInputPrompt("http://");
    website.setWidth("100%");
    form.addComponent(website);

    TextArea shortbio = new TextArea("Short Bio");
    shortbio.setValue(
            "Quis aute iure reprehenderit in voluptate velit esse. Cras mattis iudicium purus sit amet fermentum.");
    shortbio.setWidth("100%");
    shortbio.setRows(2);
    form.addComponent(shortbio);

    final RichTextArea bio = new RichTextArea("Bio");
    bio.setWidth("100%");
    bio.setValue(
            "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi  dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>");
    form.addComponent(bio);

    form.setReadOnly(true);
    bio.setReadOnly(true);

    Button edit = new Button("Edit", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            boolean readOnly = form.isReadOnly();
            if (readOnly) {
                bio.setReadOnly(false);
                form.setReadOnly(false);
                form.removeStyleName("light");
                event.getButton().setCaption("Save");
                event.getButton().addStyleName("primary");
            } else {
                bio.setReadOnly(true);
                form.setReadOnly(true);
                form.addStyleName("light");
                event.getButton().setCaption("Edit");
                event.getButton().removeStyleName("primary");
            }
        }
    });

    HorizontalLayout footer = new HorizontalLayout();
    footer.setMargin(new MarginInfo(true, false, true, false));
    footer.setSpacing(true);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    form.addComponent(footer);
    footer.addComponent(edit);

    Label lastModified = new Label("Last modified by you a minute ago");
    lastModified.addStyleName("light");
    footer.addComponent(lastModified);
}

From source file:com.cavisson.gui.dashboard.components.controls.SplitPanels.java

License:Apache License

public SplitPanels() {
    setMargin(true);/*  w  w w . ja v  a2s .c o  m*/

    Label h1 = new Label("Split Panels");
    h1.addStyleName("h1");
    addComponent(h1);

    addComponent(new Label(
            "Outlines are just to show the areas of the SplitPanels. They are not part of the actual component style."));

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    row.setMargin(new MarginInfo(true, false, false, false));
    addComponent(row);

    HorizontalSplitPanel sp = new HorizontalSplitPanel();
    sp.setCaption("Default style");
    sp.setWidth("400px");
    sp.setHeight(null);
    sp.setFirstComponent(getContent());
    sp.setSecondComponent(getContent());
    row.addComponent(sp);

    VerticalSplitPanel sp2 = new VerticalSplitPanel();
    sp2.setCaption("Default style");
    sp2.setWidth("300px");
    sp2.setHeight("200px");
    sp2.setFirstComponent(getContent());
    sp2.setSecondComponent(getContent());
    row.addComponent(sp2);

    sp = new HorizontalSplitPanel();
    sp.setCaption("Large style");
    sp.setWidth("300px");
    sp.setHeight("200px");
    sp.addStyleName("large");
    sp.setFirstComponent(getContent());
    sp.setSecondComponent(getContent());
    row.addComponent(sp);

    sp2 = new VerticalSplitPanel();
    sp2.setCaption("Large style");
    sp2.setWidth("300px");
    sp2.setHeight("200px");
    sp2.addStyleName("large");
    sp2.setFirstComponent(getContent());
    sp2.setSecondComponent(getContent());
    row.addComponent(sp2);
}