com.vaadin.ui.Window Java Examples

The following examples show how to use com.vaadin.ui.Window. 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: NoUserSessionHandler.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
protected void doHandle(App app, String className, String message, @Nullable Throwable throwable) {
    try {
        AppUI ui = AppUI.getCurrent();

        // we may show two or more dialogs if user pressed F5 and we have no valid user session
        // just remove previous dialog and show new
        List<Window> noUserSessionDialogs = ui.getWindows().stream()
                .filter(w -> w instanceof NoUserSessionExceptionDialog)
                .collect(Collectors.toList());
        for (Window dialog : noUserSessionDialogs) {
            ui.removeWindow(dialog);
        }

        showNoUserSessionDialog(ui);
    } catch (Throwable th) {
        log.error("Unable to handle NoUserSessionException", throwable);
        log.error("Exception in NoUserSessionHandler", th);
    }
}
 
Example #3
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 #4
Source File: DemoUI.java    From gantt with Apache License 2.0 6 votes vote down vote up
private void commit(final Window win, final Binder<? extends AbstractStep> binder,
        final NativeSelect<Step> parentStepSelect) {
    AbstractStep step = binder.getBean();
    gantt.markStepDirty(step);
    if (parentStepSelect.isEnabled() && parentStepSelect.getValue() != null) {
        SubStep subStep = addSubStep(parentStepSelect, step);
        step = subStep;
    }
    if (step instanceof Step && !gantt.getSteps().contains(step)) {
        gantt.addStep((Step) step);
    }
    if (ganttListener != null && step instanceof Step) {
        ganttListener.stepModified((Step) step);
    }
    win.close();
}
 
Example #5
Source File: LoadBalancerButtonsBottom.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
private void editButtonClick(ClickEvent event) {
    LoadBalancerDto loadBalancer = (LoadBalancerDto) sender.loadBalancerPanel.loadBalancerTable.getValue();

    Window winLoadBalancerEdit;
    if (PCCConstant.PLATFORM_TYPE_CLOUDSTACK.equals(loadBalancer.getLoadBalancer().getType())) {
        winLoadBalancerEdit = new WinCloudStackLoadBalancerEdit(loadBalancer.getLoadBalancer().getLoadBalancerNo());
    } else {
        winLoadBalancerEdit = new WinLoadBalancerEdit(loadBalancer.getLoadBalancer().getLoadBalancerNo());
    }

    winLoadBalancerEdit.addListener(new Window.CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            refreshTable();
        }
    });

    getWindow().addWindow(winLoadBalancerEdit);
}
 
Example #6
Source File: WinServerAdd.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void attachButtonClick(ClickEvent event) {
    if (cloudTable.getValue() == null || imageTable.getValue() == null) {
        return;
    }

    ImageDto image = findImage(cloudTable.getValue(), imageTable.getValue());

    WinServerAttachService winServerAttachService = new WinServerAttachService(null, image,
            selectedComponentNos);
    winServerAttachService.addListener(new Window.CloseListener() {
        @Override
        public void windowClose(Window.CloseEvent e) {
            List<Long> componentNos = (List<Long>) ContextUtils.getAttribute("componentNos");
            if (componentNos != null) {
                ContextUtils.removeAttribute("componentNos");
                selectedComponentNos = componentNos;
            }
        }
    });

    getWindow().getApplication().getMainWindow().addWindow(winServerAttachService);
}
 
Example #7
Source File: WinServerEdit.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void addButtonClick(ClickEvent event) {
    WinServerDataDiskConfig winServerDataDiskConfig = new WinServerDataDiskConfig(getApplication(),
            instance.getInstance().getInstanceNo(), null);
    winServerDataDiskConfig.addListener(new Window.CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            dataDiskTable.loadData();
            dataDiskTable.show();
        }
    });
    getWindow().getApplication().getMainWindow().addWindow(winServerDataDiskConfig);
}
 
Example #8
Source File: SubSetSelector.java    From viritin with Apache License 2.0 5 votes vote down vote up
protected void addEntity(String stringInput) {
    final ET newInstance = instantiateOption(stringInput);

    if (newInstanceForm != null) {
        String caption = "Add new " + elementType.getSimpleName();
        newInstanceForm.setEntity(newInstance);
        newInstanceForm.setSavedHandler(this);
        newInstanceForm.setResetHandler(this);
        Window w = newInstanceForm.openInModalPopup();
        w.setWidth("70%");
        w.setCaption(caption);
    } else {
        onSave(newInstance);
    }
}
 
Example #9
Source File: InvoiceForm.java    From jpa-invoicer with The Unlicense 5 votes vote down vote up
@Override
public Window openInModalPopup() {
    final Window p = super.openInModalPopup();
    p.setWidth("80%");
    p.setHeight("95%");
    return p;
}
 
