Example usage for com.vaadin.ui Button setIcon

List of usage examples for com.vaadin.ui Button setIcon

Introduction

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

Prototype

@Override
public void setIcon(Resource icon) 

Source Link

Document

Sets the component's icon.

Usage

From source file:annis.gui.CitationLinkGenerator.java

License:Apache License

@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
    Button btLink = new Button();
    btLink.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    btLink.setIcon(FontAwesome.SHARE_ALT);
    btLink.setDescription("Share query reference link");
    btLink.addClickListener(this);

    if (itemId instanceof DisplayedResultQuery) {
        btLink.addClickListener(new LinkClickListener((DisplayedResultQuery) itemId));
    } else if (itemId instanceof Query) {
        final CitationProvider citationProvider = new CitationProviderForQuery((Query) itemId);
        btLink.addClickListener(new LinkClickListener(citationProvider));
    } else if (itemId instanceof CitationProvider) {
        final CitationProvider citationProvider = (CitationProvider) itemId;
        btLink.addClickListener(new LinkClickListener(citationProvider));
    }//w  ww . j  a va2 s  .c  o  m

    return btLink;
}

From source file:annis.gui.components.HelpButton.java

License:Apache License

public HelpButton(Field<T> field) {
    Validate.notNull(field);/*from   w  ww . j a v a  2 s. c om*/
    this.field = field;

    CssLayout layout = new CssLayout();
    setCompositionRoot(layout);

    Button btHelp = new Button("");
    btHelp.setIcon(FontAwesome.QUESTION);
    btHelp.addStyleName(ChameleonTheme.BUTTON_BORDERLESS);
    btHelp.addStyleName("helpbutton");
    btHelp.addClickListener((Button.ClickListener) this);

    setCaption(field.getCaption());
    field.setCaption(null);

    layout.addComponent(field);
    layout.addComponent(btHelp);

}

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  .ja  va  2 s  .co  m

    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.controlpanel.QueryPanel.java

License:Apache License

