Example usage for com.vaadin.ui GridLayout setSpacing

List of usage examples for com.vaadin.ui GridLayout setSpacing

Introduction

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

Prototype

@Override
    public void setSpacing(boolean spacing) 

Source Link

Usage

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

License:Mozilla Public License

private void initElements() {
    additionalDocRefList = parent.getInvoice().getAdditionalDocumentReference();
    setWidth("100%");
    setHeight("100%");
    //final GridLayout grid = new GridLayout(4, 4);
    final VerticalLayout outerLayout = new VerticalLayout();
    //outerLayout.setMargin(true);
    //outerLayout.setSpacing(true);

    //grid that contains "Details", "Contract", "Order"
    final GridLayout topGridLayout = new GridLayout(2, 2);
    //topGridLayout.setSizeFull();
    topGridLayout.setMargin(true);//from  w w  w.jav  a2s .c  om
    topGridLayout.setSpacing(true);

    hiddenContent = new VerticalLayout();
    hiddenContent.setSpacing(true);
    hiddenContent.setMargin(true);

    final Panel outerPanel = new Panel("Invoice Header");
    //outerPanel.addComponent(grid);
    outerPanel.setScrollable(true);
    outerPanel.setContent(outerLayout);
    //outerLayout.addComponent(outerPanel);

    VerticalLayout tabLayout = new VerticalLayout();
    tabLayout.addComponent(outerPanel);

    outerLayout.addComponent(topGridLayout);

    final Panel invoiceDetailsPanel = new Panel("Invoice Header Details");
    invoiceDetailsPanel.setStyleName("light");
    invoiceDetailsPanel.setWidth("50%");
    //invoiceDetailsPanel.setSizeFull();
    invoiceDetailsPanel.addComponent(createInvoiceTopForm());
    topGridLayout.addComponent(invoiceDetailsPanel, 0, 0);

    final Panel orderReferencePanel = new Panel("Referencing Order");
    orderReferencePanel.setStyleName("light");
    orderReferencePanel.setWidth("50%");
    //orderReferencePanel.setSizeFull();
    orderReferencePanel.addComponent(createInvoiceOrderReferenceForm());
    topGridLayout.addComponent(orderReferencePanel, 0, 1);

    final VerticalLayout tableVerticalLayout = new VerticalLayout();
    //tableVerticalLayout.setSpacing (true);
    tableVerticalLayout.setMargin(true);
    outerLayout.addComponent(tableVerticalLayout);

    table = new InvoiceAdditionalDocRefTable(parent.getInvoice().getAdditionalDocumentReference());
    table.setSelectable(true);
    table.setImmediate(true);
    table.setNullSelectionAllowed(false);
    table.setHeight(150, UNITS_PIXELS);
    table.setSizeFull();
    //table.setWidth("300px");
    table.setFooterVisible(false);
    table.addStyleName("striped strong");

    Panel tablePanel = new Panel("Relevant Documents");
    tablePanel.setStyleName("light");
    tablePanel.setWidth("60%");
    tableVerticalLayout.addComponent(tablePanel);

    GridLayout h = new GridLayout(2, 2);
    h.setMargin(true);
    h.setSpacing(true);
    tablePanel.setContent(h);
    h.addComponent(table, 0, 0);
    h.setColumnExpandRatio(0, 3);
    h.setColumnExpandRatio(1, 1);
    h.setSizeFull();

    Button addButton = new Button("Add new");
    Button editButton = new Button("Edit selected");
    Button deleteButton = new Button("Delete selected");

    VerticalLayout buttonsContainer = new VerticalLayout();
    buttonsContainer.setSpacing(true);
    buttonsContainer.addComponent(addButton);
    buttonsContainer.addComponent(editButton);
    buttonsContainer.addComponent(deleteButton);

    InvoiceAdditionalDocRefTableEditor editor = new InvoiceAdditionalDocRefTableEditor(editMode);
    Label label = new Label("<h3>Adding new relevant document</h3>", Label.CONTENT_XHTML);
    addButton.addListener(editor.addButtonListener(editButton, deleteButton, hiddenContent, table,
            additionalDocRefList, label));
    label = new Label("<h3>Edit relevant document</h3>", Label.CONTENT_XHTML);
    editButton.addListener(editor.editButtonListener(addButton, deleteButton, hiddenContent, table,
            additionalDocRefList, label));
    deleteButton.addListener(editor.deleteButtonListener(table));

    final Button addContractReferenceBtn = new Button("Add Contract Reference");
    final Button removeContractReferenceBtn = new Button("Remove Contract Reference");
    removeContractReferenceBtn.setVisible(false);
    addContractReferenceBtn.setStyleName("marginLeft");
    removeContractReferenceBtn.setStyleName("marginLeft");

    addContractReferenceBtn.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Panel panel = createInvoiceContractReference(removeContractReferenceBtn);
            topGridLayout.removeComponent(1, 0);
            topGridLayout.addComponent(panel, 1, 0);
            removeContractReferenceBtn.setVisible(true);
        }
    });

    removeContractReferenceBtn.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            //remove the legal entity component panel
            Component c = removeContractReferenceBtn.getParent().getParent();
            topGridLayout.removeComponent(c);
            if (parent.getInvoice().getContractDocumentReference().size() > 0) {
                //parent.getInvoice().getContractDocumentReference().remove(0);
                parent.getInvoice().getContractDocumentReference().clear();
                ValidatorsList.removeListeners(Utils.getFieldListeners(contractReferenceForm));
            }

            topGridLayout.addComponent(addContractReferenceBtn, 1, 0);
        }
    });

    h.addComponent(buttonsContainer, 1, 0);
    topGridLayout.addComponent(addContractReferenceBtn, 1, 0);
    if (parent.getInvoice().getContractDocumentReference().size() > 0)
        addContractReferenceBtn.click();

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

    h.addComponent(formLayout, 0, 1);
    // ---- HIDDEN FORM ENDS -----

    setLayout(tabLayout);
}

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

License:Mozilla Public License

