Example usage for com.vaadin.ui Panel setContent

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

Introduction

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

Prototype

@Override
public void setContent(Component content) 

Source Link

Document

Sets the content of this container.

Usage

From source file:ac.uk.icl.dell.vaadin.glycanbuilder.GlycanBuilder.java

License:Open Source License

private void initToolBars() {
    theToolBarPanel = new Panel();
    theToolBarPanel.setContent(new HorizontalLayout());

    NavigableApplication.getCurrentNavigableAppLevelWindow().addActionHandler(new Handler() {
        private static final long serialVersionUID = 1735392108529734256L;

        Action actionDelete = new ShortcutAction("Delete", ShortcutAction.KeyCode.DELETE, null);
        Action actionCopy = new ShortcutAction("Copy", ShortcutAction.KeyCode.C,
                new int[] { ShortcutAction.ModifierKey.CTRL });
        Action actionPaste = new ShortcutAction("Paste", ShortcutAction.KeyCode.V,
                new int[] { ShortcutAction.ModifierKey.CTRL });
        Action actionCut = new ShortcutAction("Cut", ShortcutAction.KeyCode.X,
                new int[] { ShortcutAction.ModifierKey.CTRL });
        Action actionSelectAll = new ShortcutAction("Select all", ShortcutAction.KeyCode.A,
                new int[] { ShortcutAction.ModifierKey.CTRL });
        Action actionUnSelectAll = new ShortcutAction("UnSelect all", ShortcutAction.KeyCode.A,
                new int[] { ShortcutAction.ModifierKey.CTRL, ShortcutAction.ModifierKey.SHIFT });

        @Override/*from  www  .j  ava 2 s .c o m*/
        public Action[] getActions(Object target, Object sender) {
            return new Action[] { actionDelete, actionCopy, actionPaste, actionCut, actionSelectAll,
                    actionUnSelectAll };
        }

        @Override
        public void handleAction(Action action, Object sender, Object target) {

            GlycanCanvas canvas = theCanvas.theCanvas;
            if (theCanvas.theCanvas.hasSelected()) {
                if (action == actionDelete) {
                    canvas.delete();
                } else if (action == actionCopy) {
                    canvas.copy();
                } else if (action == actionCut) {
                    canvas.cut();
                }
            }

            if (action == actionSelectAll) {
                canvas.selectAll();
                canvas.documentUpdated();
            } else if (action == actionUnSelectAll) {
                canvas.resetSelection();
                canvas.documentUpdated();
            } else if (action == actionPaste) {
                System.err.println("Paste picked up!");
                canvas.paste();
            }
        }
    });

    theCanvas.appendGeneralToolBar(theToolBarPanel);

    //theToolBarPanel.setScrollable(true);

    mainLayout.addComponent(theToolBarPanel);

    Panel theLinkageToolBarPanel = new Panel();
    theLinkageToolBarPanel.setContent(new HorizontalLayout());
    theLinkageToolBarPanel.setWidth("100%");
    //theLinkageToolBarPanel.setScrollable(true);

    theCanvas.appendLinkageToolBar(theLinkageToolBarPanel);

    //theLinkageToolBarPanel.setScrollable(false);

    mainLayout.addComponent(theLinkageToolBarPanel);

    theResidueCanvas = new VaadinGlycanCanvas();
    theResidueCanvas.setBackgroundColor("#CCF");
    theResidueCanvas.setName("residueCanvas");

    theResidueCanvas.setHeight("25px");
    theResidueCanvas.setWidth("100%");

    theResidueCanvas.enableMouseSelectionRectangle(false);
    theResidueCanvas.theCanvas.theGlycanRenderer.getGraphicOptions().MARGIN_TOP = 2;

    mainLayout.addComponent(theResidueCanvas);
    //mainLayout.setExpandRatio(theResidueCanvas, 1);

    final VaadinGlycanCanvas finalCanvas = theResidueCanvas;
    finalCanvas.enableResidueToolBarMode();

    theResidueCanvas.theCanvas.addGlycanCanvasUpdateListener(new GlycanCanvasUpdateListener() {
        @Override
        public void glycanCanvasUpdated() {
            Residue selectedResidues[] = theResidueCanvas.theCanvas.selectedResidues.toArray(new Residue[0]);

            theResidueCanvas.theCanvas.selectedResidues.clear();

            theCanvas.theCanvas.setDocumentChangedEventFiring(false);

            for (Residue toinsert : selectedResidues) {
                System.err.println("Selected residue: " + toinsert.getTypeName());
                theCanvas.theCanvas.addResidueByNameToSelected(toinsert.getTypeName());
            }

            theCanvas.theCanvas.setDocumentChangedEventFiring(true);
            theCanvas.theCanvas.documentUpdated();
        }
    });
}

