Java Code Examples for com.vaadin.ui.Window#setContent()

The following examples show how to use com.vaadin.ui.Window#setContent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WindowBuilder.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Build window based on type.
 *
 * @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;
}
 
Example 2
Source File: AutoApplication.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void init() {
    // エラーハンドリング
    setErrorHandler(new ErrorHandler(this));

    // ログアウト後の画面設定
    String logoutUrl;
    try {
        logoutUrl = new URL(getURL(), "..").toExternalForm();
    } catch (MalformedURLException e) {
        logoutUrl = "../../../";
    }
    setLogoutURL(logoutUrl);

    Window mainWindow = new Window(ViewProperties.getCaption("window.main"));
    mainWindow.setWidth("960px");
    mainWindow.setHeight("100%");
    setTheme("classy");
    setMainWindow(mainWindow);

    MainView mainView = new MainView();
    mainWindow.setContent(mainView);
}
 
Example 3
Source File: SwModuleDetails.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private void showArtifactDetailsWindow(final SoftwareModule softwareModule) {
    final Window artifactDtlsWindow = new Window();
    artifactDtlsWindow.setId(UIComponentIdProvider.SHOW_ARTIFACT_DETAILS_POPUP_ID);
    artifactDtlsWindow.setAssistivePrefix(HawkbitCommonUtil
            .getArtifactoryDetailsLabelId(softwareModule.getName(), getI18n()) + " " + "<b>");
    artifactDtlsWindow.setCaption(softwareModule.getName() + ":" + softwareModule.getVersion());
    artifactDtlsWindow.setAssistivePostfix("</b>");
    artifactDtlsWindow.setClosable(true);
    artifactDtlsWindow.setResizable(true);
    artifactDtlsWindow.setImmediate(true);
    artifactDtlsWindow.setWindowMode(WindowMode.NORMAL);
    artifactDtlsWindow.setModal(true);
    artifactDtlsWindow.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION);

    artifactDetailsLayout.setFullWindowMode(false);
    artifactDetailsLayout.populateArtifactDetails(softwareModule);
    artifactDetailsLayout.getArtifactDetailsTable().setWidth(700, Unit.PIXELS);
    artifactDetailsLayout.getArtifactDetailsTable().setHeight(500, Unit.PIXELS);
    artifactDtlsWindow.setContent(artifactDetailsLayout.getArtifactDetailsTable());

    artifactDtlsWindow.addWindowModeChangeListener(event -> {
        if (event.getWindowMode() == WindowMode.MAXIMIZED) {
            artifactDtlsWindow.setSizeFull();
            artifactDetailsLayout.setFullWindowMode(true);
            artifactDetailsLayout.createMaxArtifactDetailsTable();
            artifactDetailsLayout.getMaxArtifactDetailsTable().setWidth(100, Unit.PERCENTAGE);
            artifactDetailsLayout.getMaxArtifactDetailsTable().setHeight(100, Unit.PERCENTAGE);
            artifactDtlsWindow.setContent(artifactDetailsLayout.getMaxArtifactDetailsTable());
        } else {
            artifactDtlsWindow.setSizeUndefined();
            artifactDtlsWindow.setContent(artifactDetailsLayout.getArtifactDetailsTable());
        }
    });
    UI.getCurrent().addWindow(artifactDtlsWindow);
}
 
Example 4
Source File: JobLogView.java    From chipster with MIT License 5 votes vote down vote up
private void showTextWindow(String caption, String content) {
	
	Label textComponent = new Label(content);
	textComponent.setContentMode(ContentMode.PREFORMATTED);
	
	Window subWindow = new Window(caption);
	subWindow.setContent(textComponent);
	
	subWindow.setWidth(70, Unit.PERCENTAGE);
	subWindow.setHeight(90, Unit.PERCENTAGE);
	subWindow.center();
	
	this.getUI().addWindow(subWindow);
}
 