@SuppressWarnings("serial")
private void initElements() {
    editMode = false;/*w  w  w . j  av  a  2  s  . c o  m*/
    paymentMeansList = parent.getInvoice().getPaymentMeans();
    //paymentMeansItem = createPaymentMeansItem();
    //paymentMeansList.add (paymentMeansItem);

    //paymentTermsList = parent.getInvoice().getPaymentTerms ();
    //PaymentTermsType pt = new PaymentTermsType();
    //paymentTermsList.add (pt);

    if (parent.getInvoice().getPaymentTerms().size() == 0) {
        paymentTermsItem = new PaymentTermsType();
        paymentTermsItem.getNote().add(new NoteType());
        parent.getInvoice().getPaymentTerms().add(paymentTermsItem);
    } else {
        paymentTermsItem = parent.getInvoice().getPaymentTerms().get(0);
    }

    //payeeParty = parent.getInvoice().getPayeeParty ();
    if (parent.getInvoice().getPayeeParty() == null) {
        payeeParty = createPayeePartyItem();
        parent.getInvoice().setPayeeParty(payeeParty);
    } else {
        payeeParty = parent.getInvoice().getPayeeParty();
    }
    //payeeParty = new PartyType();
    //payeeParty.setParty(new PartyType());

    hiddenContent = new VerticalLayout();
    hiddenContent.setSpacing(true);
    hiddenContent.setMargin(true);

    final GridLayout grid = new GridLayout(2, 2);
    grid.setSpacing(true);
    //grid.setMargin(true);
    final VerticalLayout outerLayout = new VerticalLayout();

    final Panel outerPanel = new Panel("Payment");
    outerPanel.addComponent(grid);
    outerPanel.setScrollable(true);
    outerLayout.addComponent(outerPanel);

    final Panel invoiceDetailsPanel = new Panel("Payment Details");
    invoiceDetailsPanel.setStyleName("light");
    invoiceDetailsPanel.setSizeFull();
    //invoiceDetailsPanel.addComponent(createInvoicePaymentTopForm());
    //grid.addComponent(invoiceDetailsPanel, 0, 0);

    final Panel payeePartyPanel = new Panel("Payee Details");
    payeePartyPanel.setStyleName("light");
    payeePartyPanel.setSizeFull();
    payeePartyPanel.addComponent(createInvoicePayeePartyForm());
    //payeeForm = new PartyDetailForm("Payee", payeeParty);
    //payeePartyPanel.addComponent(payeeForm);
    grid.addComponent(payeePartyPanel, 0, 0);

    final Panel paymentTermsPanel = new Panel("Payment Terms");
    paymentTermsPanel.setStyleName("light");
    paymentTermsPanel.setSizeFull();
    paymentTermsPanel.addComponent(createInvoicePaymentTermsForm());
    grid.addComponent(paymentTermsPanel, 1, 0);

    final Panel paymentMeansPanel = new Panel("Payment Means");
    VerticalLayout paymentMeansLayout = new VerticalLayout();
    paymentMeansPanel.setContent(paymentMeansLayout);
    paymentMeansPanel.setStyleName("light");
    paymentMeansPanel.setSizeFull();
    paymentMeansLayout.setSpacing(true);
    paymentMeansLayout.setMargin(true);

    table = new PaymentMeansTable(paymentMeansList);
    table.setSelectable(true);
    table.setImmediate(true);
    table.setNullSelectionAllowed(false);
    table.setHeight(200, UNITS_PIXELS);
    table.setSizeFull();
    table.setWidth("80%");
    table.setFooterVisible(false);
    table.addStyleName("striped strong");

    HorizontalLayout tableLayout = new HorizontalLayout();
    paymentMeansLayout.addComponent(tableLayout);
    paymentMeansLayout.addComponent(hiddenContent);
    hiddenContent.setVisible(false);

    VerticalLayout tableButtonsLayout = new VerticalLayout();
    tableButtonsLayout.setSpacing(true);
    tableButtonsLayout.setMargin(true);
    final Button addButton = new Button("Add new");
    final Button editButton = new Button("Edit selected");
    final Button deleteButton = new Button("Delete selected");
    tableButtonsLayout.addComponent(addButton);
    tableButtonsLayout.addComponent(editButton);
    tableButtonsLayout.addComponent(deleteButton);

    tableLayout.addComponent(table);
    tableLayout.addComponent(tableButtonsLayout);

    outerPanel.addComponent(paymentMeansPanel);

    grid.setSizeUndefined();

    PaymentMeansTableEditor editor = new PaymentMeansTableEditor(editMode, parent.getInvoice());
    Label label = new Label("<h3>Adding new payments means</h3>", Label.CONTENT_XHTML);
    addButton.addListener(
            editor.addButtonListener(editButton, deleteButton, hiddenContent, table, paymentMeansList, label));
    label = new Label("<h3>Edit payment means line</h3>", Label.CONTENT_XHTML);
    editButton.addListener(
            editor.editButtonListener(addButton, deleteButton, hiddenContent, table, paymentMeansList, label));
    deleteButton.addListener(editor.deleteButtonListener(table));

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

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

License:Mozilla Public License

@SuppressWarnings("serial")
private void initElements() {
    taxTotalList = parent.getInvoice().getTaxTotal();
    if (taxTotalList.size() == 0) {
        taxTotalItem = createTaxTotalItem();
        taxTotalList.add(taxTotalItem);// w ww  . j  a va  2s  . com
    } else {
        taxTotalItem = taxTotalList.get(0);
    }

    //taxSubtotalList = parent.getInvoice ().getTaxTotal ().get (0).getTaxSubtotal ();
    taxSubtotalList = taxTotalItem.getTaxSubtotal();

    final GridLayout grid = new GridLayout(4, 4);
    final VerticalLayout outerLayout = new VerticalLayout();
    hiddenContent = new VerticalLayout();
    hiddenContent.setSpacing(true);
    hiddenContent.setMargin(true);

    final Panel outerPanel = new Panel("Tax Total");
    outerPanel.addComponent(grid);
    outerPanel.setScrollable(true);
    outerLayout.addComponent(outerPanel);

    table = new InvoiceTaxSubtotalTable(taxTotalList.get(0).getTaxSubtotal());
    table.setSelectable(true);
    table.setImmediate(true);
    table.setNullSelectionAllowed(false);
    table.setHeight(150, UNITS_PIXELS);
    table.setFooterVisible(true);
    table.addStyleName("striped strong");
    final VerticalLayout tableContainer = new VerticalLayout();
    tableContainer.addComponent(table);
    tableContainer.setMargin(false, true, false, false);

    Button addButton = new Button("Add new");
    Button editButton = new Button("Edit selected");
    Button deleteButton = new Button("Delete selected");

    final VerticalLayout buttonsContainer = new VerticalLayout();
    buttonsContainer.setSpacing(true);
    buttonsContainer.addComponent(addButton);
    buttonsContainer.addComponent(editButton);
    buttonsContainer.addComponent(deleteButton);

    InvoiceTaxSubtotalTableEditor editor = new InvoiceTaxSubtotalTableEditor(editMode);
    Label label = new Label("<h3>Adding new tax subtotal</h3>", Label.CONTENT_XHTML);
    addButton.addListener(
            editor.addButtonListener(editButton, deleteButton, hiddenContent, table, taxSubtotalList, label));
    label = new Label("<h3>Edit tax subtotal</h3>", Label.CONTENT_XHTML);
    editButton.addListener(
            editor.editButtonListener(addButton, deleteButton, hiddenContent, table, taxSubtotalList, label));
    deleteButton.addListener(editor.deleteButtonListener(table));

    /*    // buttons Add, Edit, Delete
        final Button addBtn = new Button ("Add New", new Button.ClickListener () {
          @Override
          public void buttonClick (final Button.ClickEvent event) {
            
            addMode = true;
            hiddenContent.removeAllComponents ();
            taxSubtotalItem = createTaxSubtotalItem ();
            
            final Label formLabel = new Label ("<h3>Adding new tax subtotal line</h3>", Label.CONTENT_XHTML);
            
            hiddenContent.addComponent (formLabel);
            hiddenContent.addComponent (createInvoiceTaxSubtotalForm ());
            
            // Save new line button
            final HorizontalLayout buttonLayout = new HorizontalLayout ();
            buttonLayout.setSpacing (true);
            buttonLayout.addComponent (new Button ("Save tax subtotal line", new Button.ClickListener () {
              @Override
              public void buttonClick (final ClickEvent event) {
    // update table (and consequently add new item to taxSubtotalList
    // list)
    table.addTaxSubtotalLine (taxSubtotalItem);
    // hide form
    hiddenContent.setVisible (false);
    addMode = false;
            
    // update Total Tax Amount
    taxTotalItem.getTaxAmount ().setValue (SumTaxSubtotalAmount ());
            
    // update form as well
    // invoiceTaxTotalTopForm.getField("Tax Total Amount").setRequired(true);
    invoiceTaxTotalTopForm.getField ("Tax Total Amount").setValue (taxTotalItem.getTaxAmount ().getValue ());
              }
            }));
            buttonLayout.addComponent (new Button ("Cancel", new Button.ClickListener () {
              @Override
              public void buttonClick (final ClickEvent event) {
    hiddenContent.removeAllComponents ();
    // hide form
    hiddenContent.setVisible (false);
    addMode = false;
              }
            }));
            
            hiddenContent.addComponent (buttonLayout);
            
            // hiddenContent.setVisible(!hiddenContent.isVisible());
            hiddenContent.setVisible (true);
            
          }
        });
        final Button editBtn = new Button ("Edit Selected", new Button.ClickListener () {
          @Override
          public void buttonClick (final Button.ClickEvent event) {
            /*
             * Object rowId = table.getValue(); // get the selected rows id if(rowId
             * != null){ if(addMode || editMode){ parent.getWindow
             * ().showNotification("Info", "You cannot edit while in add/edit mode",
             * Window.Notification.TYPE_HUMANIZED_MESSAGE); return; } final String
             * sid =
             * (String)table.getContainerProperty(rowId,"ID.value").getValue(); //
             * TODO: PUT THIS IN FUNCTION BEGINS editMode = true;
             * hiddenContent.removeAllComponents (); //get selected item
             * allowanceChargeItem = (InvoiceAllowanceChargeAdapter)
             * allowanceChargeList.get (table.getIndexFromID (sid)); //clone it to
             * original item originalItem = new InvoiceAllowanceChargeAdapter ();
             * cloneInvoiceAllowanceChargeItem(allowanceChargeItem, originalItem);
             * Label formLabel = new Label("<h3>Editing allowance charge line</h3>",
             * Label.CONTENT_XHTML); hiddenContent.addComponent (formLabel);
             * hiddenContent.addComponent(createInvoiceAllowanceChargeForm());
             * //Save new line button HorizontalLayout buttonLayout = new
             * HorizontalLayout(); buttonLayout.setSpacing (true);
             * buttonLayout.addComponent(new Button("Save changes",new
             * Button.ClickListener(){
             * @Override public void buttonClick (ClickEvent event) { //update table
             * (and consequently edit item to allowanceChargeList list)
             * table.setAllowanceChargeLine (sid, allowanceChargeItem); //hide form
             * hiddenContent.setVisible(false); editMode = false; } }));
             * buttonLayout.addComponent(new Button("Cancel editing",new
             * Button.ClickListener(){
             * @Override public void buttonClick (ClickEvent event) {
             * hiddenContent.removeAllComponents (); table.setAllowanceChargeLine
             * (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); }
             */
    /*      }
        });
        editBtn.setEnabled (false);
        final Button deleteBtn = new Button ("Delete Selected", 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 (addMode || editMode) {
    parent.getWindow ().showNotification ("Info",
                                          "You cannot delete while in add/edit mode",
                                          Window.Notification.TYPE_HUMANIZED_MESSAGE);
    return;
              }
              if (table.getContainerProperty (rowId, "TableLineID").getValue () != null) {
    final String sid = (String) table.getContainerProperty (rowId, "TableLineID").getValue ();
    table.removeTaxSubtotalLine (sid);
            
    // update Total Tax Amount
    taxTotalItem.getTaxAmount ().setValue (SumTaxSubtotalAmount ());
            
    invoiceTaxTotalTopForm.getField ("Tax Total Amount").setValue (taxTotalItem.getTaxAmount ().getValue ());
            
              }
            }
            else {
              parent.getWindow ().showNotification ("Info",
                                        "No table line is selected",
                                        Window.Notification.TYPE_HUMANIZED_MESSAGE);
            
            }
            
          }
        });*/

    final Panel invoiceDetailsPanel = new Panel("Tax Total Details");
    invoiceDetailsPanel.setStyleName("light");
    invoiceDetailsPanel.setSizeFull();
    invoiceDetailsPanel.addComponent(createInvoiceTaxTotalTopForm());

    table.addListener(new ItemSetChangeListener() {

        @Override
        public void containerItemSetChange(ItemSetChangeEvent event) {
            Field f = invoiceTaxTotalTopForm.getField(taxTotalAmount);
            f.setValue(addTaxSubTotals());
        }

    });

    grid.setSpacing(true);
    grid.addComponent(invoiceDetailsPanel, 0, 0);
    grid.addComponent(tableContainer, 0, 1);
    grid.addComponent(buttonsContainer, 1, 1);
    grid.setSizeUndefined();

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

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

From source file:biz.eelis.translation.EntriesFlowlet.java

License:Apache License

@Override
public void initialize() {
    final List<FieldDescriptor> fieldDescriptors = TranslationSiteFields.getFieldDescriptors(Entry.class);

    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();

    filterDefinitions.add(new FilterDescriptor("basename", "basename", "Basename", new TextField(), 200, "like",
            String.class, ""));

    filterDefinitions.add(new FilterDescriptor("language", "language", "Language", new TextField(), 30, "=",
            String.class, ""));

    filterDefinitions.add(/*from  w w  w .j  a va  2s .  co  m*/
            new FilterDescriptor("country", "country", "Country", new TextField(), 30, "=", String.class, ""));

    filterDefinitions
            .add(new FilterDescriptor("key", "key", "Key", new TextField(), 200, "like", String.class, ""));

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    container = new LazyEntityContainer<Entry>(entityManager, true, true, false, Entry.class, 1000,
            new String[] { "basename", "key", "language", "country" }, new boolean[] { true, true, true, true },
            "entryId");

    ContainerUtil.addContainerProperties(container, fieldDescriptors);

    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setSizeUndefined();
    gridLayout.addComponent(buttonLayout, 0, 0);

    final Table table = new FormattingTable();
    grid = new Grid(table, container);
    grid.setFields(fieldDescriptors);
    grid.setFilters(filterDefinitions);

    table.setColumnCollapsed("entryId", true);
    table.setColumnCollapsed("path", true);
    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    gridLayout.addComponent(grid, 0, 1);

    final Button addButton = getSite().getButton("add");
    buttonLayout.addComponent(addButton);
    addButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Entry entry = new Entry();
            entry.setCreated(new Date());
            entry.setModified(entry.getCreated());
            entry.setOwner((Company) getSite().getSiteContext().getObject(Company.class));
            final EntryFlowlet entryView = getViewSheet().forward(EntryFlowlet.class);
            entryView.edit(entry, true);
        }
    });

    final Button editButton = getSite().getButton("edit");
    buttonLayout.addComponent(editButton);
    editButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Entry entity = container.getEntity(grid.getSelectedItemId());
            final EntryFlowlet entryView = getViewSheet().forward(EntryFlowlet.class);
            entryView.edit(entity, false);
        }
    });

    final Button removeButton = getSite().getButton("remove");
    buttonLayout.addComponent(removeButton);
    removeButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            container.removeItem(grid.getSelectedItemId());
            container.commit();
        }
    });

    final Company company = getSite().getSiteContext().getObject(Company.class);
    container.removeDefaultFilters();
    container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId()));
    grid.refresh();
}

