Example usage for com.vaadin.ui Window Window

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

Introduction

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

Prototype

public Window(String caption) 

Source Link

Document

Creates a new, empty window with a given title.

Usage

From source file:org.casbah.ui.CasbahMainApplication.java

License:Open Source License

@Override
public void init() {
    try {/*from   ww  w  .  j ava 2 s.  c o m*/
        window = new Window("CASBaH Application");
        setMainWindow(window);
        final CasbahConfiguration config = CasbahConfiguration.loadConfiguration();
        provider = config.getProvider();
        if (!provider.isCASetup()) {
            logger.warning("CA is not setup, setting it up now");
            final SetupCaComponent scc = new SetupCaComponent(this);
            scc.init(new Button.ClickListener() {

                @Override
                public void buttonClick(ClickEvent event) {
                    try {
                        provider.setUpCA(scc.getPrincipal().toX500Principal(), scc.getPassphrase());
                        buildMainLayout(config);
                    } catch (CasbahException e) {
                        getMainWindow().showNotification("An exception prevented setting up the CA",
                                Notification.TYPE_ERROR_MESSAGE);
                    }

                }
            });
            getMainWindow().setContent(scc);
        } else {
            buildMainLayout(config);
        }
    } catch (CAProviderException cpe) {
        cpe.printStackTrace();
    } catch (CasbahException ce) {
        ce.printStackTrace();
    }
}

From source file:org.casbah.ui.IssuedCertificateList.java

License:Open Source License

private void collectKeyCertificateInfo() throws CAProviderException {
    final Window principalWindow = new Window("Specify Certificate Details");
    principalWindow.setPositionX(200);/*from  ww  w.  j a v  a2s .  c  o  m*/
    principalWindow.setPositionY(100);
    principalWindow.setWidth("600px");
    principalWindow.setHeight("500px");
    principalWindow.addListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1L;

        public void windowClose(CloseEvent e) {
            parentApplication.getMainWindow().removeWindow(principalWindow);

        }
    });

    VerticalLayout vl = new VerticalLayout();
    final PrincipalComponent pc = new PrincipalComponent();
    Principal parentPrincipal = new Principal(provider.getCACertificate().getSubjectX500Principal());
    pc.init(new Principal(parentPrincipal, provider.getRuleMap()));
    vl.addComponent(pc);
    HorizontalLayout passLayout = new HorizontalLayout();
    vl.addComponent(passLayout);
    final TextField pass1 = new TextField("Private key/keystore passphrase");
    pass1.setSecret(true);
    final TextField pass2 = new TextField();
    pass2.setSecret(true);
    passLayout.addComponent(pass1);
    passLayout.addComponent(pass2);
    passLayout.setComponentAlignment(pass1, Alignment.BOTTOM_CENTER);
    passLayout.setComponentAlignment(pass2, Alignment.BOTTOM_CENTER);

    final OptionGroup type = new OptionGroup("Bundle Type");
    type.addItem(BundleType.OPENSSL);
    type.addItem(BundleType.PKCS12);
    type.addItem(BundleType.JKS);
    type.setValue(BundleType.OPENSSL);
    vl.addComponent(type);

    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.addComponent(new Button("Create", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (pass1.getValue().equals(pass2.getValue())) {
                try {
                    createKeyCertificatePair(pc.toPrincipal(), (String) pass1.getValue(),
                            (BundleType) type.getValue());
                    parentApplication.getMainWindow().removeWindow(principalWindow);
                } catch (Exception e) {
                    logger.severe(e.getMessage());
                    parentApplication.getMainWindow().showNotification(
                            "An error prevented the correct creation of the key/certificate pair",
                            Notification.TYPE_ERROR_MESSAGE);
                }
            } else {
                parentApplication.getMainWindow().showNotification("Passphrases do not match",
                        Notification.TYPE_ERROR_MESSAGE);
            }
        }
    }));
    buttonsLayout.addComponent(new Button("Cancel", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            parentApplication.getMainWindow().removeWindow(principalWindow);
        }
    }));

    vl.addComponent(buttonsLayout);
    principalWindow.setContent(vl);
    parentApplication.getMainWindow().addWindow(principalWindow);
}

From source file:org.casbah.ui.MainCAView.java

License:Open Source License

