Example usage for com.vaadin.ui Window setCaption

List of usage examples for com.vaadin.ui Window setCaption

Introduction

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

Prototype

@Override
    public void setCaption(String caption) 

Source Link

Usage

From source file:org.opencms.ui.A_CmsUI.java

License:Open Source License

/**
 * Replaces the ui content with a single dialog.<p>
 *
 * TODO: In the future this should only handle window creation, refactor dialog contents to CmsBasicDialog
 *
 * @param caption the caption//from w  w w  .j a  va  2 s  .c  om
 * @param component the dialog content
 */
public void setContentToDialog(String caption, Component component) {

    setContent(new Label());
    Window window = CmsBasicDialog.prepareWindow(DialogWidth.narrow);
    CmsBasicDialog dialog = new CmsBasicDialog();
    VerticalLayout result = new VerticalLayout();
    dialog.setContent(result);
    window.setContent(dialog);
    window.setCaption(caption);
    window.setClosable(false);
    addWindow(window);
    window.center();
    if (component instanceof I_CmsHasButtons) {
        I_CmsHasButtons hasButtons = (I_CmsHasButtons) component;
        for (Button button : hasButtons.getButtons()) {
            dialog.addButton(button);
        }

    }
    result.addComponent(component);

}

From source file:org.opencms.ui.components.CmsConfirmationDialog.java

License:Open Source License

/**
 * Shows the confirmation dialog in a window.<p>
 *
 * @param title the window title/*  w  ww  .  j  ava2  s.  co  m*/
 * @param message the message to display in the dialog
 * @param okAction the action to execute when the user clicks OK
 * @param cancelAction the action for the cancel case
 */
public static void show(String title, String message, final Runnable okAction, final Runnable cancelAction) {

    final Window window = CmsBasicDialog.prepareWindow();
    window.setCaption(title);
    CmsConfirmationDialog dialog = new CmsConfirmationDialog(message, new Runnable() {

        public void run() {

            window.close();
            okAction.run();
        }
    }, new Runnable() {

        public void run() {

            if (cancelAction != null) {
                cancelAction.run();
            }
            window.close();
        }
    });
    window.setContent(dialog);
    UI.getCurrent().addWindow(window);
}

From source file:org.opencms.ui.components.CmsErrorDialog.java

License:Open Source License

/**
 * Shows the error dialog.<p>//from w ww  .ja  va 2s  .  c o m
 *
 * @param message the error message
 * @param t the error to be displayed
 * @param onClose executed on close
 */
public static void showErrorDialog(String message, Throwable t, Runnable onClose) {

    Window window = prepareWindow(DialogWidth.wide);
    window.setCaption(Messages.get().getBundle(A_CmsUI.get().getLocale()).key(Messages.GUI_ERROR_0));
    window.setContent(new CmsErrorDialog(message, t, onClose, window));
    A_CmsUI.get().addWindow(window);
}

From source file:org.opencms.ui.components.fileselect.A_CmsFileSelectField.java

License:Open Source License

/**
 * Opens the file selector dialog.<p>
 *///from  w ww  .  j  a v  a 2 s  .c  o m
protected void openFileSelector() {

    try {

        final Window window = CmsBasicDialog.prepareWindow();
        window.setCaption(m_fileSelectCaption != null ? m_fileSelectCaption
                : CmsVaadinUtils.getMessageText(org.opencms.ui.components.Messages.GUI_FILE_SELECT_CAPTION_0));
        A_CmsUI.get().addWindow(window);
        CmsResourceSelectDialog fileSelect = new CmsResourceSelectDialog(m_filter);
        fileSelect.showSitemapView(m_startWithSitemapView);

        T value = getValue();
        if (value instanceof CmsResource) {
            fileSelect.showStartResource((CmsResource) value);
        } else if (value instanceof String) {
            fileSelect.openPath((String) value);
        }

        window.setContent(fileSelect);
        fileSelect.addSelectionHandler(new I_CmsSelectionHandler<CmsResource>() {

            public void onSelection(CmsResource selected) {

                setResourceValue(selected);
                window.close();
            }
        });
    } catch (CmsException e) {
        LOG.error(e.getLocalizedMessage(), e);
        CmsErrorDialog.showErrorDialog(e);
    }
}