From source file:ac.uk.icl.dell.vaadin.glycanbuilder.VaadinGlycanCanvas.java

License:Open Source License

public void appendGeneralToolBar(Panel theToolBarPanel) {
    HorizontalLayout toolBar = new HorizontalLayout();
    toolBar.setWidth("100%");

    toolBar.setStyleName("toolbar");

    NativeButton deleteButton = new NativeButton("Delete");
    deleteButton.setIcon(new ThemeResource("icons/deleteNew.png"));
    deleteButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 1289257412952359727L;

        @Override/*from   w  w w.ja va  2 s .com*/
        public void buttonClick(ClickEvent event) {
            theCanvas.delete();
        }
    });
    deleteButton.setEnabled(false);

    NativeButton copyButton = new NativeButton("Copy");
    final NativeButton pasteButton = new NativeButton("Paste");
    copyButton.setIcon(new ThemeResource("icons/editcopy.png"));
    copyButton.addListener(new ClickListener() {
        private static final long serialVersionUID = -1740735587078805580L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.copy();
            pasteButton.setEnabled(true);
        }
    });
    copyButton.setEnabled(false);

    pasteButton.setIcon(new ThemeResource("icons/editpaste.png"));
    pasteButton.addListener(new ClickListener() {
        private static final long serialVersionUID = -8732259244009686729L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.paste();
            pasteButton.setEnabled(false);
        }
    });
    pasteButton.setEnabled(false);

    final NativeButton bracketButton = new NativeButton("Bracket");
    bracketButton.setIcon(new ThemeResource("icons/bracket.png"));
    bracketButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 5201094306113759901L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.addBracket();
        }
    });
    bracketButton.setEnabled(false);

    final NativeButton repeatButton = new NativeButton("Repeat");
    repeatButton.setIcon(new ThemeResource("icons/repeat.png"));
    repeatButton.addListener(new ClickListener() {
        private static final long serialVersionUID = -23302591439643695L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                theCanvas.addRepeat();
            } catch (Exception ex) {
                showMessage(ex.getMessage(), "400px", "100px", "Error creating repeat");
            }
        }
    });
    repeatButton.setEnabled(false);

    componentsWithResidueSelectionDependency.add(repeatButton);
    componentsWithResidueSelectionDependency.add(bracketButton);
    componentsWithResidueSelectionDependency.add(deleteButton);
    componentsWithResidueSelectionDependency.add(copyButton);

    final NativeButton orientationButton = new NativeButton("Orientation");

    orientationButton.setIcon(new ThemeResource("icons/" + theCanvas.getOrientationIcon()));
    orientationButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 6621021858668446143L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.changeOrientation();
            orientationButton.setIcon(new ThemeResource("icons/" + theCanvas.getOrientationIcon()));
        }
    });

    final NativeButton selectAllButton = new NativeButton("Select all");

    selectAllButton.setIcon(new ThemeResource("icons/selectall.png"));
    selectAllButton.addListener(new ClickListener() {
        private static final long serialVersionUID = -5848923636575805154L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.selectAll();
            theCanvas.documentUpdated();
        }
    });

    final NativeButton deSelectAllButton = new NativeButton("Select none");

    deSelectAllButton.setIcon(new ThemeResource("icons/deselect.png"));
    deSelectAllButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 8339468775345706027L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.resetSelection();
            theCanvas.documentUpdated();
        }
    });

    final NativeButton moveCWButton = new NativeButton("Move CW");

    moveCWButton.setIcon(new ThemeResource("icons/rotatecw.png"));
    moveCWButton.addListener(new ClickListener() {
        private static final long serialVersionUID = -6061975045440741204L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.onMoveCW();
        }
    });

    componentsWithResidueSelectionDependency.add(moveCWButton);

    final NativeButton moveCCWButton = new NativeButton("Move CCW");

    moveCCWButton.setIcon(new ThemeResource("icons/rotateccw.png"));
    moveCCWButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 3555726070782377309L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.onMoveCCW();
        }
    });

    componentsWithResidueSelectionDependency.add(moveCCWButton);

    toolBar.addComponent(deleteButton);
    toolBar.addComponent(copyButton);
    toolBar.addComponent(pasteButton);
    toolBar.addComponent(orientationButton);
    toolBar.addComponent(selectAllButton);
    toolBar.addComponent(deSelectAllButton);
    toolBar.addComponent(bracketButton);
    toolBar.addComponent(repeatButton);
    toolBar.addComponent(moveCWButton);
    toolBar.addComponent(moveCCWButton);

    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();

    toolBar.addComponent(layout);
    toolBar.setExpandRatio(layout, 1);

    theToolBarPanel.setContent(toolBar);
}

