Example usage for com.vaadin.ui Window center

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

Introduction

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

Prototype

public void center() 

Source Link

Document

Sets this window to be centered relative to its parent window.

Usage

From source file:com.etest.view.tq.TQCoverageUI.java

Window getMaxItemsWindow(Item item, double previousValue) {
    Window sub = new Window("Field Value: ");
    sub.setWidth("150px");
    sub.setModal(true);//from   ww  w.  jav  a2  s  .c o m
    sub.center();
    sub.setResizable(false);

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);
    v.setSpacing(true);

    TextField field = new CommonTextField("Enter Value..", "Enter a Value: ");
    v.addComponent(field);

    Button button = new Button("CLOSE");
    button.setWidth("100%");
    button.setIcon(FontAwesome.TASKS);
    button.addStyleName(ValoTheme.BUTTON_PRIMARY);
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    button.addClickListener((Button.ClickEvent event) -> {
        boolean isNumeric = CommonUtilities.isNumeric(field.getValue().trim());
        if (!isNumeric) {
            return;
        }

        item.getItemProperty("Max Items").setValue(CommonUtilities.convertStringToDouble(field.getValue()));
        if (tq.calculateTotalMaxItems(grid) == CommonUtilities
                .convertStringToDouble(totalItems.getValue().trim())) {
            footer.getCell("Max Items").setText(String.valueOf(tq.calculateTotalMaxItems(grid)));
        } else {
            item.getItemProperty("Max Items").setValue(previousValue);
            footer.getCell("Max Items").setText(String.valueOf(tq.calculateTotalMaxItems(grid)));
            ShowErrorNotification.warning("Total Max Items should be equal to Total Test Items");
            return;
        }

        sub.close();
    });
    v.addComponent(button);
    v.setComponentAlignment(button, Alignment.BOTTOM_CENTER);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();

    return sub;
}

From source file:com.etest.view.tq.TQCoverageWindow.java

Window confirmDeleteWindow() {
    Window sub = new Window("TQ Coverage");
    sub.setWidth("250px");
    sub.setResizable(false);/*from ww  w  .  j a v  a  2 s  .  c om*/
    sub.setModal(true);
    sub.center();

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);

    Button delete = new Button("DELETE TQ?");
    delete.setWidth("100%");
    delete.setIcon(FontAwesome.TRASH_O);
    delete.addStyleName(ValoTheme.BUTTON_PRIMARY);
    delete.addStyleName(ValoTheme.BUTTON_SMALL);
    delete.addClickListener((Button.ClickEvent event) -> {
        boolean result = tq.deleteTQCoverage(getTQCoverageId());
        if (result) {
            sub.close();
            close();
        }
    });
    v.addComponent(delete);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();

    return sub;
}

From source file:com.haulmont.cuba.web.exception.NoUserSessionHandler.java

License:Apache License

protected void showNoUserSessionDialog(App app) {
    Messages messages = AppBeans.get(Messages.NAME);

    Window dialog = new NoUserSessionExceptionDialog();
    dialog.setStyleName("c-nousersession-dialog");
    dialog.setCaption(messages.getMainMessage("dialogs.Information", locale));
    dialog.setClosable(false);/* w w  w  . jav  a2  s  .co m*/
    dialog.setResizable(false);
    dialog.setModal(true);

    AppUI ui = app.getAppUI();

    if (ui.isTestMode()) {
        dialog.setCubaId("optionDialog");
        dialog.setId(ui.getTestIdManager().getTestId("optionDialog"));
    }

    Label messageLab = new CubaLabel();
    messageLab.setWidthUndefined();
    messageLab.setValue(messages.getMainMessage("noUserSession.message", locale));

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setWidthUndefined();
    layout.setStyleName("c-nousersession-dialog-layout");
    layout.setSpacing(true);
    dialog.setContent(layout);

    Button reloginBtn = new Button();
    if (ui.isTestMode()) {
        reloginBtn.setCubaId("reloginBtn");
        reloginBtn.setId(ui.getTestIdManager().getTestId("reloginBtn"));
    }
    reloginBtn.addStyleName(WebButton.ICON_STYLE);
    reloginBtn.addStyleName("c-primary-action");
    reloginBtn.addClickListener(event -> relogin());
    reloginBtn.setCaption(messages.getMainMessage(Type.OK.getMsgKey()));

    String iconName = AppBeans.get(Icons.class).get(Type.OK.getIconKey());
    reloginBtn.setIcon(WebComponentsHelper.getIcon(iconName));

    ClientConfig clientConfig = AppBeans.get(Configuration.class).getConfig(ClientConfig.class);
    setClickShortcut(reloginBtn, clientConfig.getCommitShortcut());

    reloginBtn.focus();

    layout.addComponent(messageLab);
    layout.addComponent(reloginBtn);

    layout.setComponentAlignment(reloginBtn, Alignment.BOTTOM_RIGHT);

    ui.addWindow(dialog);

    dialog.center();
}