From source file:biz.eelis.translation.EntryFlowlet.java

License:Apache License

@Override
public void initialize() {
    entityManager = getSite().getSiteContext().getObject(EntityManager.class);

    final GridLayout gridLayout = new GridLayout(1, 3);
    gridLayout.setSizeFull();/*  w w  w.j  a  v  a2 s.c o  m*/
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(2, 1f);
    setViewContent(gridLayout);

    entryEditor = new ValidatingEditor(TranslationSiteFields.getFieldDescriptors(Entry.class));
    entryEditor.setCaption("Entry");
    entryEditor.addListener((ValidatingEditorStateListener) this);
    gridLayout.addComponent(entryEditor, 0, 0);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    gridLayout.addComponent(buttonLayout, 0, 1);

    saveButton = new Button("Save");
    saveButton.setImmediate(true);
    buttonLayout.addComponent(saveButton);
    saveButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            entryEditor.commit();
            entityManager.getTransaction().begin();
            try {
                entity = entityManager.merge(entity);
                entity.setAuthor(getSite().getSecurityProvider().getUser());
                entity.setModified(new Date());
                entityManager.persist(entity);
                entityManager.getTransaction().commit();
                entityManager.detach(entity);
                entryEditor.discard();
                container.refresh();
            } catch (final Throwable t) {
                if (entityManager.getTransaction().isActive()) {
                    entityManager.getTransaction().rollback();
                }
                throw new RuntimeException("Failed to save entity: " + entity, t);
            }
        }
    });

    discardButton = new Button("Discard");
    discardButton.setImmediate(true);
    buttonLayout.addComponent(discardButton);
    discardButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            entryEditor.discard();
        }
    });

    final List<FieldDescriptor> fieldDescriptors = TranslationSiteFields.getFieldDescriptors(Entry.class);

    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();

    container = new LazyEntityContainer<Entry>(entityManager, true, true, false, Entry.class, 1000,
            new String[] { "basename", "key", "language", "country" }, new boolean[] { true, true, true, true },
            "entryId");
    container.getQueryView().getQueryDefinition().setMaxQuerySize(1);

    ContainerUtil.addContainerProperties(container, fieldDescriptors);

    final Table table = new FormattingTable();
    final Grid grid = new Grid(table, container);
    grid.setCaption("All Translations");
    grid.setSizeFull();
    grid.setFields(fieldDescriptors);
    grid.setFilters(filterDefinitions);

    table.setColumnCollapsed("entryId", true);
    table.setColumnCollapsed("path", true);
    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    gridLayout.addComponent(grid, 0, 2);

}

