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.escidoc.browser.ui.listeners.OnContextAdminDescriptor.java

License:Open Source License

/**
 * Editing since it has a parameter//from   ww  w.  j  a  v  a  2  s  .  c o  m
 * 
 * @param adminDescriptor
 */
public void adminDescriptorForm(AdminDescriptor adminDescriptor) {

    // Editing
    final Window subwindow = new Window("A modal subwindow");
    subwindow.setModal(true);
    subwindow.setWidth("650px");

    VerticalLayout layout = (VerticalLayout) subwindow.getContent();
    layout.setMargin(true);
    layout.setSpacing(true);

    final TextField txtName = new TextField("Name");
    txtName.setValue(adminDescriptor.getName());
    txtName.setImmediate(true);
    txtName.setValidationVisible(true);
    final TextArea txtContent = new TextArea("Content");
    txtContent.setColumns(30);
    txtContent.setRows(40);
    try {
        txtContent.setValue(adminDescriptor.getContentAsString());
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    txtContent.setColumns(30);

    Button addAdmDescButton = new Button("Add Description");
    addAdmDescButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {

            if (txtName.getValue().toString() == null) {
                router.getMainWindow().showNotification(ViewConstants.PLEASE_ENTER_A_NAME,
                        Notification.TYPE_ERROR_MESSAGE);

            } else if (!XmlUtil.isWellFormed(txtContent.getValue().toString())) {
                router.getMainWindow().showNotification(ViewConstants.XML_IS_NOT_WELL_FORMED,
                        Notification.TYPE_ERROR_MESSAGE);
            } else {
                controller.addAdminDescriptor(txtName.getValue().toString(), txtContent.getValue().toString());
                (subwindow.getParent()).removeWindow(subwindow);
                router.getMainWindow().showNotification("Addedd Successfully",
                        Notification.TYPE_HUMANIZED_MESSAGE);
            }
        }
    });

    subwindow.addComponent(txtName);
    subwindow.addComponent(txtContent);
    subwindow.addComponent(addAdmDescButton);

    Button close = new Button(ViewConstants.CLOSE, new Button.ClickListener() {
        @Override
        public void buttonClick(@SuppressWarnings("unused") ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
        }
    });
    layout.addComponent(close);
    layout.setComponentAlignment(close, Alignment.TOP_RIGHT);

    router.getMainWindow().addWindow(subwindow);

}

From source file:org.escidoc.browser.ui.listeners.OnEditContainerMetadata.java

License:Open Source License

private static Window buildModalWindow() {
    final Window subwindow = new Window(ViewConstants.EDIT_METADATA);
    subwindow.setWidth("600px");
    subwindow.setModal(true);
    return subwindow;
}

From source file:org.escidoc.browser.ui.listeners.RelationsClickListener.java

License:Open Source License

@Override
public void buttonClick(final ClickEvent event) {
    final Window subwindow = new Window("Relations");
    subwindow.setWidth("600px");
    subwindow.setModal(true);

    String id = "";
    if (event.getButton().getCaption().equals("Container Content Relations")) {
        id = containerProxy.getId();//from w w w.ja v a 2 s  .c  o  m
    } else if (event.getButton().getCaption().equals("Item Content Relations")) {
        id = itemProxy.getId();
    } else {
        throw new RuntimeException("Bug: unexpected event button: " + event.getButton());
    }

    try {
        content = getRelations(itemOrContainerRepository, id, subwindow);
    } catch (final EscidocClientException e) {
        content = new HorizontalLayout();
        content.addComponent(new Label("No information available"));
    }

    subwindow.addComponent(content);
    if (subwindow.getParent() != null) {
        mainWindow.showNotification("Window is already open");
    } else {
        mainWindow.addWindow(subwindow);
    }
}

From source file:org.escidoc.browser.ui.listeners.ResourceDeleteConfirmation.java

License:Open Source License

