Example usage for com.vaadin.ui Label Label

List of usage examples for com.vaadin.ui Label Label

Introduction

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

Prototype

public Label(String text) 

Source Link

Document

Creates a new instance with text content mode and the given text.

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/*ww  w.ja v  a  2 s.  c  o  m*/
        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:ac.uk.icl.dell.vaadin.glycanbuilder.VaadinGlycanCanvas.java

License:Open Source License

public void showMessage(String message, String width, String height, String caption) {
    Window window = new Window();
    window.setCaption(caption);//from   www .  j  a  va  2s.  co  m
    window.setWidth(width);
    window.setHeight(height);

    window.center();

    Panel panel = new Panel();

    panel.getContent().addComponent(new Label(message));

    window.getContent().addComponent(panel);

    getWindow().addWindow(window);
}

From source file:ac.uk.icl.dell.vaadin.MessageDialogBox.java

License:Open Source License

public void init(String title, String message, Window parent) {
    Label messageLabel = new Label(message);

    Panel panel = new Panel();

    panel.getContent().addComponent(messageLabel);
    ((VerticalLayout) panel.getContent()).setComponentAlignment(messageLabel, Alignment.MIDDLE_CENTER);

    getContent().addComponent(panel);//from w  w w  .  jav  a 2s.c  o m

    setCaption(title);

    parent.addWindow(this);

    getContent().setWidth("400px");

    center();
}

From source file:ac.uk.icl.dell.vaadin.navigator7.IGGAppLevelWindow.java

License:Open Source License

@Override
protected Component createFooter() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth("100%");

    layout.addStyleName("white-background");

    layout.addComponent(new Label("GlycanBuilder"));

    return layout;
}

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();// ww w .  ja  va 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.CorpusBrowserPanel.java

License:Apache License

/**
 * Places a label with the text "(No <caption>)" in the centered middle of the accordion
 * tab./*from  ww w .j ava  2s  .c  o m*/
 *
 * @param accordion the target accordion
 * @param caption is set as caption of the accordion tab
 */
private void placeEmptyLabel(Accordion accordion, String caption) {
    VerticalLayout v = new VerticalLayout();
    v.setSizeFull();
    Label l = new Label("(No " + caption + ")");
    v.addComponent(l);
    l.setSizeUndefined();
    v.setComponentAlignment(l, Alignment.MIDDLE_CENTER);
    accordion.addTab(v, caption, null);
    l.setSizeUndefined();
}

From source file:annis.gui.ExampleQueriesPanel.java

License:Apache License

/**
 * Sets some layout properties./*from  w  w  w. j a  va 2  s .  c o  m*/
 */
private void setUpTable() {
    setSizeFull();
    // expand the table
    table.setSizeFull();

    // Allow selecting items from the table.
    table.setSelectable(false);

    // Send changes in selection immediately to server.
    table.setImmediate(true);

    // set custom style
    table.addStyleName("example-queries-table");

    // put stripes to the table
    table.addStyleName(ChameleonTheme.TABLE_STRIPED);

    // configure columns
    table.addGeneratedColumn(COLUMN_OPEN_CORPUS_BROWSER, new ShowCorpusBrowser());

    table.addGeneratedColumn(COLUMN_EXAMPLE_QUERY, new QueryColumn());

    table.addGeneratedColumn(COLUMN_DESCRIPTION, new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            ExampleQuery eQ = (ExampleQuery) itemId;
            Label l = new Label(eQ.getDescription());
            l.setContentMode(ContentMode.TEXT);
            l.addStyleName(Helper.CORPUS_FONT_FORCE);
            return l;
        }
    });

    table.setVisibleColumns(
            new Object[] { COLUMN_EXAMPLE_QUERY, COLUMN_DESCRIPTION, COLUMN_OPEN_CORPUS_BROWSER });

    table.setColumnExpandRatio(table.getVisibleColumns()[0], 0.40f);
    table.setColumnExpandRatio(table.getVisibleColumns()[1], 0.40f);

    table.setColumnHeader(table.getVisibleColumns()[0], "Example Query");
    table.setColumnHeader(table.getVisibleColumns()[1], "Description");
    table.setColumnHeader(table.getVisibleColumns()[2], "open corpus browser");

}

From source file:annis.gui.ExportPanel.java

License:Apache License