public QueryPanel(final AnnisUI ui) {
    super(4, 5);/*from   www  . j  a  va 2 s. co  m*/
    this.ui = ui;

    this.lastPublicStatus = "Welcome to ANNIS! " + "A tutorial is available on the right side.";

    this.state = ui.getQueryState();

    setSpacing(true);
    setMargin(false);

    setRowExpandRatio(0, 1.0f);
    setColumnExpandRatio(0, 0.0f);
    setColumnExpandRatio(1, 0.1f);
    setColumnExpandRatio(2, 0.0f);
    setColumnExpandRatio(3, 0.0f);

    txtQuery = new AqlCodeEditor();
    txtQuery.setPropertyDataSource(state.getAql());
    txtQuery.setInputPrompt("Please enter AQL query");
    txtQuery.addStyleName("query");
    if (ui.getInstanceFont() == null) {
        txtQuery.addStyleName("default-query-font");
        txtQuery.setTextareaStyle("default-query-font");
    } else {
        txtQuery.addStyleName(Helper.CORPUS_FONT);
        txtQuery.setTextareaStyle(Helper.CORPUS_FONT);
    }

    txtQuery.addStyleName("keyboardInput");
    txtQuery.setWidth("100%");
    txtQuery.setHeight(15f, Unit.EM);
    txtQuery.setTextChangeTimeout(500);

    final VirtualKeyboardCodeEditor virtualKeyboard;
    if (ui.getInstanceConfig().getKeyboardLayout() == null) {
        virtualKeyboard = null;
    } else {
        virtualKeyboard = new VirtualKeyboardCodeEditor();
        virtualKeyboard.setKeyboardLayout(ui.getInstanceConfig().getKeyboardLayout());
        virtualKeyboard.extend(txtQuery);
    }

    txtStatus = new TextArea();
    txtStatus.setValue(this.lastPublicStatus);
    txtStatus.setWidth("100%");
    txtStatus.setHeight(4.0f, Unit.EM);
    txtStatus.addStyleName("border-layout");
    txtStatus.setReadOnly(true);

    piCount = new ProgressBar();
    piCount.setIndeterminate(true);
    piCount.setEnabled(false);
    piCount.setVisible(false);

    btShowResult = new Button("Search");
    btShowResult.setIcon(FontAwesome.SEARCH);
    btShowResult.setWidth("100%");
    btShowResult.addClickListener(new ShowResultClickListener());
    btShowResult.setDescription("<strong>Show Result</strong><br />Ctrl + Enter");
    btShowResult.setClickShortcut(KeyCode.ENTER, ModifierKey.CTRL);
    btShowResult.setDisableOnClick(true);

    VerticalLayout historyListLayout = new VerticalLayout();
    historyListLayout.setSizeUndefined();

    lstHistory = new ListSelect();
    lstHistory.setWidth("200px");
    lstHistory.setNullSelectionAllowed(false);
    lstHistory.setValue(null);
    lstHistory.addValueChangeListener((ValueChangeListener) this);
    lstHistory.setImmediate(true);
    lstHistory.setContainerDataSource(historyContainer);
    lstHistory.setItemCaptionPropertyId("query");
    lstHistory.addStyleName(Helper.CORPUS_FONT);

    Button btShowMoreHistory = new Button("Show more details", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (historyWindow == null) {
                historyWindow = new Window("History");
                historyWindow.setModal(false);
                historyWindow.setWidth("400px");
                historyWindow.setHeight("250px");
            }
            historyWindow.setContent(new HistoryPanel(state.getHistory(), ui.getQueryController()));

            if (UI.getCurrent().getWindows().contains(historyWindow)) {
                historyWindow.bringToFront();
            } else {
                UI.getCurrent().addWindow(historyWindow);
            }
        }
    });
    btShowMoreHistory.setWidth("100%");

    historyListLayout.addComponent(lstHistory);
    historyListLayout.addComponent(btShowMoreHistory);

    historyListLayout.setExpandRatio(lstHistory, 1.0f);
    historyListLayout.setExpandRatio(btShowMoreHistory, 0.0f);

    btHistory = new PopupButton("History");
    btHistory.setContent(historyListLayout);
    btHistory.setDescription("<strong>Show History</strong><br />"
            + "Either use the short overview (arrow down) or click on the button " + "for the extended view.");

    Button btShowKeyboard = null;
    if (virtualKeyboard != null) {
        btShowKeyboard = new Button();
        btShowKeyboard.setWidth("100%");
        btShowKeyboard.setDescription("Click to show a virtual keyboard");
        btShowKeyboard.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        btShowKeyboard.addStyleName(ValoTheme.BUTTON_SMALL);
        btShowKeyboard.setIcon(new ClassResource(VirtualKeyboardCodeEditor.class, "keyboard.png"));
        btShowKeyboard.addClickListener(new ShowKeyboardClickListener(virtualKeyboard));
    }

    Button btShowQueryBuilder = new Button("Query<br />Builder");
    btShowQueryBuilder.setHtmlContentAllowed(true);
    btShowQueryBuilder.addStyleName(ValoTheme.BUTTON_SMALL);
    btShowQueryBuilder.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
    btShowQueryBuilder.setIcon(new ThemeResource("images/tango-icons/32x32/document-properties.png"));
    btShowQueryBuilder.addClickListener(new ShowQueryBuilderClickListener(ui));

    VerticalLayout moreActionsLayout = new VerticalLayout();
    moreActionsLayout.setWidth("250px");
    btMoreActions = new PopupButton("More");
    btMoreActions.setContent(moreActionsLayout);

    //    btShowResultNewTab = new Button("Search (open in new tab)");
    //    btShowResultNewTab.setWidth("100%");
    //    btShowResultNewTab.addClickListener(new ShowResultInNewTabClickListener());
    //    btShowResultNewTab.setDescription("<strong>Show Result and open result in new tab</strong><br />Ctrl + Shift + Enter");
    //    btShowResultNewTab.setDisableOnClick(true);
    //    btShowResultNewTab.setClickShortcut(KeyCode.ENTER, ModifierKey.CTRL, ModifierKey.SHIFT);
    //    moreActionsLayout.addComponent(btShowResultNewTab);

    Button btShowExport = new Button("Export", new ShowExportClickListener(ui));
    btShowExport.setIcon(FontAwesome.DOWNLOAD);
    btShowExport.setWidth("100%");
    moreActionsLayout.addComponent(btShowExport);

    Button btShowFrequency = new Button("Frequency Analysis", new ShowFrequencyClickListener(ui));
    btShowFrequency.setIcon(FontAwesome.BAR_CHART_O);
    btShowFrequency.setWidth("100%");
    moreActionsLayout.addComponent(btShowFrequency);

    /*
     * We use the grid layout for a better rendering efficiency, but this comes
     * with the cost of some complexity when defining the positions of the
     * elements in the layout.
     * 
     * This grid hopefully helps a little bit in understanding the "magic"
     * numbers better.
     * 
     * Q: Query text field
     * QB: Button to toggle query builder // TODO
     * KEY: Button to show virtual keyboard
     * SEA: "Search" button
     * MOR: "More actions" button 
     * HIST: "History" button
     * STAT: Text field with the real status
     * PROG: indefinite progress bar (spinning circle)
     * 
     *   \  0  |  1  |  2  |  3  
     * --+-----+---+---+---+-----
     * 0 |  Q  |  Q  |  Q  | QB 
     * --+-----+-----+-----+-----
     * 1 |  Q  |  Q  |  Q  | KEY 
     * --+-----+-----+-----+-----
     * 2 | SEA | MOR | HIST|     
     * --+-----+-----+-----+-----
     * 3 | STAT| STAT| STAT| PROG
     */
    addComponent(txtQuery, 0, 0, 2, 1);
    addComponent(txtStatus, 0, 3, 2, 3);
    addComponent(btShowResult, 0, 2);
    addComponent(btMoreActions, 1, 2);
    addComponent(btHistory, 2, 2);
    addComponent(piCount, 3, 3);
    addComponent(btShowQueryBuilder, 3, 0);
    if (btShowKeyboard != null) {
        addComponent(btShowKeyboard, 3, 1);
    }

    // alignment
    setRowExpandRatio(0, 0.0f);
    setRowExpandRatio(1, 1.0f);
    setColumnExpandRatio(0, 1.0f);
    setColumnExpandRatio(1, 0.0f);
    setColumnExpandRatio(2, 0.0f);
    setColumnExpandRatio(3, 0.0f);

    //setComponentAlignment(btShowQueryBuilder, Alignment.BOTTOM_CENTER);
}

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

