Example usage for com.google.gwt.user.client.ui PopupPanel center

List of usage examples for com.google.gwt.user.client.ui PopupPanel center

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui PopupPanel center.

Prototype

public void center() 

Source Link

Document

Centers the popup in the browser window and shows it.

Usage

From source file:com.edgenius.wiki.gwt.client.widgets.Lightbox.java

License:Open Source License

/**
 * Only show background mask on owner scope. if owner is null, then it is entire page scope. 
 * @param owner/*from w  w  w  .  ja v a  2 s .co  m*/
 * @param popup
 */
public Lightbox(UIObject owner, final PopupPanel popup) {
    this.popup = popup;
    this.owner = owner;
    background = new PopupPanel();
    background.setStyleName(Css.LIGHT_BOX_BK);

    if (owner == null) {
        DOM.setStyleAttribute(background.getElement(), "width", "100%");
        DOM.setStyleAttribute(background.getElement(), "height", "5000px"); //Window.getClientHeight()

        evtReg = Window.addResizeHandler(new ResizeHandler() {
            public void onResize(ResizeEvent event) {
                //background need be adjust size, but popup won't display if it is not showing. 
                if (popup.isShowing()) {
                    popup.center();
                    if (popup instanceof DialogBox) {
                        List<DialogListener> listeners = ((DialogBox) popup).getDialogListeners();
                        if (listeners != null) {
                            for (DialogListener listener : listeners) {
                                listener.dialogRelocated((DialogBox) popup);
                            }
                        }
                    }
                }
            }
        });
    } else {
        background.setPopupPosition(owner.getAbsoluteLeft(), owner.getAbsoluteTop());
        DOM.setStyleAttribute(background.getElement(), "width", owner.getOffsetWidth() + "px");
        DOM.setStyleAttribute(background.getElement(), "height", owner.getOffsetHeight() + "px");
    }

}

From source file:com.google.appinventor.client.explorer.youngandroid.ReportList.java

License:Open Source License

/**
 * Helper method of creating a sending email popup
 * @param report/*from   www  . java 2  s .  c o  m*/
 */
private void sendEmailPopup(final GalleryAppReport report) {
    // Create a PopUpPanel with a button to close it
    final PopupPanel popup = new PopupPanel(true);
    popup.setStyleName("ode-InboxContainer");
    final FlowPanel content = new FlowPanel();
    content.addStyleName("ode-Inbox");
    Label title = new Label(MESSAGES.emailSendTitle());
    title.addStyleName("InboxTitle");
    content.add(title);

    Button closeButton = new Button(MESSAGES.symbolX());
    closeButton.addStyleName("CloseButton");
    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            popup.hide();
        }
    });
    content.add(closeButton);

    final FlowPanel emailPanel = new FlowPanel();
    emailPanel.addStyleName("app-actions");
    final Label sentFrom = new Label(MESSAGES.emailSentFrom());
    final Label sentTo = new Label(MESSAGES.emailSentTo() + report.getOffender().getUserName());
    final TextArea emailBodyText = new TextArea();
    emailBodyText.addStyleName("action-textarea");
    final Button sendEmail = new Button(MESSAGES.buttonSendEmail());
    sendEmail.addStyleName("action-button");

    // Account Drop Down Button
    List<DropDownItem> templateItems = Lists.newArrayList();
    // Email Template 1
    templateItems.add(
            new DropDownItem("template1", MESSAGES.inappropriateAppContentRemoveTitle(), new TemplateAction(
                    emailBodyText, EMAIL_INAPPROPRIATE_APP_CONTENT_REMOVE, report.getApp().getTitle())));
    templateItems.add(new DropDownItem("template2", MESSAGES.inappropriateAppContentTitle(),
            new TemplateAction(emailBodyText, EMAIL_INAPPROPRIATE_APP_CONTENT, report.getApp().getTitle())));
    templateItems.add(new DropDownItem("template3", MESSAGES.inappropriateUserProfileContentTitle(),
            new TemplateAction(emailBodyText, EMAIL_INAPPROPRIATE_USER_PROFILE_CONTENT, null)));

    templateButton = new DropDownButton("template", MESSAGES.labelChooseTemplate(), templateItems, true);
    templateButton.setStyleName("ode-TopPanelButton");

    new TemplateAction(emailBodyText, EMAIL_INAPPROPRIATE_APP_CONTENT, report.getApp().getTitle()).execute();

    emailPanel.add(templateButton);
    emailPanel.add(sentFrom);
    emailPanel.add(sentTo);
    emailPanel.add(emailBodyText);
    emailPanel.add(sendEmail);

    content.add(emailPanel);
    popup.setWidget(content);
    // Center and show the popup
    popup.center();

    final User currentUser = Ode.getInstance().getUser();
    sentFrom.setText(MESSAGES.emailSentFrom() + currentUser.getUserName());
    sendEmail.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final OdeAsyncCallback<Long> emailCallBack = new OdeAsyncCallback<Long>(MESSAGES.galleryError()) {
                @Override
                public void onSuccess(final Long emailId) {
                    if (emailId == Email.NOTRECORDED) {
                        Window.alert(MESSAGES.moderationErrorFailToSendEmail());
                        popup.hide();
                    } else {
                        popup.hide();
                        storeModerationAction(report.getReportId(), report.getApp().getGalleryAppId(), emailId,
                                GalleryModerationAction.SENDEMAIL, getEmailPreview(emailBodyText.getText()));
                    }
                }
            };
            String emailBody = emailBodyText.getText() + MESSAGES.galleryVisitGalleryAppLinkLabel(
                    Window.Location.getHost(), report.getApp().getGalleryAppId());
            Ode.getInstance().getGalleryService().sendEmail(currentUser.getUserId(),
                    report.getOffender().getUserId(), report.getOffender().getUserEmail(),
                    MESSAGES.moderationSendEmailTitle(), emailBody, emailCallBack);
        }
    });
}