From source file:org.opencms.ui.dialogs.CmsCopyMoveDialog.java

License:Open Source License

/**
 * Displays the confirm overwrite dialog.<p>
 *
 * @param collidingResources the colliding resources
 *//*from   w w  w.j av  a 2 s  .c  om*/
private void showConfirmOverwrite(List<CmsResource> collidingResources) {

    final Window window = CmsBasicDialog.prepareWindow();
    window.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_CONFIRM_OVERWRITE_TITLE_0));
    CmsConfirmationDialog dialog = new CmsConfirmationDialog(
            CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_CONFIRM_OVERWRITE_MESSAGE_0), new Runnable() {

                public void run() {

                    window.close();
                    submit(true);
                }
            }, new Runnable() {

                public void run() {

                    window.close();
                    cancel();
                }
            });
    dialog.displayResourceInfo(collidingResources);
    window.setContent(dialog);
    UI.getCurrent().addWindow(window);
}

From source file:org.opencms.ui.dialogs.history.CmsHistoryDialog.java

License:Open Source License

/**
 * Replaces the contents of the window containing a given component with a basic dialog
 * consisting of a back button to restore the previous window state and another user provided widget.<p>
 *
 * @param currentComponent the component whose parent window's content should be replaced
 * @param newView the user supplied part of the new window content
 * @param newCaption the caption for the child dialog
 *///www. j  a va 2 s. c om
public static void openChildDialog(Component currentComponent, Component newView, String newCaption) {

    final Window window = CmsVaadinUtils.getWindow(currentComponent);
    final String oldCaption = window.getCaption();
    CmsBasicDialog dialog = new CmsBasicDialog();

    VerticalLayout vl = new VerticalLayout();
    dialog.setContent(vl);
    Button backButton = new Button(CmsVaadinUtils.getMessageText(Messages.GUI_CHILD_DIALOG_GO_BACK_0));
    HorizontalLayout buttonBar = new HorizontalLayout();
    buttonBar.addComponent(backButton);
    buttonBar.setMargin(true);
    vl.addComponent(buttonBar);
    vl.addComponent(newView);
    final Component oldContent = window.getContent();
    if (oldContent instanceof CmsBasicDialog) {
        List<CmsResource> infoResources = ((CmsBasicDialog) oldContent).getInfoResources();
        dialog.displayResourceInfo(infoResources);
        if (oldContent instanceof CmsHistoryDialog) {
            dialog.addButton(((CmsHistoryDialog) oldContent).createCloseButton());
        }
    }
    backButton.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {

            window.setContent(oldContent);
            window.setCaption(oldCaption);
            window.center();

        }

    });
    window.setContent(dialog);
    window.setCaption(newCaption);
    window.center();

}

From source file:org.opencms.ui.login.CmsLoginUI.java

License:Open Source License

/**
 * Shows the password reset dialog.<p>
 *///from   w  w w.jav a  2s.c om
public void showPasswordResetDialog() {

    String caption = CmsVaadinUtils.getMessageText(Messages.GUI_PWCHANGE_FORGOT_PASSWORD_0);
    A_CmsUI r = A_CmsUI.get();
    r.setContent(new Label());
    Window window = CmsBasicDialog.prepareWindow(DialogWidth.narrow);
    CmsBasicDialog dialog = new CmsBasicDialog();
    VerticalLayout result = new VerticalLayout();
    dialog.setContent(result);
    window.setContent(dialog);
    window.setCaption(caption);
    window.setClosable(true);
    final CmsForgotPasswordDialog forgotPassword = new CmsForgotPasswordDialog();
    window.addCloseListener(new CloseListener() {

        /** Serial version id. */
        private static final long serialVersionUID = 1L;

        public void windowClose(CloseEvent e) {

            forgotPassword.cancel();
        }

    });
    for (Button button : forgotPassword.getButtons()) {
        dialog.addButton(button);
    }

    r.addWindow(window);
    window.center();
    VerticalLayout vl = result;
    vl.addComponent(forgotPassword);
}