License:Apache License

public Button generateInfoButtonCell(final String docName) {
    Button btn = new Button();
    btn.setStyleName(ChameleonTheme.BUTTON_BORDERLESS);
    btn.setIcon(INFO_ICON);
    btn.addClickListener(new Button.ClickListener() {
        @Override//from www.ja  va 2  s  .  com
        public void buttonClick(Button.ClickEvent event) {
            try {

                List<Annotation> annos = getDocMetaData(docName);

                /**
                 * Transforms to a list of key value pairs. The values concates the
                 * namespace and ordinary value. Namespaces "NULL" are ignored.
                 */
                // create datasource and bind it to a table
                BeanItemContainer<Annotation> metaContainer = new BeanItemContainer<>(Annotation.class);
                metaContainer.addAll(annos);
                metaContainer.sort(new Object[] { "namespace", "name" }, new boolean[] { true, true });

                Table metaTable = new Table();
                metaTable.setContainerDataSource(metaContainer);
                metaTable.addGeneratedColumn("genname",
                        new MetaDataPanel.MetaTableNameGenerator(metaContainer));
                metaTable.addGeneratedColumn("genvalue",
                        new MetaDataPanel.MetaTableValueGenerator(metaContainer));

                metaTable.setVisibleColumns("genname", "genvalue");

                metaTable.setColumnHeaders(new String[] { "Name", "Value" });
                metaTable.setSizeFull();
                metaTable.setColumnWidth("genname", -1);
                metaTable.setColumnExpandRatio("genvalue", 1.0f);
                metaTable.addStyleName(ChameleonTheme.TABLE_STRIPED);

                // create and style the extra window for the metadata table
                Window metaWin = new Window();
                metaWin.setContent(metaTable);
                metaWin.setCaption("metadata doc " + docName);
                metaWin.center();
                metaWin.setWidth(400, Unit.PIXELS);
                metaWin.setHeight(400, Unit.PIXELS);

                // paint the window
                docBrowserPanel.getUI().addWindow(metaWin);
            } catch (UniformInterfaceException ex) {
                log.error("can not retrieve metadata for document " + docName, ex);
            }

        }
    });
    return btn;
}