From source file:com.google.appinventor.client.explorer.youngandroid.ReportList.java

License:Open Source License

/**
 * Helper method for deactivating App Popup
 * @param report GalleryAppReport Gallery App Report
 * @param rw ReportWidgets Report Widgets
 *///from ww  w  .j a va2s.  com
private void deactivateAppPopup(final GalleryAppReport report, final ReportWidgets rw) {
    // Create a PopUpPanel with a button to close it
    final PopupPanel popup = new PopupPanel(true);
    popup.setStyleName("ode-InboxContainer");
    final FlowPanel content = new FlowPanel();
    content.addStyleName("ode-Inbox");
    Label title = new Label(MESSAGES.emailSendTitle());
    title.addStyleName("InboxTitle");
    content.add(title);

    Button closeButton = new Button(MESSAGES.symbolX());
    closeButton.addStyleName("CloseButton");
    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            popup.hide();
        }
    });
    content.add(closeButton);

    final FlowPanel emailPanel = new FlowPanel();
    emailPanel.addStyleName("app-actions");
    final Label sentFrom = new Label(MESSAGES.emailSentFrom());
    final Label sentTo = new Label(MESSAGES.emailSentTo() + report.getOffender().getUserName());
    final TextArea emailBodyText = new TextArea();
    emailBodyText.addStyleName("action-textarea");
    final Button sendEmailAndDeactivateApp = new Button(MESSAGES.labelDeactivateAppAndSendEmail());
    sendEmailAndDeactivateApp.addStyleName("action-button");
    final Button cancel = new Button(MESSAGES.labelCancel());
    cancel.addStyleName("action-button");

    // Account Drop Down Button
    List<DropDownItem> templateItems = Lists.newArrayList();
    // Email Template 1
    templateItems.add(
            new DropDownItem("template1", MESSAGES.inappropriateAppContentRemoveTitle(), new TemplateAction(
                    emailBodyText, EMAIL_INAPPROPRIATE_APP_CONTENT_REMOVE, report.getApp().getTitle())));
    templateItems.add(new DropDownItem("template2", MESSAGES.inappropriateAppContentTitle(),
            new TemplateAction(emailBodyText, EMAIL_INAPPROPRIATE_APP_CONTENT, report.getApp().getTitle())));
    templateItems.add(new DropDownItem("template3", MESSAGES.inappropriateUserProfileContentTitle(),
            new TemplateAction(emailBodyText, EMAIL_INAPPROPRIATE_USER_PROFILE_CONTENT, null)));
    templateButton = new DropDownButton("template", MESSAGES.labelChooseTemplate(), templateItems, true);
    templateButton.setStyleName("ode-TopPanelButton");

    // automatically choose first template
    new TemplateAction(emailBodyText, EMAIL_INAPPROPRIATE_APP_CONTENT_REMOVE, report.getApp().getTitle())
            .execute();

    emailPanel.add(templateButton);
    emailPanel.add(sentFrom);
    emailPanel.add(sentTo);
    emailPanel.add(emailBodyText);
    emailPanel.add(sendEmailAndDeactivateApp);
    emailPanel.add(cancel);

    content.add(emailPanel);
    popup.setWidget(content);
    // Center and show the popup
    popup.center();

    cancel.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            popup.hide();
        }
    });

    final User currentUser = Ode.getInstance().getUser();
    sentFrom.setText(MESSAGES.emailSentFrom() + currentUser.getUserName());
    sendEmailAndDeactivateApp.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final OdeAsyncCallback<Long> emailCallback = new OdeAsyncCallback<Long>(MESSAGES.galleryError()) {
                @Override
                public void onSuccess(final Long emailId) {
                    if (emailId == Email.NOTRECORDED) {
                        Window.alert(MESSAGES.moderationErrorFailToSendEmail());
                        popup.hide();
                    } else {
                        popup.hide();
                        final OdeAsyncCallback<Boolean> callback = new OdeAsyncCallback<Boolean>(
                                // failure message
                                MESSAGES.galleryError()) {
                            @Override
                            public void onSuccess(Boolean success) {
                                if (!success)
                                    return;
                                if (rw.appActive == true) { //app was active, now is deactive
                                    rw.deactiveAppButton.setText(MESSAGES.labelReactivateApp());//revert button
                                    rw.appActive = false;
                                    storeModerationAction(report.getReportId(),
                                            report.getApp().getGalleryAppId(), emailId,
                                            GalleryModerationAction.DEACTIVATEAPP,
                                            getEmailPreview(emailBodyText.getText()));
                                } else { //app was deactive, now is active
                                    /*This should not be reached, just in case*/
                                    rw.deactiveAppButton.setText(MESSAGES.labelDeactivateApp());//revert button
                                    rw.appActive = true;
                                    storeModerationAction(report.getReportId(),
                                            report.getApp().getGalleryAppId(), emailId,
                                            GalleryModerationAction.REACTIVATEAPP,
                                            getEmailPreview(emailBodyText.getText()));
                                }
                                //update gallery list
                                galleryClient.appWasChanged();
                            }
                        };
                        Ode.getInstance().getGalleryService()
                                .deactivateGalleryApp(report.getApp().getGalleryAppId(), callback);
                    }
                }
            };
            String emailBody = emailBodyText.getText() + MESSAGES.galleryVisitGalleryAppLinkLabel(
                    Window.Location.getHost(), report.getApp().getGalleryAppId());
            Ode.getInstance().getGalleryService().sendEmail(currentUser.getUserId(),
                    report.getOffender().getUserId(), report.getOffender().getUserEmail(),
                    MESSAGES.moderationAppDeactivatedTitle(), emailBody, emailCallback);
        }
    });
}