From source file:ch.bfh.ti.soed.hs16.srs.purple.view.ReservationView.java

License:Open Source License

/**
 * Shows the popup window where a reservation can be modified, deleted or inserted
 * @param res The Reservation Object (for a new reservation, fill the startDate with the current Timestamp!)
 *///from  w  w w  . j  a v a 2s . c  o  m
@SuppressWarnings("serial")
private void showPopup(Reservation res) {
    this.res = res; //Update the member
    boolean newRes = res.getReservationID() > 0 ? false : true;
    boolean isHost = isHost(actualUser, res.getHostList());
    boolean isParticipant = isHost(actualUser, res.getParticipantList());
    final GridLayout gridLayout = new GridLayout(3, 5);
    ValueChangeListener vcl = new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            List<Room> roomList = resCont.getAllFreeRooms(new Timestamp(startDate.getValue().getTime()),
                    new Timestamp(endDate.getValue().getTime()));
            if (ReservationView.this.res.getReservationID() > 0) {
                System.out.println("Aktuellen Raum");
                rooms.addItem(ReservationView.this.res.getRoom().getRoomID());
                rooms.setItemCaption(ReservationView.this.res.getRoom().getRoomID(),
                        ReservationView.this.res.getRoom().getName() + " ("
                                + ReservationView.this.res.getRoom().getNumberOfSeats() + " Pltze)");
                rooms.select(ReservationView.this.res.getRoom().getRoomID());
            }
            for (int i = 0; i < roomList.size(); i++) {
                rooms.addItem(roomList.get(i).getRoomID());
                String caption = roomList.get(i).getName() + " (" + roomList.get(i).getNumberOfSeats()
                        + " Pltze)";
                rooms.setItemCaption(roomList.get(i).getRoomID(), caption);
            }
            if (ReservationView.this.res.getReservationID() <= 0 && actualRoom != null)
                rooms.select(actualRoom.getRoomID());
        }
    };
    popUpWindow = new Window();
    popUpWindow.center();
    popUpWindow.setModal(true);
    startDate = new DateField("Startzeit");
    startDate.setLocale(VaadinSession.getCurrent().getLocale());
    startDate.setValue(res.getStart());
    startDate.addValueChangeListener(vcl);
    startDate.setDateFormat("dd.MM.yyyy HH:mm");
    startDate.setResolution(Resolution.HOUR);
    endDate = new DateField("Endzeit");
    endDate.setValue(res.getEnd());
    endDate.addValueChangeListener(vcl);
    endDate.setDateFormat("dd.MM.yyyy HH:mm");
    endDate.setLocale(VaadinSession.getCurrent().getLocale());
    endDate.setResolution(Resolution.HOUR);
    title = new TextField("Titel");
    title.setValue(res.getTitle());
    title.setWidth(100, Unit.PERCENTAGE);
    description = new TextArea("Beschreibung");
    description.setValue(res.getDescription());
    description.setRows(3);
    description.setWidth(100, Unit.PERCENTAGE);
    hosts = new ListSelect("Reservierender");
    hosts.setMultiSelect(true);
    hosts.clear();
    for (int i = 0; i < hostList.size(); i++) {
        hosts.addItem(hostList.get(i).getUserID());
        hosts.setItemCaption(hostList.get(i).getUserID(), hostList.get(i).getUsername());
    }
    //select the hosts in list
    if (!newRes) {
        List<User> resHosts = res.getHostList();
        for (int i = 0; i < resHosts.size(); i++)
            for (int y = 0; y < hostList.size(); y++)
                if (hostList.get(y).getUserID() == resHosts.get(i).getUserID())
                    hosts.select(resHosts.get(i).getUserID());
    } else
        hosts.select(actualUser.getUserID());
    hosts.select(0);
    hosts.setRows(hostList.size() > 5 ? 5 : hostList.size());
    participantList = new ListSelect("Teilnehmer");
    participantList.setMultiSelect(true);
    participantList.clear();

    for (int i = 0; i < participant.size(); i++) {
        participantList.addItem(participant.get(i).getUserID());
        participantList.setItemCaption(participant.get(i).getUserID(), participant.get(i).getUsername());
    }
    //select the participants in list
    if (!newRes) {
        List<User> resPart = res.getParticipantList();
        for (int i = 0; i < resPart.size(); i++)
            for (int y = 0; y < participant.size(); y++)
                if (participant.get(y).getUserID() == resPart.get(i).getUserID())
                    participantList.select(resPart.get(i).getUserID());
    }
    participantList.setRows(participant.size() > 5 ? 5 : participant.size());
    rooms = new NativeSelect("Raum");
    rooms.setNullSelectionAllowed(false);
    rooms.removeAllItems();
    List<Room> roomList = resCont.getAllFreeRooms(new Timestamp(startDate.getValue().getTime()),
            new Timestamp(endDate.getValue().getTime()));
    if (!newRes) {
        rooms.addItem(res.getRoom().getRoomID());
        rooms.setItemCaption(res.getRoom().getRoomID(),
                res.getRoom().getName() + " (" + res.getRoom().getNumberOfSeats() + " Pltze)");
        rooms.select(res.getRoom().getRoomID());
    }
    for (int i = 0; i < roomList.size(); i++) {
        rooms.addItem(roomList.get(i).getRoomID());
        String caption = roomList.get(i).getName() + " (" + roomList.get(i).getNumberOfSeats() + " Pltze)";
        rooms.setItemCaption(roomList.get(i).getRoomID(), caption);
    }
    if (newRes && actualRoom != null)
        rooms.select(actualRoom.getRoomID());
    saveButton = new Button("Speichern");
    saveButton.addClickListener(clButton);
    deleteButton = new Button("Lschen");
    deleteButton.addClickListener(clButton);
    deleteButton.setVisible(res.getReservationID() > 0 ? true : false);
    if (!newRes)
        setEditable(false);
    gridLayout.addComponent(startDate, 0, 0);
    gridLayout.addComponent(endDate, 0, 1);
    gridLayout.addComponent(hosts, 1, 0, 1, 1);
    gridLayout.addComponent(participantList, 2, 0, 2, 1);
    gridLayout.addComponent(title, 0, 2);
    gridLayout.addComponent(rooms, 1, 2, 2, 2);
    gridLayout.addComponent(description, 0, 3, 1, 3);
    if (roomList.size() == 0)
        saveButton.setEnabled(false);
    if (isHost || newRes) //show buttons for edit and delete only if the user is host or its a new reservation
    {
        gridLayout.addComponent(saveButton, 0, 4);
        gridLayout.addComponent(deleteButton, 1, 4);
    }
    if (isParticipant) //show buttons for accept oder decline a reservation
    {
        acceptButton = new Button("Zusagen");
        rejectButton = new Button("Absagen");
        acceptButton.addClickListener(clButton);
        rejectButton.addClickListener(clButton);
        if (isHost(actualUser, res.getAcceptedParticipantsList())) {
            acceptButton.setEnabled(false);
            rejectButton.setEnabled(true);
        } else {
            rejectButton.setEnabled(false);
            acceptButton.setEnabled(true);
        }
        gridLayout.addComponent(acceptButton, 0, 4);
        gridLayout.addComponent(rejectButton, 1, 4);
    }
    gridLayout.setSpacing(true);
    gridLayout.setMargin(new MarginInfo(false, false, false, true));
    gridLayout.setWidth(100, Unit.PERCENTAGE);
    popUpWindow.setContent(gridLayout);
    popUpWindow.setWidth("600px");
    popUpWindow.setHeight("450px");
    popUpWindow.setCaption(res.getReservationID() > 0 ? "Reservierungsdetails" : "Neue Reservierung");
    UI.getCurrent().addWindow(popUpWindow);
}

