Example usage for com.vaadin.ui Window getParent

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

Introduction

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

Prototype

@Override
    public HasComponents getParent() 

Source Link

Usage

From source file:eu.lod2.DeleteGraphs.java

License:Apache License

private Button showConfirmDialog(String message) {
    final Window notifier = new Window("Are you sure?");
    notifier.setWidth("400px");
    notifier.setModal(true);/*w  w  w  .  jav  a  2 s.  co  m*/

    VerticalLayout layout = (VerticalLayout) notifier.getContent();
    layout.setMargin(true);
    layout.setSpacing(true);

    Label messageLabel = new Label(message);
    notifier.addComponent(messageLabel);

    Button yes = new Button("Yes", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            notifier.getParent().removeWindow(notifier);
        }
    });
    Button no = new Button("No", new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            notifier.getParent().removeWindow(notifier);
        }
    });

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.addComponent(yes);
    buttons.addComponent(no);
    notifier.addComponent(buttons);

    getWindow().addWindow(notifier);

    return yes;
}

From source file:eu.lod2.ExportSelector.java

License:Apache License

public void addNewItem(String newItemCaption) {
    final String newItem = newItemCaption;

    // request the user whether to add it to the list or to reject his choice.
    final Window subwindow = new Window("Create new graph");
    subwindow.setModal(true);//from   ww w  .jav  a2  s .  c  o m

    // Configure the windows layout; by default a VerticalLayout
    VerticalLayout swlayout = (VerticalLayout) subwindow.getContent();

    Label desc = new Label(
            "The graphname " + newItemCaption + " is not a known graph. Shall we create the graph?");
    HorizontalLayout buttons = new HorizontalLayout();

    Button ok = new Button("Create graph", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            createGraph(newItem);
            (subwindow.getParent()).removeWindow(subwindow);
        }
    });
    ok.setDebugId(this.getClass().getSimpleName() + "_ok");
    Button cancel = new Button("Cancel", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
        }
    });
    cancel.setDebugId(this.getClass().getSimpleName() + "_cancel");

    swlayout.addComponent(desc);
    swlayout.addComponent(buttons);
    buttons.addComponent(ok);
    buttons.addComponent(cancel);
    buttons.setComponentAlignment(ok, Alignment.BOTTOM_RIGHT);
    buttons.setComponentAlignment(cancel, Alignment.BOTTOM_RIGHT);
    getWindow().addWindow(subwindow);
    subwindow.setWidth("300px");

}

From source file:eu.lod2.ExportSelector3.java

License:Apache License

public void addNewItem(String newItemCaption) {
    final String newItem = newItemCaption;

    // request the user whether to add it to the list or to reject his choice.
    final Window subwindow = new Window("Create new graph");
    subwindow.setModal(true);//from  ww  w.  j  a  v  a2 s  .  com

    // Configure the windows layout; by default a VerticalLayout
    VerticalLayout swlayout = (VerticalLayout) subwindow.getContent();

    Label desc = new Label(
            "The graphname " + newItemCaption + " is not a known graph. Shall we create the graph?");
    HorizontalLayout buttons = new HorizontalLayout();

    Button ok = new Button("Create graph", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            createGraph(newItem);
            (subwindow.getParent()).removeWindow(subwindow);
        }
    });
    ok.setDebugId(this.getClass().getSimpleName() + "_ok");
    Button cancel = new Button("Cancel", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
        }
    });
    cancel.setDebugId(this.getClass().getSimpleName() + "_cancel");
    swlayout.addComponent(desc);
    swlayout.addComponent(buttons);
    buttons.addComponent(ok);
    buttons.addComponent(cancel);
    buttons.setComponentAlignment(ok, Alignment.BOTTOM_RIGHT);
    buttons.setComponentAlignment(cancel, Alignment.BOTTOM_RIGHT);
    getWindow().addWindow(subwindow);
    subwindow.setWidth("300px");

}

From source file:eu.lod2.stat.StatLOD2Demo.java

License:Apache License

/**
 * A function to get an ontowiki export command
 * @param format - the formating string defining the format to export in
 *///from   w ww  . j a va2s.  c om
