Example usage for com.vaadin.ui Alignment MIDDLE_RIGHT

List of usage examples for com.vaadin.ui Alignment MIDDLE_RIGHT

Introduction

In this page you can find the example usage for com.vaadin.ui Alignment MIDDLE_RIGHT.

Prototype

Alignment MIDDLE_RIGHT

To view the source code for com.vaadin.ui Alignment MIDDLE_RIGHT.

Click Source Link

Usage

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

License:Open Source License

@Override
public void initComponents() {
    isotopeSelect = new Select();
    isotopeSelect.addStyleName("igg-mass-options-panel-item");
    isotopeSelect.setNullSelectionAllowed(false);
    isotopeSelect.setNewItemsAllowed(false);
    isotopeSelect.setWidth("120px");

    derivatizationSelect = new Select();
    derivatizationSelect.addStyleName("igg-mass-options-panel-item");
    derivatizationSelect.setNullSelectionAllowed(false);
    derivatizationSelect.setNewItemsAllowed(false);
    derivatizationSelect.setWidth("120px");

    reducingEndSelect = new Select();
    reducingEndSelect.addStyleName("igg-mass-options-panel-item");
    reducingEndSelect.setNullSelectionAllowed(false);
    reducingEndSelect.setImmediate(true);
    reducingEndSelect.setNewItemsAllowed(false);
    reducingEndSelect.setWidth("120px");

    reducingEndSelect.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1067195208212460144L;

        @Override//from  w  ww. ja v a 2 s .c om
        public void valueChange(ValueChangeEvent event) {
            if (((String) reducingEndSelect.getValue()).equals("Other...")) {
                otherNameField.setEnabled(true);
                otherMassField.setEnabled(true);
            } else {
                otherNameField.setEnabled(false);
                otherMassField.setEnabled(false);
            }
        }
    });

    otherNameField = new TextField();
    otherNameField.addStyleName("igg-mass-options-panel-item");
    otherNameField.setWidth("120px");

    otherMassField = new TextField();
    otherMassField.addStyleName("igg-mass-options-panel-item");
    otherMassField.setWidth("120px");

    negativeModeField = new CheckBox();
    negativeModeField.addStyleName("igg-mass-options-panel-item");

    hIonCountSelect = new Select("#H ions");
    hIonCountSelect.addStyleName("igg-mass-options-panel-item");
    hIonCountSelect.setNewItemsAllowed(false);
    hIonCountSelect.setWidth("120px");

    naIonCountSelect = new Select("#Na ions");
    naIonCountSelect.addStyleName("igg-mass-options-panel-item");
    naIonCountSelect.setNewItemsAllowed(false);
    naIonCountSelect.setWidth("120px");

    exNAIonCountSelect = new Select("ext. #Na ions");
    exNAIonCountSelect.addStyleName("igg-mass-options-panel-item");
    exNAIonCountSelect.setNewItemsAllowed(false);
    exNAIonCountSelect.setWidth("120px");

    liIonCountSelect = new Select("#Li ions");
    liIonCountSelect.addStyleName("igg-mass-options-panel-item");
    liIonCountSelect.setNewItemsAllowed(false);
    liIonCountSelect.setWidth("120px");

    exLIIonCountSelect = new Select("ext. #Li ions");
    exLIIonCountSelect.addStyleName("igg-mass-options-panel-item");
    exLIIonCountSelect.setNewItemsAllowed(false);
    exLIIonCountSelect.setWidth("120px");

    kIonCountSelect = new Select("#K ions");
    kIonCountSelect.addStyleName("igg-mass-options-panel-item");
    kIonCountSelect.setNewItemsAllowed(false);
    kIonCountSelect.setWidth("120px");

    exKIonCountSelect = new Select("ext. #K ions");
    exKIonCountSelect.addStyleName("igg-mass-options-panel-item");
    exKIonCountSelect.setNewItemsAllowed(false);
    exKIonCountSelect.setWidth("120px");

    clIonCountSelect = new Select("#Cl ions");
    clIonCountSelect.addStyleName("igg-mass-options-panel-item");
    clIonCountSelect.setNewItemsAllowed(false);
    clIonCountSelect.setWidth("120px");

    exClIonCountSelect = new Select("ext. #Cl ions");
    exClIonCountSelect.addStyleName("igg-mass-options-panel-item");
    exClIonCountSelect.setNewItemsAllowed(false);
    exClIonCountSelect.setWidth("120px");

    h2po4IonCountSelect = new Select("#H2PO4 ions");
    h2po4IonCountSelect.addStyleName("igg-mass-options-panel-item");
    h2po4IonCountSelect.setNewItemsAllowed(false);
    h2po4IonCountSelect.setWidth("120px");

    exH2po4IonCountSelect = new Select("ext. #H2PO4 ions");
    exH2po4IonCountSelect.addStyleName("igg-mass-options-panel-item");
    exH2po4IonCountSelect.setNewItemsAllowed(false);
    exH2po4IonCountSelect.setWidth("120px");

    //column,row
    layout.addComponent(new Label("Isotope"), 0, 0, 0, 0);
    layout.addComponent(isotopeSelect, 1, 0, 1, 0);
    layout.addComponent(new Label("Derivatization"), 0, 1, 0, 1);
    layout.addComponent(derivatizationSelect, 1, 1, 1, 1);
    layout.addComponent(new Label("Reducing end"), 0, 2, 0, 2);
    layout.addComponent(reducingEndSelect, 1, 2, 1, 2);

    {
        Label nameLabel = new Label("name");
        nameLabel.setWidth("40px");
        layout.addComponent(nameLabel, 1, 3, 1, 3);
        layout.addComponent(otherNameField, 2, 3, 2, 3);

        layout.setComponentAlignment(nameLabel, Alignment.MIDDLE_RIGHT);
    }

    {
        Label massLabel = new Label("mass");
        massLabel.setWidth("40px");
        layout.addComponent(massLabel, 1, 4, 1, 4);
        layout.addComponent(otherMassField, 2, 4, 2, 4);
        layout.setComponentAlignment(massLabel, Alignment.MIDDLE_RIGHT);
    }

    int row = 5;

    {
        Label divider = new Label("<hr/>", Label.CONTENT_XHTML);

        layout.addComponent(divider, 0, row, 2, row++);
    }

    layout.addComponent(new Label("Negative mode"), 0, row, 0, row);
    layout.addComponent(negativeModeField, 1, row, 1, row++);

    layout.addComponent(hIonCountSelect, 0, row, 0, row++);

    layout.addComponent(naIonCountSelect, 0, row, 0, row);

    layout.addComponent(exNAIonCountSelect, 1, row, 1, row++);

    layout.addComponent(liIonCountSelect, 0, row, 0, row);

    layout.addComponent(exLIIonCountSelect, 1, row, 1, row++);

    layout.addComponent(kIonCountSelect, 0, row, 0, row);

    layout.addComponent(exKIonCountSelect, 1, row, 1, row++);

    {
        Label divider = new Label("<hr/>", Label.CONTENT_XHTML);

        layout.addComponent(divider, 0, row, 2, row++);
    }

    layout.addComponent(clIonCountSelect, 0, row, 0, row);

    layout.addComponent(exClIonCountSelect, 1, row, 1, row++);

    layout.addComponent(h2po4IonCountSelect, 0, row, 0, row);

    layout.addComponent(exH2po4IonCountSelect, 1, row, 1, row++);

    NativeButton update = new NativeButton("Apply mass options");
    update.addListener(new ClickListener() {
        private static final long serialVersionUID = -6188200798103156691L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                config.retrieveData();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            fireMassOptionsChanged(config.getMassOptions(), glycans);
        }
    });

    layout.addComponent(update, 0, row, 0, row);
}