From source file:com.bellkenz.modules.PersonalInformation.java

public ComponentContainer personalInformation() {
    employeeInformationDAO = new EmployeeInformationDAO(getEmployeeId());
    employeePersonalInformation = new EmployeePersonalInformation();

    GridLayout glayout = new GridLayout(5, 9);
    glayout.setSpacing(true);
    glayout.setMargin(true);/*from  ww w  .  ja  v a2  s.com*/

    final Panel imagePanel = new Panel();
    imagePanel.setStyleName("light");
    AbstractLayout panelLayout = (AbstractLayout) imagePanel.getContent();
    panelLayout.setMargin(false);
    imagePanel.setSizeFull();

    employeeImage = new Embedded(null, new ThemeResource("../myTheme/images/ronnie.jpg"));
    employeeImage.setImmediate(true);
    employeeImage.setWidth(90, Sizeable.UNITS_PIXELS);
    employeeImage.setHeight(90, Sizeable.UNITS_PIXELS);
    employeeImage.setStyleName("logo-img");
    imagePanel.addComponent(employeeImage);
    glayout.addComponent(employeeImage, 0, 0, 0, 1);
    glayout.setComponentAlignment(imagePanel, Alignment.MIDDLE_CENTER);

    firstname = createTextField("Firstname: ");
    glayout.addComponent(firstname, 1, 0, 2, 0);

    final TextField middlename = createTextField("Middlename: ");
    glayout.addComponent(middlename, 3, 0);

    final TextField lastname = createTextField("Lastname: ");
    glayout.addComponent(lastname, 4, 0);

    final TextField houseNo = createTextField("No: ");
    houseNo.setWidth("40px");
    glayout.addComponent(houseNo, 1, 1);

    final TextField street = createTextField("Street: ");
    street.setWidth("118");
    glayout.addComponent(street, 2, 1);

    final TextField city = createTextField("City: ");
    glayout.addComponent(city, 3, 1);

    final TextField zipCode = createTextField("Zip Code:");
    glayout.addComponent(zipCode, 4, 1);

    final TextField nickname = createTextField("Nickname: ");
    nickname.setWidth("90px");
    glayout.addComponent(nickname, 0, 2);

    final TextField permanentAddress = createTextField("Permanent/Provincial Address: ");
    permanentAddress.setWidth("533px");
    glayout.addComponent(permanentAddress, 1, 2, 4, 2);

    Button uploadPicture = new Button("Upload...");
    uploadPicture.setWidth("100%");
    uploadPicture.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (employeeId == null) {
                getWindow().showNotification("You did not select and Employee!",
                        Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            Window uploadImage = new UploadImage(imagePanel, employeeImage, employeeId);
            uploadImage.setWidth("450px");
            if (uploadImage.getParent() == null) {
                getWindow().addWindow(uploadImage);
            }
            uploadImage.setModal(true);
            uploadImage.center();
        }
    });
    glayout.addComponent(uploadPicture, 0, 3);

    final TextField landline = createTextField("Landline #: ");
    glayout.addComponent(landline, 1, 3, 2, 3);

    final TextField mobileNo = createTextField("Mobile #: ");
    glayout.addComponent(mobileNo, 3, 3);

    final TextField age = createTextField("Age: ");
    glayout.addComponent(age, 4, 3);

    final TextField emailAddress = createTextField("Email Address: ");
    glayout.addComponent(emailAddress, 1, 4, 2, 4);

    final PopupDateField dob = (PopupDateField) createDateField("Date of Birth: ");
    glayout.addComponent(dob, 3, 4);

    final TextField height = createTextField("Height: ");
    glayout.addComponent(height, 4, 4);

    final ComboBox civilStatus = new ComboBox("Civil Status: ");
    civilStatus.setWidth("100%");
    dropDownBoxList.populateCivilStatusList(civilStatus);
    glayout.addComponent(civilStatus, 1, 5, 2, 5);

    final ComboBox gender = new ComboBox("Gender: ");
    gender.setWidth("100%");
    dropDownBoxList.populateGenderList(gender);
    glayout.addComponent(gender, 3, 5);

    final TextField weight = createTextField("Weigth: ");
    glayout.addComponent(weight, 4, 5);

    final TextField driversLicenseNo = createTextField("Drivers License: ");
    glayout.addComponent(driversLicenseNo, 1, 6, 2, 6);

    final TextField restrictionCode = createTextField("Restriction Code: ");
    glayout.addComponent(restrictionCode, 3, 6);

    final TextField religion = createTextField("Religion: ");
    glayout.addComponent(religion, 4, 6);

    final ComboBox division = new ComboBox("Division: ");
    division.setWidth("100%");
    dropDownBoxList.populateBranchComboBox(division);
    glayout.addComponent(division, 1, 7, 2, 7);

    final ComboBox department = dropDownBoxList.populateDepartment(new ComboBox());
    department.setWidth("100%");
    division.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (division.getValue() == null) {
            } else {
                divisionId = branchDAO.getBranchId(division.getValue().toString());
            }
        }

    });
    glayout.addComponent(department, 3, 7);

    final TextField position = createTextField("Position: ");
    glayout.addComponent(position, 4, 7);
    //glayout.setComponentAlignment(position, Alignment.BOTTOM_LEFT);

    Button transferButton = new Button("Transfer Employee");
    transferButton.setWidth("100%");
    transferButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (getEmployeeId() == null) {
                getWindow().showNotification("You did not select an Employee!",
                        Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            Window subWindow = transferEmployee(getEmployeeId(), division, department, position);
            if (subWindow.getParent() == null) {
                getWindow().addWindow(subWindow);
            }
            subWindow.setModal(true);
            subWindow.center();
        }
    });
    glayout.addComponent(transferButton, 1, 8, 2, 8);
    glayout.setComponentAlignment(transferButton, Alignment.BOTTOM_CENTER);

    if (employeeId != null) {
        epiList = employeeInformationDAO.employeePersonalInformation();
        for (EmployeePersonalInformation epi : epiList) {
            final byte[] image = epi.getImage();
            if (image != null) {
                StreamResource.StreamSource imageSource = new StreamResource.StreamSource() {

                    @Override
                    public InputStream getStream() {
                        return new ByteArrayInputStream(image);
                    }

                };

                StreamResource imageResource = new StreamResource(imageSource, epi.getFirstname() + ".jpg",
                        getApplication());
                imageResource.setCacheTime(0);
                employeeImage.setSource(imageResource);
            }
            firstname.setValue(epi.getFirstname());
            middlename.setValue(epi.getMiddlename());
            lastname.setValue(epi.getLastname());
            houseNo.setValue(epi.getHouseNumber());

            street.setValue(epi.getStreet());
            city.setValue(epi.getStreet());
            zipCode.setValue(epi.getZipCode());
            nickname.setValue(epi.getNickname());
            permanentAddress.setValue(epi.getPermanentAddress());
            landline.setValue(epi.getLandlineNumber());
            mobileNo.setValue(epi.getMobileNumber());
            age.setValue(epi.getAge());
            emailAddress.setValue(epi.getEmailAddress());

            if (epi.getDob() != null) {
                dob.setValue(conUtil.parsingDate(epi.getDob()));
            } else {
                dob.setValue(null);
            }

            height.setValue(epi.getHeight());

            if (epi.getCivilStatus() != null) {
                Object civilStatusId = civilStatus.addItem();
                civilStatus.setItemCaption(civilStatusId, epi.getCivilStatus());
                civilStatus.setValue(civilStatusId);
            }

            if (epi.getGender() != null) {
                Object genderId = gender.addItem();
                gender.setItemCaption(genderId, epi.getGender());
                gender.setValue(genderId);
            }

            weight.setValue(epi.getWeight());
            driversLicenseNo.setValue(epi.getDriversLicense());
            restrictionCode.setValue(epi.getRestrictionCode());
            religion.setValue(epi.getReligion());
            position.setValue(epi.getPosition());

            Object divisionObjectId = division.addItem();
            division.setItemCaption(divisionObjectId, epi.getDivision());
            division.setValue(divisionObjectId);

            Object departmentObjectId = department.addItem();
            department.setItemCaption(departmentObjectId, epi.getDepartment());
            department.setValue(departmentObjectId);
        }
    }

    firstname.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            employeePersonalInformation.setFirstname(event.getProperty().getValue().toString());
        }
    });
    firstname.setImmediate(true);
    setInformation(employeePersonalInformation);

    return glayout;
}

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