public ExportPanel(QueryPanel queryPanel, QueryController controller, QueryUIState state) {
    super(2, 3);//from w  ww . j  av  a  2s. c  o  m
    this.queryPanel = queryPanel;
    this.controller = controller;
    this.state = state;

    this.eventBus = new EventBus();
    this.eventBus.register(ExportPanel.this);

    this.formLayout = new FormLayout();
    formLayout.setWidth("-1px");

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

    initHelpMessages();

    setColumnExpandRatio(0, 0.0f);
    setColumnExpandRatio(1, 1.0f);

    cbExporter = new ComboBox("Exporter");
    cbExporter.setNewItemsAllowed(false);
    cbExporter.setNullSelectionAllowed(false);
    cbExporter.setImmediate(true);

    for (Exporter e : SearchView.EXPORTER) {
        cbExporter.addItem(e.getClass().getSimpleName());
    }

    cbExporter.setValue(SearchView.EXPORTER[0].getClass().getSimpleName());
    cbExporter.addValueChangeListener(new ExporterSelectionHelpListener());

    formLayout.addComponent(cbExporter);
    addComponent(formLayout, 0, 0);

    lblHelp = new Label(help4Exporter.get((String) cbExporter.getValue()));
    lblHelp.setContentMode(ContentMode.HTML);
    addComponent(lblHelp, 1, 0);

    cbLeftContext = new ComboBox("Left Context");
    cbRightContext = new ComboBox("Right Context");

    cbLeftContext.setNullSelectionAllowed(false);
    cbRightContext.setNullSelectionAllowed(false);

    cbLeftContext.setNewItemsAllowed(true);
    cbRightContext.setNewItemsAllowed(true);

    cbLeftContext
            .addValidator(new IntegerRangeValidator("must be a number", Integer.MIN_VALUE, Integer.MAX_VALUE));
    cbRightContext
            .addValidator(new IntegerRangeValidator("must be a number", Integer.MIN_VALUE, Integer.MAX_VALUE));

    for (Integer i : SearchOptionsPanel.PREDEFINED_CONTEXTS) {
        cbLeftContext.addItem(i);
        cbRightContext.addItem(i);
    }

    cbLeftContext.setValue(5);
    cbRightContext.setValue(5);

    formLayout.addComponent(cbLeftContext);
    formLayout.addComponent(cbRightContext);

    txtAnnotationKeys = new TextField("Annotation Keys");
    txtAnnotationKeys.setDescription("Some exporters will use this comma "
            + "seperated list of annotation keys to limit the exported data to these " + "annotations.");
    formLayout.addComponent(new HelpButton(txtAnnotationKeys));

    txtParameters = new TextField("Parameters");
    txtParameters.setDescription(
            "You can input special parameters " + "for certain exporters. See the description of each exporter "
                    + "(? button above) for specific parameter settings.");
    formLayout.addComponent(new HelpButton(txtParameters));

    btExport = new Button("Perform Export");
    btExport.setIcon(FontAwesome.PLAY);
    btExport.setDisableOnClick(true);
    btExport.addClickListener(new ExportButtonListener());

    btCancel = new Button("Cancel Export");
    btCancel.setIcon(FontAwesome.TIMES_CIRCLE);
    btCancel.setEnabled(false);
    btCancel.addClickListener(new CancelButtonListener());
    btCancel.setVisible(SearchView.EXPORTER[0].isCancelable());

    btDownload = new Button("Download");
    btDownload.setDescription("Click here to start the actual download.");
    btDownload.setIcon(FontAwesome.DOWNLOAD);
    btDownload.setDisableOnClick(true);
    btDownload.setEnabled(false);

    HorizontalLayout layoutExportButtons = new HorizontalLayout(btExport, btCancel, btDownload);
    addComponent(layoutExportButtons, 0, 1, 1, 1);

    VerticalLayout vLayout = new VerticalLayout();
    addComponent(vLayout, 0, 2, 1, 2);

    progressBar = new ProgressBar();
    progressBar.setVisible(false);
    progressBar.setIndeterminate(true);
    vLayout.addComponent(progressBar);

    progressLabel = new Label();
    vLayout.addComponent(progressLabel);

    if (state != null) {
        cbLeftContext.setPropertyDataSource(state.getLeftContext());
        cbRightContext.setPropertyDataSource(state.getRightContext());
        cbExporter.setPropertyDataSource(state.getExporterName());

        state.getExporterName().setValue(SearchView.EXPORTER[0].getClass().getSimpleName());

        txtAnnotationKeys.setConverter(new CommaSeperatedStringConverterList());
        txtAnnotationKeys.setPropertyDataSource(state.getExportAnnotationKeys());

        txtParameters.setPropertyDataSource(state.getExportParameters());

    }

}

From source file:annis.gui.flatquerybuilder.SearchBox.java

License:Apache License