Example 5
Source File: MismatchedUserSessionHandler.java    From cuba with Apache License 2.0 4 votes vote down vote up
protected void showMismatchedSessionDialog(AppUI ui) {
    Messages messages = beanLocator.get(Messages.class);

    Connection connection = ui.getApp().getConnection();
    //noinspection ConstantConditions
    Locale locale = connection.getSession().getLocale();

    Window dialog = new MismatchedUserSessionExceptionDialog();
    dialog.setStyleName("c-sessionchanged-dialog");
    dialog.setCaption(messages.getMainMessage("dialogs.Information", locale));
    dialog.setClosable(false);
    dialog.setResizable(false);
    dialog.setModal(true);

    CubaLabel messageLab = new CubaLabel();
    messageLab.setWidthUndefined();
    messageLab.setValue(messages.getMainMessage("sessionChangedMsg", locale));

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

    CubaButton reloginBtn = new CubaButton();
    reloginBtn.addStyleName(WebButton.PRIMARY_ACTION_STYLENAME);
    reloginBtn.setCaption(messages.getMainMessage(DialogAction.Type.OK.getMsgKey(), locale));
    reloginBtn.addClickListener(event ->
            ui.getApp().recreateUi(ui));

    String iconName = beanLocator.get(Icons.class)
            .get(DialogAction.Type.OK.getIconKey());
    reloginBtn.setIcon(beanLocator.get(IconResolver.class)
            .getIconResource(iconName));

    ClientConfig clientConfig = beanLocator.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();

    if (ui.isTestMode()) {
        dialog.setCubaId("optionDialog");
        reloginBtn.setCubaId("reloginBtn");
    }

    if (ui.isPerformanceTestMode()) {
        dialog.setId(ui.getTestIdManager().getTestId("optionDialog"));
        reloginBtn.setId(ui.getTestIdManager().getTestId("reloginBtn"));
    }
}
 
Example 6
Source File: NoUserSessionHandler.java    From cuba with Apache License 2.0 4 votes vote down vote up
protected void showNoUserSessionDialog(AppUI ui) {
    Messages messages = beanLocator.get(Messages.class);

    Connection connection = ui.getApp().getConnection();
    //noinspection ConstantConditions
    Locale locale = connection.getSession().getLocale();

    Window dialog = new NoUserSessionExceptionDialog();
    dialog.setStyleName("c-nousersession-dialog");
    dialog.setCaption(messages.getMainMessage("dialogs.Information", locale));
    dialog.setClosable(false);
    dialog.setResizable(false);
    dialog.setModal(true);

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

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

    CubaButton reloginBtn = new CubaButton();
    reloginBtn.addStyleName(WebButton.PRIMARY_ACTION_STYLENAME);
    reloginBtn.addClickListener(event -> relogin());
    reloginBtn.setCaption(messages.getMainMessage(Type.OK.getMsgKey()));

    String iconName = beanLocator.get(Icons.class)
            .get(Type.OK.getIconKey());
    reloginBtn.setIcon(beanLocator.get(IconResolver.class)
            .getIconResource(iconName));

    ClientConfig clientConfig = beanLocator.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();

    if (ui.isTestMode()) {
        dialog.setCubaId("optionDialog");
        reloginBtn.setCubaId("reloginBtn");
    }

    if (ui.isPerformanceTestMode()) {
        dialog.setId(ui.getTestIdManager().getTestId("optionDialog"));
        reloginBtn.setId(ui.getTestIdManager().getTestId("reloginBtn"));
    }
}
 
Example 7
Source File: ConfirmationDialog.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Constructor for configuring confirmation dialog.
 *
 * @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);
}
 
Example 8
Source File: SetGoogleAuthenticatorCredentialClickListener.java    From cia with Apache License 2.0 4 votes vote down vote up
@Override
public void buttonClick(final ClickEvent event) {
	final SetGoogleAuthenticatorCredentialResponse response = (SetGoogleAuthenticatorCredentialResponse) getApplicationManager().service(googleAuthRequest);

	if (ServiceResult.SUCCESS == response.getResult()) {

		try {
			final URI keyUri = new URI(response.getOtpAuthTotpURL());
			final QRCode qrCode = new QRCode(QR_CODE, keyUri.toASCIIString());
			qrCode.setHeight(QR_CODE_IMAGE_SIZE);
			qrCode.setWidth(QR_CODE_IMAGE_SIZE);

			final Window mywindow = new Window(GOOGLE_AUTHENTICATOR_QR_CODE);
			mywindow.setHeight(MODAL_WINDOW_SIZE);
			mywindow.setWidth(MODAL_WINDOW_SIZE);

			mywindow.setPositionX(WINDOW_POSITION);
			mywindow.setPositionY(WINDOW_POSITION);

			final VerticalLayout panelContent = new VerticalLayout();

			mywindow.setContent(panelContent);
			panelContent.addComponent(qrCode);

			mywindow.setModal(true);
			UI.getCurrent().addWindow(mywindow);

		} catch (final URISyntaxException e) {
			LOGGER.warn(PROBLEM_DISPLAYING_QR_CODE,e);
			showNotification(PROBLEM_DISPLAYING_QR_CODE,
	                  ERROR_MESSAGE,
	                  Notification.Type.WARNING_MESSAGE);
		}

	} else {
		showNotification(PROBLEM_ENABLE_GOOGLE_AUTHENTICATOR,
                  ERROR_MESSAGE,
                  Notification.Type.WARNING_MESSAGE);
		LOGGER.info(PROBLEM_ENABLE_GOOGLE_AUTHENTICATOR_SESSIONID,googleAuthRequest.getSessionId());
	}
}