From source file:com.google.appinventor.client.explorer.youngandroid.ReportList.java

License:Open Source License

/**
 * Helper method of creating popup window to show all associated moderation actions.
 * @param report GalleryAppReport gallery app report
 *//*w ww  .  j a v  a  2 s  .  c o m*/
private void seeAllActionsPopup(GalleryAppReport report) {
    // Create a PopUpPanel with a button to close it
    final PopupPanel popup = new PopupPanel(true);
    popup.setStyleName("ode-InboxContainer");
    final FlowPanel content = new FlowPanel();
    content.addStyleName("ode-Inbox");
    Label title = new Label(MESSAGES.titleSeeAllActionsPopup());
    title.addStyleName("InboxTitle");
    content.add(title);

    Button closeButton = new Button(MESSAGES.symbolX());
    closeButton.addStyleName("CloseButton");
    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            popup.hide();
        }
    });
    content.add(closeButton);

    final FlowPanel actionPanel = new FlowPanel();
    actionPanel.addStyleName("app-actions");

    final OdeAsyncCallback<List<GalleryModerationAction>> callback = new OdeAsyncCallback<List<GalleryModerationAction>>(
            // failure message
            MESSAGES.galleryError()) {
        @Override
        public void onSuccess(List<GalleryModerationAction> moderationActions) {
            for (final GalleryModerationAction moderationAction : moderationActions) {
                FlowPanel record = new FlowPanel();
                Label time = new Label();
                Date createdDate = new Date(moderationAction.getDate());
                DateTimeFormat dateFormat = DateTimeFormat.getFormat("yyyy/MM/dd HH:mm:ss");
                time.setText(dateFormat.format(createdDate));
                time.addStyleName("time-label");
                record.add(time);
                Label moderatorLabel = new Label();
                moderatorLabel.setText(moderationAction.getModeratorName());
                moderatorLabel.addStyleName("moderator-link");
                moderatorLabel.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        Ode.getInstance().switchToUserProfileView(moderationAction.getModeratorId(),
                                1 /* 1 for public view*/ );
                        popup.hide();
                    }
                });
                record.add(moderatorLabel);
                final Label actionLabel = new Label();
                actionLabel.addStyleName("inline-label");
                record.add(actionLabel);
                int actionType = moderationAction.getActonType();
                switch (actionType) {
                case GalleryModerationAction.SENDEMAIL:
                    actionLabel.setText(MESSAGES.moderationActionSendAnEmail());
                    createEmailCollapse(record, moderationAction.getMesaageId(),
                            moderationAction.getEmailPreview());
                    break;
                case GalleryModerationAction.DEACTIVATEAPP:
                    actionLabel.setText(MESSAGES.moderationActionDeactivateThisAppWithEmail());
                    createEmailCollapse(record, moderationAction.getMesaageId(),
                            moderationAction.getEmailPreview());
                    break;
                case GalleryModerationAction.REACTIVATEAPP:
                    actionLabel.setText(MESSAGES.moderationActionReactivateThisApp());
                    break;
                case GalleryModerationAction.MARKASRESOLVED:
                    actionLabel.setText(MESSAGES.moderationActionMarkThisReportAsResolved());
                    break;
                case GalleryModerationAction.MARKASUNRESOLVED:
                    actionLabel.setText(MESSAGES.moderationActionMarkThisReportAsUnresolved());
                    break;
                default:
                    break;
                }
                actionPanel.add(record);
            }
        }
    };
    Ode.getInstance().getGalleryService().getModerationActions(report.getReportId(), callback);

    content.add(actionPanel);
    popup.setWidget(content);
    // Center and show the popup
    popup.center();
}

From source file:com.google.appinventor.client.wizards.youngandroid.RemixedYoungAndroidProjectWizard.java

License:Open Source License

/**
 * Creates a new YoungAndroid project wizard.
 *///ww w .  jav a  2  s.com