public SearchBox(final String ebene, final FlatQueryBuilder sq, final VerticalNode vn, boolean isRegex,
        boolean negativeSearch) {
    this.vn = vn;
    this.ebene = ebene;
    this.sq = sq;
    this.vfs = new ArrayList<>();
    vnframe = new VerticalLayout();
    vnframe.setSpacing(true);//www.  ja va  2  s . c  o  m
    vnframe.setImmediate(true);
    this.sb = new VerticalLayout(); //maybe other name? sb is "reserved" by SearchBox
    sb.setImmediate(true);
    sb.setSpacing(false); //used to be true
    lbl = new Label(ebene);
    HorizontalLayout sbtoolbar = new HorizontalLayout();
    sbtoolbar.setSpacing(false);
    // searchbox tickbox for regex
    reBox = new CheckBox(CAPTION_REBOX);
    reBox.setImmediate(true);
    sbtoolbar.addComponent(reBox);
    reBox.addValueChangeListener(new ValueChangeListener() {
        // TODO make this into a nice subroutine
        @Override
        public void valueChange(ValueChangeEvent event) {
            if (reBox.getValue()) {
                for (ValueField vf : vfs) {
                    String value = vf.getValue();
                    vf.setValueMode(ValueField.ValueMode.REGEX);
                    if (value != null) {
                        vf.setValue(sq.escapeRegexCharacters(value));
                    }
                }
            } else {
                for (ValueField vf : vfs) {
                    String value = vf.getValue();
                    vf.setValueMode(ValueField.ValueMode.NORMAL);
                    if (value != null) {
                        vf.setValue(sq.unescape(value));
                    }
                }
            }
        }
    });
    reBox.setValue(isRegex);
    reBox.setEnabled(true);
    reBoxSingleValue = isRegex;
    // searchbox tickbox for negative search
    negSearchBox = new CheckBox(NEGATIVE_SEARCH_LABEL);
    negSearchBox.setImmediate(true);
    negSearchBox.setValue(negativeSearch);

    sbtoolbar.addComponent(negSearchBox);
    // close the searchbox
    btClose = new Button(BUTTON_CLOSE_LABEL, (Button.ClickListener) this);
    btClose.setStyleName(ValoTheme.BUTTON_SMALL);

    HorizontalLayout titleBar = new HorizontalLayout();
    titleBar.setWidth(vnframe.getWidth(), vnframe.getWidthUnits());
    titleBar.addComponent(lbl);
    titleBar.setComponentAlignment(lbl, Alignment.BOTTOM_LEFT);
    titleBar.addComponent(btClose);
    titleBar.setComponentAlignment(btClose, Alignment.TOP_RIGHT);

    btAdd = new Button(LABEL_BUTTON_ADD);
    btAdd.addClickListener((Button.ClickListener) this);
    btAdd.setStyleName(ValoTheme.BUTTON_SMALL);

    vnframe.addComponent(titleBar);
    vnframe.addComponent(sb);
    vnframe.addComponent(btAdd);
    vnframe.setComponentAlignment(btAdd, Alignment.BOTTOM_RIGHT);
    vnframe.addComponent(sbtoolbar);

    ValueField vf = new ValueField(sq, this, ebene);
    vf.setProtected(true);
    vfs.add(vf);
    sb.addComponent(vf);

    setContent(vnframe);
}

From source file:annis.gui.flatquerybuilder.SpanBox.java

License:Apache License

public SpanBox(final String ebene, final FlatQueryBuilder sq, boolean isRegex) {
    this.ebene = ebene;
    this.sq = sq;
    sb = new HorizontalLayout();
    sb.setImmediate(true);/*from   w w w.ja  va2s.c o  m*/
    sb.setSpacing(true);
    sb.setMargin(true);
    ConcurrentSkipListSet<String> annos = new ConcurrentSkipListSet<>();
    for (String a : sq.getAvailableAnnotationLevels(ebene)) {
        annos.add(a);
    }
    this.annonames = annos;
    Label tf = new Label(ebene);
    sb.addComponent(tf);
    this.cb = new SensitiveComboBox();
    cb.setWidth(SB_CB_WIDTH);
    cb.addStyleName(Helper.CORPUS_FONT_FORCE);
    // configure & load content
    cb.setImmediate(true);
    cb.setNewItemsAllowed(true);
    cb.setTextInputAllowed(true);
    for (String annoname : this.annonames) {
        cb.addItem(annoname);
    }
    cb.setFilteringMode(AbstractSelect.Filtering.FILTERINGMODE_OFF);
    cb.addListener((FieldEvents.TextChangeListener) this);
    sb.addComponent(cb);
    HorizontalLayout sbtoolbar = new HorizontalLayout();
    sbtoolbar.setSpacing(true);
    // searchbox tickbox for regex
    CheckBox tb = new CheckBox("Regex");
    tb.setImmediate(true);
    tb.setValue(isRegex);
    sbtoolbar.addComponent(tb);
    tb.addValueChangeListener(new ValueChangeListener() {
        // TODO make this into a nice subroutine
        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean r = reBox.getValue();
            if (!r) {
                SpanBox.buildBoxValues(cb, ebene, sq);
            } else if (cb.getValue() != null) {
                String escapedItem = sq.escapeRegexCharacters(cb.getValue().toString());
                cb.addItem(escapedItem);
                cb.setValue(escapedItem);
            }
        }
    });
    reBox = tb;
    // close the searchbox
    btClose = new Button(BUTTON_CLOSE_LABEL, (Button.ClickListener) this);
    btClose.setStyleName(ChameleonTheme.BUTTON_SMALL);
    sbtoolbar.addComponent(btClose);
    // make visable
    sb.addComponent(sbtoolbar);
    setContent(sb);
}