From source file:com.iton.gittest.HelloWorld.MyVaadinApplication.java

License:Apache License

@Override
public void init() {
    window = new Window("My Vaadin Application");
    setMainWindow(window);/*from www.  j  a  va 2  s  . c  o m*/
    Button button = new Button("Click Me");
    button.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            Window win = new Window("PopUp Form");
            win.setModal(true);
            win.setScrollable(false);
            win.setDraggable(false);
            win.setResizable(false);
            win.center();
            win.setWidth("350px");
            win.addComponent(new Form());
            window.addWindow(win);
        }
    });
    window.addComponent(button);

}

From source file:com.kelt.disk.db.web.DiskDBApplication.java

License:Apache License

@Override
public void init() {
    final Window mainWindow = new Window("Samplevaadin Application");
    final Window window = new Window("Some Window");
    window.setWidth(800, Sizeable.UNITS_PIXELS);
    window.setHeight(601, Sizeable.UNITS_PIXELS);
    window.setClosable(false);/*from   w w w.jav a2 s. c  o m*/
    window.setDraggable(false);
    window.setResizable(false);
    window.center();
    setUpWindow(window);
    mainWindow.addWindow(window);
    setMainWindow(mainWindow);
}

From source file:com.liferay.mail.vaadin.PreferencesView.java

License:Open Source License

private void editAccount(Account account) {

    String windowTitle = Lang.get(account == null ? "add-mail-account" : "edit-account");
    final Window editorWindow = new Window(windowTitle);
    editorWindow.setSizeUndefined();/*from   ww  w .  java  2  s  . c  o m*/
    editorWindow.center();
    editorWindow.setModal(true);
    editorWindow.setResizable(false);

    AccountEditor.AccountEditorListener listener = new SaveAccountListener(editorWindow);

    // show a pre-filled edit dialog
    AccountEditor editor = new AccountEditor(account, controller, listener);
    editorWindow.setContent(editor);
    controller.getApplication().getMainWindow().addWindow(editorWindow);
}

From source file:com.liferay.mail.vaadin.PreferencesView.java

License:Open Source License

private void editGmailAccount(Account account) {
    String windowTitle = Lang.get(account == null ? "add-gmail-account" : "edit-gmail-account");
    final Window editorWindow = new Window(windowTitle);
    editorWindow.setSizeUndefined();/* w  ww  . jav a2s . c  om*/
    editorWindow.center();
    editorWindow.setModal(true);
    editorWindow.setResizable(false);

    AccountEditor.AccountEditorListener listener = new SaveAccountListener(editorWindow);

    // show a pre-filled edit dialog
    AccountEditor editor = new GMailAccountEditor(account, controller, listener);
    editorWindow.setContent(editor);
    controller.getApplication().getMainWindow().addWindow(editorWindow);
}

From source file:com.lizardtech.expresszip.vaadin.MapToolbarViewComponent.java

License:Apache License