From source file:annis.gui.AboutWindow.java

License:Apache License

public AboutWindow() {
    setSizeFull();//from ww w.ja  va 2s  . c om

    layout = new VerticalLayout();
    setContent(layout);
    layout.setSizeFull();
    layout.setMargin(true);

    HorizontalLayout hLayout = new HorizontalLayout();

    Embedded logoAnnis = new Embedded();
    logoAnnis.setSource(new ThemeResource("images/annis-logo-128.png"));
    logoAnnis.setType(Embedded.TYPE_IMAGE);
    hLayout.addComponent(logoAnnis);

    Embedded logoSfb = new Embedded();
    logoSfb.setSource(new ThemeResource("images/sfb-logo.jpg"));
    logoSfb.setType(Embedded.TYPE_IMAGE);
    hLayout.addComponent(logoSfb);

    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(lnkFork);

    hLayout.setComponentAlignment(logoAnnis, Alignment.MIDDLE_LEFT);
    hLayout.setComponentAlignment(logoSfb, Alignment.MIDDLE_RIGHT);
    hLayout.setComponentAlignment(lnkFork, Alignment.TOP_RIGHT);

    layout.addComponent(hLayout);

    layout.addComponent(new Label(
            "ANNIS is a project of the " + "<a href=\"http://www.sfb632.uni-potsdam.de/\">SFB632</a>.",
            Label.CONTENT_XHTML));
    layout.addComponent(new Label("Homepage: " + "<a href=\"http://corpus-tools.org/annis/\">"
            + "http://corpus-tools.org/annis/</a>.", Label.CONTENT_XHTML));
    layout.addComponent(new Label("Version: " + VersionInfo.getVersion()));
    layout.addComponent(new Label("Vaadin-Version: " + Version.getFullVersion()));

    TextArea txtThirdParty = new TextArea();
    txtThirdParty.setSizeFull();

    StringBuilder sb = new StringBuilder();

    sb.append("The ANNIS team wants to thank these third party software that "
            + "made the ANNIS GUI possible:\n");

    File thirdPartyFolder = new File(VaadinService.getCurrent().getBaseDirectory(), "THIRD-PARTY");
    if (thirdPartyFolder.isDirectory()) {
        for (File c : thirdPartyFolder.listFiles((FileFilter) new WildcardFileFilter("*.txt"))) {
            if (c.isFile()) {
                try {
                    sb.append(FileUtils.readFileToString(c)).append("\n");
                } catch (IOException ex) {
                    log.error("Could not read file", ex);
                }
            }
        }
    }

    txtThirdParty.setValue(sb.toString());
    txtThirdParty.setReadOnly(true);
    txtThirdParty.addStyleName("shared-text");
    txtThirdParty.setWordwrap(false);

    layout.addComponent(txtThirdParty);

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

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

}

