Example usage for com.vaadin.server ThemeResource ThemeResource

List of usage examples for com.vaadin.server ThemeResource ThemeResource

Introduction

In this page you can find the example usage for com.vaadin.server ThemeResource ThemeResource.

Prototype

public ThemeResource(String resourceId) 

Source Link

Document

Creates a resource.

Usage

From source file:annis.gui.AboutWindow.java

License:Apache License

public AboutWindow() {
    setSizeFull();//from w  w  w  .j a  va2  s.  c o m

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

License:Apache License

public ExportPanel(QueryPanel queryPanel, CorpusListPanel corpusListPanel) {
    this.queryPanel = queryPanel;
    this.corpusListPanel = corpusListPanel;

    setWidth("99%");
    setHeight("-1px");
    addStyleName("contextsensible-formlayout");

    initHelpMessages();/*from www  .ja v  a  2  s .c o m*/

    cbExporter = new ComboBox("Exporter");
    cbExporter.setNewItemsAllowed(false);
    cbExporter.setNullSelectionAllowed(false);
    cbExporter.setImmediate(true);
    exporterMap = new HashMap<String, Exporter>();
    for (Exporter e : EXPORTER) {
        String name = e.getClass().getSimpleName();
        exporterMap.put(name, e);
        cbExporter.addItem(name);
    }
    cbExporter.setValue(EXPORTER[0].getClass().getSimpleName());
    cbExporter.addListener(new ExporterSelectionHelpListener());
    cbExporter.setDescription(help4Exporter.get((String) cbExporter.getValue()));

    addComponent(new HelpButton(cbExporter));

    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 IntegerValidator("must be a number"));
    cbRightContext.addValidator(new IntegerValidator("must be a number"));

    for (String s : SearchOptionsPanel.PREDEFINED_CONTEXTS) {
        cbLeftContext.addItem(s);
        cbRightContext.addItem(s);
    }

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

    addComponent(cbLeftContext);
    addComponent(cbRightContext);

    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.");
    addComponent(new HelpButton(txtParameters));

    btExport = new Button("Perform Export");
    btExport.setIcon(new ThemeResource("tango-icons/16x16/media-playback-start.png"));
    btExport.setDisableOnClick(true);
    btExport.addClickListener((Button.ClickListener) this);

    btDownload = new Button("Download");
    btDownload.setDescription("Click here to start the actual download.");
    btDownload.setIcon(new ThemeResource("tango-icons/16x16/document-save.png"));
    btDownload.setDisableOnClick(true);
    btDownload.setEnabled(false);

    HorizontalLayout layoutExportButtons = new HorizontalLayout(btExport, btDownload);
    addComponent(layoutExportButtons);

    progressIndicator = new ProgressIndicator();
    progressIndicator.setEnabled(false);
    progressIndicator.setIndeterminate(true);
    addComponent(progressIndicator);
}

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

License:Apache License