Example #10
Source File: InvoicerForm.java    From jpa-invoicer with The Unlicense 5 votes vote down vote up
@Override
public Window openInModalPopup() {
    final Window window = super.openInModalPopup();
    window.setHeight("80%");
    window.setWidth("50%");
    return window;
}
 
Example #11
Source File: MismatchedUserSessionHandler.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void closeAllDialogs(AppUI ui) {
    List<Window> changedSessionDialogs = ui.getWindows()
            .stream()
            .filter(w -> w instanceof MismatchedUserSessionExceptionDialog)
            .collect(Collectors.toList());

    for (Window dialog : changedSessionDialogs) {
        ui.removeWindow(dialog);
    }
}
 
Example #12
Source File: DialogConfirm.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
public void buttonClick(Button.ClickEvent event) {
    if (getParent() != null) {
        ((Window) getParent()).removeWindow(this);
    }
    if (callback != null) {
        callback.onDialogResult((Result) event.getButton().getData());
    }
}
 
Example #13
Source File: ServiceButtonsBottom.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void addButtonClick(ClickEvent event) {
    WinServiceAdd winServiceAdd = new WinServiceAdd();
    winServiceAdd.addListener(new Window.CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            refreshTable();
        }
    });

    getWindow().addWindow(winServiceAdd);
}
 
Example #14
Source File: ServiceButtonsBottom.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void editButtonClick(Button.ClickEvent event) {
    ComponentDto component = (ComponentDto) sender.servicePanel.serviceTable.getValue();

    WinServiceEdit winServiceEdit = new WinServiceEdit(component.getComponent().getComponentNo());
    winServiceEdit.addListener(new Window.CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            refreshTable();
        }
    });

    getWindow().addWindow(winServiceEdit);
}
 
Example #15
Source File: ServerButtonsBottom.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void addButtonClick(ClickEvent event) {
    WinServerAdd winServerAdd = new WinServerAdd();
    winServerAdd.addListener(new Window.CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            refreshTable();
        }
    });

    getWindow().addWindow(winServerAdd);
}
 
Example #16
Source File: ServerButtonsBottom.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void editButtonClick(Button.ClickEvent event) {
    InstanceDto instance = (InstanceDto) sender.serverPanel.serverTable.getValue();

    WinServerEdit winServerEdit = new WinServerEdit(instance.getInstance().getInstanceNo());
    winServerEdit.addListener(new Window.CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            refreshTable();
        }
    });

    getWindow().addWindow(winServerEdit);
}
 
Example #17
Source File: AbstractForm.java    From viritin with Apache License 2.0 5 votes vote down vote up
public Window openInModalPopup() {
    popup = new Window(getModalWindowTitle(), this);
    popup.setModal(true);
    UI.getCurrent().addWindow(popup);
    focusFirst();
    return popup;
}
 
Example #18
Source File: WinServerEdit.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void editButtonClick(ClickEvent event) {
    DataDiskDto dataDiskDto = (DataDiskDto) dataDiskTable.getValue();
    WinServerDataDiskConfig winServerDataDiskConfig = new WinServerDataDiskConfig(getApplication(),
            instance.getInstance().getInstanceNo(), dataDiskDto);
    winServerDataDiskConfig.addListener(new Window.CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            dataDiskTable.loadData();
            dataDiskTable.show();
        }
    });
    getWindow().getApplication().getMainWindow().addWindow(winServerDataDiskConfig);
}
 
Example #19
Source File: WinServerEdit.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void addButtonClick(ClickEvent event) {
    WinServerNetworkConfig winServerDataDiskConfig = new WinServerNetworkConfig(getApplication(),
            instance.getInstance().getInstanceNo(), instance.getInstance().getPlatformNo(), null,
            instanceNetworks);
    winServerDataDiskConfig.addListener(new Window.CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            //テーブル再表示
            networkTable.loadData();
            networkTable.show();
        }
    });
    getWindow().getApplication().getMainWindow().addWindow(winServerDataDiskConfig);
}
 
Example #20
Source File: WinServerEdit.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void editButtonClick(ClickEvent event) {
    InstanceNetworkDto instanceNetwork = (InstanceNetworkDto) networkTable.getValue();
    WinServerNetworkConfig winServerDataDiskConfig = new WinServerNetworkConfig(getApplication(),
            instance.getInstance().getInstanceNo(), instance.getInstance().getPlatformNo(), instanceNetwork,
            instanceNetworks);
    winServerDataDiskConfig.addListener(new Window.CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            //テーブル再表示
            networkTable.loadData();
            networkTable.show();
        }
    });
    getWindow().getApplication().getMainWindow().addWindow(winServerDataDiskConfig);
}
 