public RemixedYoungAndroidProjectWizard(final GalleryApp app, final Button actionButton) {
    super(MESSAGES.remixedYoungAndroidProjectWizardCaption());

    this.actionButton = actionButton;
    gallery = GalleryClient.getInstance();
    // Initialize the UI
    setStylePrimaryName("ode-DialogBox");

    projectNameTextBox = new LabeledTextBox(MESSAGES.projectNameLabel());
    projectNameTextBox.setText(replaceNonTextChar(app.getTitle()));
    projectNameTextBox.getTextBox().addKeyDownHandler(new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {
            int keyCode = event.getNativeKeyCode();
            if (keyCode == KeyCodes.KEY_ENTER) {
                handleOkClick();
            } else if (keyCode == KeyCodes.KEY_ESCAPE) {
                handleCancelClick();
            }
        }
    });

    VerticalPanel page = new VerticalPanel();
    page.add(projectNameTextBox);
    addPage(page);
    // Create finish command (create a new Young Android project)
    initFinishCommand(new Command() {
        @Override
        public void execute() {
            String projectName = projectNameTextBox.getText();
            final PopupPanel popup = new PopupPanel(true);
            final FlowPanel content = new FlowPanel();
            popup.setWidget(content);
            Label loading = new Label();
            loading.setText(MESSAGES.loadingAppIndicatorText());
            // loading indicator will be hided or forced to be hided in gallery.loadSourceFile
            content.add(loading);
            popup.center();
            boolean success = gallery.loadSourceFile(app, projectNameTextBox.getText(), popup);
            if (success) {
                gallery.appWasDownloaded(app.getGalleryAppId(), app.getDeveloperId());
            } else {
                show();
                center();
                return;
            }
        }
    });
}

From source file:com.google.gwt.sample.showcase.client.content.popups.CwBasicPopup.java

License:Apache License

/**
 * Initialize this example.//from w  w w . j a  va 2s  .  c o  m
 */
@ShowcaseSource
@Override
public Widget onInitialize() {
    // Create a basic popup widget
    final DecoratedPopupPanel simplePopup = new DecoratedPopupPanel(true);
    simplePopup.ensureDebugId("cwBasicPopup-simplePopup");
    simplePopup.setWidth("150px");
    simplePopup.setWidget(new HTML(constants.cwBasicPopupClickOutsideInstructions()));

    // Create a button to show the popup
    Button openButton = new Button(constants.cwBasicPopupShowButton(), new ClickHandler() {
        public void onClick(ClickEvent event) {
            // Reposition the popup relative to the button
            Widget source = (Widget) event.getSource();
            int left = source.getAbsoluteLeft() + 10;
            int top = source.getAbsoluteTop() + 10;
            simplePopup.setPopupPosition(left, top);

            // Show the popup
            simplePopup.show();
        }
    });

    // Create a popup to show the full size image
    Image jimmyFull = new Image(Showcase.images.jimmy());
    final PopupPanel imagePopup = new PopupPanel(true);
    imagePopup.setAnimationEnabled(true);
    imagePopup.ensureDebugId("cwBasicPopup-imagePopup");
    imagePopup.setWidget(jimmyFull);
    jimmyFull.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            imagePopup.hide();
        }
    });

    // Add an image thumbnail
    Image jimmyThumb = new Image(Showcase.images.jimmyThumb());
    jimmyThumb.ensureDebugId("cwBasicPopup-thumb");
    jimmyThumb.addStyleName("cw-BasicPopup-thumb");
    jimmyThumb.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            imagePopup.center();
        }
    });

    // Add the widgets to a panel
    VerticalPanel vPanel = new VerticalPanel();
    vPanel.setSpacing(5);
    vPanel.add(openButton);
    vPanel.add(new HTML("<br><br><br>" + constants.cwBasicPopupInstructions()));
    vPanel.add(jimmyThumb);

    // Return the panel
    return vPanel;
}

From source file:com.google.gwt.sample.stockwatcher.client.NotificationServer.java

private static void renderPopup(String title, PopupPanel popup, ScrollPanel scrollPanel, FlexTable table,
        Button closeButton) {//from ww w . j  a  v a2  s  .c o m
    scrollPanel.clear();
    scrollPanel.setHeight("400px");
    scrollPanel.add(table);

    VerticalPanel lol = new VerticalPanel();
    lol.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    lol.setSpacing(10);
    lol.add(new HTML(title));
    lol.add(scrollPanel);
    lol.add(closeButton);

    popup.clear();
    popup.setVisible(true);
    popup.add(lol);
    popup.show();
    popup.center();
    popup.setVisible(false);

    popupList.add(popup);
}

From source file:com.google.gwt.sample.stockwatcher.client.OntologyBasedContentManagement.java