From source file:annis.gui.controlpanel.CorpusListPanel.java

License:Apache License

public CorpusListPanel(InstanceConfig instanceConfig, ExampleQueriesPanel autoGenQueries, final AnnisUI ui) {
    this.instanceConfig = instanceConfig;
    this.autoGenQueries = autoGenQueries;
    this.ui = ui;

    final CorpusListPanel finalThis = this;

    setSizeFull();/*  w w  w.  j  a  v a 2s .  com*/

    selectionLayout = new HorizontalLayout();
    selectionLayout.setWidth("100%");
    selectionLayout.setHeight("-1px");
    selectionLayout.setVisible(false);

    Label lblVisible = new Label("Visible: ");
    lblVisible.setSizeUndefined();
    selectionLayout.addComponent(lblVisible);

    cbSelection = new ComboBox();
    cbSelection.setDescription("Choose corpus selection set");
    cbSelection.setWidth("100%");
    cbSelection.setHeight("-1px");
    cbSelection.addStyleName(ValoTheme.COMBOBOX_SMALL);
    cbSelection.setInputPrompt("Add new corpus selection set");
    cbSelection.setNullSelectionAllowed(false);
    cbSelection.setNewItemsAllowed(true);
    cbSelection.setNewItemHandler((AbstractSelect.NewItemHandler) this);
    cbSelection.setImmediate(true);
    cbSelection.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {

            updateCorpusTable();
            updateAutoGeneratedQueriesPanel();

        }
    });

    selectionLayout.addComponent(cbSelection);
    selectionLayout.setExpandRatio(cbSelection, 1.0f);
    selectionLayout.setSpacing(true);
    selectionLayout.setComponentAlignment(cbSelection, Alignment.MIDDLE_RIGHT);
    selectionLayout.setComponentAlignment(lblVisible, Alignment.MIDDLE_LEFT);

    addComponent(selectionLayout);

    txtFilter = new TextField();
    txtFilter.setVisible(false);
    txtFilter.setInputPrompt("Filter");
    txtFilter.setImmediate(true);
    txtFilter.setTextChangeTimeout(500);
    txtFilter.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            BeanContainer<String, AnnisCorpus> availableCorpora = ui.getQueryState().getAvailableCorpora();

            if (textFilter != null) {
                // remove the old filter
                availableCorpora.removeContainerFilter(textFilter);
                textFilter = null;
            }

            if (event.getText() != null && !event.getText().isEmpty()) {
                Set<String> selectedIDs = ui.getQueryState().getSelectedCorpora().getValue();

                textFilter = new SimpleStringFilter("name", event.getText(), true, false);
                availableCorpora.addContainerFilter(textFilter);
                // select the first item
                List<String> filteredIDs = availableCorpora.getItemIds();

                Set<String> selectedAndFiltered = new HashSet<>(selectedIDs);
                selectedAndFiltered.retainAll(filteredIDs);

                Set<String> selectedAndOutsideFilter = new HashSet<>(selectedIDs);
                selectedAndOutsideFilter.removeAll(filteredIDs);

                for (String id : selectedAndOutsideFilter) {
                    tblCorpora.unselect(id);
                }

                if (selectedAndFiltered.isEmpty() && !filteredIDs.isEmpty()) {
                    for (String id : selectedIDs) {
                        tblCorpora.unselect(id);
                    }
                    tblCorpora.select(filteredIDs.get(0));
                }
            }
        }
    });
    txtFilter.setWidth("100%");
    txtFilter.setHeight("-1px");
    txtFilter.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    addComponent(txtFilter);

    pbLoadCorpora = new ProgressBar();
    pbLoadCorpora.setCaption("Loading corpus list...");
    pbLoadCorpora.setIndeterminate(true);
    addComponent(pbLoadCorpora);

    tblCorpora = new Table();

    addComponent(tblCorpora);

    tblCorpora.setVisible(false); // don't show list before it was not loaded
    tblCorpora.setContainerDataSource(ui.getQueryState().getAvailableCorpora());
    tblCorpora.setMultiSelect(true);
    tblCorpora.setPropertyDataSource(ui.getQueryState().getSelectedCorpora());

    tblCorpora.addGeneratedColumn("info", new InfoGenerator());
    tblCorpora.addGeneratedColumn("docs", new DocLinkGenerator());

    tblCorpora.setVisibleColumns("name", "textCount", "tokenCount", "info", "docs");
    tblCorpora.setColumnHeaders("Name", "Texts", "Tokens", "", "");
    tblCorpora.setHeight("100%");
    tblCorpora.setWidth("100%");
    tblCorpora.setSelectable(true);
    tblCorpora.setNullSelectionAllowed(false);
    tblCorpora.setColumnExpandRatio("name", 0.6f);
    tblCorpora.setColumnExpandRatio("textCount", 0.15f);
    tblCorpora.setColumnExpandRatio("tokenCount", 0.25f);
    tblCorpora.addStyleName(ValoTheme.TABLE_SMALL);

    tblCorpora.addActionHandler((Action.Handler) this);
    tblCorpora.setImmediate(true);
    tblCorpora.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            Set selections = (Set) tblCorpora.getValue();
            if (selections.size() == 1 && event.isCtrlKey() && tblCorpora.isSelected(event.getItemId())) {
                tblCorpora.setValue(null);
            }
        }
    });
    tblCorpora.setItemDescriptionGenerator(new TooltipGenerator());
    tblCorpora.addValueChangeListener(new CorpusTableChangedListener(finalThis));

    Button btReload = new Button();
    btReload.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            updateCorpusSetList(false, false);
            Notification.show("Reloaded corpus list", Notification.Type.HUMANIZED_MESSAGE);
        }
    });
    btReload.setIcon(FontAwesome.REFRESH);
    btReload.setDescription("Reload corpus list");
    btReload.addStyleName(ValoTheme.BUTTON_ICON_ONLY);

    selectionLayout.addComponent(btReload);
    selectionLayout.setComponentAlignment(btReload, Alignment.MIDDLE_RIGHT);

    tblCorpora.setSortContainerPropertyId("name");

    setExpandRatio(tblCorpora, 1.0f);

    updateCorpusSetList(true, true);

}

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  ww  . ja va2s. com*/

    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.MainToolbar.java

