Example usage for com.vaadin.ui Window setDraggable

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

Introduction

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

Prototype

public void setDraggable(boolean draggable) 

Source Link

Document

Enables or disables that a window can be dragged (moved) by the user.

Usage

From source file:org.processbase.ui.servlet.MainWindow.java

License:Open Source License

void openLogoutWindow() {
    Window logout = new Window(((PbApplication) getApplication()).getPbMessages().getString("btnLogout"));
    logout.setModal(true);//from  www  . j  av  a2  s.c  om
    //        logout.setStyleName(Reindeer.WINDOW_BLACK);
    logout.setWidth("260px");
    logout.setResizable(false);
    logout.setClosable(false);
    logout.setDraggable(false);
    logout.setCloseShortcut(KeyCode.ESCAPE, null);

    Label helpText = new Label("Are you sure you want to log out?", Label.CONTENT_XHTML);
    logout.addComponent(helpText);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    Button yes = new Button(((PbApplication) getApplication()).getPbMessages().getString("btnLogout"),
            new Button.ClickListener() {

                public void buttonClick(ClickEvent event) {
                    WebApplicationContext applicationContext = (WebApplicationContext) getApplication()
                            .getContext();
                    getApplication().close();
                    applicationContext.getHttpSession().invalidate();
                }
            });
    yes.setStyleName(Reindeer.BUTTON_DEFAULT);
    yes.focus();
    buttons.addComponent(yes);
    Button no = new Button(((PbApplication) getApplication()).getPbMessages().getString("btnCancel"),
            new Button.ClickListener() {

                public void buttonClick(ClickEvent event) {
                    removeWindow(event.getButton().getWindow());
                }
            });
    buttons.addComponent(no);

    logout.addComponent(buttons);
    ((VerticalLayout) logout.getContent()).setComponentAlignment(buttons, Alignment.MIDDLE_CENTER);
    ((VerticalLayout) logout.getContent()).setSpacing(true);

    addWindow(logout);
}

From source file:org.vaadin.addon.ewopener.demo.DemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    EnhancedBrowserWindowOpener opener1 = new EnhancedBrowserWindowOpener().popupBlockerWorkaround(true);
    Button button1 = new Button("Click me");
    button1.addClickListener(e -> {//from  w w  w .j  a  v a  2  s . c  o  m
        opener1.open(generateResource());
    });
    opener1.extend(button1);

    EnhancedBrowserWindowOpener opener4 = new EnhancedBrowserWindowOpener().popupBlockerWorkaround(true);
    Button button4 = new Button("Nothing to open here");
    button4.addClickListener(e -> {
        opener4.open((Resource) null);
    });
    opener4.extend(button4);

    Button button2 = new Button("Click me");
    button2.addClickListener(e -> {
        EnhancedBrowserWindowOpener.extendOnce(button2).open(generateResource());
    });

    Button button3 = new Button("Click me");
    EnhancedBrowserWindowOpener opener3 = new EnhancedBrowserWindowOpener().popupBlockerWorkaround(true)
            .withGeneratedContent("myFileName.txt", this::generateContent).doExtend(button3);
    button3.addClickListener(opener3::open);

    Link link = new Link("Click me", null);
    new EnhancedBrowserWindowOpener().clientSide(true)
            .withGeneratedContent("myFileName.txt", this::generateContent).doExtend(link);

    Link link2 = new Link("Click me", null);
    new EnhancedBrowserWindowOpener().clientSide(true)
            .withGeneratedContent("myFileName.txt", this::generateContent, resource -> {
                resource.setCacheTime(0);
                resource.setFilename("runtimeFileName-" + Instant.now().getEpochSecond() + ".txt");
            }).doExtend(link2);

    EnhancedBrowserWindowOpener opener5 = new EnhancedBrowserWindowOpener(
            new ClassResource(DemoUI.class, "static.txt"));
    CssLayout hiddenComponent = new MCssLayout().withWidth("0").withHeight("0");
    opener5.extend(hiddenComponent);
    CompletableFuture.runAsync(this::doSomeLongProcessing).thenRun(() -> getUI().access(opener5::open));

    table = new Table("Select items to download",
            new BeanItemContainer<>(DummyService.Person.class, DummyService.data()));
    table.setImmediate(true);
    table.setVisibleColumns("name", "age");
    table.setColumnHeaders("Name", "Age");
    table.setWidth("100%");
    table.setPageLength(20);
    table.setMultiSelectMode(MultiSelectMode.DEFAULT);
    table.setMultiSelect(true);
    table.setSelectable(true);

    final MyPopupContent popupContent = new MyPopupContent();
    Button popupButton = new Button("Open modal", event -> {
        Window window = new Window("Test", popupContent);
        window.setWidth(40, Sizeable.Unit.PERCENTAGE);
        window.setHeight(200, Sizeable.Unit.PIXELS);
        window.setModal(true);
        window.setDraggable(false);
        window.setResizable(false);
        window.center();
        getUI().addWindow(window);
    });

    MenuBar.Command cmd = selectedItem -> Notification.show("Item clicked",
            "Item is " + selectedItem.getDescription(), Notification.Type.TRAY_NOTIFICATION);
    MenuBar menuBar = new MenuBar();
    menuBar.setSizeFull();
    EnhancedBrowserWindowOpener opener6 = new EnhancedBrowserWindowOpener()
            .withGeneratedContent("menu-item-serverside.txt", this::generateContent)
            .popupBlockerWorkaround(true);
    EnhancedBrowserWindowOpener opener7 = new EnhancedBrowserWindowOpener()
            .withGeneratedContent("menu-item-clientside-1.txt", this::generateContent).clientSide(true);
    EnhancedBrowserWindowOpener opener8 = new EnhancedBrowserWindowOpener()
            .withGeneratedContent("menu-item-clientside-2.txt", this::generateContent).clientSide(true);
    MenuBar.MenuItem menuItem = menuBar.addItem("Download from Menu (Client side)", selectedItem -> {
        System.out.println("OK, Invoked");
    });
    MenuBar.MenuItem subMenu = menuBar.addItem("Sub menu", null);
    subMenu.addItem("Item 1", cmd);
    subMenu.addItem("Item 2", cmd);
    MenuBar.MenuItem subItem = subMenu.addItem("Download (client side)", cmd);
    MenuBar.MenuItem subItem2 = subMenu.addItem("Download (server side)", selectedItem -> opener6.open());
    opener7.doExtend(menuBar, menuItem);
    opener6.doExtend(menuBar, subItem2);
    opener8.doExtend(menuBar, subItem);

    // Show it in the middle of the screen
    final Layout layout = new MVerticalLayout(
            new MLabel("Enhanced Window Opener Demo").withStyleName(ValoTheme.LABEL_COLORED,
                    ValoTheme.LABEL_H1),
            new MHorizontalLayout().add(table, 1)
                    .add(new MCssLayout(menuBar, readMarkdown("code_menu.md").withFullWidth(),
                            new MVerticalLayout(readMarkdown("code1.md"), button1)
                                    .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false),
                            new MVerticalLayout(readMarkdown("code2.md"), button2)
                                    .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false),
                            new MVerticalLayout(readMarkdown("code7.md"), button3)
                                    .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false),
                            new MVerticalLayout(readMarkdown("code5.md"), link)
                                    .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false),
                            new MVerticalLayout(readMarkdown("code6.md"), link2)
                                    .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false),
                            new MVerticalLayout(readMarkdown("code3.md"), button4)
                                    .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false),
                            new MVerticalLayout(readMarkdown("code8.md"), popupButton)
                                    .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false),
                            new MVerticalLayout(readMarkdown("code4.md"), hiddenComponent)
                                    .alignAll(Alignment.MIDDLE_CENTER).withWidthUndefined().withMargin(false))
                                            .withFullWidth().withStyleName("demo-samples"),
                            5)
                    .withFullWidth()).withFullWidth().withMargin(true);

    setContent(layout);

}