@SuppressWarnings("deprecation")
@Override/*from w ww. j  a va 2  s  .co  m*/
public void onModuleLoad() {
    /*
     * Create file interface
     */
    // Create a FormPanel and point it at a service.
    form = new FormPanel();
    form.setAction(GWT.getModuleBaseURL() + "greet");
    form.setEncoding(FormPanel.ENCODING_MULTIPART);
    form.setMethod(FormPanel.METHOD_POST);

    form.setWidget(secondPanel);
    // secondPanel.add(statusLabel);
    // fileUpload.setName(form.getTitle());
    fileUpload.setName("UploadFile");

    secondPanel.add(fileUpload);
    uploadedOntologies.add(loadFile);
    ClickHandler load_handler = new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            form.submit();
        }
    };
    loadFile.addClickHandler(load_handler);

    ontologies = new ListBox();
    ontologies.setSize("152px", "18px");

    uploadedOntologies.add(ontologies);
    uploadedOntologies.setSpacing(5);
    // secondPanel.add(uploadedOntologies);

    /*
     * end file creation
     */
    logger.log(Level.SEVERE, "Log!");
    Ont_Table.setText(1, 0, "Class"); // 3 columns
    Ont_Table.setText(1, 2, "Object Property");
    Ont_Table.setText(1, 4, "Data Property");
    double wi = Window.getClientWidth() / 3.5;
    String tablewidth = Double.toString(wi);
    tripleTable.getColumnFormatter().setWidth(0, tablewidth);
    tripleTable.getColumnFormatter().setWidth(1, tablewidth);
    tripleTable.getColumnFormatter().setWidth(2, tablewidth);
    tripleTable.setStyleName("Prompt-User");
    tripleTable.setText(0, 0, "Subject");
    tripleTable.setText(0, 1, "Predicate");
    tripleTable.setText(0, 2, "Object");
    tripleTable.getRowFormatter().addStyleName(0, "Prompt-User");
    tripleTable.getColumnFormatter().addStyleName(0, "columnOne");
    tripleTable.getColumnFormatter().addStyleName(1, "columnTwo");
    tripleTable.getColumnFormatter().addStyleName(2, "columnThree");
    tripleTable.addStyleName("tripleTable");
    row = tripleTable.getRowCount();

    webBox.setText(url);
    webBox.setWidth("340px");
    frameWidth = String.valueOf(Window.getClientWidth() / 3.3) + "px";
    queryBox.setText("\n\n\n\n\n\t\t\t\t\tEnter Query");
    queryBox.setSize("369px", "332px");

    queryBox.addFocusHandler(new FocusHandler() {

        @Override
        public void onFocus(FocusEvent event) {
            queryBox.selectAll();
        }

    });
    ontology_from_disk.setText("/Users/markhender/ontologies/pizzas/pizza.rdf");
    ontology_from_disk.setWidth("340px");
    frame = new Frame();
    frame.setUrl(url);
    frameWidth = String.valueOf(Window.getClientWidth() / 1.5) + "px"; // works
    // cross
    // browsers
    frameHeight = String.valueOf(String.valueOf(Window.getClientHeight() / 1.3) + "px");
    frame.setWidth(frameWidth);
    frame.setHeight(frameHeight);
    frame.setVisible(true);

    /*
     * Popup Panel
     */
    popupHolder.add(closePopup);

    popup.setWidget(popupContents);
    closePopup.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            int end_of_list = ft.getRowCount();
            int count = 1;

            while (count < end_of_list) {
                logger.log(Level.SEVERE, "line");
                CheckBox box = (CheckBox) ft.getWidget(count, 3);
                if (box.getValue()) {
                    // tripleTable.setText(tripleTable.getRowCount(), 0,
                    // ft.getText(count, 0));
                    printSuggestedSubject(ft.getText(count, 0));
                    addPredicate(ft.getText(count, 1));
                    if (ft.getText(count, 1).endsWith("*"))
                        addLitObject(ft.getText(count, 2));
                    else
                        addObject(ft.getText(count, 2));
                }
                count++;
            }
            logger.log(Level.SEVERE, "BINGO");
            ft.removeAllRows();

            popup.hide();
            popupContents.clear();
            popupContents.add(popupHolder);
        }
    });
    content.setText("Search for content in webpage");
    content.addFocusHandler(new FocusHandler() {

        @Override
        public void onFocus(FocusEvent event) {
            content.setFocus(true);
            if (content.getText().equals("Search for content in webpage"))
                content.setText("");
            else
                content.selectAll();
        }
    });
    addPanel.add(webBox);

    searchPanel.add(content); // content search box
    searchPanel.add(search); // trigger content search button
    search.setHeight("37px");
    dBox.setText("Triple Report");
    close.setText("Close");
    close.addClickListener(new ClickListener() {

        @Override
        public void onClick(Widget sender) {
            dialogBoxContents.clear();
            dBox.hide();
        }
    });
    dialogBoxholder.add(close);

    loadOntologyInternet.add(ontology_from_internet);
    loadOntologyInternet.add(load_ontology_web_button);
    radioButtonPanel.add(radioA);
    radioButtonPanel.add(radioB);
    searchPanel.add(radioButtonPanel);
    bottomOfScreen.add(searchPanel);
    bottomOfScreen.add(tripleTable);
    tripleTable.setSize("981px", "67px");
    // bottomOfScreen.setSpacing(10);
    search.setText("Enter");
    content.setSize("282px", "29px");
    ListBox listbox = new ListBox();
    ontology_Classes = new ListBox(); // Ontology class listbox
    property_Resources = new ListBox(); // " property listbox
    property_Literals = new ListBox(); // " individual listbox
    ontology_Classes.setWidth("100px");
    property_Resources.setWidth("100px");
    property_Literals.setWidth("100px");

    listbox.setWidth("100px");
    listbox.setHeight("400px");
    save.setText("Save");
    listbox.setVisible(false);
    /*
     * before new page
     */
    final PopupPanel contextpanel = new PopupPanel();

    final Button ok = new Button("OK");
    final HorizontalPanel hori = new HorizontalPanel();
    contextpanel.setWidget(hori);
    entercontext.setText("context");
    hori.add(ok);
    final ClickHandler download_handler = new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            greetingService.downloadRepository(entercontext.getText(), new downloadRepository());
            if (repository_downloaded)
                loadPageTwo(export_fp);
            repository_downloaded = true;
            logger.log(Level.SEVERE, "download_handler called");
        }
    };
    ClickHandler newpage_handler = new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            contextpanel.center();
            ok.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    if (repository_downloaded)
                        loadPageTwo(export_fp);
                    else {
                        download_handler.onClick(event);

                    }
                    contextpanel.hide();

                }

            });
            logger.log(Level.SEVERE, "export path: " + filepathofexport);

        }

    };
    new_page.addClickHandler(newpage_handler);
    download_repository.addClickHandler(download_handler);
    /* Return to homepage */
    home_page.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            loadHomePage();
        }
    });
    /* home page */

    //mainPanel.add(frame); // browser
    mainPanel.add(uploadedOntologies);
    mainPanel.add(addPanel); // url for browser
    addPanel.add(webSend);
    webSend.setHeight("32px");

    webSend.setText("GO");

    // Listen for mouse events on webSend Button
    // to get new website
    webSend.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            frame.setUrl(webBox.getText()); // take url from textbox
            logger.log(Level.SEVERE, frame.getUrl());
            content.setFocus(true);
            content.selectAll();
        }
    });
    mainPanel.add(loadOntologyInternet);
    mainPanel.add(Ont_Table); // listboxes
    mainPanel.add(queryBox);
    mainPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    mainPanel.add(queryButton);
    mainPanel.add(new_page);
    mainPanel.add(download_repository);

    RootPanel.get("stockList").add(frame, RootPanel.get("stockList").getAbsoluteLeft(),
            RootPanel.get("stockList").getAbsoluteTop());
    RootPanel.get("stockList").add(bottomOfScreen, 0, 725);
    bottomOfScreen.setSize("984px", "128px");
    RootPanel.get("stockList").add(form, frame.getOffsetWidth() + 10, frame.getAbsoluteTop());
    RootPanel.get("stockList").add(mainPanel, frame.getOffsetWidth() + 10,
            form.getOffsetHeight() + frame.getAbsoluteTop());
    // listen for keyboard events in the textbox
    webBox.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                frame.setUrl(webBox.getText());
                content.setFocus(true);
                content.selectAll();
            }
        }
    });
    frame.addLoadHandler(new LoadHandler() {

        @Override
        public void onLoad(LoadEvent event) {

        }

    });
    final AsyncCallback<ArrayList<String>> ontology_class = new AsyncCallback<ArrayList<String>>() {

        @Override
        public void onFailure(Throwable caught) {

        }

        @Override
        public void onSuccess(ArrayList<String> result) {
            classes = result;
            ontology.get(ontology.size() - 1).setClasses(result);
            if (ontology.size() == 1)
                populate_ClassBox(0);
        }
    };
    final AsyncCallback<ArrayList<String>> property_resource = new AsyncCallback<ArrayList<String>>() {
        @Override
        public void onFailure(Throwable caught) {

        }

        @Override
        public void onSuccess(ArrayList<String> result) {
            properties = result;
            ontology.get(ontology.size() - 1).setProperties(result);
            if (ontology.size() == 1)
                populate_PropertyBox(0);
        }
    };
    final AsyncCallback<ArrayList<String>> property_literal = new AsyncCallback<ArrayList<String>>() {

        @Override
        public void onFailure(Throwable caught) {

        }

        @Override
        public void onSuccess(ArrayList<String> result) {
            literals = result;
            ontology.get(ontology.size() - 1).setLiterals(result);
            if (ontology.size() == 1)
                populate_LiteralBox(0);
        }
    };

    load_ontology_web_button.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            // TODO load ontologies from a web address
        }

    });
    final AsyncCallback<Integer[]> subjectIndexOfContent = new AsyncCallback<Integer[]>() {

        @Override
        public void onFailure(Throwable caught) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onSuccess(Integer[] result) {
            if (result[0] != -99 && result[1] != -99) {
                // word found
                printSubject();
            } else
                Window.alert("Word not found");
        }

    };

    final AsyncCallback<String> getOntName = new AsyncCallback<String>() {
        @Override
        public void onFailure(Throwable caught) {

        }

        @Override
        public void onSuccess(String result) {
            ontName = result;
            ontology.get(ontology.size() - 1).setName(result);
            logger.log(Level.SEVERE, ("OntologyName = " + ontName));
        }

    };

    final AsyncCallback<String> geturi = new AsyncCallback<String>() {

        @Override
        public void onFailure(Throwable caught) {

        }

        @Override
        public void onSuccess(String result) {
            baseURI = result;
            ontology.get(ontology.size() - 1).setBaseURI(result);
            logger.log(Level.SEVERE, "The baseURI is " + baseURI);
        }

    };
    final AsyncCallback<ArrayList<String[]>> suggestedTriples = new AsyncCallback<ArrayList<String[]>>() {

        @Override
        public void onFailure(Throwable caught) {

        }

        @Override
        public void onSuccess(ArrayList<String[]> result) {
            logger.log(Level.SEVERE, "First");
            populateSuggestedTriples(result);
            Window.alert("Pass");
        }

    };
    tripleTable.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            com.google.gwt.user.client.ui.HTMLTable.Cell cell = tripleTable.getCellForEvent(event);
            int cellIndex = cell.getCellIndex();
            int rowIndex = cell.getRowIndex();
            if (cellIndex == 4 || cellIndex == 0) {
                logger.log(Level.SEVERE, "Sending: " + tripleTable.getText(rowIndex, 0));
                greetingService.suggestedTriples(tripleTable.getHTML(rowIndex, 0), suggestedTriples);

            }

        }
    });

    search.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            String blah = content.getText();
            if (radioA.isChecked() || !radioB.isChecked())
                greetingService.wordExists(blah, webBox.getText(), subjectIndexOfContent);
            else {
                printSubject();
            }
            content.setFocus(true);
            content.selectAll();
        }
    });

    content.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent event) {

            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                if (radioA.isChecked() || !radioB.isChecked())
                    greetingService.wordExists(content.getText(), webBox.getText(), subjectIndexOfContent);
                else
                    printSubject();
                content.setFocus(true);
                content.selectAll();
            }
        }
    });
    save.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            String[] temp = new String[3];
            temp = getTriples();
            repository_downloaded = false;
        }
    });

    Ont_Table.setWidget(0, 2, menuBar);
    menuBar.setSize("100%", "100%");

    Classes = new MenuItem("Classes", false, menuBar_3);
    Ontology_Contents_Holder.addItem(Classes);
    menuBar_2.addItem(mntmObject);
    menuBar_2.addItem(mntmData);
    Ontology_Contents_Holder.addItem(Properties);
    menuBar.addItem(Ontology_Name);

    Ont_Table.setWidget(2, 2, property_Resources);
    Ont_Table.setWidget(2, 4, property_Literals);

    /*
     * Adding Change listener to listboxes
     */
    ontologies.addChangeListener(new ChangeListener() {
        @Override
        public void onChange(Widget sender) {
            int listIndex = ontologies.getSelectedIndex();

            populate_ClassBox(listIndex);
            populate_PropertyBox(listIndex);
            populate_LiteralBox(listIndex);
        }
    });
    ontology_Classes.addChangeListener(new ChangeListener() {

        @Override
        public void onChange(Widget sender) {
            int listIndex = ontology_Classes.getSelectedIndex();
            String uri = ontology.get(ontologies.getSelectedIndex()).getBaseURI();
            String item = uri + ontology_Classes.getItemText(listIndex);
            addObject(item);
        }

    });
    property_Resources.addChangeListener(new ChangeListener() {

        @Override
        public void onChange(Widget sender) {
            // TODO Auto-generated method stub
            int listIndex = property_Resources.getSelectedIndex();
            logger.log(Level.SEVERE, property_Resources.getItemText(listIndex));
            if (!(property_Resources.getItemText(listIndex).equals("RDF.type"))) {
                logger.log(Level.SEVERE, "not rdf.type");
                String uri = ontology.get(ontologies.getSelectedIndex()).getBaseURI();
                String item = uri + property_Resources.getItemText(listIndex);
                addPredicate(item);
            } else {
                logger.log(Level.SEVERE, "rdf.type");
                String item = property_Resources.getItemText(listIndex);
                addPredicate(item);
            }

        }

    });

    property_Literals.addChangeListener(new ChangeListener() {
        @Override
        public void onChange(Widget sender) {
            if (property_Literals.getItemCount() == 0)
                Window.alert("This list is empty!");
            else {
                int listIndex = property_Literals.getSelectedIndex();
                String uri = ontology.get(ontologies.getSelectedIndex()).getBaseURI();
                String item = uri + property_Literals.getItemText(listIndex);
                addPredicate(item);
            }
        }
    });

    /*
     * File submit handling
     */
    form.addFormHandler(new FormHandler() {

        @Override
        public void onSubmit(FormSubmitEvent event) {
            // logger.log(Level.SEVERE, "form title: "+
            // fileUpload.getFilename().substring(fileUpload.getFilename().lastIndexOf('\\')
            // + 1));
            ontName = fileUpload.getFilename().substring(fileUpload.getFilename().lastIndexOf('\\') + 1);

        }

        @Override
        public void onSubmitComplete(FormSubmitCompleteEvent event) {
            // TODO Auto-generated method stub

        }

    });
    form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {

        @Override
        public void onSubmitComplete(SubmitCompleteEvent event) {
            logger.log(Level.SEVERE, "form title: " + form.getTitle());
            form.reset();
            AsyncCallback<String> pathfile = new AsyncCallback<String>() {

                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub
                    Window.alert("Fail");
                }

                @Override
                public void onSuccess(String result) {
                    // TODO Auto-generated method stub
                    path_of_uploaded_file = result;
                    ontology.get(ontology.size() - 1).setFilePath(result);
                    Window.alert("Pass");
                    greetingService.greetServer(list, path_of_uploaded_file, 1, ontology_class);
                    greetingService.greetServer(list, path_of_uploaded_file, 2, property_resource);
                    greetingService.greetServer(list, path_of_uploaded_file, 3, property_literal);

                    ontologies.addItem(ontology.get(ontology.size() - 1).getName());

                    // logger.log(Level.SEVERE, baseURI);
                }

            };
            greetingService.filePath(pathfile);
            greetingService.getBaseURI(geturi);
            // greetingService.getOntName(getOntName);
            ontology.add(new Ontology(ontName, path_of_uploaded_file, baseURI, classes, properties, literals));
            // greetingService.getOntName(getOntName);
            if (ontology.size() == 1) {
                // populate_listBoxes();
            }
            logger.log(Level.SEVERE, "baseuri = " + baseURI);
        }

    });

}

