Example usage for com.vaadin.ui Window setContent

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

Introduction

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

Prototype

@Override
public void setContent(Component content) 

Source Link

Document

Sets the content of this container.

Usage

From source file:com.tripoin.util.ui.calendar.BeanItemContainerTestUI.java

License:Apache License

/**
 * Opens up a modal dialog window where an event can be modified
 * /*from   ww  w  .  j  a  v a 2s.c o m*/
 * @param event
 *            The event to modify
 */
private void editEvent(final BasicEvent event) {
    Window modal = new Window("Add event");
    modal.setModal(true);
    modal.setResizable(false);
    modal.setDraggable(false);
    modal.setWidth("300px");
    final FieldGroup fieldGroup = new FieldGroup();

    FormLayout formLayout = new FormLayout();
    TextField captionField = new TextField("Caption");
    captionField.setImmediate(true);
    TextField descriptionField = new TextField("Description");
    descriptionField.setImmediate(true);
    DateField startField = new DateField("Start");
    startField.setResolution(Resolution.MINUTE);
    startField.setImmediate(true);
    DateField endField = new DateField("End");
    endField.setImmediate(true);
    endField.setResolution(Resolution.MINUTE);

    formLayout.addComponent(captionField);
    formLayout.addComponent(descriptionField);
    formLayout.addComponent(startField);
    formLayout.addComponent(endField);

    fieldGroup.bind(captionField, ContainerEventProvider.CAPTION_PROPERTY);
    fieldGroup.bind(descriptionField, ContainerEventProvider.DESCRIPTION_PROPERTY);
    fieldGroup.bind(startField, ContainerEventProvider.STARTDATE_PROPERTY);
    fieldGroup.bind(endField, ContainerEventProvider.ENDDATE_PROPERTY);

    fieldGroup.setItemDataSource(new BeanItem<BasicEvent>(event,
            Arrays.asList(ContainerEventProvider.CAPTION_PROPERTY, ContainerEventProvider.DESCRIPTION_PROPERTY,
                    ContainerEventProvider.STARTDATE_PROPERTY, ContainerEventProvider.ENDDATE_PROPERTY)));
    modal.setContent(formLayout);
    modal.addCloseListener(new Window.CloseListener() {
        /**
        * 
        */
        private static final long serialVersionUID = -3427881784024691882L;

        @Override
        public void windowClose(CloseEvent e) {
            // Commit changes to bean
            try {
                fieldGroup.commit();
            } catch (CommitException e1) {
                e1.printStackTrace();
            }

            if (events.containsId(event)) {
                /*
                 * BeanItemContainer does not notify container listeners
                 * when the bean changes so we need to trigger a
                 * ItemSetChange event
                 */
                BasicEvent dummy = new BasicEvent();
                events.addBean(dummy);
                events.removeItem(dummy);

            } else {
                events.addBean(event);
            }
        }
    });
    getUI().addWindow(modal);
}

From source file:com.zklogtool.web.components.MainLayout.java

License:Apache License

public MainLayout() {

    buildMainLayout();//  w  ww  .  j  a  v a  2 s .c om

    setCompositionRoot(mainLayout);

    versionLabel.setValue("zklogtoolwebapp " + projectVersion());

    MenuItem fileMenuItem = menuBar_1.addItem("File", null, null);

    fileMenuItem.addItem("Open transaction log", new MenuBar.Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {

            final Window window = new Window("Open transaction log file");
            window.setModal(true);

            OpenTransactionLogFileDialog openFileDialog = new OpenTransactionLogFileDialog(tabSheet_1, window);
            window.setHeight(300, Unit.PIXELS);
            window.setWidth(600, Unit.PIXELS);

            window.setContent(openFileDialog);
            UI.getCurrent().addWindow(window);

        }

    });

    fileMenuItem.addItem("Open snapshot", new MenuBar.Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {

            final Window window = new Window("Open snapshot file");
            window.setModal(true);

            OpenSnapshotFileDialog openFileDialog = new OpenSnapshotFileDialog(tabSheet_1, window);
            window.setHeight(250, Unit.PIXELS);
            window.setWidth(600, Unit.PIXELS);

            window.setContent(openFileDialog);
            UI.getCurrent().addWindow(window);

        }

    });

    MenuItem helpMenuItem = menuBar_1.addItem("Help", null, null);

    helpMenuItem.addItem("About", new MenuBar.Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {

            final Window window = new Window("About");
            window.setModal(true);

            final VerticalLayout verticalLayout = new VerticalLayout();
            verticalLayout.setMargin(true);
            verticalLayout.addComponent(new Label("This is zklogtool web front end in development"));

            window.setContent(verticalLayout);
            UI.getCurrent().addWindow(window);

        }

    });

}

