Example usage for com.vaadin.ui Window setModal

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

Introduction

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

Prototype

public void setModal(boolean modal) 

Source Link

Document

Sets window modality.

Usage

From source file:org.yozons.vaadin.ckeditor.CKEditorForVaadin7UI.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {
    getPage().setTitle("CKEditor for Vaadin 7");

    final VerticalLayout layout = new VerticalLayout();
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setMargin(true);/*from  www  .j  a v a2s.  c  o  m*/
    layout.setSpacing(true);
    setContent(layout);

    layout.addComponent(new Button("Hit server"));

    final String editor1InitialValue = "<p>CKEditor for Vaadin 7 is an entirely new JavaScriptComponent add-on.</p>";

    CKEditorConfig config1 = new CKEditorConfig();
    config1.useCompactTags();
    config1.disableElementsPath();
    config1.setResizeDir(CKEditorConfig.RESIZE_DIR.HORIZONTAL);
    config1.disableSpellChecker();
    final CKEditor editor1 = new CKEditor(config1, editor1InitialValue);
    layout.addComponent(editor1);

    editor1.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(String newValue) {
            if (!newValue.equals(editor1.getValue()))
                Notification.show("ERROR - Event value does not match editor #1's current value");
            else
                Notification.show("ValueChangeListener CKEditor v" + editor1.getVersion() + "/" + getVersion()
                        + " - #1 contents: " + newValue);
            editor1.focus();
        }
    });

    Button testButton = new Button("Reset editor #1");
    testButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (!editor1.isReadOnly()) {
                editor1.setValue(editor1InitialValue);
                Notification.show("Reset CKEditor v" + editor1.getVersion() + "/" + getVersion()
                        + " - #1 contents: " + editor1.getValue());
            }
        }

    });
    layout.addComponent(testButton);

    Button toggleReadOnlyButton1 = new Button("Toggle read-only editor #1");
    toggleReadOnlyButton1.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            editor1.setReadOnly(!editor1.isReadOnly());
        }
    });
    layout.addComponent(toggleReadOnlyButton1);

    Button toggleViewWithoutEditorButton1 = new Button("Toggle view-without-editor #1");
    toggleViewWithoutEditorButton1.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            editor1.setViewWithoutEditor(!editor1.isViewWithoutEditor());
        }
    });
    layout.addComponent(toggleViewWithoutEditorButton1);

    // Now add in a second editor....
    final String editor2InitialValue = "<p>Here is editor #2.</p><h1>Hope you find this useful in your Vaadin 7 projects.</h1>";

    CKEditorConfig config2 = new CKEditorConfig();
    config2.addCustomToolbarLine(
            "{ items : ['Source','Styles','Bold','VaadinSave','-','Undo','Redo','-','NumberedList','BulletedList'] }");
    config2.enableVaadinSavePlugin();
    config2.addToRemovePlugins("scayt");

    final CKEditor editor2 = new CKEditor(config2);
    editor2.setWidth(600, Unit.PIXELS);
    layout.addComponent(editor2);
    editor2.setValue(editor2InitialValue);

    editor2.addValueChangeListener(new ValueChangeListener() {

        public void valueChange(String newValue) {
            if (!newValue.equals(editor2.getValue()))
                Notification.show("ERROR - Event value does not match editor #2's current value");
            else
                Notification.show("ValueChangeListener CKEditor v" + editor2.getVersion() + "/" + getVersion()
                        + " - #2 contents: " + newValue);
        }
    });

    Button resetTextButton2 = new Button("Reset editor #2");
    resetTextButton2.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (!editor2.isReadOnly()) {
                editor2.setValue(editor2InitialValue);
                Notification.show("Reset CKEditor v" + editor1.getVersion() + "/" + getVersion()
                        + " - #2 contents: " + editor2.getValue());
            }
        }
    });
    layout.addComponent(resetTextButton2);

    Button toggleReadOnlyButton2 = new Button("Toggle read-only editor #2");
    toggleReadOnlyButton2.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            editor2.setReadOnly(!editor2.isReadOnly());
        }
    });
    layout.addComponent(toggleReadOnlyButton2);

    Button toggleViewWithoutEditorButton2 = new Button("Toggle view-without-editor #2");
    toggleViewWithoutEditorButton2.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            editor2.setViewWithoutEditor(!editor2.isViewWithoutEditor());
        }
    });
    layout.addComponent(toggleViewWithoutEditorButton2);

    // Now some extra tests for modal windows, etc.
    layout.addComponent(new Button("Open Modal Subwindow", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Window sub = new Window("Subwindow modal");
            VerticalLayout subLayout = new VerticalLayout();
            sub.setContent(subLayout);

            CKEditorConfig config = new CKEditorConfig();
            config.useCompactTags();
            config.disableElementsPath();
            config.disableSpellChecker();
            config.enableVaadinSavePlugin();
            // set BaseFloatZIndex 1000 higher than CKEditor's default of 10000; probably a result of an editor opening
            // in a window that's on top of the main two editors of this demo app
            config.setBaseFloatZIndex(11000);
            config.setHeight("150px");

            final CKEditor ckEditor = new CKEditor(config);
            ckEditor.addValueChangeListener(new ValueChangeListener() {

                public void valueChange(String newValue) {
                    Notification.show("CKEditor v" + ckEditor.getVersion() + "/" + getVersion()
                            + " - POPUP MODAL contents: " + newValue);
                }
            });
            ckEditor.focus();

            subLayout.addComponent(ckEditor);

            sub.setWidth("80%");
            sub.setModal(true);
            sub.center();

            event.getButton().getUI().addWindow(sub);
        }
    }));

    layout.addComponent(new Button("Open Non-Modal Subwindow with 100% Height", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Window sub = new Window("Subwindow non-modal 100% height");
            VerticalLayout subLayout = new VerticalLayout();
            sub.setContent(subLayout);
            sub.setWidth("80%");
            sub.setHeight("500px");

            subLayout.setSizeFull();

            CKEditorConfig config = new CKEditorConfig();
            config.useCompactTags();
            config.disableElementsPath();
            config.disableSpellChecker();
            config.enableVaadinSavePlugin();
            // set BaseFloatZIndex 1000 higher than CKEditor's default of 10000; probably a result of an editor opening
            // in a window that's on top of the main two editors of this demo app
            config.setBaseFloatZIndex(11000);
            config.setStartupFocus(true);

            final CKEditor ckEditor = new CKEditor(config);
            ckEditor.setHeight("100%");
            ckEditor.addValueChangeListener(new ValueChangeListener() {

                public void valueChange(String newValue) {
                    Notification.show("CKEditor v" + ckEditor.getVersion() + "/" + getVersion()
                            + " - POPUP NON-MODAL 100% HEIGHT contents: " + ckEditor.getValue());
                }
            });
            subLayout.addComponent(ckEditor);
            subLayout.setExpandRatio(ckEditor, 1.0f);

            final TextField textField = new TextField("TextField");
            textField.setImmediate(true);
            textField.addValueChangeListener(new Property.ValueChangeListener() {

                public void valueChange(ValueChangeEvent event) {
                    Notification.show("TextField - POPUP NON-MODAL 100% HEIGHT contents: "
                            + event.getProperty().getValue().toString());
                }
            });
            subLayout.addComponent(textField);

            sub.center();

            event.getButton().getUI().addWindow(sub);
        }
    }));
}

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();// www . j  ava2s . c o 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();//ww  w  . java 2  s  .co  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.c  om*/
    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();
}