From source file:com.nitrous.gwt.earth.client.demo.ShimDemo.java

License:Apache License

/**
 * This is how to display a GWT PopupPanel over the top of the Google Earth
 * Plug-in using the 'shim' technique. The shim technique places an IFrame
 * in-front of the earth plug-in but behind the PopupPanel by configuring
 * the absolute position, size and z-index of the IFrame.
 *//*w  w  w .j a  v a  2s .c  o m*/
private void showPopupWindow() {

    // the HTML content to be rendered inside the PopupPanel
    HTML content = new HTML("<b>Window test</b><br>"
            + "This PopupPanel is visible since we have an IFrame (shim) between the PopupPanel and the Google Earth Plugin. "
            + "View source code <a href=\""
            + "http://code.google.com/p/gwt-earth-3/source/browse/trunk/src/com/nitrous/gwt/earth/client/demo/ShimDemo.java\""
            + " target=\"new\">here</a>");

    // configure the PopupPanel size and position
    final PopupPanel window = new PopupPanel(false, false);
    window.setTitle("Shim test");
    window.add(content);
    final int width = 300;
    final int height = 80;
    window.setSize(width + "px", height + "px");
    window.center();
    final int left = window.getPopupLeft();
    final int top = window.getPopupTop();

    // Configure the z-index of the PopupPanel HTML content so that it is rendered in-front of everything (highest z-index)
    content.getElement().setAttribute("style", "z-index: " + (Integer.MAX_VALUE) + ";" + " width: " + width
            + "px;" + " height: " + height + "px;");

    // PopupPanel is to be displayed immediately behind content (slightly lower z-index)
    window.getElement().setAttribute("style", "z-index: " + (Integer.MAX_VALUE - 1) + ";"
            + " position: absolute;" + " left: " + left + "px;" + " top: " + top + "px;");

    window.show();

    // Allow some time for the browser to render the window and then configure the IFrame shim
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        @Override
        public void execute() {
            final IFrameElement iframe = Document.get().createIFrameElement();

            // Initialize the IFrame to be the same size and position as the
            // window but with a smaller z-index value.
            // The size of the IFrame is tweaked by +9px to allow the border of the PopupPanel to be rendered correctly.
            iframe.setAttribute("style",
                    "z-index: " + (Integer.MAX_VALUE - 2) + ";" + " width: " + (width + 9) + "px;" + " height: "
                            + (height + 9) + "px;" + " position: absolute;" + " left: " + left + "px;"
                            + " top: " + top + "px;");

            // add the IFrame to the document body
            Document.get().getBody().appendChild(iframe);

            // remove the IFrame when the PopupPanel is closed
            window.addCloseHandler(new CloseHandler<PopupPanel>() {
                @Override
                public void onClose(CloseEvent<PopupPanel> event) {
                    iframe.removeFromParent();
                }
            });
        }
    });
}