private void uploadAndSignCsr() throws CAProviderException {
    final Window csrWindow = new Window("Upload CSR");
    csrWindow.setPositionX(200);//from w ww.  j a  v  a2  s  .  c  o m
    csrWindow.setPositionY(100);
    csrWindow.setWidth("800px");
    csrWindow.setHeight("300px");
    csrWindow.addListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1L;

        public void windowClose(CloseEvent e) {
            application.getMainWindow().removeWindow(csrWindow);

        }
    });

    final TextField csrData = new TextField("DER Encoded CSR");
    csrData.setColumns(80);
    csrData.setRows(20);
    csrData.setWordwrap(false);
    csrWindow.addComponent(csrData);
    HorizontalLayout hl = new HorizontalLayout();
    csrWindow.addComponent(hl);
    hl.addComponent(new Button("Cancel", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            application.getMainWindow().removeWindow(csrWindow);

        }
    }));
    hl.addComponent(new Button("Upload", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            String csr = (String) csrData.getValue();
            try {
                X509Certificate result = provider.sign(csr);
                showEncodedCertificate(result, result.getSerialNumber().toString(16));

            } catch (CAProviderException cpe) {
                cpe.printStackTrace();
            }
        }
    }));
    csrWindow.setModal(true);
    application.getMainWindow().addWindow(csrWindow);
}

From source file:org.casbah.ui.MainCAView.java

License:Open Source License

private void showEncodedCertificate(X509Certificate cert, String serialNumber) throws CAProviderException {
    final Window certWindow = new Window(serialNumber);
    certWindow.setPositionX(200);//  w w  w .  j  av a 2 s  .  c  om
    certWindow.setPositionY(100);
    certWindow.setWidth("800px");
    certWindow.setHeight("300px");
    certWindow.addListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1L;

        public void windowClose(CloseEvent e) {
            application.getMainWindow().removeWindow(certWindow);

        }
    });
    String certData = CertificateHelper.encodeCertificate(cert, true);
    TextField encodedCert = new TextField("Encoded Certificate", certData);
    encodedCert.setReadOnly(true);
    encodedCert.setColumns(80);
    encodedCert.setRows(certData.split("\n").length);
    encodedCert.setWordwrap(false);
    certWindow.addComponent(encodedCert);
    certWindow.addComponent(new Button("Close", new Button.ClickListener() {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            application.getMainWindow().removeWindow(certWindow);
        }
    }));
    certWindow.setModal(true);
    application.getMainWindow().addWindow(certWindow);

}

From source file:org.codingvienna.dc6.vaadin.widgetset.DC6Application.java

License:Open Source License

@Override
public void init() {
    Window mainWindow = new Window("DC6Application");
    setMainWindow(mainWindow);
}

From source file:org.eclipse.hawkbit.ui.common.builder.WindowBuilder.java

License:Open Source License

/**
 * Build window based on type.//from w  w w. ja  v  a 2 s  .  c  om
 *
 * @return Window
 */
public Window buildWindow() {
    final Window window = new Window(caption);
    window.setContent(content);
    window.setSizeUndefined();
    window.setModal(true);
    window.setResizable(false);

    decorateWindow(window);

    if (SPUIDefinitions.CREATE_UPDATE_WINDOW.equals(type)) {
        window.setClosable(false);
    }

    return window;
}

From source file:org.eclipse.hawkbit.ui.common.ConfirmationDialog.java

License:Open Source License

/**
 * Constructor for configuring confirmation dialog.
 * // w  ww. jav a2 s .co  m
 * @param caption
 *            the dialog caption.
 * @param question
 *            the question.
 * @param okLabel
 *            the Ok button label.
 * @param cancelLabel
 *            the cancel button label.
 * @param callback
 *            the callback.
 * @param icon
 *            the icon of the dialog
 * @param id
 *            the id of the confirmation dialog
 * @param tab
 *            ConfirmationTab which contains more information about the
 *            action which has to be confirmed, e.g. maintenance window
 * @param mapCloseToCancel
 *            Flag indicating whether or not the close event on the
 *            enclosing window should be mapped to a cancel event.
 */
public ConfirmationDialog(final String caption, final String question, final String okLabel,
        final String cancelLabel, final ConfirmationDialogCallback callback, final Resource icon,
        final String id, final ConfirmationTab tab, final boolean mapCloseToCancel) {
    window = new Window(caption);
    if (!StringUtils.isEmpty(id)) {
        window.setId(id);
    }
    window.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION);

    if (icon != null) {
        window.setIcon(icon);
    }

    okButton = createOkButton(okLabel);

    final Button cancelButton = createCancelButton(cancelLabel);
    if (mapCloseToCancel) {
        window.addCloseListener(e -> {
            if (!isImplicitClose) {
                cancelButton.click();
            }
        });
    }
    window.setModal(true);
    window.addStyleName(SPUIStyleDefinitions.CONFIRMBOX_WINDOW_STYLE);
    if (this.callback == null) {
        this.callback = callback;
    }
    final VerticalLayout vLayout = new VerticalLayout();
    if (question != null) {
        vLayout.addComponent(createConfirmationQuestion(question));
    }
    if (tab != null) {
        vLayout.addComponent(tab);
    }

    final HorizontalLayout hButtonLayout = createButtonLayout(cancelButton);
    hButtonLayout.addStyleName("marginTop");
    vLayout.addComponent(hButtonLayout);
    vLayout.setComponentAlignment(hButtonLayout, Alignment.BOTTOM_CENTER);

    window.setContent(vLayout);
    window.setResizable(false);
}

