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:dev.DevUI.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {

    final VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSpacing(true);/*from  w ww  .j a v a  2 s.co  m*/
    mainLayout.setMargin(true);

    PluploadManager mgr = createUploadManager("Manager 1");
    PluploadManager mgr2 = createUploadManager("Manager 2");
    PluploadManager mgr3 = createChunkingUploadManager("Manager 3");

    mgr.getUploader().addFilter(new PluploadFilter("music", "mp3,flac"));

    VerticalLayout dropZone = new VerticalLayout() {
        {
            addComponent(new Label("Additional drop zone for music files"));
            setId("music-drop-zone");
        }
    };

    mgr.getUploader().addDropZone(dropZone);

    mgr2.getUploader().addFilter(new PluploadFilter("images", "jpg, jpeg, png"));
    mgr2.getUploader().setImageResize(
            new PluploadImageResize().setEnabled(true).setCrop(true).setHeight(200).setWidth(400));

    mainLayout.addComponent(mgr);
    mainLayout.addComponent(dropZone);
    mainLayout.addComponent(mgr2);
    mainLayout.addComponent(mgr3);

    PluploadField<File> field = createUploadField();
    final Form form = new Form();
    form.addField("file", field);
    field.addValidator(new NullValidator("file must not be null", false));
    Button submit = new Button("commit form");
    submit.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            form.commit();
        }
    });
    mainLayout.addComponent(form);
    mainLayout.addComponent(submit);

    PluploadField<byte[]> byteField = createByteUploadField();
    mainLayout.addComponent(byteField);

    final Plupload uploader = createSimpleUploader();
    uploader.setEnabled(false);
    Button b = new Button("toggle Enabled!", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            uploader.setEnabled(!uploader.isEnabled());
        }
    });
    mainLayout.addComponent(b);
    mainLayout.addComponent(uploader);
    final Counter c = new Counter();
    final Button.ClickListener l = new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window w = new Window("win");

            if (c.get() < 5) {
                w.setContent(new Button("win", this));
                c.increment();
            } else {
                Field f = createUploadField();
                w.setContent(f);
                c.reset();
            }
            w.setWidth("400px");
            w.setHeight("200px");
            getUI().addWindow(w);
        }
    };

    Button win = new Button("Win");
    win.addClickListener(l);
    mainLayout.addComponent(win);

    Button modal = new Button("modal");
    modal.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window w = new Window("modal");

            final PluploadField f = createUploadField();
            w.addCloseListener(new Window.CloseListener() {

                @Override
                public void windowClose(Window.CloseEvent e) {
                    Notification.show("closed modal");
                    f.getUploader().destroy();
                }
            });
            VerticalLayout lay = new VerticalLayout();
            lay.addComponent(f);
            lay.addComponent(new Button("destroy", new Button.ClickListener() {

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    f.getUploader().destroy();
                }
            }));

            w.setContent(lay);
            w.setModal(true);
            getUI().addWindow(w);
        }
    });

    Accordion acc = new Accordion();
    acc.addTab(this.createUploadManager("mgr3"), "uploader");
    acc.addTab(new HorizontalLayout(), "Stub");

    mainLayout.addComponent(acc);

    mainLayout.addComponent(modal);
    this.setContent(mainLayout);

}

From source file:dhbw.ka.mwi.businesshorizon2.ui.initialscreen.projectlist.ProjectListViewImpl.java

License:Open Source License

/**
 * Zeige das Projekt-Hinzufuegen-Dialogfenster, bei dem ein Eingabefeld fuer
 * den Namen des Projekts und ein Hinzfuege-Button vorhanden ist. Funktion
 * bei geklicktem Button siehe Clicklistener in dieser Klasse. Das
 * horizontale Layout zur Darstellung besitzt ein Formlayout und den Button,
 * die nebeneinander dargestellt werden.
 * /*from  w w  w . j  av  a  2  s.  c om*/
 * @author Christian Scherer, Mirko Gpfrich
 */