From source file:com.zklogtool.web.components.TransactionLogView.java

License:Apache License

public TransactionLogView(final File transactionLogFile, final File snapshotDir, final boolean follow,
        final boolean startFromLast, final TabSheet displayTabSheet, final String name) {
    buildMainLayout();/*from www . j a  v a 2 s  .c  o  m*/
    setCompositionRoot(mainLayout);

    descriptionLabel.setContentMode(ContentMode.PREFORMATTED);

    final Container container = new IndexedContainer();
    container.addContainerProperty("zxid", String.class, 0);
    container.addContainerProperty("cxid", String.class, 0);
    container.addContainerProperty("client id", String.class, 0);
    //container.addContainerProperty("time", Date.class, 0);
    container.addContainerProperty("operation", ZkOperations.class, "");
    container.addContainerProperty("path", String.class, "");

    reconstructDataTreeButton.setVisible(false);
    filterTable.setContainerDataSource(container);
    filterTable.setFilterBarVisible(true);
    filterTable.setFilterDecorator(new TransactionFilterDecoder());
    filterTable.setSelectable(true);
    filterTable.setImmediate(true);

    final TransactionLog transactionLog;
    final Iterator<Transaction> iterator;
    final Map<String, Transaction> transactionMap = new HashMap<String, Transaction>();

    filterTable.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {

            if (filterTable.getValue() == null)
                return;

            StringBuilder description = new StringBuilder();

            TransactionPrinter printer = new TransactionPrinter(description, new UnicodeDecoder());

            printer.print(transactionMap.get("0x" + filterTable.getValue().toString()));

            descriptionLabel.setValue(description.toString());

            if (snapshotDir != null && transactionLogFile.isDirectory()) {

                reconstructDataTreeButton.setVisible(true);

            }

        }
    });

    if (transactionLogFile.isFile()) {

        transactionLog = new TransactionLog(transactionLogFile, new TransactionLogReaderFactory());
    } else {

        transactionLog = new TransactionLog(new DataDirTransactionLogFileList(transactionLogFile),
                new TransactionLogReaderFactory());
    }

    iterator = transactionLog.iterator();

    if (startFromLast) {

        while (iterator.hasNext()) {

            iterator.next();
        }
    }

    final Runnable fillData = new Runnable() {

        @Override
        public void run() {
            // TODO Auto-generated method stub

            while (iterator.hasNext()) {

                Transaction t = iterator.next();

                transactionMap.put(Util.longToHexString(t.getTxnHeader().getZxid()), t);

                Item item = container.addItem(Long.toHexString(t.getTxnHeader().getZxid()));
                item.getItemProperty("zxid").setValue(Util.longToHexString(t.getTxnHeader().getZxid()));

                item.getItemProperty("cxid").setValue(Util.longToHexString(t.getTxnHeader().getCxid()));

                item.getItemProperty("client id")
                        .setValue(Util.longToHexString(t.getTxnHeader().getClientId()));

                /*item.getItemProperty("time").setValue(
                 new Date(t.getTxnHeader().getTime()));*/
                switch (t.getTxnHeader().getType()) {

                case OpCode.create:
                    CreateTxn createTxn = (CreateTxn) t.getTxnRecord();
                    item.getItemProperty("operation").setValue(ZkOperations.CREATE);
                    item.getItemProperty("path").setValue(createTxn.getPath());
                    break;

                case OpCode.delete:
                    DeleteTxn deleteTxn = (DeleteTxn) t.getTxnRecord();
                    item.getItemProperty("operation").setValue(ZkOperations.DELTE);
                    item.getItemProperty("path").setValue(deleteTxn.getPath());
                    break;

                case OpCode.setData:
                    SetDataTxn setDataTxn = (SetDataTxn) t.getTxnRecord();
                    item.getItemProperty("operation").setValue(ZkOperations.SET_DATA);
                    item.getItemProperty("path").setValue(setDataTxn.getPath());
                    break;

                case OpCode.setACL:
                    SetACLTxn setACLTxn = (SetACLTxn) t.getTxnRecord();
                    item.getItemProperty("operation").setValue(ZkOperations.SET_ACL);
                    item.getItemProperty("path").setValue(setACLTxn.getPath());
                    break;

                case OpCode.check:
                    CheckVersionTxn checkVersionTxn = (CheckVersionTxn) t.getTxnRecord();
                    item.getItemProperty("operation").setValue(ZkOperations.CHECK);
                    item.getItemProperty("path").setValue(checkVersionTxn.getPath());
                    break;

                case OpCode.multi:
                    item.getItemProperty("operation").setValue(ZkOperations.MULTI);
                    break;

                case OpCode.createSession:
                    item.getItemProperty("operation").setValue(ZkOperations.CREATE_SESSION);
                    break;

                case OpCode.closeSession:
                    item.getItemProperty("operation").setValue(ZkOperations.CLOSE_SESSION);
                    break;

                case OpCode.error:
                    item.getItemProperty("operation").setValue(ZkOperations.ERROR);
                    break;

                }

            }
        }

    };

    fillData.run();

    Thread monitorThread = new Thread(new Runnable() {

        @Override
        public void run() {

            while (true) {
                //push UI
                UI.getCurrent().access(fillData);

                try {
                    Thread.sleep(250);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }

    });

    if (follow) {
        monitorThread.start();

    }

    reconstructDataTreeButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {

            DataDirHelper dataDirHelper = new DataDirHelper(transactionLogFile, snapshotDir);
            List<File> snapshots = dataDirHelper.getSortedSnapshotList();
            DataDirTransactionLogFileList l = new DataDirTransactionLogFileList(transactionLogFile);
            TransactionLog transactionLog = new TransactionLog(l, new TransactionLogReaderFactory());

            File snapFile = null;
            DataState dataState = null;

            long currentZxid = Long.parseLong(filterTable.getValue().toString(), 16);

            int i = snapshots.size() - 1;
            while (i >= 0) {

                long snapZxid = Util.getZxidFromName(snapshots.get(i).getName());

                if (snapZxid <= currentZxid) {

                    if (i == 0) {
                        snapFile = snapshots.get(0);
                    } else {
                        snapFile = snapshots.get(i - 1);
                    }

                    break;

                }

                i--;

            }

            if (snapFile == null) {
                dispalyNotEnoughDataErrorMessage();
                return;
            }

            long TS = Util.getZxidFromName(snapFile.getName());

            //catch this exception and print error
            SnapshotFileReader snapReader = new SnapshotFileReader(snapFile, TS);

            try {
                dataState = snapReader.restoreDataState(transactionLog.iterator());
            } catch (Exception ex) {
                //dispay error dialog
                //not enough information
                dispalyNotEnoughDataErrorMessage();
                return;
            }

            //set iterator to last zxid
            TransactionIterator iterator = transactionLog.iterator();
            Transaction t;

            do {

                t = iterator.next();

            } while (t.getTxnHeader().getZxid() < TS);

            while (iterator.nextTransactionState() == TransactionState.OK
                    && dataState.getLastZxid() < currentZxid) {
                dataState.processTransaction(iterator.next());
            }

            HorizontalLayout horizontalLayout = new HorizontalLayout();
            horizontalLayout.setCaption(name + " at zxid 0x" + Long.toString(currentZxid, 16));
            horizontalLayout.addComponent(new SnapshotView(dataState));
            horizontalLayout.setWidth("100%");
            horizontalLayout.setHeight("100%");
            Tab snapshotTab = displayTabSheet.addTab(horizontalLayout);
            snapshotTab.setClosable(true);
            displayTabSheet.setSelectedTab(snapshotTab);

        }

        void dispalyNotEnoughDataErrorMessage() {

            final Window window = new Window("Error");
            window.setModal(true);

            final VerticalLayout verticalLayout = new VerticalLayout();
            verticalLayout.setMargin(true);
            verticalLayout.addComponent(new Label("Not enough data to reconstruct data tree"));

            window.setContent(verticalLayout);
            UI.getCurrent().addWindow(window);

        }

    });

}