private void delete(final Container container, final ContainerRepository containerRepository,
        final Window mainWindow) {
    final Window subwindow = new Window(ViewConstants.DELETE_RESOURCE_WINDOW_NAME);
    subwindow.setModal(true);
    final Label message = new Label(ViewConstants.QUESTION_DELETE_RESOURCE);
    subwindow.addComponent(message);//ww  w.  j  a  v a 2 s .  c om

    @SuppressWarnings("serial")
    final Button okConfirmed = new Button("Yes", new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
            try {
                containerRepository.finalDelete(container);
                mainWindow.showNotification(
                        new Window.Notification(ViewConstants.DELETED, Notification.TYPE_TRAY_NOTIFICATION));
            } catch (final EscidocClientException e) {
                mainWindow.showNotification(new Window.Notification(ViewConstants.ERROR, e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE));
            }
        }

    });
    @SuppressWarnings("serial")
    final Button cancel = new Button("Cancel", new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
        }
    });
    final HorizontalLayout hl = new HorizontalLayout();
    hl.addComponent(okConfirmed);
    hl.addComponent(cancel);
    subwindow.addComponent(hl);
    mainWindow.addWindow(subwindow);
}

From source file:org.escidoc.browser.ui.listeners.ResourceDeleteConfirmation.java

License:Open Source License

private void delete(final Item item, final ItemRepository itemRepository, final Window mainWindow)
        throws EscidocClientException {
    final Window subwindow = new Window(ViewConstants.DELETE_RESOURCE_WINDOW_NAME);
    subwindow.setModal(true);
    Label message = new Label(ViewConstants.QUESTION_DELETE_RESOURCE);
    subwindow.addComponent(message);//from   w ww. j  a v a  2s  . c  o  m

    @SuppressWarnings("serial")
    Button okConfirmed = new Button("Yes", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
            try {
                itemRepository.finalDelete(item);
                mainWindow.showNotification(
                        new Window.Notification(ViewConstants.DELETED, Notification.TYPE_TRAY_NOTIFICATION));
            } catch (EscidocClientException e) {
                mainWindow.showNotification(new Window.Notification(ViewConstants.ERROR, e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE));
            }
        }

    });
    @SuppressWarnings("serial")
    Button cancel = new Button("Cancel", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
        }
    });
    HorizontalLayout hl = new HorizontalLayout();
    hl.addComponent(okConfirmed);
    hl.addComponent(cancel);
    subwindow.addComponent(hl);
    mainWindow.addWindow(subwindow);
}

From source file:org.escidoc.browser.ui.listeners.VersionHistoryClickListener.java

License:Open Source License

@Override
public void buttonClick(final ClickEvent event) {
    final Window subwindow = new Window("Version History");
    subwindow.setWidth("600px");
    subwindow.setModal(true);

    // if (event.getButton().getCaption().equals("Container Version History")
    // || event.getButton().getCaption().equals(" Has previous version")) {
    // id = containerProxy.getId();
    // }/*  w  ww .j  av a  2s . c om*/
    // else if (event.getButton().getCaption().equals("Item Version History")
    // || event.getButton().getCaption().equals(" Has previous versions")) {
    // id = itemProxy.getId();
    // }
    // else {
    // throw new RuntimeException("Bug: unexpected event button: " + event.getButton());
    // }

    try {
        wndContent = getVersionHistory(repository, id);
    } catch (final EscidocClientException e) {

        wndContent = "No information ?" + e.getMessage();
    }

    final Label msgWindow = new Label(wndContent, Label.CONTENT_RAW);

    subwindow.addComponent(msgWindow);
    if (subwindow.getParent() != null) {
        mainWindow.showNotification("Window is already open");
    } else {
        mainWindow.addWindow(subwindow);
    }
}

From source file:org.escidoc.browser.ui.maincontent.ContainerMetadataRecordsView.java

License:Open Source License