@Override
public void buttonClick(ClickEvent event) {
    Button b = event.getButton();
    if (b == btnJobQueueStatus) {
        Window subWindow = new Window("Job Manager");
        subWindow.setWidth("500px");
        subWindow.center();
        getApplication().getMainWindow().addWindow(subWindow);

        Panel p = new Panel(new JobsStatusViewComponent(getApplication().getURL()));
        p.getContent().setWidth("100%");
        p.setWidth("100%");
        subWindow.addComponent(p);/*from ww w . j a  va  2  s.c om*/
        subWindow.setModal(true);
    } else if (b == help) {
        String HelpURL = getApplication().getURL().toExternalForm() + "doc";
        getApplication().getMainWindow().open(new ExternalResource(HelpURL), "_blank");
    } else if (b == restart) {
        ((ExpressZipWindow) getApplication().getMainWindow()).getApplication().close();
    }
}

From source file:com.mechanicshop.components.TableLayout.java

public void createCustomMessage() {
    final TextArea textArea = new TextArea();
    textArea.setImmediate(true);/*from www .  j ava 2 s. com*/
    textArea.setColumns(30);
    textArea.setRows(10);
    textArea.addStyleName(ValoTheme.TEXTAREA_SMALL);
    textArea.setRequired(true);
    final Window subWindow = new Window();
    subWindow.setModal(true);
    subWindow.setHeight("350px");
    subWindow.setWidth("500px");
    subWindow.setCaption("Insert Message");
    subWindow.setStyleName(ValoTheme.WINDOW_TOP_TOOLBAR);
    subWindow.setClosable(false);
    subWindow.setResizable(false);

    HorizontalLayout layoutButtons = new HorizontalLayout();
    layoutButtons.setMargin(false);
    Button sendBtn = new Button("Send");
    sendBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                textArea.validate();
                String message = textArea.getValue();
                smsSenderService.sendMessageMassive(message);
                subWindow.close();
                Notification.show("Message Sent");
            } catch (Exception e) {

            }
        }
    });
    sendBtn.setImmediate(true);
    sendBtn.setStyleName(ValoTheme.BUTTON_TINY);
    sendBtn.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    Button cancelBtn = new Button("Cancel");
    cancelBtn.setStyleName(ValoTheme.BUTTON_TINY);
    cancelBtn.addStyleName(ValoTheme.BUTTON_DANGER);
    cancelBtn.setImmediate(true);
    cancelBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            subWindow.close();

        }
    });

    layoutButtons.setSizeUndefined();
    layoutButtons.setSpacing(true);
    layoutButtons.addComponents(cancelBtn, sendBtn);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.addComponent(textArea);
    layout.addComponent(layoutButtons);
    layout.setComponentAlignment(textArea, Alignment.MIDDLE_CENTER);
    layout.setComponentAlignment(layoutButtons, Alignment.MIDDLE_RIGHT);
    layout.setExpandRatio(textArea, 3);

    layout.setSizeFull();

    subWindow.setContent(layout);
    subWindow.center();

    getUI().addWindow(subWindow);
}

From source file:com.mymita.vaadlets.VaadletsBuilder.java

License:Apache License

private static void setWindowAttributes(final com.vaadin.ui.Component vaadinComponent,
        final com.mymita.vaadlets.core.Component vaadletsComponent) {
    if (vaadletsComponent instanceof com.mymita.vaadlets.ui.Window) {
        final com.vaadin.ui.Window vaadinWindow = (com.vaadin.ui.Window) vaadinComponent;
        final com.mymita.vaadlets.ui.Window vaadletsWindow = (com.mymita.vaadlets.ui.Window) vaadletsComponent;
        if (vaadletsWindow.isCenter()) {
            vaadinWindow.center();
        }/*  ww  w .j  a v  a 2  s .  c  om*/
        final Short positionX = vaadletsWindow.getPositionX();
        if (positionX != null) {
            vaadinWindow.setPositionX(positionX);
        }
        final Short positionY = vaadletsWindow.getPositionY();
        if (positionY != null) {
            vaadinWindow.setPositionY(positionY);
        }
        vaadinWindow.setBorder(vaadletsWindow.getBorder().ordinal());
        vaadinWindow.setModal(vaadletsWindow.isModal());
        vaadinWindow.setClosable(vaadletsWindow.isCloseable());
        vaadinWindow.setDraggable(vaadletsWindow.isDraggable());
        vaadinWindow.setResizable(vaadletsWindow.isResizeable());
        vaadinWindow.setResizeLazy(vaadletsWindow.isResizeLazy());
    }
}