License:Apache License

Panel notifications() {
    Panel p = new Panel("Notifications");
    VerticalLayout content = new VerticalLayout() {
        Notification notification = new Notification("");
        TextField title = new TextField("Title");
        TextArea description = new TextArea("Description");
        MenuBar style = new MenuBar();
        MenuBar type = new MenuBar();
        String typeString = "";
        String styleString = "";
        TextField delay = new TextField();
        {//from   w w w. ja  v  a2 s.c o  m
            setSpacing(true);
            setMargin(true);

            title.setInputPrompt("Title for the notification");
            title.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    if (title.getValue() == null || title.getValue().length() == 0) {
                        notification.setCaption(null);
                    } else {
                        notification.setCaption(title.getValue());
                    }
                }
            });
            title.setValue("Notification Title");
            title.setWidth("100%");
            addComponent(title);

            description.setInputPrompt("Description for the notification");
            description.addStyleName("small");
            description.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    if (description.getValue() == null || description.getValue().length() == 0) {
                        notification.setDescription(null);
                    } else {
                        notification.setDescription(description.getValue());
                    }
                }
            });
            description.setValue(
                    "A more informative message about what has happened. Nihil hic munitissimus habendi senatus locus, nihil horum? Inmensae subtilitatis, obscuris et malesuada fames. Hi omnes lingua, institutis, legibus inter se differunt.");
            description.setWidth("100%");
            addComponent(description);

            Command typeCommand = new Command() {
                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    if (selectedItem.getText().equals("Humanized")) {
                        typeString = "";
                        notification.setStyleName(styleString.trim());
                    } else {
                        typeString = selectedItem.getText().toLowerCase();
                        notification.setStyleName((typeString + " " + styleString.trim()).trim());
                    }
                    for (MenuItem item : type.getItems()) {
                        item.setChecked(false);
                    }
                    selectedItem.setChecked(true);
                }
            };

            type.setCaption("Type");
            MenuItem humanized = type.addItem("Humanized", typeCommand);
            humanized.setCheckable(true);
            humanized.setChecked(true);
            type.addItem("Tray", typeCommand).setCheckable(true);
            type.addItem("Warning", typeCommand).setCheckable(true);
            type.addItem("Error", typeCommand).setCheckable(true);
            type.addItem("System", typeCommand).setCheckable(true);
            addComponent(type);
            type.addStyleName("small");

            Command styleCommand = new Command() {
                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    styleString = "";
                    for (MenuItem item : style.getItems()) {
                        if (item.isChecked()) {
                            styleString += " " + item.getText().toLowerCase();
                        }
                    }
                    if (styleString.trim().length() > 0) {
                        notification.setStyleName((typeString + " " + styleString.trim()).trim());
                    } else if (typeString.length() > 0) {
                        notification.setStyleName(typeString.trim());
                    } else {
                        notification.setStyleName(null);
                    }
                }
            };

            style.setCaption("Additional style");
            style.addItem("Dark", styleCommand).setCheckable(true);
            style.addItem("Success", styleCommand).setCheckable(true);
            style.addItem("Failure", styleCommand).setCheckable(true);
            style.addItem("Bar", styleCommand).setCheckable(true);
            style.addItem("Small", styleCommand).setCheckable(true);
            style.addItem("Closable", styleCommand).setCheckable(true);
            addComponent(style);
            style.addStyleName("small");

            CssLayout group = new CssLayout();
            group.setCaption("Fade delay");
            group.addStyleName("v-component-group");
            addComponent(group);

            delay.setInputPrompt("Infinite");
            delay.addStyleName("align-right");
            delay.addStyleName("small");
            delay.setWidth("7em");
            delay.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    try {
                        notification.setDelayMsec(Integer.parseInt(delay.getValue()));
                    } catch (Exception e) {
                        notification.setDelayMsec(-1);
                        delay.setValue("");
                    }

                }
            });
            delay.setValue("1000");
            group.addComponent(delay);

            Button clear = new Button(null, new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    delay.setValue("");
                }
            });
            clear.setIcon(FontAwesome.TIMES_CIRCLE);
            clear.addStyleName("last");
            clear.addStyleName("small");
            clear.addStyleName("icon-only");
            group.addComponent(clear);
            group.addComponent(new Label("&nbsp; msec", ContentMode.HTML));

            GridLayout grid = new GridLayout(3, 3);
            grid.setCaption("Show in position");
            addComponent(grid);
            grid.setSpacing(true);

            Button pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.TOP_LEFT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.TOP_CENTER);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.TOP_RIGHT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.MIDDLE_LEFT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.MIDDLE_CENTER);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.MIDDLE_RIGHT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.BOTTOM_LEFT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.BOTTOM_CENTER);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.BOTTOM_RIGHT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

        }
    };
    p.setContent(content);

    return p;
}