From source file:annis.gui.AutoGeneratedQueries.java

License:Apache License

private Panel getOpenCorpusPanel(final String corpusName) {
    Panel p = new Panel();
    p.addStyleName(ChameleonTheme.PANEL_BORDERLESS);

    final Button btn = new Button(corpusName);
    final HorizontalLayout l = new HorizontalLayout();

    p.setContent(l);
    btn.setStyleName(BaseTheme.BUTTON_LINK);
    btn.addClickListener(new Button.ClickListener() {
        @Override/*from  w  w w  .j a  v  a 2s . com*/
        public void buttonClick(Button.ClickEvent event) {
            CorpusListPanel corpusList = ui.getControlPanel().getCorpusList();
            corpusList.initCorpusBrowser(corpusName);
        }
    });

    l.addComponent(btn);

    return p;
}

From source file:annis.gui.docbrowser.DocBrowserController.java

License:Apache License

public void openDocVis(String corpus, String doc, Visualizer visConfig, Button btn) {

    final String canonicalTitle = corpus + " > " + doc + " - " + "Visualizer: " + visConfig.getDisplayName();
    final String tabCaption = StringUtils.substring(canonicalTitle, 0, 15) + "...";

    if (visibleVisHolder.containsKey(canonicalTitle)) {
        Panel visHolder = visibleVisHolder.get(canonicalTitle);
        ui.getSearchView().getTabSheet().setSelectedTab(visHolder);
        return;//w  w w .  ja v a  2 s .  c  om
    }

    Panel visHolder = new Panel();
    visHolder.setSizeFull();
    visHolder.addDetachListener(new ClientConnector.DetachListener() {
        @Override
        public void detach(ClientConnector.DetachEvent event) {
            visibleVisHolder.remove(canonicalTitle);
        }
    });

    // first set loading indicator
    ProgressBar progressBar = new ProgressBar(1.0f);
    progressBar.setIndeterminate(true);
    progressBar.setSizeFull();
    VerticalLayout layoutProgress = new VerticalLayout(progressBar);
    layoutProgress.setSizeFull();
    layoutProgress.setComponentAlignment(progressBar, Alignment.MIDDLE_CENTER);

    visHolder.setContent(layoutProgress);

    Tab visTab = ui.getSearchView().getTabSheet().addTab(visHolder, tabCaption);
    visTab.setDescription(canonicalTitle);
    visTab.setIcon(EYE_ICON);
    visTab.setClosable(true);
    ui.getSearchView().getTabSheet().setSelectedTab(visTab);

    // register visible visHolder
    this.visibleVisHolder.put(canonicalTitle, visHolder);

    Background.run(new DocVisualizerFetcher(corpus, doc, canonicalTitle, visConfig.getType(), visHolder,
            visConfig, btn, UI.getCurrent()));
}