Example #21
Source File: LoadBalancerButtonsBottom.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void addButtonClick(ClickEvent event) {
    WinLoadBalancerAdd winLoadBalancerAdd = new WinLoadBalancerAdd();
    winLoadBalancerAdd.addListener(new Window.CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            refreshTable();
        }
    });

    getWindow().addWindow(winLoadBalancerAdd);
}
 
Example #22
Source File: LoadBalancerDescBasic.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void editButtonClick(Button.ClickEvent event) {
    LoadBalancerListener listener = (LoadBalancerListener) event.getButton().getData();

    WinLoadBalancerConfigListener win = new WinLoadBalancerConfigListener(listener.getLoadBalancerNo(),
            listener.getLoadBalancerPort());
    win.addListener(new Window.CloseListener() {
        @Override
        public void windowClose(Window.CloseEvent e) {
            refreshTable();
        }
    });

    getWindow().addWindow(win);
}
 
Example #23
Source File: LoadBalancerDescBasic.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void addButtonClick(Button.ClickEvent event) {
    WinLoadBalancerConfigListener win = new WinLoadBalancerConfigListener(
            loadBalancer.getLoadBalancer().getLoadBalancerNo(), null);
    win.addListener(new Window.CloseListener() {
        @Override
        public void windowClose(Window.CloseEvent e) {
            refreshTable();
        }
    });

    getWindow().addWindow(win);
}
 
Example #24
Source File: MainView.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
public void showLogin() {
    WinLogin winLogin = new WinLogin();
    winLogin.addListener(new Window.CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            // ログインに成功した場合
            Long userNo = ViewContext.getUserNo();
            if (userNo != null) {
                topBar.loginSuccess();
            }
        }
    });
    getApplication().getMainWindow().addWindow(winLogin);
}
 
Example #25
Source File: AbstractForm.java    From viritin with Apache License 2.0 5 votes vote down vote up
public Window openInModalPopup() {
    popup = new Window(getModalWindowTitle(), this);
    popup.setModal(true);
    UI.getCurrent().addWindow(popup);
    focusFirst();
    return popup;
}
 
Example #26
Source File: WindowBuilder.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private void decorateWindow(final Window window) {
    if (id != null) {
        window.setId(id);
    }

    if (SPUIDefinitions.CONFIRMATION_WINDOW.equals(type)) {
        window.setDraggable(false);
        window.setClosable(true);
        window.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION);

    } else if (SPUIDefinitions.CREATE_UPDATE_WINDOW.equals(type)) {
        window.setDraggable(true);
        window.setClosable(true);
    }
}
 
Example #27
Source File: VaadinUtils.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Return the window where a component is attached
 * @param component
 * @return the window or null if none
 */
public static Window getWindow(Component component) {
	while (component.getParent() != null) {
		if (component.getParent() instanceof Window)
			return (Window) component.getParent();
		
		component = component.getParent();
	}
	
	return null;
}
 
Example #28
Source File: CancelAction.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void buttonClick(ClickEvent event) {

	Window window = VaadinUtils.getWindow(getView().getPanel());
	
	if (window != null)
		getView().getPanel().getUI().removeWindow(window);
	
	if (getView() instanceof Editor) {
		((Editor<?>) getView()).cancel();
	}
}
 
Example #29
Source File: DefaultExceptionHandler.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void showDialog(App app, AppUI ui, Throwable exception) {
    Throwable rootCause = ExceptionUtils.getRootCause(exception);
    if (rootCause == null) {
        rootCause = exception;
    }
    ExceptionDialog dialog = new ExceptionDialog(rootCause);
    for (Window window : ui.getWindows()) {
        if (window.isModal()) {
            dialog.setModal(true);
            break;
        }
    }
    ui.addWindow(dialog);
    dialog.focus();
}
 
Example #30
Source File: App.java    From cuba with Apache License 2.0 5 votes vote down vote up
/**
 * Removes all windows in the given {@code uis}.
 *
 * @param uis {@link AppUI} instances
 */
protected void removeAllWindows(List<AppUI> uis) {
    log.debug("Closing all windows in all UIs");
    try {
        for (AppUI ui : uis) {
            Screens screens = ui.getScreens();
            if (screens != null) {
                Screen rootScreen = screens.getOpenedScreens().getRootScreenOrNull();
                if (rootScreen != null) {
                    screens.removeAll();

                    screens.remove(rootScreen);
                }
            }

            // also remove all native Vaadin windows, that is not under CUBA control
            Window[] windows = ui.getWindows().toArray(new Window[0]);

            for (com.vaadin.ui.Window win : windows) {
                ui.removeWindow(win);
            }

            List<Notification> notifications = ui.getExtensions()
                    .stream()
                    .filter(ext -> ext instanceof Notification)
                    .map(ext -> (Notification) ext)
                    .collect(Collectors.toList());

            notifications.forEach(Notification::close);

        }
    } catch (Throwable e) {
        log.error("Error closing all windows", e);
    }
}