@Override
public void showAddProjectDialog() {
    addDialog = new Window("Projekt hinzufgen");
    addDialog.setModal(true);
    addDialog.setWidth(410, UNITS_PIXELS);
    addDialog.setResizable(false);
    addDialog.setDraggable(false);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(false);

    FormLayout formLayout = new FormLayout();
    formLayout.setMargin(true);
    formLayout.setSpacing(true);

    //TextFeld fr Name dem Formular hinzufgen
    tfName = new TextField("Name whlen:");
    tfName.setRequired(true);
    tfName.addValidator(new StringLengthValidator("Der Projektname muss zwischen 2 und 20 Zeichen lang sein.",
            2, 20, false));
    tfName.setRequiredError("Pflichtfeld");
    tfName.setSizeFull();
    formLayout.addComponent(tfName);

    //TextArea fr Beschreibung dem Formular hinzufgen
    taDescription = new TextArea("Beschreibung whlen");
    taDescription.setSizeFull();
    formLayout.addComponent(taDescription);

    //Formular dem Layout hinzufgen
    layout.addComponent(formLayout);

    //Hinzufge-Button erstllen und dem Layout hinzufgen
    dialogAddBtn = new Button("Hinzufgen", this);
    layout.addComponent(dialogAddBtn);

    //Layout dem Dialog-Fenster hinzufgen
    addDialog.addComponent(layout);

    //Dialog dem Hauptfenster hinzufgen
    getWindow().addWindow(addDialog);
    logger.debug("Hinzufuege-Dialog erzeugt");
}

From source file:dhbw.ka.mwi.businesshorizon2.ui.initialscreen.projectlist.ProjectListViewImpl.java

License:Open Source License

/**Methode zur Implementierung des Dialogfensters fr Projekt-nderungen.
 * //from  ww w  .  j  a v a 2s  .  c  om
 */
@Override
public void showEditProjectDialog(Project project) {
    editDialog = new Window("Projekt bearbeiten");
    editDialog.setModal(true);
    editDialog.setWidth(410, UNITS_PIXELS);
    editDialog.setResizable(false);
    editDialog.setDraggable(false);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);

    FormLayout formLayout = new FormLayout();
    formLayout.setMargin(true);
    formLayout.setSpacing(true);

    //TextFeld fr Name dem Formular hinzufgen
    tfName = new TextField("Name ndern:", project.getName());
    tfName.setRequired(true);
    tfName.addValidator(new StringLengthValidator("Der Projektname muss zwischen 2 und 20 Zeichen lang sein.",
            2, 20, false));
    tfName.setRequiredError("Pflichtfeld");
    tfName.setSizeFull();
    formLayout.addComponent(tfName);

    //TextArea fr Beschreibung dem Formular hinzufgen
    taDescription = new TextArea("Beschreibung ndern:", project.getDescription());
    taDescription.setSizeFull();
    formLayout.addComponent(taDescription);

    //Formular dem Layout hinzufgen
    layout.addComponent(formLayout);

    //Speichern-Button erstllen und dem Layout hinzufgen
    //TODO: ist das korrekt? Gute Frage, I have no idea what u r doing
    dialogEditBtn = new Button("Speichern");
    layout.addComponent(dialogEditBtn);

    dialogEditBtn.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {

            if (tfName.isValid()) {
                boolean succed = presenter.editProject(projects.get(indexEditBtn), (String) tfName.getValue(),
                        (String) taDescription.getValue());
                if (succed) {
                    getWindow().removeWindow(editDialog);
                    logger.debug("Projekt-bearbeiten Dialog geschlossen");

                }

            } else {
                getWindow().showNotification("",
                        "Projektname ist ein Pflichtfeld. Bitte geben Sie einen Projektnamen an",
                        Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });

    //Layout dem Dialog-Fenster hinzufgen
    editDialog.addComponent(layout);

    //Dialog dem Hauptfenster hinzufgen
    getWindow().addWindow(editDialog);
    logger.debug("Bearbeiten-Dialog erzeugt");

}

From source file:dhbw.ka.mwi.businesshorizon2.ui.login.LogInScreenViewImpl.java

License:Open Source License

/**
 * Konkrete Erzeugung des Dialogfensters zur Registrierung eines neuen
 * Users.//from  w ww.j  a  v a2 s .  c om
 * 
 * @author Christian Scherer, Marcel Rosenberger, Annika Weis
 */