private MenuBar.Command getOWExportCommand(final String format) {
    return new MenuBar.Command() {
        public void menuSelected(final MenuItem selectedItem) {
            String currentGraph = state.getCurrentGraph();
            if (currentGraph == null || currentGraph.isEmpty()) {
                final Window window = new Window("No graph selected");
                window.setWidth("550px");
                LOD2DemoState.CurrentGraphListener listener = new LOD2DemoState.CurrentGraphListener() {
                    boolean ignoreFirst = true;

                    public void notifyCurrentGraphChange(String graph) {
                        if (ignoreFirst) {
                            ignoreFirst = false;
                            return;
                        }
                        window.getParent().removeWindow(window);
                        menuSelected(selectedItem);
                        state.removeCurrentGraphListener(this);
                    }
                };
                VerticalLayout layout = (VerticalLayout) window.getContent();
                layout.addComponent(new Label(
                        "You did not specify a graph to work with. Please do so below and try again: "));
                ConfigurationTab configure = new ConfigurationTab(state);
                layout.addComponent(configure);
                layout.setComponentAlignment(configure, Alignment.BOTTOM_CENTER);
                getMainWindow().addWindow(window);
                window.center();
                state.addCurrentGraphListener(listener);
                return;
            }
            try {
                getMainWindow()
                        .open(new ExternalResource(state.getHostNameWithoutPort() + "/ontowiki/model/export?m="
                                + URLEncoder.encode(currentGraph, "UTF-8") + "&f=" + format));
            } catch (UnsupportedEncodingException e) {
                // should never happen
                throw new RuntimeException("The lod2 server encountered error when exporting the graph: "
                        + e.getMessage() + " Please contact an administrator");
            }
        }
    };
}

From source file:it.vige.greenarea.bpm.custom.ui.dettaglio.KmlDocumentViewer.java

License:Apache License

public KmlDocumentViewer(String focusedFeature, Coordinate coordinate) {
    super();//w  w  w  . java  2 s .  c  o m
    setImmediate(true);
    loadDocument();
    setWidth(100, UNITS_PERCENTAGE);
    addComponent(ufu);
    addLayer(osm);
    addLayer(vectorLayer);

    extractStyles(doc);

    displayFeatures(focusedFeature);

    vectorLayer.setSelectionMode(SIMPLE);
    vectorLayer.setImmediate(true);
    vectorLayer.addListener(new VectorSelectedListener() {
        public void vectorSelected(VectorSelectedEvent event) {
            final Area component = (Area) event.getVector();
            final String data = (String) component.getData();

            final Window window = new Window("Details");
            window.getContent().setSizeFull();
            window.setHeight("50%");
            window.setWidth("50%");

            Button button = new Button("Focus this feature");
            button.addListener(new ClickListener() {
                private static final long serialVersionUID = 3286851301965195290L;

                @Override
                public void buttonClick(ClickEvent event) {
                    ufu.setFragment(data);
                    displayFeatures(data);
                    window.getParent().removeWindow(window);
                }
            });
            window.addComponent(button);
            window.setClosable(true);
            window.center();
            getWindow().addWindow(window);
            vectorLayer.setSelectedVector(null);
        }
    });

    if (coordinate != null) {
        // Definig a Marker Layer
        MarkerLayer markerLayer = new MarkerLayer();

        // Defining a new Marker

        final Marker marker = new Marker(coordinate.getLongitude(), coordinate.getLatitude());
        // URL of marker Icon
        marker.setIcon(new ThemeResource("img/marker.png"), 60, 60);
        markerLayer.addComponent(marker);
        addLayer(markerLayer);
        setCenter(coordinate.getLongitude(), coordinate.getLatitude());
    }

}

From source file:module.contents.presentationTier.component.ContentEditorWindow.java

License:Open Source License

public ContentEditorWindow(final String widnowTitle, final String okButtonTitle) {
    super(widnowTitle, new ContentEditorLayout(okButtonTitle, false));
    layout = (ContentEditorLayout) getContent();
    final Window window = this;
    layout.setContentEditorCloseListner(new ContentEditorCloseListner() {
        @Override//from  www  . j a  v a2 s  .  c om
        public void close() {
            window.getParent().removeWindow(window);
        }
    });
}

From source file:module.contents.presentationTier.component.ContentEditorWindow.java

License:Open Source License

public void setContentEditorSaveListner(final ContentEditorSaveListner contentEditorSaveListner) {
    final Window window = this;
    layout.setContentEditorSaveListner(new ContentEditorSaveListner() {
        @Override/*from w  ww .j a  va 2 s .c om*/
        public void save(final String title, final String content) {
            contentEditorSaveListner.save(title, content);
            window.getParent().removeWindow(window);
        }
    });
}

From source file:nl.amc.biolab.nsg.display.component.ProcessingStatusForm.java

License:Open Source License