From source file:com.ponysdk.ui.terminal.ui.PTPopupPanel.java

License:Apache License

@Override
public void update(final PTInstruction update, final UIService uiService) {
    final PopupPanel popup = cast();

    if (update.containsKey(PROPERTY.ANIMATION)) {
        popup.setAnimationEnabled(update.getBoolean(PROPERTY.ANIMATION));
    } else if (update.containsKey(PROPERTY.POPUP_CENTER)) {
        popup.center();
    } else if (update.containsKey(PROPERTY.POPUP_SHOW)) {
        popup.show();/*from w  w  w  .j  ava 2 s  .c  o  m*/
    } else if (update.containsKey(PROPERTY.POPUP_HIDE)) {
        popup.hide();
    } else if (update.containsKey(PROPERTY.POPUP_GLASS_ENABLED)) {
        popup.setGlassEnabled(update.getBoolean(PROPERTY.POPUP_GLASS_ENABLED));
    } else if (update.containsKey(PROPERTY.POPUP_MODAL)) {
        popup.setModal(update.getBoolean(PROPERTY.POPUP_MODAL));
    } else if (update.containsKey(PROPERTY.POPUP_POSITION)) {
        final int left = update.getInt(PROPERTY.POPUP_POSITION_LEFT);
        final int top = update.getInt(PROPERTY.POPUP_POSITION_TOP);
        popup.setPopupPosition(left, top);
    } else if (update.containsKey(PROPERTY.POPUP_DRAGGABLE)) {
        final boolean draggable = update.containsKey(PROPERTY.POPUP_DRAGGABLE);
        if (draggable) {
            popup.addDomHandler(this, MouseDownEvent.getType());
            popup.addDomHandler(this, MouseUpEvent.getType());
            popup.addDomHandler(this, MouseMoveEvent.getType());
        }
    } else {
        super.update(update, uiService);
    }
}