From source file:org.opencms.workplace.tools.git.ui.CmsGitToolOptionsPanel.java

License:Open Source License

/**
 * Opens a modal window with the given component as content.<p>
 *
 * @param component the window content//  w w  w.  j av a 2  s  . c o  m
 *
 * @return the window which is opened
 */
public Window addAsWindow(Component component) {

    // Have to use an array because Vaadin declarative tries to bind the field otherwise
    if (m_currentWindow[0] != null) {
        m_currentWindow[0].close();
        m_currentWindow[0] = null;
    }

    Window window = new Window();
    window.setContent(component);
    window.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_GIT_SCRIPT_RESULTS_0));
    window.setWidth("1000px");
    window.setModal(true);
    window.setResizable(false);
    A_CmsUI.get().addWindow(window);

    m_currentWindow[0] = window;
    return window;
}

From source file:org.opennms.features.topology.app.internal.TopologyUI.java

License:Open Source License

@Override
public void menuBarUpdated(CommandManager commandManager) {
    if (m_menuBar != null) {
        m_rootLayout.removeComponent(m_menuBar);
    }/*ww w .j a  va2 s  .  co  m*/

    if (m_contextMenu != null) {
        m_contextMenu.detach();
    }

    m_menuBar = commandManager.getMenuBar(m_graphContainer, this);
    m_menuBar.setWidth(100, Unit.PERCENTAGE);
    // Set expand ratio so that extra space is not allocated to this vertical component
    if (m_showHeader) {
        m_rootLayout.addComponent(m_menuBar, 1);
    } else {
        m_rootLayout.addComponent(m_menuBar, 0);
    }

    m_contextMenu = commandManager
            .getContextMenu(new DefaultOperationContext(this, m_graphContainer, DisplayLocation.CONTEXTMENU));
    m_contextMenu.setAsContextMenuOf(this);

    // Add Menu Item to share the View with others
    m_menuBar.addItem("Share", FontAwesome.SHARE, new MenuBar.Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            // create the share link
            String fragment = getPage().getLocation().getFragment();
            String url = getPage().getLocation().toString().replace("#" + getPage().getLocation().getFragment(),
                    "");
            String shareLink = String.format("%s?%s=%s", url,
                    TopologyUIRequestHandler.PARAMETER_HISTORY_FRAGMENT, fragment);

            // Create the Window
            Window shareWindow = new Window();
            shareWindow.setCaption("Share Link");
            shareWindow.setModal(true);
            shareWindow.setClosable(true);
            shareWindow.setResizable(false);
            shareWindow.setWidth(400, Unit.PIXELS);

            TextArea shareLinkField = new TextArea();
            shareLinkField.setValue(shareLink);
            shareLinkField.setReadOnly(true);
            shareLinkField.setRows(3);
            shareLinkField.setWidth(100, Unit.PERCENTAGE);

            // Close Button
            Button close = new Button("Close");
            close.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);
            close.addClickListener(event -> shareWindow.close());

            // Layout for Buttons
            HorizontalLayout buttonLayout = new HorizontalLayout();
            buttonLayout.setMargin(true);
            buttonLayout.setSpacing(true);
            buttonLayout.setWidth("100%");
            buttonLayout.addComponent(close);
            buttonLayout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT);

            // Content Layout
            VerticalLayout verticalLayout = new VerticalLayout();
            verticalLayout.setMargin(true);
            verticalLayout.setSpacing(true);
            verticalLayout.addComponent(
                    new Label("Please use the following link to share the current view with others."));
            verticalLayout.addComponent(shareLinkField);
            verticalLayout.addComponent(buttonLayout);

            shareWindow.setContent(verticalLayout);

            getUI().addWindow(shareWindow);
        }
    });

    updateMenuItems();
}