private void createSubmissionButtons(final VaadinTestApplication app, final SubmissionIO submissionIO,
        final nl.amc.biolab.datamodel.objects.Error error) {
    final Link statusLink = new Link("download", new StreamResource(new StreamSource() {
        private static final long serialVersionUID = 2010850543250392280L;

        public InputStream getStream() {
            String status;/*from  w  ww  .  j a  v a  2s  . c  om*/
            if (error != null) {
                status = error.getCode() + "\n" + error.getMessage() + "\n" + error.getDescription();
            } else {
                status = "No message";
            }
            return new ByteArrayInputStream(status.getBytes());
        }
    }, "status", getApplication()), "", 400, 300, 2);

    viewStatusButton = new NativeButton("Details");
    viewStatusButton.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = -8337533736203519683L;

        @Override
        public void buttonClick(ClickEvent event) {
            app.getMainWindow().addWindow(new Window() {
                private static final long serialVersionUID = 1520192489661790818L;

                {
                    center();
                    setWidth("700px");
                    setHeight("500px");
                    VerticalLayout vl = new VerticalLayout();
                    vl.addComponent(statusLink);
                    String status;
                    if (error != null) {
                        status = error.getCode() + "\n" + error.getMessage() + "\n" + error.getDescription();
                    } else {
                        status = "No message";
                    }
                    //status += "<img src=\"images/prov.png\"";
                    vl.addComponent(new Label(status, Label.CONTENT_PREFORMATTED));
                    addComponent(vl);
                }
            });
        }
    });

    resubmitButton = new NativeButton("Resume");
    resubmitButton.setData(processingStatusForm);
    resubmitButton.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = -6410875548044234734L;

        @Override
        public void buttonClick(ClickEvent event) {
            long dbId = processingStatus.getProcessing().getDbId();
            long liferayID = app.getLiferayId(processingStatus.getProcessing().getUser().getLiferayID());
            processingService.resubmit(dbId, submissionIO.getSubmission().getDbId(),
                    userDataService.getUserId(), liferayID);
            processingStatusForm.attach();
        }
    });

    markFailButton = new NativeButton("Abort");
    markFailButton.setData(processingStatusForm);
    markFailButton.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = -5019762936706219454L;

        @Override
        public void buttonClick(ClickEvent event) {
            app.getMainWindow().addWindow(new Window() {
                private static final long serialVersionUID = 3852384470521127702L;

                {
                    final Window window = this;
                    center();
                    setWidth("500px");
                    setHeight("300px");
                    VerticalLayout vl = new VerticalLayout();

                    final TextField text = new TextField("Remarks to the user");
                    text.setWidth("97%");
                    text.setHeight("150px");
                    vl.addComponent(text);

                    final Button okButton = new NativeButton();
                    okButton.setCaption("Save");
                    okButton.setImmediate(true);
                    okButton.setWidth("-1px");
                    okButton.setHeight("-1px");
                    okButton.addListener(new Button.ClickListener() {
                        private static final long serialVersionUID = 1754437322024958253L;

                        public void buttonClick(ClickEvent event) {
                            long dbId = processingStatus.getProcessing().getDbId();
                            long userID = processingStatus.getProcessing().getUser().getDbId();
                            long liferayID = app
                                    .getLiferayId(processingStatus.getProcessing().getUser().getLiferayID());
                            processingService.markFailed(submissionIO.getSubmission().getDbId(),
                                    (String) text.getValue());
                            processingStatus = processingService.getProcessingStatus(
                                    userDataService.getProcessing(dbId), userID, liferayID, false);
                            refreshButton.setData(processingStatus);
                            processingStatusForm.fireValueChange(false);//fireEvent(new Event(refreshButton));
                            window.getParent().removeWindow(window);
                        }
                    });
                    vl.addComponent(okButton);
                    addComponent(vl);
                }
            });
        }
    });
    //      }

    remarksButton = new NativeButton("Why?");
    remarksButton.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = -267778012100029422L;

        @Override
        public void buttonClick(ClickEvent event) {
            app.getMainWindow().addWindow(new Window() {
                private static final long serialVersionUID = -5026454769214596711L;

                {
                    List<nl.amc.biolab.datamodel.objects.Error> temp = submissionIO.getSubmission().getErrors();

                    center();
                    setWidth("700px");
                    setHeight("500px");
                    VerticalLayout vl = new VerticalLayout();
                    vl.addComponent(
                            new Label(temp.get(temp.size() - 1).getMessage(), Label.CONTENT_PREFORMATTED));
                    addComponent(vl);
                }
            });
        }
    });
}

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  w  w  w  .j  a v a 2s . c o 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.escidoc.browser.ui.listeners.AddMetaDataFileItemBehaviour.java

License:Open Source License