@SuppressWarnings("serial")
private Panel lblAddtionalResources() {
    final Panel pnl = new Panel();
    pnl.setSizeFull();//  w ww. j a  v a2 s.  com
    VerticalLayout hl = new VerticalLayout();
    hl.setSizeFull();
    final Button btnVersionHistoryContainer = new Button("Container Version History",
            new VersionHistoryClickListener(resourceProxy, mainWindow, repositories));
    btnVersionHistoryContainer.setStyleName(BaseTheme.BUTTON_LINK);
    btnVersionHistoryContainer.setDescription("Show Version history in a Pop-up");

    final CssLayout cssLayout = new CssLayout();
    buildPanelHeader(cssLayout, "Additional Resources");
    ThemeResource ICON = new ThemeResource("images/assets/plus.png");

    final Button addResourceButton = new Button();
    addResourceButton.setStyleName(BaseTheme.BUTTON_LINK);
    addResourceButton.addStyleName("floatright paddingtop3");
    addResourceButton.setWidth("20px");
    addResourceButton.setIcon(ICON);
    addResourceButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(final ClickEvent event) {
            final Window subwindow = new Window("A modal subwindow");
            subwindow.setModal(true);
            subwindow.setWidth("650px");
            VerticalLayout layout = (VerticalLayout) subwindow.getContent();
            layout.setMargin(true);
            layout.setSpacing(true);

            subwindow.addComponent(new Label("Not yet implemented"));
            Button close = new Button("Close", new Button.ClickListener() {
                @Override
                public void buttonClick(@SuppressWarnings("unused") ClickEvent event) {
                    (subwindow.getParent()).removeWindow(subwindow);
                }
            });
            layout.addComponent(close);
            layout.setComponentAlignment(close, Alignment.TOP_RIGHT);

            router.getMainWindow().addWindow(subwindow);

        }

    });
    cssLayout.addComponent(addResourceButton);
    hl.addComponent(cssLayout);

    hl.addComponent(btnVersionHistoryContainer);
    pnl.setContent(hl);
    return pnl;
}

From source file:org.escidoc.browser.ui.maincontent.ContextRightPanel.java

License:Open Source License

@SuppressWarnings("serial")
private Panel buildOrganizationUnit() {
    final Panel pnlOrgUnit = new Panel();
    pnlOrgUnit.setSizeFull();//from   w  ww  .  ja v  a 2 s .co  m
    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();

    final CssLayout cssLayout = new CssLayout();
    buildPanelHeader(cssLayout, ViewConstants.ORGANIZATIONAL_UNIT);
    ThemeResource ICON = new ThemeResource("images/assets/plus.png");

    if (contextController.canAddOUs()) {
        final Button addResourceButton = new Button();
        addResourceButton.setStyleName(BaseTheme.BUTTON_LINK);
        addResourceButton.addStyleName("floatright paddingtop3");
        addResourceButton.setWidth("20px");
        addResourceButton.setIcon(ICON);
        addResourceButton.addListener(new ClickListener() {

            @Override
            public void buttonClick(@SuppressWarnings("unused") final ClickEvent event) {
                final Window subwindow = new Window("A modal subwindow");
                subwindow.setModal(true);
                subwindow.setWidth("650px");
                VerticalLayout layout = (VerticalLayout) subwindow.getContent();
                layout.setMargin(true);
                layout.setSpacing(true);

                try {
                    subwindow.addComponent(new AddOrgUnitstoContext(router, resourceProxy, contextController,
                            resourceProxy.getOrganizationalUnit()));
                } catch (EscidocClientException e) {
                    contextController.showError(e);
                }
                Button close = new Button(ViewConstants.CLOSE, new Button.ClickListener() {
                    @Override
                    public void buttonClick(@SuppressWarnings("unused") ClickEvent event) {
                        subwindow.getParent().removeWindow(subwindow);
                    }
                });
                layout.addComponent(close);
                layout.setComponentAlignment(close, Alignment.TOP_RIGHT);

                router.getMainWindow().addWindow(subwindow);

            }

        });
        cssLayout.addComponent(addResourceButton);
    }
    vl.addComponent(cssLayout);

    OrganizationalUnitsTableVH orgUnitTable = new OrganizationalUnitsTableVH(contextController,
            resourceProxy.getOrganizationalUnit(), router, resourceProxy);
    orgUnitTable.buildTable();
    vl.addComponent(orgUnitTable);
    vl.setComponentAlignment(orgUnitTable, Alignment.TOP_LEFT);
    vl.setExpandRatio(orgUnitTable, 9f);

    pnlOrgUnit.setContent(vl);
    return pnlOrgUnit;
}