License:Apache License

/**
 * Adds the login button + login text to the toolbar. This is only happened,
 * when the gui is not started via the kickstarter.
 *
 * <p>/*from   w  ww .ja  v a2 s.co  m*/
 * The Kickstarter overrides the "kickstarterEnvironment" context parameter
 * and set it to "true", so the gui can detect, that is not necessary to offer
 * a login button.</p>
 *
 * component.
 */
private void addLoginButton() {
    VaadinSession session = VaadinSession.getCurrent();
    if (session != null) {
        boolean kickstarter = Helper.isKickstarter(session);

        if (!kickstarter) {
            addComponent(lblUserName);
            setComponentAlignment(lblUserName, Alignment.MIDDLE_RIGHT);
            addComponent(btLogin);
            setComponentAlignment(btLogin, Alignment.MIDDLE_RIGHT);

        }
    }
}

From source file:annis.gui.MainToolbar.java

License:Apache License

private void updateUserInformation() {
    if (lblUserName == null) {
        return;//from  www . j  a v a 2 s. c om
    }

    if (navigationTarget == NavigationTarget.ADMIN) {
        // don't show administration link per default
        btNavigate.setVisible(false);
    }

    AnnisUser user = Helper.getUser();

    // always close the window
    if (windowLogin != null) {
        windowLogin.close(user != null);
    }

    if (user == null) {
        Object loginErrorOject = VaadinSession.getCurrent().getSession().getAttribute(USER_LOGIN_ERROR);
        if (loginErrorOject != null && loginErrorOject instanceof String) {
            Notification.show((String) loginErrorOject, Notification.Type.WARNING_MESSAGE);
        }
        VaadinSession.getCurrent().getSession().removeAttribute(AnnisBaseUI.USER_LOGIN_ERROR);

        lblUserName.setValue("not logged in");
        if (getComponentIndex(btLogout) > -1) {
            replaceComponent(btLogout, btLogin);
            setComponentAlignment(btLogin, Alignment.MIDDLE_RIGHT);
        }
    } else {
        // logged in
        if (user.getUserName() != null) {
            Notification.show("Logged in as \"" + user.getUserName() + "\"",
                    Notification.Type.TRAY_NOTIFICATION);

            lblUserName.setValue("logged in as \"" + user.getUserName() + "\"");

        }
        if (getComponentIndex(btLogin) > -1) {
            replaceComponent(btLogin, btLogout);
            setComponentAlignment(btLogout, Alignment.MIDDLE_RIGHT);
        }
        // do not show the logout button if the user cannot logout using ANNIS
        btLogout.setVisible(!user.isRemote());

        if (navigationTarget == NavigationTarget.ADMIN) {
            // check in background if display is necessary
            if (user.getUserName() != null) {
                Background.run(new CheckIfUserIsAdministratorJob(user.getUserName(), UI.getCurrent()));
            }
        }
    }

}