From source file:ro.zg.netcell.vaadin.action.user.LoginHandler.java

License:Apache License

@Override
public void handle(ActionContext actionContext) throws Exception {
    Window w = new Window();
    w.setModal(true);
    OpenGroupsApplication app = actionContext.getApp();
    if (app.getAppConfigManager().isInstancePrivate()) {
        w.setClosable(false);//  w  w  w .ja v  a  2s  .  c  o  m
    }

    OpenGroupsMainWindow mainWindow = actionContext.getWindow();

    UserAction ua = actionContext.getUserAction();
    w.setWidth("600px");
    w.setHeight("300px");
    w.center();
    w.setCaption(getMessage(ua.getActionName() + ".window.caption"));
    mainWindow.addWindow(w);

    ComponentContainer loginView = getLoginView(actionContext);

    w.setContent(loginView);

}

From source file:ro.zg.netcell.vaadin.action.user.RegisterUserHandler.java

License:Apache License

@Override
public void handle(ActionContext actionContext) throws Exception {
    Window w = new Window();
    w.setModal(true);
    OpenGroupsApplication app = actionContext.getApp();
    OpenGroupsMainWindow mainWindow = actionContext.getWindow();
    UserAction ua = actionContext.getUserAction();
    w.setWidth("400px");
    w.setHeight("300px");
    w.center();/*w  w  w .j  av a  2  s.  c o  m*/
    w.setCaption(getMessage(ua.getActionName() + ".window.caption"));
    mainWindow.addWindow(w);

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    Form form = getRegisterForm(actionContext.getUserAction(), app, actionContext.getWindow(),
            actionContext.getEntity(), actionContext);
    w.setContent(layout);
    layout.addComponent(form);
    form.setWidth("60%");
    //   form.setHeight("30%");
    layout.setComponentAlignment(form, Alignment.MIDDLE_CENTER);

}

From source file:ro.zg.netcell.vaadin.action.user.RequestPasswordResetHandler.java

License:Apache License