public void showAddWindow() {
    final Window subwindow = new Window(ViewConstants.ADD_ITEM_S_METADATA);
    subwindow.setWidth("600px");
    subwindow.setModal(true);//from  w ww . j  a  va  2s .c o m
    receiver = new MetadataFileReceiver();
    // Make uploading start immediately when file is selected
    upload = new Upload("", receiver);
    upload.setImmediate(true);
    upload.setButtonCaption("Select file");

    progressLayout.setSpacing(true);
    progressLayout.setVisible(false);
    progressLayout.addComponent(pi);
    progressLayout.setComponentAlignment(pi, Alignment.MIDDLE_LEFT);

    /**
     * =========== Add needed listener for the upload component: start, progress, finish, success, fail ===========
     */

    upload.addListener(new Upload.StartedListener() {
        @Override
        public void uploadStarted(final StartedEvent event) {
            upload.setVisible(false);
            progressLayout.setVisible(true);
            pi.setValue(Float.valueOf(0f));
            pi.setPollingInterval(500);
            status.setValue("Uploading file \"" + event.getFilename() + "\"");
        }
    });

    upload.addListener(new Upload.SucceededListener() {

        @Override
        public void uploadSucceeded(final SucceededEvent event) {
            // This method gets called when the upload finished successfully
            status.setValue("Uploading file \"" + event.getFilename() + "\" succeeded");
            final String fileContent = receiver.getFileContent();
            final boolean isWellFormed = XmlUtil.isWellFormed(fileContent);
            receiver.setWellFormed(isWellFormed);
            if (isWellFormed) {
                status.setValue(ViewConstants.XML_IS_WELL_FORMED);
                hl.setVisible(true);
                upload.setEnabled(false);
            } else {
                status.setValue(ViewConstants.XML_IS_NOT_WELL_FORMED);
            }
        }
    });

    upload.addListener(new Upload.FailedListener() {
        @Override
        public void uploadFailed(final FailedEvent event) {
            // This method gets called when the upload failed
            status.setValue("Uploading interrupted");
        }
    });

    upload.addListener(new Upload.FinishedListener() {
        @Override
        public void uploadFinished(final FinishedEvent event) {
            // This method gets called always when the upload finished,
            // either succeeding or failing
            progressLayout.setVisible(false);
            upload.setVisible(true);
            upload.setCaption("Select another file");
        }
    });
    mdName = new TextField("Metadata name");
    mdName.setValue("");
    mdName.setImmediate(true);
    mdName.setValidationVisible(false);

    hl = new HorizontalLayout();
    hl.setMargin(true);
    final Button btnAdd = new Button("Save", new Button.ClickListener() {
        Item item;

        private boolean containSpace(final String text) {
            final Pattern pattern = Pattern.compile("\\s");
            final Matcher matcher = pattern.matcher(text);
            return matcher.find();
        }

        @Override
        public void buttonClick(final ClickEvent event) {
            if (mdName.getValue().equals("")) {
                mdName.setComponentError(new UserError("You have to add a name for your MetaData"));
            } else if (containSpace(((String) mdName.getValue()))) {
                mdName.setComponentError(new UserError("The name of MetaData can not contain space"));
            } else {
                mdName.setComponentError(null);

                if (receiver.getFileContent().isEmpty()) {
                    upload.setComponentError(
                            new UserError("Please select a well formed XML file as metadata."));
                } else if (!receiver.isWellFormed()) {
                    upload.setComponentError(new UserError(ViewConstants.XML_IS_NOT_WELL_FORMED));
                } else {
                    final MetadataRecord metadataRecord = new MetadataRecord(mdName.getValue().toString());
                    try {
                        item = repositories.item().findItemById(resourceProxy.getId());
                        metadataRecord.setContent(getMetadataContent());
                        repositories.item().addMetaData(metadataRecord, item);
                        upload.setEnabled(true);
                        subwindow.getParent().removeWindow(subwindow);
                    } catch (final EscidocClientException e) {
                        LOG.error(e.getLocalizedMessage());
                        mdName.setComponentError(new UserError(
                                "Failed to add the new Metadata record" + e.getLocalizedMessage()));
                    } catch (final SAXException e) {
                        LOG.error(e.getLocalizedMessage());
                        mdName.setComponentError(new UserError(
                                "Failed to add the new Metadata record" + e.getLocalizedMessage()));
                    } catch (final IOException e) {
                        LOG.error(e.getLocalizedMessage());
                        mdName.setComponentError(new UserError(
                                "Failed to add the new Metadata record" + e.getLocalizedMessage()));
                    } catch (final ParserConfigurationException e) {
                        LOG.error(e.getLocalizedMessage());
                        mdName.setComponentError(new UserError(
                                "Failed to add the new Metadata record" + e.getLocalizedMessage()));
                    }
                }
            }
        }

    });

    final Button cnclAdd = new Button("Cancel", new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
        }
    });

    hl.addComponent(btnAdd);
    hl.addComponent(cnclAdd);
    subwindow.addComponent(mdName);
    subwindow.addComponent(status);
    subwindow.addComponent(upload);
    subwindow.addComponent(progressLayout);
    subwindow.addComponent(hl);
    mainWindow.addWindow(subwindow);

}