From source file:annis.gui.docbrowser.DocBrowserTable.java

License:Apache License

private Panel generateVisualizerLinks(String docName) {
    Panel p = new Panel();
    VerticalLayout l = new VerticalLayout();
    p.addStyleName(ChameleonTheme.PANEL_BORDERLESS);

    if (docVisualizerConfig != null) {
        Visualizer[] visualizers = docVisualizerConfig.getVisualizers();

        if (visualizers != null) {
            for (Visualizer visualizer : visualizers) {
                Button openVis = new Button(visualizer.getDisplayName());
                openVis.setDescription("open visualizer with the full text of " + docName);
                openVis.addClickListener(new OpenVisualizerWindow(docName, visualizer, openVis));
                openVis.setStyleName(BaseTheme.BUTTON_LINK);
                openVis.setDisableOnClick(true);
                l.addComponent(openVis);
            }//from ww w.ja va  2  s.  co  m
        }
    }

    p.setContent(l);
    return p;
}

From source file:annis.visualizers.component.pdf.PDFFullVisualizer.java

License:Apache License

@Override
public Panel createComponent(VisualizerInput input, VisualizationToggle visToggle) {
    Panel p = new Panel();
    p.setHeight(input.getMappings().getProperty("height", "-1") + "px");
    p.setContent(new PDFPanel(input, "-1"));
    return p;/* w  ww  .ja  v  a 2  s .  com*/
}

From source file:annis.visualizers.component.RawTextVisualizer.java

License:Apache License

@Override
public Panel createComponent(VisualizerInput visInput, VisualizationToggle visToggle) {

    // get config for alignment
    boolean vertical = Boolean.parseBoolean(visInput.getMappings().getProperty("vertical", "true"));

    // get the texts
    RawTextWrapper texts = visInput.getRawText();

    // create the main panel
    Panel p = new Panel();
    p.setSizeFull();/*w  ww .j av  a  2s  . c om*/

    // some layout configuration
    p.addStyleName(ChameleonTheme.PANEL_BORDERLESS);
    p.addStyleName(PANEL_CLASS);

    // enable webfonts
    p.addStyleName(Helper.CORPUS_FONT_FORCE);

    Layout l;

    // if no text available inform user and exit
    if (texts == null) {
        Label text = new Label(NO_TEXT);
        text.addStyleName(LABEL_CLASS);
        text.setSizeFull();
        p.setContent(text);
        return p;
    }

    if (texts.hasMultipleTexts()) {

        // set the aligmnent
        if (vertical) {
            l = new VerticalLayout();
        } else {
            l = new GridLayout(texts.getTexts().size(), 1);
        }

        // limit the size to the parent panel.
        l.setSizeFull();

        // add the texts to the layout
        for (int i = 0; i < texts.getTexts().size(); i++) {

            String s = texts.getTexts().get(i);
            Label lblText;

            // check if the text is empty
            if (s == null || hasOnlyWhiteSpace(s)) {
                lblText = new Label(NO_TEXT);
            } else {
                lblText = new Label(s, ContentMode.TEXT);
            }

            lblText.setCaption("text " + (i + 1));
            lblText.addStyleName(LABEL_CLASS);
            lblText.setWidth(98, Sizeable.Unit.PERCENTAGE);

            l.addComponent(lblText);
        }

        // apply the panel
        p.setContent(l);
        return p;
    }

    Label lblText;
    if (texts.hasTexts() && !hasOnlyWhiteSpace(texts.getFirstText())) {
        lblText = new Label(texts.getFirstText(), ContentMode.TEXT);
    } else {
        lblText = new Label(NO_TEXT);
    }

    lblText.setSizeFull();
    lblText.addStyleName(LABEL_CLASS);
    p.setContent(lblText);

    return p;
}