From source file:org.opennms.features.topology.app.internal.ui.ToolbarPanel.java

License:Open Source License

public ToolbarPanel(final ToolbarPanelController controller) {
    addStyleName(Styles.TOOLBAR);//from  www. ja v  a  2s .  com
    this.layoutManager = controller.getLayoutManager();

    final Property<Double> scale = controller.getScaleProperty();
    final Boolean[] eyeClosed = new Boolean[] { false };
    final Button showFocusVerticesBtn = new Button();
    showFocusVerticesBtn.setIcon(FontAwesome.EYE);
    showFocusVerticesBtn.setDescription("Toggle Highlight Focus Nodes");
    showFocusVerticesBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (eyeClosed[0]) {
                showFocusVerticesBtn.setIcon(FontAwesome.EYE);
            } else {
                showFocusVerticesBtn.setIcon(FontAwesome.EYE_SLASH);
            }
            eyeClosed[0] = !eyeClosed[0]; // toggle
            controller.toggleHighlightFocus();
        }
    });

    final Button magnifyBtn = new Button();
    magnifyBtn.setIcon(FontAwesome.PLUS);
    magnifyBtn.setDescription("Magnify");
    magnifyBtn.addClickListener(
            (Button.ClickListener) event -> scale.setValue(Math.min(1, scale.getValue() + 0.25)));

    final Button demagnifyBtn = new Button();
    demagnifyBtn.setIcon(FontAwesome.MINUS);
    demagnifyBtn.setDescription("Demagnify");
    demagnifyBtn.addClickListener(
            (Button.ClickListener) event -> scale.setValue(Math.max(0, scale.getValue() - 0.25)));

    m_szlOutBtn = new Button();
    m_szlOutBtn.setId("szlOutBtn");
    m_szlOutBtn.setIcon(FontAwesome.ANGLE_DOWN);
    m_szlOutBtn.setDescription("Decrease Semantic Zoom Level");
    m_szlOutBtn.setEnabled(controller.getSemanticZoomLevel() > 0);
    m_szlOutBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            int szl = controller.getSemanticZoomLevel();
            if (szl > 0) {
                setSemanticZoomLevel(controller, szl - 1);
                controller.saveHistory();
            }
        }
    });

    final Button szlInBtn = new Button();
    szlInBtn.setId("szlInBtn");
    szlInBtn.setIcon(FontAwesome.ANGLE_UP);
    szlInBtn.setDescription("Increase Semantic Zoom Level");
    szlInBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            setSemanticZoomLevel(controller, controller.getSemanticZoomLevel() + 1);
            controller.saveHistory();
        }
    });

    m_zoomLevelLabel.setId("szlInputLabel");

    m_panBtn = new Button();
    m_panBtn.setIcon(FontAwesome.ARROWS);
    m_panBtn.setDescription("Pan Tool");
    m_panBtn.addStyleName(Styles.SELECTED);

    m_selectBtn = new Button();
    m_selectBtn.setIcon(IonicIcons.ANDROID_EXPAND);
    m_selectBtn.setDescription("Selection Tool");
    m_selectBtn.setStyleName("toolbar-button");
    m_selectBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            m_selectBtn.addStyleName(Styles.SELECTED);
            m_panBtn.removeStyleName(Styles.SELECTED);
            controller.setActiveTool(ActiveTool.select);
        }
    });

    m_panBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            m_panBtn.addStyleName(Styles.SELECTED);
            m_selectBtn.removeStyleName(Styles.SELECTED);
            controller.setActiveTool(ActiveTool.pan);
        }
    });

    Button showAllMapBtn = new Button();
    showAllMapBtn.setId("showEntireMapBtn");
    showAllMapBtn.setIcon(FontAwesome.GLOBE);
    showAllMapBtn.setDescription("Show Entire Map");
    showAllMapBtn.addClickListener((Button.ClickListener) event -> controller.showAllMap());

    Button centerSelectionBtn = new Button();
    centerSelectionBtn.setIcon(FontAwesome.LOCATION_ARROW);
    centerSelectionBtn.setDescription("Center On Selection");
    centerSelectionBtn.addClickListener((Button.ClickListener) event -> controller.centerMapOnSelection());

    Button shareButton = new Button("", FontAwesome.SHARE_SQUARE_O);
    shareButton.setDescription("Share");
    shareButton.addClickListener((x) -> {
        // Create the share link
        String fragment = getUI().getPage().getLocation().getFragment();
        String url = getUI().getPage().getLocation().toString().replace("#" + fragment, "");
        String shareLink = String.format("%s?%s=%s", url, PARAMETER_HISTORY_FRAGMENT, fragment);

        // Create the Window
        Window shareWindow = new Window();
        shareWindow.setCaption("Share Link");
        shareWindow.setModal(true);
        shareWindow.setClosable(true);
        shareWindow.setResizable(false);
        shareWindow.setWidth(400, Sizeable.Unit.PIXELS);

        TextArea shareLinkField = new TextArea();
        shareLinkField.setValue(shareLink);
        shareLinkField.setReadOnly(true);
        shareLinkField.setRows(3);
        shareLinkField.setWidth(100, Sizeable.Unit.PERCENTAGE);

        // Close Button
        Button close = new Button("Close");
        close.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);
        close.addClickListener(event -> shareWindow.close());

        // Layout for Buttons
        HorizontalLayout buttonLayout = new HorizontalLayout();
        buttonLayout.setMargin(true);
        buttonLayout.setSpacing(true);
        buttonLayout.setWidth("100%");
        buttonLayout.addComponent(close);
        buttonLayout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT);

        // Content Layout
        VerticalLayout verticalLayout = new VerticalLayout();
        verticalLayout.setMargin(true);
        verticalLayout.setSpacing(true);
        verticalLayout.addComponent(
                new Label("Please use the following link to share the current view with others."));
        verticalLayout.addComponent(shareLinkField);
        verticalLayout.addComponent(buttonLayout);

        shareWindow.setContent(verticalLayout);

        getUI().addWindow(shareWindow);
    });

    // Refresh Button
    Button refreshButton = new Button();
    refreshButton.setId("refreshNow");
    refreshButton.setIcon(FontAwesome.REFRESH);
    refreshButton.setDescription("Refresh Now");
    refreshButton.addClickListener((event) -> controller.refreshUI());

    // Layer Layout
    layerLayout = new VerticalLayout();
    layerLayout.setId("layerComponent");
    layerLayout.setSpacing(true);
    layerLayout.setMargin(true);

    // Layer Button
    layerButton = new Button();
    layerButton.setId("layerToggleButton");
    layerButton.setIcon(FontAwesome.BARS);
    layerButton.setDescription("Layers");
    layerButton.addClickListener((event) -> {
        boolean isCollapsed = layerButton.getStyleName().contains(Styles.EXPANDED);
        setLayerLayoutVisible(!isCollapsed);
    });

    // Save button
    layerSaveButton = new Button();
    layerSaveButton.setId("saveLayerButton");
    layerSaveButton.setIcon(FontAwesome.FLOPPY_O);
    layerSaveButton.addClickListener((event) -> controller.saveLayout());

    // Actual Layout for the Toolbar
    CssLayout contentLayout = new CssLayout();
    contentLayout.addStyleName("toolbar-component");
    contentLayout.addComponent(createGroup(szlInBtn, m_zoomLevelLabel, m_szlOutBtn));
    contentLayout.addComponent(
            createGroup(refreshButton, centerSelectionBtn, showAllMapBtn, layerButton, showFocusVerticesBtn));
    contentLayout.addComponent(createGroup(m_panBtn, m_selectBtn));
    contentLayout.addComponent(createGroup(magnifyBtn, demagnifyBtn));
    contentLayout.addComponent(createGroup(shareButton));
    contentLayout.addComponent(createGroup(layerSaveButton));

    // Toolbar
    addComponent(contentLayout);
}