@Override
public void handle(ActionContext actionContext) throws Exception {
    Window w = new Window();
    w.setModal(true);
    OpenGroupsApplication app = actionContext.getApp();
    OpenGroupsMainWindow mainWindow = actionContext.getWindow();
    UserAction ua = actionContext.getUserAction();
    w.setWidth("400px");
    w.setHeight("300px");
    w.center();/*ww  w .j  ava 2  s.  co  m*/
    w.setCaption(getMessage(ua.getActionName() + ".window.caption"));
    mainWindow.addWindow(w);

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    Form form = getForm(actionContext.getUserAction(), app, actionContext);
    w.setContent(layout);
    layout.addComponent(form);
    form.setWidth("60%");
    // form.setHeight("30%");
    layout.setComponentAlignment(form, Alignment.MIDDLE_CENTER);
}

From source file:ro.zg.netcell.vaadin.action.user.ResetPasswordHandler.java

License:Apache License

@Override
public void handle(ActionContext actionContext) throws Exception {
    Window w = new Window();
    w.setModal(true);
    OpenGroupsApplication app = actionContext.getApp();
    OpenGroupsMainWindow mainWindow = actionContext.getWindow();
    UserAction ua = actionContext.getUserAction();
    w.setWidth("400px");
    w.setHeight("300px");
    w.center();//from   w  ww.  j a  va2 s .c om
    w.setCaption(getMessage(ua.getActionName() + ".window.caption"));
    mainWindow.addWindow(w);

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    Form form = getForm(actionContext.getUserAction(), app, actionContext.getParams(), actionContext);
    w.setContent(layout);
    layout.addComponent(form);
    form.setWidth("60%");
    // form.setHeight("30%");
    layout.setComponentAlignment(form, Alignment.MIDDLE_CENTER);

    /* hide the content of the main window */
    mainWindow.setContentVisible(false);

}

From source file:ru.codeinside.gses.manager.processdefeniton.ProcessDefenitionQuery.java

License:Mozilla Public License