public QueryPanel(final AnnisUI ui) {
    super(4, 5);/*from  w ww .  ja  v  a 2s  .  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.MainToolbar.java

License:Apache License

public MainToolbar() {

    String bugmail = (String) VaadinSession.getCurrent().getAttribute(BUG_MAIL_KEY);
    if (bugmail != null && !bugmail.isEmpty() && !bugmail.startsWith("${")
            && new EmailValidator("").isValid(bugmail)) {
        this.bugEMailAddress = bugmail;
    } else {/*ww w.j a  v a  2  s. c om*/
        this.bugEMailAddress = null;
    }

    UI ui = UI.getCurrent();
    if (ui instanceof CommonUI) {
        ((CommonUI) ui).getSettings().addedLoadedListener(MainToolbar.this);
    }

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

    addStyleName("toolbar");
    addStyleName("border-layout");

    btAboutAnnis = new Button("About ANNIS");
    btAboutAnnis.addStyleName(ValoTheme.BUTTON_SMALL);
    btAboutAnnis.setIcon(new ThemeResource("images/annis_16.png"));
    btAboutAnnis.addClickListener(new AboutClickListener());

    btSidebar = new Button();
    btSidebar.setDisableOnClick(true);
    btSidebar.addStyleName(ValoTheme.BUTTON_SMALL);
    btSidebar.setDescription("Show and hide search sidebar");
    btSidebar.setIconAlternateText(btSidebar.getDescription());

    btBugReport = new Button("Report Problem");
    btBugReport.addStyleName(ValoTheme.BUTTON_SMALL);
    btBugReport.setDisableOnClick(true);
    btBugReport.setIcon(FontAwesome.ENVELOPE_O);
    btBugReport.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            reportBug();
        }
    });
    btBugReport.setVisible(this.bugEMailAddress != null);

    btNavigate = new Button();
    btNavigate.setVisible(false);
    btNavigate.setDisableOnClick(true);
    btNavigate.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            btNavigate.setEnabled(true);
            if (navigationTarget != null) {
                UI.getCurrent().getNavigator().navigateTo(navigationTarget.state);
            }
        }
    });
    lblUserName = new Label("not logged in");
    lblUserName.setWidth("-1px");
    lblUserName.setHeight("-1px");
    lblUserName.addStyleName("right-aligned-text");

    btLogin = new Button("Login", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            showLoginWindow(false);
        }
    });

    btLogout = new Button("Logout", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            // logout
            Helper.setUser(null);
            for (LoginListener l : loginListeners) {
                l.onLogout();
            }
            Notification.show("Logged out", Notification.Type.TRAY_NOTIFICATION);
            updateUserInformation();
        }
    });

    btLogin.setSizeUndefined();
    btLogin.setStyleName(ValoTheme.BUTTON_SMALL);
    btLogin.setIcon(FontAwesome.USER);

    btLogout.setSizeUndefined();
    btLogout.setStyleName(ValoTheme.BUTTON_SMALL);
    btLogout.setIcon(FontAwesome.USER);

    btOpenSource = new Button("Help us to make ANNIS better!");
    btOpenSource.setStyleName(BaseTheme.BUTTON_LINK);
    btOpenSource.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.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");
            UI.getCurrent().addWindow(w);
            w.center();
        }
    });

    addComponent(btSidebar);
    setComponentAlignment(btSidebar, Alignment.MIDDLE_LEFT);

    addComponent(btAboutAnnis);
    addComponent(btBugReport);
    addComponent(btNavigate);

    addComponent(btOpenSource);

    setSpacing(true);
    setComponentAlignment(btAboutAnnis, Alignment.MIDDLE_LEFT);
    setComponentAlignment(btBugReport, Alignment.MIDDLE_LEFT);
    setComponentAlignment(btNavigate, Alignment.MIDDLE_LEFT);

    setComponentAlignment(btOpenSource, Alignment.MIDDLE_CENTER);
    setExpandRatio(btOpenSource, 1.0f);

    addLoginButton();

    btSidebar.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            btSidebar.setEnabled(true);

            // decide new state
            switch (sidebarState) {
            case VISIBLE:
                if (event.isCtrlKey()) {
                    sidebarState = SidebarState.AUTO_VISIBLE;
                } else {
                    sidebarState = SidebarState.HIDDEN;
                }
                break;
            case HIDDEN:
                if (event.isCtrlKey()) {
                    sidebarState = SidebarState.AUTO_HIDDEN;
                } else {
                    sidebarState = SidebarState.VISIBLE;
                }
                break;

            case AUTO_VISIBLE:
                if (event.isCtrlKey()) {
                    sidebarState = SidebarState.VISIBLE;
                } else {
                    sidebarState = SidebarState.AUTO_HIDDEN;
                }
                break;
            case AUTO_HIDDEN:
                if (event.isCtrlKey()) {
                    sidebarState = SidebarState.HIDDEN;
                } else {
                    sidebarState = SidebarState.AUTO_VISIBLE;
                }
                break;
            }

            updateSidebarState();
        }
    });

    screenshotExtension = new ScreenshotMaker(this);

    JavaScript.getCurrent().addFunction("annis.gui.logincallback", new LoginCloseCallback());

    updateSidebarState();
    MainToolbar.this.updateUserInformation();
}

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

License:Apache License