From source file:annis.gui.paging.PagingComponent.java

License:Apache License

public PagingComponent(int count, int pageSize) {
    if (pageSize <= 0) {
        pageSize = 1;//from w w w. j  a  va  2s.  c o m
    }
    if (count < 0) {
        count = 0;
    }
    currentPage = 1;
    this.count = new AtomicInteger(pageSize);
    this.pageSize = pageSize;

    setWidth("100%");
    setHeight("-1px");

    addStyleName("toolbar");

    callbacks = new HashSet<>();

    layout = new HorizontalLayout();
    layout.setSpacing(true);
    layout.setMargin(new MarginInfo(false, true, false, true));

    setContent(layout);
    addStyleName(ChameleonTheme.PANEL_LIGHT);

    lblInfo = new Label();
    lblInfo.setContentMode(ContentMode.HTML);
    lblInfo.addStyleName("right-aligned-text");

    btShareQuery = new Button(FontAwesome.SHARE_ALT);
    btShareQuery.setDescription("Share query reference link");
    btShareQuery.addStyleName(ValoTheme.BUTTON_BORDERLESS);

    layout.setWidth("100%");
    layout.setHeight("-1px");

    btFirst = new Button();
    btFirst.setIcon(FIRST);
    btFirst.setDescription("jump to first page");
    btFirst.addClickListener((Button.ClickListener) this);
    btFirst.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY);
    btFirst.addStyleName(ChameleonTheme.BUTTON_SMALL);
    btFirst.setDisableOnClick(true);

    btLast = new Button();
    btLast.setIcon(LAST);
    btLast.setDescription("jump to last page");
    btLast.addClickListener((Button.ClickListener) this);
    btLast.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY);
    btLast.addStyleName(ChameleonTheme.BUTTON_SMALL);
    btLast.setDisableOnClick(true);

    btNext = new Button();
    btNext.setIcon(RIGHT_ARROW);
    btNext.setDescription("jump to next page");
    btNext.addClickListener((Button.ClickListener) this);
    btNext.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY);
    btNext.addStyleName(ChameleonTheme.BUTTON_SMALL);
    btNext.setDisableOnClick(true);

    btPrevious = new Button();
    btPrevious.setIcon(LEFT_ARROW);
    btPrevious.setDescription("jump to previous page");
    btPrevious.addClickListener((Button.ClickListener) this);
    btPrevious.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY);
    btPrevious.addStyleName(ChameleonTheme.BUTTON_SMALL);
    btPrevious.setDisableOnClick(true);

    txtPage = new TextField();
    txtPage.setDescription("current page");
    txtPage.setHeight("-1px");
    txtPage.setWidth(5.f, UNITS_EM);
    Validator pageValidator = new PageValidator("must be an integer greater than zero");
    txtPage.addValidator(pageValidator);
    addActionHandler(new EnterHandler(txtPage));

    lblMaxPages = new Label();
    lblMaxPages.setDescription("maximal pages");
    lblMaxPages.setSizeUndefined();

    lblStatus = new Label();
    lblStatus.setSizeUndefined();

    layout.addComponent(btFirst);
    layout.addComponent(btPrevious);
    layout.addComponent(txtPage);
    layout.addComponent(lblMaxPages);
    layout.addComponent(btNext);
    layout.addComponent(btLast);
    layout.addComponent(lblStatus);
    layout.addComponent(lblInfo);
    layout.addComponent(btShareQuery);

    layout.setComponentAlignment(btFirst, Alignment.MIDDLE_LEFT);
    layout.setComponentAlignment(btPrevious, Alignment.MIDDLE_LEFT);
    layout.setComponentAlignment(lblStatus, Alignment.MIDDLE_LEFT);
    layout.setComponentAlignment(lblMaxPages, Alignment.MIDDLE_CENTER);
    layout.setComponentAlignment(txtPage, Alignment.MIDDLE_RIGHT);
    layout.setComponentAlignment(btNext, Alignment.MIDDLE_RIGHT);
    layout.setComponentAlignment(btLast, Alignment.MIDDLE_RIGHT);

    layout.setExpandRatio(lblStatus, 1.0f);
    layout.setComponentAlignment(lblInfo, Alignment.MIDDLE_RIGHT);
    layout.setExpandRatio(lblInfo, 10.0f);

    update(false);
}