From source file:org.escidoc.browser.ui.maincontent.ContextView.java

License:Open Source License

/**
 * Called in the reSwapComponents()//from   w w w . j  a v a  2s.  c o  m
 * 
 * @return String
 */
public void addCommentWindow(final String status) {
    final Window subwindow = new Window(ViewConstants.SUBWINDOW_EDIT);
    subwindow.setModal(true);
    // Configure the windws layout; by default a VerticalLayout
    VerticalLayout layout = (VerticalLayout) subwindow.getContent();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeUndefined();

    final TextArea editor = new TextArea("Your Comment");
    editor.setRequired(true);
    editor.setRequiredError("The Field may not be empty.");

    HorizontalLayout hl = new HorizontalLayout();

    Button close = new Button("Update", new Button.ClickListener() {

        @Override
        public void buttonClick(@SuppressWarnings("unused") com.vaadin.ui.Button.ClickEvent event) {
            // close the window by removing it from the parent window
            String comment = editor.getValue().toString();
            try {
                contextController.updatePublicStatus(status, resourceProxy.getId(), comment);
                mainWindow.showNotification("Context Status updated successfully",
                        Notification.TYPE_TRAY_NOTIFICATION);
            } catch (EscidocClientException e) {
                mainWindow.showNotification(
                        "Could not update Context Type, an error occurred" + e.getLocalizedMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
            }
            (subwindow.getParent()).removeWindow(subwindow);

        }
    });
    Button cancel = new Button("Cancel", new Button.ClickListener() {
        @Override
        public void buttonClick(@SuppressWarnings("unused") com.vaadin.ui.Button.ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);

        }
    });

    hl.addComponent(close);
    hl.addComponent(cancel);

    subwindow.addComponent(editor);
    subwindow.addComponent(hl);
    mainWindow.addWindow(subwindow);
}

From source file:org.escidoc.browser.ui.maincontent.ItemContent.java

License:Open Source License

private void initView() {
    final CssLayout cssLayout = new CssLayout();
    cssLayout.setHeight("20px");
    buildPanelHeader(cssLayout, ViewConstants.COMPONENTS);
    ThemeResource ICON = new ThemeResource("images/assets/plus.png");

    if (true) {/*from  w w  w  . j a v  a  2 s .c om*/
        final Button btnAddNew = new Button();
        btnAddNew.addListener(new Button.ClickListener() {
            @Override
            public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {
                Window modalWindow = new Window("Select a file to add.");
                modalWindow.setWidth("25%");
                modalWindow.setHeight("20%");
                modalWindow.setModal(true);
                modalWindow.addComponent(new ComponentUploadView(repositories, controller, itemProxy,
                        ItemContent.this, mainWindow));
                mainWindow.addWindow(modalWindow);
            }
        });
        btnAddNew.setStyleName(BaseTheme.BUTTON_LINK);
        btnAddNew.addStyleName("floatright paddingtop3");
        btnAddNew.setWidth("20px");
        btnAddNew.setIcon(ICON);
        cssLayout.addComponent(btnAddNew);
    }

    verticalLayout.addComponent(cssLayout);
    wrap(verticalLayout);
    if (controller.hasComponents()) {
        verticalLayout.addComponent(buildTable());
    } else {
        final Label lblNoComponents = new Label(
                "No components in this Item. You can drag n'drop some file from your computer to this box to add new components!");
        lblNoComponents.setWidth("90%");
        lblNoComponents.setStyleName("skybluetext");
        verticalLayout.addComponent(lblNoComponents);
    }
}