public void setPrepareEdgeDock(boolean prepare) {
    this.prepareEdgeDock = prepare;

    btClear.setVisible(!prepare);// ww w.j a v  a  2s.  com
    btClose.setVisible(!prepare);
    btAdd.setVisible(!prepare);
    btMove.setVisible(!prepare);

    if (prepare) {
        btEdge.setCaption("Dock");
        btEdge.setIcon(new ThemeResource("images/pixel.png"));
    } else {
        btEdge.setIcon(FontAwesome.EXTERNAL_LINK);
        btEdge.setCaption("Edge");
    }
}

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

License:Apache License

@Override
public void buttonClick(ClickEvent event) {
    if (event.getButton() == btEdge) {
        if (prepareEdgeDock) {
            setPrepareEdgeDock(false);//w  w w  .j a  va2  s  .c  o m
            parent.addEdge(this);
        } else {
            parent.prepareAddingEdge(this);
            setPrepareEdgeDock(true);
            btEdge.setIcon(new ThemeResource("images/pixel.png"));
            btEdge.setCaption("Cancel");
        }
    } else if (event.getButton() == btClose) {
        parent.deleteNode(this);
    } else if (event.getButton() == btAdd) {
        ConstraintLayout c = new ConstraintLayout(parent, annoNames);
        c.setWidth("100%");
        c.setHeight("-1px");
        constraints.add(c);
        vLayout.addComponent(c);
        if (parent != null) {
            parent.updateQuery();
        }
    } else if (event.getButton() == btClear) {
        for (ConstraintLayout c : constraints) {
            vLayout.removeComponent(c);
        }
        constraints.clear();
        if (parent != null) {
            parent.updateQuery();
        }
    }
}

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 w  w.j ava 2 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:ar.com.zir.cipres.ui.login.LoginForm.java

@AutoGenerated
private AbsoluteLayout buildAbsoluteLayout_1() {
    // common part: create layout
    absoluteLayout_1 = new AbsoluteLayout();
    absoluteLayout_1.setImmediate(false);
    absoluteLayout_1.setWidth("100.0%");
    absoluteLayout_1.setHeight("100.0%");

    // pwdPassword
    pwdPassword = new PasswordField();
    pwdPassword.setCaption("Password");
    pwdPassword.setImmediate(true);//  w  w w.  ja va2  s.co m
    pwdPassword.setDescription("Contrasea del usuario");
    pwdPassword.setWidth("-1px");
    pwdPassword.setHeight("-1px");
    pwdPassword.setTabIndex(6);
    pwdPassword.setRequired(true);
    pwdPassword.setNullSettingAllowed(true);
    absoluteLayout_1.addComponent(pwdPassword, "top:99.0px;left:211.0px;");

    // txtUsuario
    txtUsuario = new TextField();
    txtUsuario.setCaption("Usuario");
    txtUsuario.setImmediate(true);
    txtUsuario.setDescription("Nombre de usuario");
    txtUsuario.setWidth("-1px");
    txtUsuario.setHeight("-1px");
    txtUsuario.setTabIndex(5);
    txtUsuario.setRequired(true);
    txtUsuario.setInputPrompt("Ingrese el usuario");
    txtUsuario.setMaxLength(10);
    absoluteLayout_1.addComponent(txtUsuario, "top:99.0px;left:18.0px;");

    // btnLogin
    btnLogin = new Button();
    btnLogin.setCaption("Login");
    btnLogin.setImmediate(true);
    btnLogin.setWidth("88px");
    btnLogin.setHeight("-1px");
    btnLogin.setTabIndex(7);
    absoluteLayout_1.addComponent(btnLogin, "top:99.0px;left:403.0px;");

    // embedded_1
    embedded_1 = new Embedded();
    embedded_1.setImmediate(false);
    embedded_1.setWidth("56px");
    embedded_1.setHeight("56px");
    embedded_1.setSource(new ThemeResource("security.png"));
    embedded_1.setType(1);
    embedded_1.setMimeType("image/png");
    absoluteLayout_1.addComponent(embedded_1, "top:18.0px;left:425.0px;");

    // label_1
    label_1 = new Label();
    label_1.setStyleName("login");
    label_1.setImmediate(false);
    label_1.setWidth("-1px");
    label_1.setHeight("-1px");
    label_1.setValue("<h2>Bienvenido a </h2>");
    label_1.setContentMode(ContentMode.HTML);
    absoluteLayout_1.addComponent(label_1, "top:18.0px;left:18.0px;");

    // embedded_2
    embedded_2 = new Embedded();
    embedded_2.setImmediate(false);
    embedded_2.setWidth("141px");
    embedded_2.setHeight("45px");
    embedded_2.setSource(new ThemeResource("cipres-header.png"));
    embedded_2.setType(1);
    embedded_2.setMimeType("image/png");
    absoluteLayout_1.addComponent(embedded_2, "top:25.0px;left:200.0px;");

    return absoluteLayout_1;
}