From source file:annis.gui.querybuilder.EdgeWindow.java

License:Apache License

public EdgeWindow(final TigerQueryBuilderCanvas parent, NodeWindow source, NodeWindow target) {
    this.parent = parent;
    this.source = source;
    this.target = target;

    setSizeFull();/*from   w w  w .  j a  va 2s  . c o m*/

    // HACK: use our own border since the one from chameleon does not really work
    addStyleName(ValoTheme.PANEL_BORDERLESS);
    addStyleName("border-layout");
    addStyleName("white-panel");

    VerticalLayout vLayout = new VerticalLayout();
    setContent(vLayout);
    vLayout.setMargin(false);

    HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.addStyleName("toolbar");
    toolbar.setWidth("100%");
    toolbar.setHeight("-1px");
    vLayout.addComponent(toolbar);

    Label lblTitle = new Label("AQL Operator");
    lblTitle.setWidth("100%");

    toolbar.addComponent(lblTitle);
    toolbar.setComponentAlignment(lblTitle, Alignment.MIDDLE_LEFT);
    toolbar.setExpandRatio(lblTitle, 1.0f);

    btClose = new Button();
    btClose.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    btClose.addStyleName(ValoTheme.BUTTON_SMALL);
    btClose.setIcon(FontAwesome.TIMES_CIRCLE);
    btClose.setWidth("-1px");
    btClose.addListener((Button.ClickListener) this);
    toolbar.addComponent(btClose);

    toolbar.setComponentAlignment(btClose, Alignment.MIDDLE_RIGHT);
    toolbar.setExpandRatio(btClose, 0.0f);

    cbOperator = new ComboBox();
    cbOperator.setNewItemsAllowed(false);
    cbOperator.setTextInputAllowed(false);
    cbOperator.setNullSelectionAllowed(true);
    cbOperator.addItem(CUSTOM);
    cbOperator.setItemCaption(CUSTOM, "custom");
    cbOperator.setNullSelectionItemId(CUSTOM);
    cbOperator.setNewItemHandler(new SimpleNewItemHandler(cbOperator));
    cbOperator.setImmediate(true);
    vLayout.addComponent(cbOperator);
    for (AQLOperator o : AQLOperator.values()) {
        cbOperator.addItem(o);
        cbOperator.setItemCaption(o, o.getDescription() + " (" + o.getOp() + ")");
    }
    cbOperator.setValue(AQLOperator.DIRECT_PRECEDENCE);
    cbOperator.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {

            Object val = event.getProperty().getValue();
            if (val instanceof AQLOperator) {
                txtOperator.setValue(((AQLOperator) val).getOp());
            }
        }
    });

    cbOperator.setWidth("100%");
    cbOperator.setHeight("20px");

    txtOperator = new TextField();
    txtOperator.setValue(".");
    txtOperator.setInputPrompt("select operator definition");
    txtOperator.setSizeFull();
    txtOperator.addValueChangeListener(new OperatorValueChangeListener(parent));
    txtOperator.setImmediate(true);

    vLayout.addComponent(txtOperator);

    vLayout.setExpandRatio(cbOperator, 1.0f);

}