From source file:cz.zcu.pia.social.network.frontend.components.posts.ComponentPost.java

/**
 * Adds click listeners to the buttons/*from w  w  w .  ja  v a2  s.  com*/
 */
private void addClickListeners() {
    this.likes.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Post post = componentPostService.updateLikeRating(postId);
            numberOfLikes = post.getLikeCount();
            numberOfDisagrees = post.getHateCount();
            updateHateLike();

        }
    });
    this.disagrees.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Post post = componentPostService.updateDisagreeRating(postId);

            numberOfLikes = post.getLikeCount();
            numberOfDisagrees = post.getHateCount();
            updateHateLike();
        }
    });
    this.tags.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window subWindow = new Window(msgs.getMessage("post.tags"));

            subWindow.setModal(true);
            subWindow.center();
            subWindow.setWidth(400, Unit.PIXELS);
            subWindow.setHeight(110, Unit.PIXELS);
            subWindow.setResizable(false);
            Panel panel = new Panel();

            panel.setSizeFull();
            HorizontalLayout tagsWrapper = new HorizontalLayout();
            tagsWrapper.setStyleName("margin-left-big");
            panel.setContent(tagsWrapper);
            tagsWrapper.setSpacing(true);
            tagsWrapper.setMargin(true);
            tagsWrapper.setSizeUndefined();

            for (Tag t : postService.getPostTags(postId)) {
                CustomLayout tag = new CustomLayout("tag");
                Button tagLabel = new Button(t.getTagName());
                tag.addComponent(tagLabel, "button");

                tagsWrapper.addComponent(tag);
            }

            subWindow.setContent(panel);
            UI.getCurrent().addWindow(subWindow);
        }
    });
    this.comments.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window subWindow = new Window(msgs.getMessage("post.comments"));

            subWindow.setModal(true);
            subWindow.center();
            subWindow.setWidth(400, Unit.PIXELS);
            subWindow.setHeight(600, Unit.PIXELS);
            subWindow.setResizable(true);

            ComponentPostComments componentPostComments = applicationContext
                    .getBean(ComponentPostComments.class, postId);
            subWindow.setContent(componentPostComments);
            UI.getCurrent().addWindow(subWindow);
        }
    });
    this.name.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window subWindow = new Window(msgs.getMessage("header.profile") + "- " + name.getCaption());

            subWindow.setModal(true);
            subWindow.center();
            subWindow.setWidth(400, Unit.PIXELS);
            subWindow.setHeight(350, Unit.PIXELS);
            subWindow.setResizable(true);

            Users user = postService.getPostById(postId).getUser();
            ComponentProfilePost profilePost = applicationContext.getBean(ComponentProfilePost.class, user);

            subWindow.setContent(profilePost);
            UI.getCurrent().addWindow(subWindow);
        }
    });
}