public void showRegisterUserDialog() {

    regDialog = new Window("Benutzer bei Business Horizon registrieren");
    regDialog.setModal(true);
    regDialog.setWidth(400, UNITS_PIXELS);
    regDialog.setResizable(false);
    regDialog.setDraggable(false);
    regDialog.setCaption("Registrierung eines neuen Benutzers");
    fl = new FormLayout();
    fl.setSpacing(true);
    fl.setMargin(true);
    regDialog.addComponent(fl);

    //Vorname
    textfieldFirstName = new TextField();
    textfieldFirstName.setCaption("Bitte Vornamen angeben: ");
    textfieldFirstName.setRequired(true);
    textfieldFirstName.setRequiredError("Pflichtfeld");
    fl.addComponent(textfieldFirstName);

    //Nachname
    textfieldLastName = new TextField();
    textfieldLastName.setCaption("Bitte Nachnamen angeben: ");
    textfieldLastName.setRequired(true);
    textfieldLastName.setRequiredError("Pflichtfeld");
    fl.addComponent(textfieldLastName);

    //Unternehmen
    textfieldCompany = new TextField();
    textfieldCompany.setCaption("Bitte Unternehmen angeben: ");
    textfieldCompany.setRequired(true);
    textfieldCompany.setRequiredError("Pflichtfeld");
    fl.addComponent(textfieldCompany);

    //Mailadresse
    textfieldEmailAdress = new TextField();
    textfieldEmailAdress.setCaption("Bitte Mailadresse angeben: ");
    textfieldEmailAdress.setRequired(true);
    textfieldEmailAdress.setRequiredError("Pflichtfeld");
    fl.addComponent(textfieldEmailAdress);

    //Passwort
    passwordFieldPassword = new PasswordField("Bitte Passwort whlen: ");
    passwordFieldPassword.setRequired(true);
    passwordFieldPassword.setRequiredError("Pflichtfeld");
    fl.addComponent(passwordFieldPassword);

    //Passwort WDH
    passwordFieldPasswordRep = new PasswordField("Bitte Passwort wiederholen:");
    passwordFieldPasswordRep.setRequired(true);
    passwordFieldPasswordRep.setRequiredError("Pflichtfeld");
    fl.addComponent(passwordFieldPasswordRep);

    VerticalLayout vl = new VerticalLayout();
    dialogRegBtn = new Button("Registrierung abschlieen", this);
    vl.addComponent(dialogRegBtn);
    vl.setComponentAlignment(dialogRegBtn, Alignment.MIDDLE_CENTER);
    regDialog.addComponent(vl);

    getWindow().addWindow(regDialog);

    logger.debug("Registrier-Dialog erzeugt");
}

From source file:dmc.forecaster.vaadin.VaadingaeApplication.java

License:Open Source License

@Override
public void init() {

    Window mainWindow = new Window("Financial Forecaster (v3)");
    mainWindow.setSizeFull();//from ww w  . jav a 2s.  c o  m

    // Create the application data instance
    AppData sessionData = new AppData(this);

    // Register it as a listener in the application context
    getContext().addTransactionListener(sessionData);

    TabPanel tabs = new TabPanel();

    mainWindow.addComponent(tabs);
    setMainWindow(mainWindow);

    setTheme("forecaster");

}

From source file:edu.kit.dama.ui.admin.administration.user.UserDataAdministrationTab.java

License:Apache License

/**
 * TABLE FILTERING RELATED FUNCTIONALITY *
 *//*w w w  . java2 s. c om*/
private void openFilterWindow() {
    if (filterWindow == null) {
        String id = "View";
        LOGGER.debug("Building " + DEBUG_ID_PREFIX + id + " ...");

        filterWindow = new Window("Filter Users");
        filterWindow.setContent(getFilterWindowLayout());
        filterWindow.setId(DEBUG_ID_PREFIX + id);
        filterWindow.addStyleName(CSSTokenContainer.FILTER_POSITION);

        filterWindow.addCloseListener((event) -> {
            Table table = getUserDataTablePanel().getUserDataTable();
            table.select(table.firstItemId());
            getFilterColumnBox().select(null);
            getFilterOptions().select(UserDataFilter.SearchSpace.STARTS);
            closeFilterWindow();
        });
        filterWindow.center();
        UI.getCurrent().addWindow(filterWindow);
    }
}

From source file:edu.kit.dama.ui.admin.administration.usergroup.UserGroupAdministrationTab.java

License:Apache License

/**
 * TABLE FILTERING RELATED FUNCTIONALITY *
 *//*from   w  ww . j av  a 2  s .c  o  m*/
private void openFilterWindow() {
    if (filterWindow == null) {
        String id = "View";
        LOGGER.debug("Building " + DEBUG_ID_PREFIX + id + " ...");

        filterWindow = new Window("Filter Users");

        filterWindow.setContent(getFilterWindowLayout());
        filterWindow.setId(DEBUG_ID_PREFIX + id);
        filterWindow.addStyleName(CSSTokenContainer.FILTER_POSITION);

        filterWindow.addCloseListener((event) -> {
            Table table = getUserGroupTablePanel().getUserGroupTable();
            table.select(table.firstItemId());
            getColumnBox().select(null);
            getFilterOptions().select(UserDataFilter.SearchSpace.STARTS);
            closeFilterWindow();
        });
        filterWindow.center();
        UI.getCurrent().addWindow(filterWindow);
    }
}