From source file:annis.gui.SearchUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    super.init(request);

    this.instanceConfig = getInstanceConfig(request);

    getPage().setTitle(instanceConfig.getInstanceDisplayName() + " (ANNIS Corpus Search)");

    queryController = new QueryController(this);

    refresh = new Refresher();
    // deactivate refresher by default
    refresh.setRefreshInterval(-1);//from w  ww .j  a va 2s  .c o m
    refresh.addListener(queryController);
    addExtension(refresh);

    // always get the resize events directly
    setImmediate(true);

    VerticalLayout mainLayout = new VerticalLayout();
    setContent(mainLayout);

    mainLayout.setSizeFull();
    mainLayout.setMargin(false);

    final ScreenshotMaker screenshot = new ScreenshotMaker(this);
    addExtension(screenshot);

    css = new CSSInject(this);

    HorizontalLayout layoutToolbar = new HorizontalLayout();
    layoutToolbar.setWidth("100%");
    layoutToolbar.setHeight("-1px");

    mainLayout.addComponent(layoutToolbar);
    layoutToolbar.addStyleName("toolbar");
    layoutToolbar.addStyleName("border-layout");

    Button btAboutAnnis = new Button("About ANNIS");
    btAboutAnnis.addStyleName(ChameleonTheme.BUTTON_SMALL);
    btAboutAnnis.setIcon(new ThemeResource("info.gif"));

    btAboutAnnis.addClickListener(new AboutClickListener());

    btBugReport = new Button("Report Bug");
    btBugReport.addStyleName(ChameleonTheme.BUTTON_SMALL);
    btBugReport.setDisableOnClick(true);
    btBugReport.setIcon(new ThemeResource("../runo/icons/16/email.png"));
    btBugReport.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            screenshot.makeScreenshot();
            btBugReport.setCaption("bug report is initialized...");
        }
    });

    String bugmail = (String) VaadinSession.getCurrent().getAttribute("bug-e-mail");
    if (bugmail != null && !bugmail.isEmpty() && !bugmail.startsWith("${")
            && new EmailValidator("").isValid(bugmail)) {
        this.bugEMailAddress = bugmail;
    }
    btBugReport.setVisible(this.bugEMailAddress != null);

    lblUserName = new Label("not logged in");
    lblUserName.setWidth("-1px");
    lblUserName.setHeight("-1px");
    lblUserName.addStyleName("right-aligned-text");

    btLoginLogout = new Button("Login", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (isLoggedIn()) {
                // logout
                Helper.setUser(null);
                Notification.show("Logged out", Notification.Type.TRAY_NOTIFICATION);
                updateUserInformation();
            } else {
                showLoginWindow();
            }
        }
    });
    btLoginLogout.setSizeUndefined();
    btLoginLogout.setStyleName(ChameleonTheme.BUTTON_SMALL);
    btLoginLogout.setIcon(new ThemeResource("../runo/icons/16/user.png"));

    Button btOpenSource = new Button("Help us to make ANNIS better!");
    btOpenSource.setStyleName(BaseTheme.BUTTON_LINK);
    btOpenSource.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Window w = new HelpUsWindow();
            w.setCaption("Help us to make ANNIS better!");
            w.setModal(true);
            w.setResizable(true);
            w.setWidth("600px");
            w.setHeight("500px");
            addWindow(w);
            w.center();
        }
    });

    layoutToolbar.addComponent(btAboutAnnis);
    layoutToolbar.addComponent(btBugReport);
    layoutToolbar.addComponent(btOpenSource);
    layoutToolbar.addComponent(lblUserName);
    layoutToolbar.addComponent(btLoginLogout);

    layoutToolbar.setSpacing(true);
    layoutToolbar.setComponentAlignment(btAboutAnnis, Alignment.MIDDLE_LEFT);
    layoutToolbar.setComponentAlignment(btBugReport, Alignment.MIDDLE_LEFT);
    layoutToolbar.setComponentAlignment(btOpenSource, Alignment.MIDDLE_CENTER);
    layoutToolbar.setComponentAlignment(lblUserName, Alignment.MIDDLE_RIGHT);
    layoutToolbar.setComponentAlignment(btLoginLogout, Alignment.MIDDLE_RIGHT);
    layoutToolbar.setExpandRatio(btOpenSource, 1.0f);

    //HorizontalLayout hLayout = new HorizontalLayout();
    final HorizontalSplitPanel hSplit = new HorizontalSplitPanel();
    hSplit.setSizeFull();

    mainLayout.addComponent(hSplit);
    mainLayout.setExpandRatio(hSplit, 1.0f);

    AutoGeneratedQueries autoGenQueries = new AutoGeneratedQueries("example queries", this);

    controlPanel = new ControlPanel(queryController, instanceConfig, autoGenQueries);
    controlPanel.setWidth(100f, Layout.Unit.PERCENTAGE);
    controlPanel.setHeight(100f, Layout.Unit.PERCENTAGE);
    hSplit.setFirstComponent(controlPanel);

    tutorial = new TutorialPanel();
    tutorial.setHeight("99%");

    mainTab = new TabSheet();
    mainTab.setSizeFull();
    mainTab.addTab(autoGenQueries, "example queries");
    mainTab.addTab(tutorial, "Tutorial");

    queryBuilder = new QueryBuilderChooser(queryController, this, instanceConfig);
    mainTab.addTab(queryBuilder, "Query Builder");

    hSplit.setSecondComponent(mainTab);
    hSplit.setSplitPosition(CONTROL_PANEL_WIDTH, Unit.PIXELS);
    hSplit.addSplitterClickListener(new AbstractSplitPanel.SplitterClickListener() {
        @Override
        public void splitterClick(AbstractSplitPanel.SplitterClickEvent event) {
            if (event.isDoubleClick()) {
                if (hSplit.getSplitPosition() == CONTROL_PANEL_WIDTH) {
                    // make small
                    hSplit.setSplitPosition(0.0f, Unit.PIXELS);
                } else {
                    // reset to default width
                    hSplit.setSplitPosition(CONTROL_PANEL_WIDTH, Unit.PIXELS);
                }
            }
        }
    });
    // hLayout.setExpandRatio(mainTab, 1.0f);

    addAction(new ShortcutListener("^Query builder") {
        @Override
        public void handleAction(Object sender, Object target) {
            mainTab.setSelectedTab(queryBuilder);
        }
    });

    addAction(new ShortcutListener("Tutor^eial") {
        @Override
        public void handleAction(Object sender, Object target) {
            mainTab.setSelectedTab(tutorial);
        }
    });

    getPage().addUriFragmentChangedListener(this);

    getSession().addRequestHandler(new RequestHandler() {
        @Override
        public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response)
                throws IOException {
            checkCitation(request);

            if (request.getPathInfo() != null && request.getPathInfo().startsWith("/vis-iframe-res/")) {
                String uuidString = StringUtils.removeStart(request.getPathInfo(), "/vis-iframe-res/");
                UUID uuid = UUID.fromString(uuidString);
                IFrameResourceMap map = VaadinSession.getCurrent().getAttribute(IFrameResourceMap.class);
                if (map == null) {
                    response.setStatus(404);
                } else {
                    IFrameResource res = map.get(uuid);
                    if (res != null) {
                        response.setStatus(200);
                        response.setContentType(res.getMimeType());
                        response.getOutputStream().write(res.getData());
                    }
                }
                return true;
            }

            return false;
        }
    });

    getSession().setAttribute(MediaController.class, new MediaControllerImpl());

    getSession().setAttribute(PDFController.class, new PDFControllerImpl());

    loadInstanceFonts();

    checkCitation(request);
    lastQueriedFragment = "";
    evaluateFragment(getPage().getUriFragment());

    updateUserInformation();
}

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