From source file:cz.zcu.pia.social.network.frontend.components.profile.friends.ComponentFriends.java

/**
 * Function for manage friends requests button
 *///from ww  w .j  a  v a  2  s  . c om
private void manageFriendsRequestsButtonFunction() {
    Window subWindow = new Window(msgs.getMessage("post.comments"));
    ComponentManageFriendRequest manageFriendRequest = applicationContext
            .getBean(ComponentManageFriendRequest.class);
    manageFriendRequest.setParentReference(this);
    manageFriendRequest.setSizeFull();
    subWindow.setModal(true);
    subWindow.center();
    subWindow.setWidth(500, Unit.PIXELS);
    subWindow.setHeight(400, Unit.PIXELS);
    subWindow.setResizable(true);
    subWindow.setContent(manageFriendRequest);
    UI.getCurrent().addWindow(subWindow);

}

From source file:cz.zcu.pia.social.network.frontend.views.ViewHome.java

/**
 * Add button function/* w  w  w .j av a  2s  .c  o  m*/
 * @param event  click event
 */
private void addButtonFunction(Button.ClickEvent event) {
    Window subWindow = new Window(msgs.getMessage("post.add.new"));
    subWindow.setModal(true);
    subWindow.center();
    subWindow.setWidth(400, Unit.PIXELS);
    subWindow.setHeight(300, Unit.PIXELS);
    ComponentPostAdd postAdd = applicationContext.getBean(ComponentPostAdd.class);
    postAdd.setComponentParent(this);
    postAdd.setWindow(subWindow);
    postAdd.setMargin(true);
    subWindow.setContent(postAdd);
    UI.getCurrent().addWindow(subWindow);
}