From source file:annis.visualizers.htmlvis.HTMLVis.java

License:Apache License

@Override
public Panel createComponent(VisualizerInput vi, VisualizationToggle vt) {
    Panel scrollPanel = new Panel();
    scrollPanel.setSizeFull();/*from  w  w w .  j  a  va  2  s.  c  o m*/
    Label lblResult = new Label("ERROR", ContentMode.HTML);
    lblResult.setSizeUndefined();

    List<String> corpusPath = CommonHelper.getCorpusPath(vi.getDocument().getGraph(), vi.getDocument());
    String corpusName = corpusPath.get(corpusPath.size() - 1);
    corpusName = urlPathEscape.escape(corpusName);

    String wrapperClassName = "annis-wrapped-htmlvis-" + corpusName.replaceAll("[^0-9A-Za-z-]", "_");

    scrollPanel.addStyleName(wrapperClassName);

    String visConfigName = vi.getMappings().getProperty("config");
    String hitMarkConfig = vi.getMappings().getProperty("hitmark", "true");
    hitMark = Boolean.parseBoolean(hitMarkConfig);
    mc = vi.getMarkedAndCovered();

    VisualizationDefinition[] definitions = parseDefinitions(corpusName, vi.getMappings());

    if (definitions != null) {

        lblResult.setValue(createHTML(vi.getSResult().getDocumentGraph(), definitions));

        String labelClass = vi.getMappings().getProperty("class", "htmlvis");
        lblResult.addStyleName(labelClass);

        InputStream inStreamCSSRaw = null;
        if (visConfigName == null) {
            inStreamCSSRaw = HTMLVis.class.getResourceAsStream("htmlvis.css");
        } else {
            WebResource resBinary = Helper.getAnnisWebResource().path("query/corpora/").path(corpusName)
                    .path(corpusName).path("binary").path(visConfigName + ".css");

            ClientResponse response = resBinary.get(ClientResponse.class);
            if (response.getStatus() == ClientResponse.Status.OK.getStatusCode()) {
                inStreamCSSRaw = response.getEntityInputStream();
            }
        }
        if (inStreamCSSRaw != null) {
            try (InputStream inStreamCSS = inStreamCSSRaw) {
                String cssContent = IOUtils.toString(inStreamCSS);
                UI currentUI = UI.getCurrent();
                if (currentUI instanceof AnnisBaseUI) {
                    // do not add identical CSS files
                    ((AnnisBaseUI) currentUI).injectUniqueCSS(cssContent, wrapperClassName);
                }
            } catch (IOException ex) {
                log.error("Could not parse the HTML visualizer CSS file", ex);
                Notification.show("Could not parse the HTML visualizer CSS file", ex.getMessage(),
                        Notification.Type.ERROR_MESSAGE);
            }
        }

    }

    if (vi.getMappings().containsKey("debug")) {
        TextArea txtDebug = new TextArea();
        txtDebug.setValue(lblResult.getValue());
        txtDebug.setReadOnly(true);
        txtDebug.setWidth("100%");
        Label sep = new Label("<hr/>", ContentMode.HTML);
        VerticalLayout layout = new VerticalLayout(txtDebug, sep, lblResult);
        layout.setSizeUndefined();
        scrollPanel.setContent(layout);
    } else {
        scrollPanel.setContent(lblResult);
    }

    return scrollPanel;
}

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 .j a  v a2  s . co m
    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;/*  ww  w. j  a  v 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();
}