From source file:pl.exsio.frameset.vaadin.ui.support.component.data.common.DataComponent.java

License:Open Source License

protected Window createFormWindow(String title) {
    final Window formWindow = new Window(title);
    formWindow.center();//w  w  w.  ja  v  a 2s  .co m
    formWindow.setSizeUndefined();
    formWindow.setModal(true);
    formWindow.setResizable(false);
    formWindow.setDraggable(false);
    formWindow.setResizeLazy(false);
    formWindow.setStyleName("frameset-dc-window");
    return formWindow;
}

From source file:pl.exsio.frameset.vaadin.ui.support.dialog.ConfirmationDialog.java

License:Open Source License

public static void show(final String msg, final Handler positiveHandler, final Handler negativeHandler) {
    final Window window = new Window(t("confirmation.title"));
    window.center();/*  w w w .  j  a va 2  s  .c  o m*/
    window.setWidth("450px");
    window.setModal(true);
    window.setResizable(false);
    window.setDraggable(false);

    VerticalLayout vlayout = new VerticalLayout() {
        {
            addComponent(new Label(msg));
            addComponent(getControls(window, positiveHandler, negativeHandler));
        }
    };
    vlayout.setMargin(true);
    window.setContent(vlayout);
    UI.getCurrent().addWindow(window);
    window.focus();
}

From source file:pl.exsio.frameset.vaadin.ui.support.dialog.PromptDialog.java

License:Open Source License

public static void show(final String msg, final Handler handler) {
    final Window window = new Window(t("prompt.title"));
    window.center();/*from ww  w .  j a  v a2 s  . co  m*/
    window.setWidth("450px");
    window.setModal(true);
    window.setResizable(false);
    window.setDraggable(false);

    VerticalLayout vlayout = new VerticalLayout() {
        {
            HorizontalLayout hlayout = new HorizontalLayout();
            hlayout.setSpacing(true);
            hlayout.setMargin(true);

            hlayout.addComponent(new Label(t(msg) + ": "));
            final TextField value = new TextField();
            hlayout.addComponent(value);
            addComponent(hlayout);
            addComponent(getControls(window, handler, value));
        }
    };
    vlayout.setMargin(true);
    vlayout.setSpacing(true);
    window.setContent(vlayout);
    UI.getCurrent().addWindow(window);
    window.focus();
}