From source file:de.akquinet.engineering.vaadin.vaangular.demo.VaangularUI.java

License:Apache License

private void showPopup(String eintrag) {
    Window modalWin = new Window("E-Mail is being sent...");
    modalWin.setContent(new Label("<div style=\"margin: 10px; \">" + "<h2>Season's greetings</h2>" + "<p>"
            + eintrag + "</p>" + "</div>", ContentMode.HTML));
    modalWin.setModal(true);//  w ww . j  a va 2  s .com
    modalWin.setWidth("400px");
    modalWin.setHeight("250px");
    modalWin.center();
    UI.getCurrent().addWindow(modalWin);
}

From source file:de.catma.CatmaApplication.java

License:Open Source License

@Override
public void init() {

    Properties properties = loadProperties();
    backgroundService = new BackgroundService(this);

    final Window mainWindow = new Window("CATMA 4.1 - CLA " + VERSION);
    mainWindow.addParameterHandler(this);
    HorizontalLayout mainLayout = new HorizontalLayout();
    mainLayout.setSizeUndefined();/*from   w ww  .  j a v  a 2 s  .  co m*/
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);
    mainWindow.addStyleName("catma-mainwindow");

    mainWindow.setContent(mainLayout);
    MenuFactory menuFactory = new MenuFactory();
    try {
        initTempDirectory(properties);
        tagManager = new TagManager();

        repositoryManagerView = new RepositoryManagerView(new RepositoryManager(this, tagManager, properties));

        tagManagerView = new TagManagerView(tagManager);

        taggerManagerView = new TaggerManagerView();

        analyzerManagerView = new AnalyzerManagerView();

        visualizationManagerView = new VisualizationManagerView();

        defaultProgressIndicator = new ProgressIndicator();
        defaultProgressIndicator.setIndeterminate(true);
        defaultProgressIndicator.setEnabled(false);
        defaultProgressIndicator.setPollingInterval(500);
        progressWindow = new ProgressWindow(defaultProgressIndicator);

        menu = menuFactory.createMenu(mainLayout,
                new MenuFactory.MenuEntryDefinition("Repository Manager",
                        new RepositoryManagerWindow(repositoryManagerView)),
                new MenuFactory.MenuEntryDefinition("Tag Manager", new TagManagerWindow(tagManagerView)),
                new MenuFactory.MenuEntryDefinition("Tagger", new TaggerManagerWindow(taggerManagerView)),
                new MenuFactory.MenuEntryDefinition("Analyzer", new AnalyzerManagerWindow(analyzerManagerView)),
                new MenuFactory.MenuEntryDefinition("Visualizer",
                        new VisualizationManagerWindow(visualizationManagerView)));
        Link aboutLink = new Link("About", new ExternalResource("http://www.catma.de"));
        aboutLink.setTargetName("_blank");
        mainLayout.addComponent(aboutLink);
        mainLayout.setComponentAlignment(aboutLink, Alignment.TOP_RIGHT);
        mainLayout.setExpandRatio(aboutLink, 1.0f);

        Link helpLink = new Link("Help", new ExternalResource(getURL() + "manual/"));
        helpLink.setTargetName("_blank");
        mainLayout.addComponent(helpLink);
        mainLayout.setComponentAlignment(helpLink, Alignment.TOP_RIGHT);

        Label helpLabel = new Label();
        helpLabel.setIcon(new ClassResource("ui/resources/icon-help.gif", this));
        helpLabel.setWidth("20px");
        helpLabel.setDescription(
                "<h3>Hints</h3>" + "<p>Watch out for these little question mark icons while navigating "
                        + "through CATMA. They provide useful hints for managing the first "
                        + "steps within a CATMA component.</p>" + "<h4>Login</h4>"
                        + "Once you're logged in, you will see the Repository Manager, "
                        + "which will explain the first steps to you. "
                        + "Just hover your mouse over the question mark icons!");
        VerticalLayout helpWrapper = new VerticalLayout();
        helpWrapper.addComponent(helpLabel);
        helpWrapper.setComponentAlignment(helpLabel, Alignment.TOP_RIGHT);

        Animator helpAnimator = new Animator(helpWrapper);

        helpAnimator.setFadedOut(true);

        mainLayout.addComponent(helpAnimator);
        mainLayout.setComponentAlignment(helpAnimator, Alignment.TOP_RIGHT);
        helpAnimator.fadeIn(2000, 300);

        MenuBar loginLogoutMenu = new MenuBar();
        LoginLogoutCommand loginLogoutCommand = new LoginLogoutCommand(menu, repositoryManagerView, this);
        MenuItem loginLogoutitem = loginLogoutMenu.addItem("Login", loginLogoutCommand);
        loginLogoutCommand.setLoginLogoutItem(loginLogoutitem);

        mainLayout.addComponent(loginLogoutMenu);
        mainLayout.setComponentAlignment(loginLogoutMenu, Alignment.TOP_RIGHT);
        mainLayout.setWidth("100%");
    } catch (Exception e) {
        showAndLogError("The system could not be initialized!", e);
    }

    setMainWindow(mainWindow);

    setTheme("cleatheme");
}