PropertysetItem createItem(final ProcedureProcessDefinition p) {
    PropertysetItem item = new PropertysetItem();

    ClickListener listener = new ClickListener() {

        private static final long serialVersionUID = -8900212370037948964L;

        @Override/*from  www .ja  va2s  . co  m*/
        public void buttonClick(ClickEvent event) {
            Window mainWin = event.getButton().getApplication().getMainWindow();

            ProcessDefinition processDefinition = Functions.withRepository(Flash.login(),
                    new Function<RepositoryService, ProcessDefinition>() {
                        public ProcessDefinition apply(RepositoryService srv) {
                            return srv.createProcessDefinitionQuery()
                                    .processDefinitionId(p.getProcessDefinitionId()).singleResult();
                        }
                    });

            String caption = "?? " + df.format(p.getVersion());
            Window win = Components.createWindow(mainWin, caption);
            win.center();
            ContentWindowChanger changer = new ContentWindowChanger(win);
            ProcessDefinitionShowUi putComponent = new ProcessDefinitionShowUi(processDefinition, changer);
            changer.set(putComponent, caption);
        }

    };
    ObjectProperty<Component> versionProperty = Components.buttonProperty(df.format(p.getVersion()), listener);
    item.addItemProperty("version", versionProperty);

    HorizontalLayout ll = new HorizontalLayout();
    ll.setSpacing(true);
    DefinitionStatus status = p.getStatus();
    final Label label = new Label(status.getLabelName());
    label.setWidth("100px");
    ll.addComponent(label);

    final ComboBox comboBox = new ComboBox();
    comboBox.setWidth("100px");
    comboBox.setNullSelectionAllowed(false);
    for (DefinitionStatus s : status.getAvailableStatus()) {
        comboBox.addItem(s.getLabelName());
        comboBox.setValue(s.getLabelName());
    }
    if (!status.equals(DefinitionStatus.PathToArchive) && !status.getAvailableStatus().isEmpty()) {
        ll.addComponent(comboBox);
        Button c = new Button("ok");
        c.addListener(new ClickListener() {

            private static final long serialVersionUID = 2966059295049064338L;

            @Override
            public void buttonClick(ClickEvent event) {
                Object value = comboBox.getValue();
                final String newValue = value.toString();
                final DefinitionStatus newStatus = DefinitionStatus.getStatusByLabelName(newValue);

                if (DefinitionStatus.Work.equals(newStatus)) {
                    final List<ProcedureProcessDefinition> works = ManagerService.get()
                            .getProcessDefenitionWithStatus(p, DefinitionStatus.Work);
                    if (!works.isEmpty()) {
                        final Window thisWindow = event.getButton().getWindow();
                        comfirmAction(thisWindow, p, label, newValue, newStatus, works);
                        return;

                    }
                }

                ManagerService.get().updateProcessDefinationStatus(p.getProcessDefinitionId(), newStatus);

                label.setValue(null);
                label.setCaption(newValue);
                paramLazyLoadingContainer.fireItemSetChange();
                proceduresContainer.fireItemSetChange();
            }

            private void comfirmAction(final Window thisWindow, final ProcedureProcessDefinition p,
                    final Label label, final String newValue, final DefinitionStatus newStatus,
                    final List<ProcedureProcessDefinition> works) {

                final Window window = new Window();
                window.setModal(true);
                window.setContent(new HorizontalLayout());
                window.setCaption(" ? " + df.format(works.get(0).getVersion())
                        + "       ?   ??  ");
                Button save = new Button("");
                save.addListener(new ClickListener() {

                    private static final long serialVersionUID = 3229924940535642819L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        ManagerService.get().updateProcessDefinationStatus(p.getProcessDefinitionId(),
                                newStatus);
                        label.setValue(null);
                        label.setCaption(newValue);
                        paramLazyLoadingContainer.fireItemSetChange();
                        proceduresContainer.fireItemSetChange();
                        closeWindow(thisWindow, window);
                    }

                });

                window.addComponent(save);
                Button c2 = new Button("?");
                c2.addListener(new ClickListener() {

                    private static final long serialVersionUID = 4502614143261892063L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        closeWindow(thisWindow, window);
                    }
                });
                window.addComponent(c2);
                thisWindow.addWindow(window);
            }
        });
        ll.addComponent(c);
    }
    item.addItemProperty("status", new ObjectProperty<Component>(ll));
    item.addItemProperty("date", Components.stringProperty(formatter.format(p.getDateCreated())));
    Employee creator = p.getCreator();
    item.addItemProperty("user", Components.stringProperty(creator == null ? null : creator.getLogin()));

    Button b = new Button("");

    b.addListener(new ClickListener() {

        private static final long serialVersionUID = 1362078893385574138L;

        @Override
        public void buttonClick(ClickEvent event) {
            StreamSource streamSource = new StreamSource() {

                private static final long serialVersionUID = 456334952891567271L;

                public InputStream getStream() {
                    return Functions.withEngine(new PF<InputStream>() {
                        private static final long serialVersionUID = 1L;

                        public InputStream apply(ProcessEngine s) {
                            return s.getRepositoryService().getProcessModel(p.getProcessDefinitionId());
                        }
                    });
                }
            };
            final Application application = event.getButton().getApplication();
            StreamResource resource = new StreamResource(streamSource, "test" + ".xml", application) {
                private static final long serialVersionUID = -3869546661105572851L;

                public DownloadStream getStream() {
                    final StreamSource ss = getStreamSource();
                    if (ss == null) {
                        return null;
                    }
                    final DownloadStream ds = new DownloadStream(ss.getStream(), getMIMEType(), getFilename());
                    ds.setBufferSize(getBufferSize());
                    ds.setCacheTime(getCacheTime());
                    ds.setParameter("Content-Disposition", "attachment; filename=" + getFilename());
                    return ds;
                }
            };
            Window window = event.getButton().getWindow();
            window.open(resource);
        }
    });
    item.addItemProperty("getRoute", new ObjectProperty<Component>(b));

    ObjectProperty<Component> buttonProperty = null;

    if (status.equals(DefinitionStatus.Debugging)) {
        DeploymentUploadReceiver receiver = new DeploymentUploadReceiver();

        DeploymentSucceededListener succeededListener = new DeploymentSucceededListener(receiver, procedureId,
                p.getProcessDefinitionId());
        succeededListener.addLoadingContainer(paramLazyLoadingContainer);
        succeededListener.addLoadingContainer(proceduresContainer);
        DeploymentAddUi addUi = new DeploymentAddUi(new DeploymentStartListener(), receiver, succeededListener);

        addUi.setSizeFull();
        buttonProperty = new ObjectProperty<Component>(addUi);
    } else {
        ClickListener l = new ClickListener() {

            private static final long serialVersionUID = 1362078893385574138L;

            @Override
            public void buttonClick(ClickEvent event) {

            }
        };
        buttonProperty = Components.buttonProperty("", l);
    }

    item.addItemProperty("download", buttonProperty);
    return item;
}

From source file:ui.button.ShowAchievementsButton.java

License:Apache License

private void showOnWindow() {
    final Window window = new Window();
    window.setWidth("95%");
    window.setHeight("95%");
    window.center();//w  ww.  j  av a  2  s.c o m
    window.setResizable(true);
    window.setModal(true);
    window.addCloseListener(new Window.CloseListener() {

        @Override
        public void windowClose(Window.CloseEvent e) {
            window.close();
        }
    });
    window.setContent(new UserTabSheet(userId, language));
    getUI().addWindow(window);
    window.setStyleName("window");
}