From source file:com.cms.utils.CommonUtils.java

public static void setBasicAttributeLayout(GridLayout gridLayout, String caption, boolean isCollapseable) {
    gridLayout.setWidth("100%");
    gridLayout.setHeight("-1px");
    gridLayout.setImmediate(true);//from   w w w  .  j a v  a  2s  . co  m
    gridLayout.setMargin(true);
    gridLayout.setSpacing(true);
    if (isCollapseable && !DataUtil.isStringNullOrEmpty(caption)) {
        gridLayout.setStyleName("custom-feildset");
        gridLayout.setCaption(MakeURL.makeURLForGrid(caption));
        gridLayout.setCaptionAsHtml(isCollapseable);
    }
}

From source file:com.cms.view.ListStaffDepartment.java

public ListStaffDepartment() {
    super(BundleUtils.getString("caption.title.listDept"), BundleUtils.getString("caption.title.listEmp"));
    mainLayout.setSplitPosition(30, Unit.PERCENTAGE);
    setCompositionRoot(mainLayout);/*from ww  w .jav  a 2  s.c  o  m*/
    //khoi tao cac thanh phan
    //khoi tao form search
    searchDepartmentForm = new DepartmentSearchPanel();
    //khoi tao table ui
    tblListDepartmentUI = new CommonTableFilterPanel();

    //100316 NgocND6 chuyen quyen quan ly hang hoa
    btnTransferRoleCusts = new Button(TRANSFERROLE);
    btnTransferRoleCusts.setIcon(new ThemeResource("img/transfer_icon.png"));
    //them cac component vao layout
    GridLayout horizontalLayout = new GridLayout(2, 1);
    horizontalLayout.setWidth("-1px");
    horizontalLayout.setMargin(true);
    horizontalLayout.setSpacing(true);
    //btn search
    btnSearchDept = new Button(Constants.BUTTON_SEARCH);
    btnSearchDept.setIcon(new ThemeResource(Constants.ICON.SEARCH));
    horizontalLayout.addComponent(btnSearchDept, 0, 0);
    //btn refresh
    btnRefreshDept = new Button(Constants.BUTTON_REFRESH);
    btnRefreshDept.setIcon(new ThemeResource(Constants.ICON.RESET));
    horizontalLayout.addComponent(btnRefreshDept, 1, 0);
    //add component
    leftLayout.addComponent(searchDepartmentForm);
    leftLayout.addComponent(horizontalLayout);
    leftLayout.addComponent(tblListDepartmentUI);
    leftLayout.setComponentAlignment(horizontalLayout, Alignment.MIDDLE_CENTER);
    leftLayout.setMargin(true);

    //===============right==========================
    searchStaffForm = new StaffSearchPanel();
    //khoi tao table ui
    tblListStaffUI = new CommonTableFilterPanel();

    btnAddMapStaffCustomer = new Button(BundleUtils.getString("staff.customer.map"));
    btnAddMapStaffCustomer.setDescription(BundleUtils.getString("staff.customer.map"));
    btnAddMapStaffCustomer.setIcon(new ThemeResource(Constants.ICON.IMPORT));

    btnAssignRole = new Button(BundleUtils.getString("assign.roles.button"));
    btnAssignRole.setIcon(FontAwesome.ANCHOR);
    //them cac component vao layout
    GridLayout horizontalLayout2 = new GridLayout(3, 1);
    horizontalLayout2.setWidth("-1px");
    horizontalLayout2.setMargin(true);
    horizontalLayout2.setSpacing(true);
    //NgocND6 tao layout de add button chuyen quyen cho nhan vien
    GridLayout gridLayout = new GridLayout(3, 1);
    gridLayout.setMargin(true);
    gridLayout.setSpacing(true);
    gridLayout.addComponent(btnAssignRole, 0, 0);
    //        gridLayout.addComponent(btnAddMapStaffCustomer, 1, 0);
    gridLayout.addComponent(btnTransferRoleCusts, 2, 0);
    //Tam thoi an nut phan bo lai khach hang
    btnTransferRoleCusts.setVisible(false);
    //btn search emp
    btnSearchEmp = new Button(Constants.BUTTON_SEARCH);
    btnSearchEmp.setIcon(new ThemeResource(Constants.ICON.SEARCH));
    horizontalLayout2.addComponent(btnSearchEmp, 0, 0);
    //btn refresh emp
    btnRefreshEmp = new Button(Constants.BUTTON_REFRESH);
    btnRefreshEmp.setIcon(new ThemeResource(Constants.ICON.RESET));
    horizontalLayout2.addComponent(btnRefreshEmp, 1, 0);
    //

    //add component
    rightLayout.addComponent(searchStaffForm);
    rightLayout.addComponent(horizontalLayout2);
    rightLayout.addComponent(tblListStaffUI);
    rightLayout.setComponentAlignment(horizontalLayout2, Alignment.MIDDLE_CENTER);
    rightLayout.addComponent(gridLayout);
    rightLayout.setComponentAlignment(gridLayout, Alignment.MIDDLE_CENTER);
    rightLayout.setMargin(true);
    //=============

    this.listDeptAndStaffController = new ListDeptAndStaffController(this);
}