From source file:edu.kit.dama.ui.admin.administration.usergroup.UserGroupForm.java

License:Apache License

/**
 * GROUP CREATION RELATED FUNCTIONALITY *
 *//*from  w ww.j a  v a  2 s . co m*/
private void showCreateGroupWindow() {
    if (createGroupWindow == null) {
        String id = "createGroupWindow";
        LOGGER.debug("Building " + DEBUG_ID_PREFIX + id + " ...");

        createGroupWindow = new Window("Create New Group");
        createGroupWindow.setModal(true);
        createGroupWindow.center();
        createGroupWindow.setId(DEBUG_ID_PREFIX + id);
        createGroupWindow.setContent(getCreateGroupLayout());
        //reset layout
        getNewGroupIdField().setValue("");
        getNewGroupNameField().setValue("");
        getNewGroupDescriptionField().setValue(null);

        createGroupWindow.addCloseListener((e) -> {
            hideCreateGroupWindow();
        });
    }
    UI.getCurrent().addWindow(createGroupWindow);
}

From source file:edu.kit.dama.ui.admin.schedule.SchedulerBasePropertiesLayout.java

License:Apache License

/**
 * Add a new trigger.//from  ww  w . ja v  a  2  s .  c o m
 */
private void addTrigger() {
    if (JobScheduleConfigurationTab.UNSCHEDULED_JOB_UNIQUE_ID.equals(getIdField().getValue())) {
        ConfirmationWindow7.showConfirmation("Information",
                "Triggers can only be added to committed jobs. Please commit the job before you continue.",
                ConfirmationWindow7.OPTION_TYPE.OK_OPTION, ConfirmationWindow7.MESSAGE_TYPE.INFORMATION, null);
        return;
    }
    if (addTriggerWindow == null) {
        addTriggerWindow = new Window("Add Trigger");
        addTriggerWindow.setWidth(400.0f, Unit.PIXELS);
        addTriggerComponent.reset();
        addTriggerWindow.setContent(addTriggerComponent);
        addTriggerWindow.center();
        addTriggerWindow.addCloseListener((Window.CloseEvent e) -> {
            hideAddTriggerWindow();
        });
        UI.getCurrent().addWindow(addTriggerWindow);
    } //otherwise, there is already a window open
}

From source file:edu.kit.dama.ui.admin.ServiceAccessTokenDialog.java

License:Apache License

public void showDialog(long selection) {
    selectedId = selection;/*from w  ww . j av  a2s .com*/
    //load data in case of update
    boolean updateMode = false;
    if (selectedId > 0) {
        updateMode = true;
        IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager();
        mdm.setAuthorizationContext(UIHelper.getSessionContext());

        try {
            ServiceAccessToken token = mdm.find(ServiceAccessToken.class, selectedId);
            //check if there is an authenticator for the token's service id
            boolean validAuthenticator = false;
            for (AbstractAuthenticator auth : authenticators) {
                if (auth.getAuthenticatorId().equals(token.getServiceId())) {
                    validAuthenticator = true;
                    break;
                }
            }
            if (!validAuthenticator) {
                UIComponentTools.showWarning("No authenticator for credential with serviceId '"
                        + token.getServiceId() + "' configured. Please contact a system adminstrator.");
                return;
            } else {
                authenticatorSelection.select(token.getServiceId());
                if (tokenField != null) {
                    tokenField.setValue(token.getTokenKey());
                }
                if (secretField != null) {
                    secretField.setValue(token.getSecret());
                    nosecretField.setValue(secretField.getValue());
                }
            }
        } catch (UnauthorizedAccessAttemptException ex) {
            UIComponentTools.showWarning("You are not authorized to retrieve the selected credential.");
        } catch (SecretDecryptionException ex) {
            //The secret cannot be decrypted. This can be the case if it is not encrypted, e.g. for the HTTPAuthenticator, but could also be the case of the global secret 
            //in the datamanager.xml was changed. However, we cannot see the secret but we allow to set a new one, so we warn but continue.
            UIComponentTools.showWarning(
                    "Unable to decrypt the secret of the selected credential.<br/>You can either assign a new secret or cancel the update.");
        } finally {
            mdm.close();
        }
    }

    authenticatorSelection.setEnabled(!updateMode);
    okButton.setCaption((updateMode) ? "Update" : "Create");
    //create and show new window
    currentWin = new Window((updateMode) ? "Update Credential" : "Create Credential");
    currentWin.setContent(mainLayout);
    currentWin.center();
    UI.getCurrent().addWindow(currentWin);
}