From source file:annis.gui.ReportBugWindow.java

License:Apache License

private void addScreenshotPreview(Layout layout, final byte[] rawImage, String mimeType) {
    StreamResource res = new StreamResource(new ScreenDumpStreamSource(rawImage),
            "screendump_" + UUID.randomUUID().toString() + ".png");
    res.setMIMEType(mimeType);/*from w w  w.j  av a 2  s  . c  o m*/

    final Image imgScreenshot = new Image("Attached screenshot", res);
    imgScreenshot.setAlternateText(
            "Screenshot of the ANNIS browser window, " + "no other window or part of the desktop is captured.");
    imgScreenshot.setVisible(false);
    imgScreenshot.setWidth("100%");

    Button btShowScreenshot = new Button("Show attached screenshot",
            new ShowScreenshotClickListener(imgScreenshot));
    btShowScreenshot.addStyleName(BaseTheme.BUTTON_LINK);
    btShowScreenshot.setIcon(FontAwesome.PLUS_SQUARE_O);

    layout.addComponent(btShowScreenshot);
    layout.addComponent(imgScreenshot);
}

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);/* w  w w  .jav  a2 s . c om*/
    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:br.com.anteros.mobileserver.util.UserMessages.java

License:Apache License

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

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

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

    confirm.addListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1971800928047045825L;

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

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

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

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

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

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

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

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

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

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

From source file:ch.wscr.management.ui.view.MemberView.java

/**
 * Kopfzeile fr das Grid erstellen/*from   ww  w  .  ja v  a  2  s .  c  om*/
 *
 * @param grid das Grid dem die Kopfzeile hinzugefgt werden soll
 */
private void setHeaderRow(final Grid grid) {
    // TODO Erstellung neuer Mitglieder muss noch optimiert werden

    final Button addMember = new Button("Neu", clickEvent -> {
        BeanItem<Member> beanItem = memberBeanItemContainer.addItem(new Member());
        grid.setEditorEnabled(true);
        //grid.editItem(beanItem);

    });

    addMember.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
    addMember.setIcon(FontAwesome.PLUS_CIRCLE);

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSizeFull();
    buttonLayout.setSpacing(true);
    buttonLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    buttonLayout.addComponent(addMember);

    HeaderRow headerRow = grid.prependHeaderRow();
    headerRow.join("memberId", "lastName", "firstName", "adrStreet", "adrPostalCode", "adrCity", "adrCountry",
            "birthDate", "driverLicense");
    headerRow.getCell("lastName").setComponent(buttonLayout);
}

From source file:com.adonis.ui.menu.Menu.java

private void createViewButton(final String name, String caption, com.vaadin.server.Resource icon) {
    Button button = new Button(caption, new ClickListener() {

        @Override/*from  w w  w . ja va  2 s  .  c  om*/
        public void buttonClick(ClickEvent event) {

            navigator.navigateTo(name);

        }
    });
    button.setPrimaryStyleName(ValoTheme.MENU_ITEM);
    button.setIcon(icon);
    menuItemsLayout.addComponent(button);
    viewButtons.put(name, button);
}