License:Mozilla Public License

private void initElements() {

    final GridLayout grid = new GridLayout(4, 4);
    final VerticalLayout outerLayout = new VerticalLayout();
    hiddenContent = new VerticalLayout();
    hiddenContent.setSpacing(true);/*  w w  w  . j  av  a 2s.c  om*/
    hiddenContent.setMargin(true);

    table = new InvoiceLineAllowanceChargeTable(lineAllowanceChargeList);
    table.setSelectable(true);
    table.setImmediate(true);
    table.setNullSelectionAllowed(false);
    table.setHeight(150, UNITS_PIXELS);
    table.setFooterVisible(false);
    table.addStyleName("striped strong");

    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");

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

    InvoiceLineAllowanceChargeTableEditor editor = new InvoiceLineAllowanceChargeTableEditor(editMode, inv);
    Label label = new Label("<h3>Adding allowance/charge line</h3>", Label.CONTENT_XHTML);
    addButton.addListener(editor.addButtonListener(editButton, deleteButton, hiddenContent, table,
            lineAllowanceChargeList, label));
    label = new Label("<h3>Edit allowance/charge line</h3>", Label.CONTENT_XHTML);
    editButton.addListener(editor.editButtonListener(addButton, deleteButton, hiddenContent, table,
            lineAllowanceChargeList, label));
    deleteButton.addListener(editor.deleteButtonListener(table));

    Panel outerPanel = new Panel(prefix + " Allowances/Charges");
    //outerPanel.setStyleName("light");     

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

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

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

    VerticalLayout mainLayout = new VerticalLayout();
    final VerticalLayout showHideContentLayout = new VerticalLayout();
    showHideContentLayout.addComponent(outerPanel);
    HorizontalLayout showHideButtonLayout = new HorizontalLayout();
    Button btn = new Button("Show/Hide Allowances/Charges", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            // TODO Auto-generated method stub
            showHideContentLayout.setVisible(!showHideContentLayout.isVisible());
        }
    });
    showHideButtonLayout.setWidth("100%");
    showHideButtonLayout.addComponent(btn);
    showHideButtonLayout.setComponentAlignment(btn, Alignment.MIDDLE_RIGHT);

    //mainLayout.addComponent(showHideButtonLayout);
    mainLayout.addComponent(showHideContentLayout);
    //showHideContentLayout.setVisible(false);    

    addComponent(mainLayout);

}