From source file:de.catma.ui.dialog.wizard.WizardFactory.java

License:Open Source License

public Window createWizardWindow(String caption, String width, String height) {

    Wizard wizard = new Wizard();
    wizard.getFinishButton().setEnabled(false);
    Window wizardWindow = new Window(caption);
    wizardWindow.setModal(true);/*from   w  ww. jav  a2 s. c o  m*/
    wizardWindow.setContent(wizard);
    wizardWindow.setWidth(width);
    wizardWindow.setHeight(height);

    wizard.addListener(new WizardManager(wizardWindow));
    wizard.addListener(wizardProgressListener);

    addSteps(wizard);

    return wizardWindow;
}

From source file:de.metas.ui.web.vaadin.report.VaadinJRViewerProvider.java

License:Open Source License

@Override
public void openViewer(final byte[] data, final OutputType type, final String title, final ProcessInfo pi)
        throws JRException {
    final StreamResource pdfResource = new StreamResource(() -> new ByteArrayInputStream(data), "report.pdf");

    final Window window = new Window();
    window.setCaption(title);/*w w w  . ja va2  s  .  c  o m*/

    window.setStyleName(STYLE);
    window.center();
    window.setWidth(800, Unit.PIXELS);
    window.setHeight(600, Unit.PIXELS);

    final BrowserFrame pdfComp = new BrowserFrame();
    pdfComp.setPrimaryStyleName(STYLE + "-content");
    pdfComp.setSizeFull();
    pdfComp.setSource(pdfResource);
    window.setContent(pdfComp);

    UI.getCurrent().addWindow(window);
}