From source file:by.bigvova.MainUI.java

License:Apache License

@Subscribe
private void updateUserMenu(final ProfileUpdatedEvent event) {
    UserTo userTo = controller.getUserTo();
    String imageName = userTo.getImageName();
    String fullPathToProfileImage = pathToProfileImage + '/' + imageName;
    settingsItem.setText(userTo.getName());
    String relativePathToProfileImage = UserControllerUtils.getPathToProfileImage(userTo, true);
    if (Files.exists(Paths.get(fullPathToProfileImage))) {
        resource = new FileResource(new File(fullPathToProfileImage));
    } else {// www  . j  av a2s.  c om
        resource = new ThemeResource(relativePathToProfileImage + "profile-pic-300px.jpg");
    }
    settingsItem.setIcon(resource);
}

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

public Menu(PersonService personService, VehicleService vehicleService, Navigator navigator) {
    this.navigator = navigator;
    setPrimaryStyleName(ValoTheme.MENU_ROOT);
    menuPart = new CssLayout();
    menuPart.addStyleName(ValoTheme.MENU_PART);

    setPersonsCrudProperties(personService);
    setVehiclesCrudProperties(vehicleService);

    // header of the menu
    final HorizontalLayout top = new HorizontalLayout();
    top.addStyleName(ValoTheme.MENU_TITLE);
    top.setSpacing(true);/*from   w w w.j  av a 2s  .  c o m*/

    Label title = new Label("Vehicle manager");
    title.addStyleName(ValoTheme.LABEL_H1);
    title.setSizeUndefined();

    Image image = new Image(null, new ThemeResource("img/car.png"));
    image.setStyleName(ValoTheme.MENU_LOGO);

    top.addComponent(image);
    top.addComponent(title);
    menuPart.addComponent(top);

    // logout menu item
    //        HorizontalLayout logoutLayout = new HorizontalLayout();
    //        logoutLayout.addStyleName(ValoTheme.MENU_ITEM);
    //        logoutLayout.setSpacing(false);
    //
    //        MenuBar logoutMenu = new MenuBar();
    //        logoutMenu.setStyleName(VALO_MENUITEMS);
    //        logoutMenu.addItem("Logout", new MenuBar.Command() {
    //
    //            @Override
    //            public void menuSelected(MenuBar.MenuItem selectedItem) {
    //                VaadinSession.getCurrent().getSession().invalidate();
    //                Page.getCurrent().reload();
    //            }
    //        });
    //
    //        logoutMenu.addStyleName("user-menu");
    //        Image logout = new Image(null, new ThemeResource("img/logout.png"));
    //        logoutLayout.addComponent(logout, 0);
    //        logoutLayout.addComponent(logoutMenu, 1);
    //        menuPart.addComponent(logoutLayout);

    // button for toggling the visibility of the menu when on a small screen
    showMenu = new Button("Menu", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) {
                menuPart.removeStyleName(VALO_MENU_VISIBLE);
            } else {
                menuPart.addStyleName(VALO_MENU_VISIBLE);
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName(VALO_MENU_TOGGLE);
    //        showMenu.setIcon(FontAwesome.NAVICON);
    menuPart.addComponent(showMenu);

    // container for the navigation buttons, which are added by addView()
    menuItemsLayout = new CssLayout();
    menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS);
    menuPart.addComponent(menuItemsLayout);

    addComponent(menuPart);
    addStyleName("backImage");
}