From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ReviewComponent.java

License:Open Source License

@SuppressWarnings("serial")
private Window createReviewWindow(final ProjectRating rating) {
    final Window subwindow = new Window("Rate and Review");
    subwindow.setModal(true);/*from  ww  w . j a  va2s.  co  m*/
    subwindow.setWidth("420px"); //$NON-NLS-1$
    subwindow.setHeight("320px"); //$NON-NLS-1$

    VerticalLayout vl = (VerticalLayout) subwindow.getContent();
    vl.setSpacing(true);
    vl.setSizeFull();

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSizeUndefined();

    Embedded icon = new Embedded(null, getIcon(rating));
    Label iconLabel = new Label("<b>" + HSPACE + getReviewComment(rating) + "</b>", Label.CONTENT_XHTML); //$NON-NLS-1$ //$NON-NLS-2$
    String captionTextField = getReviewCommentQuestion(rating);
    hl.addComponent(icon);
    hl.addComponent(iconLabel);
    hl.setComponentAlignment(iconLabel, Alignment.MIDDLE_LEFT);
    vl.addComponent(hl);

    final TextField editor = new TextField(captionTextField);
    editor.setRows(3);
    editor.setColumns(30);
    editor.setImmediate(true);
    vl.addComponent(editor);

    final User user = util.getLoggedInUser();
    final ArrayList<String> userSelects = new ArrayList<String>(2);
    userSelects.add("I want to vote as " + user.getDisplayName());
    if (extension.getAllowAnonymous()) {
        userSelects.add("I want to vote as Anonymous!");
    }
    final OptionGroup userSelect = new OptionGroup(null, userSelects);
    userSelect.setNullSelectionAllowed(false);
    userSelect.select(userSelects.get(0));
    vl.addComponent(userSelect);

    CssLayout css = new CssLayout() {
        @Override
        protected String getCss(Component c) {
            return "margin-left:5px;margin-right:5px;margin-top:10px"; //$NON-NLS-1$
        }
    };

    Button okButton = new Button("OK");
    okButton.setIcon(ICON_BUTTON_OK);
    okButton.setDescription("Commit changes");
    okButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            String comment = (String) editor.getValue();
            if (StringUtils.isBlank(comment)) {
                comment = "No Comment";
            }
            ((Window) subwindow.getParent()).removeWindow(subwindow);
            String userName = "Anonymous";
            if (userSelects.get(0).equals(userSelect.getValue())) {
                userName = user.getDisplayName();
            }
            ReviewEntry review = new ReviewEntry(rating, comment, userName, System.currentTimeMillis());
            extension.addReview(review);
            util.persist(project);
            reviews = extension.getReviews();
            size = reviews.size();
            currentPage = 0;
            lastPage = size / currentPageLength;
            paintReviewList();
        }
    });
    css.addComponent(okButton);

    Button cancelButton = new Button("Cancel");
    cancelButton.setIcon(ICON_BUTTON_CANCEL);
    cancelButton.setDescription("Discard changes");
    cancelButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            ((Window) subwindow.getParent()).removeWindow(subwindow);
        }
    });
    css.addComponent(cancelButton);

    vl.addComponent(css);
    vl.setComponentAlignment(css, Alignment.MIDDLE_CENTER);

    return subwindow;
}

From source file:org.eclipse.skalli.view.internal.application.ProjectApplication.java

License:Open Source License

@Override
public void init() {
    setTheme(DEFAULT_THEME);
    setMainWindow(new Window(WINDOW_TITLE));
}

From source file:org.eneuwirt.MyVaadinApplication.java

License:Apache License

@Override
public void init() {
    this.getContext().addTransactionListener(this);

    this.mainWindow = new Window("My Vaadin Application");

    this.setMainWindow(mainWindow);

    mainWindow.setContent(new LoginScreen(this));
}