Example usage for com.google.gwt.user.client.ui HTML HTML

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

Introduction

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

Prototype

protected HTML(Element element) 

Source Link

Document

This constructor may be used by subclasses to explicitly use an existing element.

Usage

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

License:Open Source License

/**
 * Creates a new GalleryPage, must take in parameters
 * @param app GalleryApp//www. j a  va 2s .  c  om
 * @param editStatus edit status
 */
public GalleryPage(final GalleryApp app, final int editStatus) {
    // Get a reference to the Gallery Client which handles the communication to
    // server to get gallery data
    gallery = GalleryClient.getInstance();
    gallery.addListener(this);

    // We are either publishing a new app, updating, or just reading. If we are publishing
    //   a new app, app has some partial info to be published. Otherwise, it has all
    //   the info for the already published app
    this.app = app;
    this.editStatus = editStatus;
    initComponents();

    // App header - image
    appHeader.addStyleName("app-header");
    // If we're editing or updating, add input form for image
    if (newOrUpdateApp()) {
        initImageComponents();
    } else { // we are just viewing this page so setup the image
        initReadOnlyImage();
    }

    // Now let's add the button for publishing, updating, or trying
    appHeader.add(appAction);
    initActionButton();
    if (editStatus == NEWAPP) {
        initCancelButton();
        /* Add Creative Commons Publishing Reference */
        appAction.add(ccLicenseRef);
    }
    if (editStatus == UPDATEAPP) {
        initRemoveButton();
        initCancelButton();
        /* Add Creative Commons Updating Reference */
        appAction.add(ccLicenseRef);
    }

    // App details - app title
    appInfo.add(titleBox);
    initAppTitle(titleBox);

    // App details - app author info
    appInfo.add(appAuthor);
    initAppAuthor(appAuthor);

    // Not showing in new app becaus it doesn't have these info
    // App details - meta
    if (!newOrUpdateApp()) {
        appInfo.add(appMeta);
        initAppStats(appMeta);
    }

    // App details - dates
    appInfo.add(appDates);
    initAppMeta(appDates);

    // App details - app description
    appInfo.add(descBox);
    initAppDesc(descBox, appDescPanel);
    /**
     * TODO: I may need to change the code logic here. appDescPanel is actually
     * not added to [appInfo], instead in public state appDescPanel will be
     * added into the [appActionTabs] (not showing in editable states) as a sub
     * tab. So it may not be the best idea to modify appDescPanel in a method
     * that resides in [appInfo]'s code block. - Vincent, 03/28/2014
     */

    // Pass app components to App Detail container
    appInfo.addStyleName("app-info-container");
    appPrimaryWrapper.add(appHeader);
    appPrimaryWrapper.add(appInfo);
    appPrimaryWrapper.addStyleName("clearfix");
    appDetails.add(appPrimaryWrapper);

    // If app is in its public state, add action tabs
    if (!newOrUpdateApp()) {
        // Add a divider
        HTML dividerPrimary = new HTML("<div class='section-divider'></div>");
        appDetails.add(dividerPrimary);
        // Initialize action tabs
        initActionTabs();
        // Initialize app share
        initAppShare();
        // Initialize app action features
        initReportSection();

        // We are not showing comments at initial launch, Such sadness :'[
        /*
        HTML dividerSecondary = new HTML("<div class='section-divider'></div>");
        appDetails.add(dividerSecondary);
        initAppComments();
        */

        // Add sidebar stuff, only in public state
        // By default, load the first tag's apps
        gallery.GetAppsByDeveloper(0, 5, app.getDeveloperId());
    }

    // Add to appSingle
    appSingle.add(appDetails);
    appDetails.addStyleName("gallery-container");
    appDetails.addStyleName("gallery-app-details");

    if (!newOrUpdateApp()) {
        appSingle.add(sidebarTabs);
        sidebarTabs.addStyleName("gallery-container");
        sidebarTabs.addStyleName("gallery-app-showcase");
    }

    // Add everything to top-level containers
    galleryGUI.add(appSingle);
    appSingle.addStyleName("gallery-app-single");
    panel.add(galleryGUI);
    galleryGUI.addStyleName("gallery");
    initWidget(panel);
}

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

License:Open Source License

/**
* Helper method called by constructor to initialize ui components
*//*from   w  w w.j a va2 s .  c  om*/
private void initComponents() {
    // Initialize UI
    panel = new VerticalPanel();
    panel.setWidth("100%");
    galleryGUI = new FlowPanel();
    appSingle = new FlowPanel();
    appDetails = new FlowPanel();
    appHeader = new FlowPanel();
    appInfo = new FlowPanel();
    appAction = new FlowPanel();
    appAuthor = new FlowPanel();
    appMeta = new FlowPanel();
    appDates = new FlowPanel();
    appPrimaryWrapper = new FlowPanel();
    appSecondaryWrapper = new FlowPanel();
    appDescPanel = new FlowPanel();
    appReportPanel = new FlowPanel();
    appSharePanel = new FlowPanel();
    appActionTabs = new TabPanel();
    sidebarTabs = new TabPanel();
    appComments = new FlowPanel();
    appCommentsList = new FlowPanel();
    appsByAuthor = new FlowPanel();
    appsByTags = new FlowPanel();
    appsRemixes = new FlowPanel();
    returnToGallery = new FlowPanel();
    //    tagSelected = "";

    appCreated = new Label();
    appChanged = new Label();
    descBox = new FlowPanel();
    titleBox = new FlowPanel();
    desc = new TextArea();
    titleText = new TextArea();
    moreInfoText = new TextArea();
    creditText = new TextArea();
    ccLicenseRef = new HTML(MESSAGES.galleryCcLicenseRef());
    ccLicenseRef.addStyleName("app-action-html");
}

From source file:com.google.appinventor.client.GalleryGuiFactory.java

License:Open Source License

/**
 * Loads the proper tab GUI with gallery's app data.
 * @param apps: list of returned gallery apps from callback.
 * @param container: the GUI panel where apps will reside.
 * @param refreshable: if true then the GUI can be reloaded later.
 *//*from  w w  w  .  j a  v  a2 s . co m*/
public void generateHorizontalAppList(List<GalleryApp> apps, FlowPanel container, Boolean refreshable) {
    if (refreshable) {
        // Flush the panel's content if we knew new stuff is coming in!
        container.clear();
    }
    for (final GalleryApp app : apps) {
        // Create the associated GUI object for app
        GalleryAppWidget gaw = new GalleryAppWidget(app);

        // Create necessary GUI wrappers and components
        FlowPanel appCard = new FlowPanel();
        FlowPanel appCardContent = new FlowPanel();
        FlowPanel appCardMeta = new FlowPanel();

        // Special processing for the app title, mainly for fade-out effect
        HTML appTitle = new HTML("" + "<div class='gallery-title'>" + gaw.nameLabel.getText()
                + "<span class='paragraph-end-block'></span></div>");

        // Special processing for the app author, mainly for fade-out effect
        HTML appAuthor = new HTML("" + "<div class='gallery-subtitle'>" + gaw.authorLabel.getText()
                + "<span class='paragraph-end-block'></span></div>");

        gaw.image.addClickHandler(new ClickHandler() {
            //  @Override
            public void onClick(ClickEvent event) {
                Ode.getInstance().switchToGalleryAppView(app, GalleryPage.VIEWAPP);
            }
        });

        appTitle.addClickHandler(new ClickHandler() {
            //  @Override
            public void onClick(ClickEvent event) {
                Ode.getInstance().switchToGalleryAppView(app, GalleryPage.VIEWAPP);
            }
        });

        // Add everything to the top-level stuff
        appCard.add(gaw.image);
        appCard.add(appCardContent);
        appCardContent.add(appTitle);
        appCardContent.add(appAuthor);
        appCardContent.add(appCardMeta);

        // Set helper icons
        Image numViews = new Image();
        numViews.setUrl("/images/numView.png");
        Image numDownloads = new Image();
        numDownloads.setUrl("/images/numDownload.png");
        Image numLikes = new Image();
        numLikes.setUrl("/images/numLikeHollow.png");
        // For generic cards, do not show comment
        //    Image numComments = new Image();
        //    numComments.setUrl("/image/numComment.png");

        //      appCardMeta.add(numViews);
        //      appCardMeta.add(gaw.numViewsLabel);
        appCardMeta.add(numDownloads);
        appCardMeta.add(gaw.numDownloadsLabel);
        appCardMeta.add(numLikes);
        appCardMeta.add(gaw.numLikesLabel);
        // For generic cards, do not show comment
        //      appCardMeta.add(numComments);
        //      appCardMeta.add(gaw.numCommentsLabel);

        // Add associated styling
        appCard.addStyleName("gallery-card");
        gaw.image.addStyleName("gallery-card-cover");
        //      gaw.nameLabel.addStyleName("gallery-title");
        //      gaw.authorLabel.addStyleName("gallery-subtitle");
        appCardContent.addStyleName("gallery-card-content");
        gaw.numViewsLabel.addStyleName("gallery-meta");
        gaw.numDownloadsLabel.addStyleName("gallery-meta");
        gaw.numLikesLabel.addStyleName("gallery-meta");
        //      gaw.numCommentsLabel.addStyleName("gallery-meta");

        container.add(appCard);
    }
    container.addStyleName("gallery-app-collection");
    container.addStyleName("clearfix"); /* For redesigned navigation buttons */

}

From source file:com.google.appinventor.client.GalleryGuiFactory.java

License:Open Source License

/**
 * Creates a sidebar showcasing apps; the CSS name will be the same as the
 * passed-in container's name. This sidebar shows up as a tab under parent.
 *
 * @param apps: list of returned gallery apps from callback.
 *
 * @param parent: the parent TabPanel that this panel will reside in.
 *
 * @param container: the panel containing this particular sidebar.
 *
 * @param name: the name or title of this particular sidebar.
 *
 * @param desc: the short description of this particular sidebar.
 *
 * @param refreshable: if true then this sidebar can be reloaded later.
 *
 * @param isDefault: if true then this sidebar is the default tab showing.
 *///from   ww w  .  j a v  a 2 s.co m
public void generateSidebar(List<GalleryApp> apps, TabPanel parent, FlowPanel container, String name,
        String desc, Boolean refreshable, Boolean isDefault) {
    if (refreshable) {
        // Flush the panel's content if we knew new stuff is coming in!
        container.clear();
    }
    parent.add(container, name);
    if (isDefault) {
        parent.selectTab(0); //TODO: fix order
    }

    Label descLabel = new Label(desc);
    descLabel.addStyleName("gallery-showcase-desc");
    container.add(descLabel);

    for (final GalleryApp app : apps) {
        // Create the associated GUI object for app
        GalleryAppWidget gaw = new GalleryAppWidget(app);

        // Create necessary GUI wrappers and components
        FlowPanel appCard = new FlowPanel();
        FlowPanel appCardContent = new FlowPanel();
        FlowPanel appCardMeta = new FlowPanel();

        // Special processing for the app title, mainly for fade-out effect
        HTML appTitle = new HTML("" + "<div class='gallery-title'>" + gaw.nameLabel.getText()
                + "<span class='paragraph-end-block'></span></div>");

        // Special processing for the app author, mainly for fade-out effect
        HTML appAuthor = new HTML("" + "<div class='gallery-subtitle'>" + gaw.authorLabel.getText()
                + "<span class='paragraph-end-block'></span></div>");

        gaw.image.addClickHandler(new ClickHandler() {
            //  @Override
            public void onClick(ClickEvent event) {
                Ode.getInstance().switchToGalleryAppView(app, GalleryPage.VIEWAPP);
            }
        });

        appTitle.addClickHandler(new ClickHandler() {
            //  @Override
            public void onClick(ClickEvent event) {
                Ode.getInstance().switchToGalleryAppView(app, GalleryPage.VIEWAPP);
            }
        });

        // Add everything to the top-level stuff
        appCard.add(gaw.image);
        appCard.add(appCardContent);
        appCardContent.add(appTitle);
        appCardContent.add(appAuthor);
        appCardContent.add(appCardMeta);

        // Set helper icons
        //      Image numViews = new Image();
        //      numViews.setUrl(NUM_VIEW_ICON_URL);
        Image numDownloads = new Image();
        numDownloads.setUrl(DOWNLOAD_ICON_URL);
        Image numLikes = new Image();
        numLikes.setUrl(HOLLOW_HEART_ICON_URL);
        // For generic cards, do not show comment
        //    Image numComments = new Image();
        //    numComments.setUrl(NUM_COMMENT_ICON_URL);

        //      appCardMeta.add(numViews);
        //      appCardMeta.add(gaw.numViewsLabel);
        appCardMeta.add(numDownloads);
        appCardMeta.add(gaw.numDownloadsLabel);
        appCardMeta.add(numLikes);
        appCardMeta.add(gaw.numLikesLabel);
        // For generic cards, do not show comment
        //      appCardMeta.add(numComments);
        //      appCardMeta.add(gaw.numCommentsLabel);

        // Add associated styling
        appCard.addStyleName("gallery-card");
        appCard.addStyleName("clearfix");
        gaw.image.addStyleName("gallery-card-cover");
        //      gaw.nameLabel.addStyleName("gallery-title");
        //      gaw.authorLabel.addStyleName("gallery-subtitle");
        appCardContent.addStyleName("gallery-card-content");
        gaw.numViewsLabel.addStyleName("gallery-meta");
        gaw.numDownloadsLabel.addStyleName("gallery-meta");
        gaw.numLikesLabel.addStyleName("gallery-meta");
        //      gaw.numCommentsLabel.addStyleName("gallery-meta");

        container.add(appCard);
    }

}

From source file:com.google.appinventor.client.Ode.java

License:Open Source License

/**
 * Creates, visually centers, and optionally displays the dialog box
 * that informs the user how to start learning about using App Inventor
 * or create a new project./* w  ww.  ja v a  2 s  .  c  o  m*/
 * @param showDialog Convenience variable to show the created DialogBox.
 * @return The created and optionally displayed Dialog box.
 */
public DialogBox createNoProjectsDialog(boolean showDialog) {
    // Create the UI elements of the DialogBox
    final DialogBox dialogBox = new DialogBox(true, false); //DialogBox(autohide, modal)
    dialogBox.setStylePrimaryName("ode-DialogBox");
    dialogBox.setText(MESSAGES.createNoProjectsDialogText());

    Grid mainGrid = new Grid(2, 2);
    mainGrid.getCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);
    mainGrid.getCellFormatter().setAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);
    mainGrid.getCellFormatter().setAlignment(1, 1, HasHorizontalAlignment.ALIGN_RIGHT,
            HasVerticalAlignment.ALIGN_MIDDLE);

    Image dialogImage = new Image(Ode.getImageBundle().androidGreenSmall());

    Grid messageGrid = new Grid(2, 1);
    messageGrid.getCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_JUSTIFY,
            HasVerticalAlignment.ALIGN_MIDDLE);
    messageGrid.getCellFormatter().setAlignment(1, 0, HasHorizontalAlignment.ALIGN_LEFT,
            HasVerticalAlignment.ALIGN_MIDDLE);

    Label messageChunk1 = new HTML(MESSAGES.createNoProjectsDialogMessage1());

    messageChunk1.setWidth("23em");
    Label messageChunk2 = new Label(MESSAGES.createNoprojectsDialogMessage2());

    // Add the elements to the grids and DialogBox.
    messageGrid.setWidget(0, 0, messageChunk1);
    messageGrid.setWidget(1, 0, messageChunk2);
    mainGrid.setWidget(0, 0, dialogImage);
    mainGrid.setWidget(0, 1, messageGrid);

    dialogBox.setWidget(mainGrid);
    dialogBox.center();

    if (showDialog) {
        dialogBox.show();
    }

    return dialogBox;
}

From source file:com.google.appinventor.client.Ode.java

License:Open Source License

/**
 * Possibly display the MIT App Inventor "Splash Screen"
 *
 * @param force Bypass the check to see if they have dimissed this version
 *//*from   w  w w  .j ava 2s.c  om*/
private void createWelcomeDialog(boolean force) {
    if (!shouldShowWelcomeDialog() && !force) {
        openProjectsTab();
        return;
    }
    // Create the UI elements of the DialogBox
    final DialogBox dialogBox = new DialogBox(false, true); // DialogBox(autohide, modal)
    dialogBox.setStylePrimaryName("ode-DialogBox");
    dialogBox.setText(MESSAGES.createWelcomeDialogText());
    dialogBox.setHeight(splashConfig.height + "px");
    dialogBox.setWidth(splashConfig.width + "px");
    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(true);
    dialogBox.center();
    VerticalPanel DialogBoxContents = new VerticalPanel();
    HTML message = new HTML(splashConfig.content);
    message.setStyleName("DialogBox-message");
    FlowPanel holder = new FlowPanel();
    Button ok = new Button(MESSAGES.createWelcomeDialogButton());
    final CheckBox noshow = new CheckBox(MESSAGES.doNotShow());
    ok.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            dialogBox.hide();
            if (noshow.getValue()) { // User checked the box
                userSettings.getSettings(SettingsConstants.SPLASH_SETTINGS).changePropertyValue(
                        SettingsConstants.SPLASH_SETTINGS_VERSION, "" + splashConfig.version);
                userSettings.saveSettings(null);
            }
            openProjectsTab();
        }
    });
    holder.add(ok);
    holder.add(noshow);
    DialogBoxContents.add(message);
    DialogBoxContents.add(holder);
    dialogBox.setWidget(DialogBoxContents);
    dialogBox.show();
}

From source file:com.google.appinventor.client.Ode.java

License:Open Source License

/**
 * Show a Survey Splash Screen to the user if they have not previously
 * acknowledged it.// ww  w.j av  a2s  . c o m
 */
private void showSurveySplash() {
    // Create the UI elements of the DialogBox
    if (isReadOnly) { // Bypass the survey if we are read-only
        maybeShowSplash();
        return;
    }
    final DialogBox dialogBox = new DialogBox(false, true); // DialogBox(autohide, modal)
    dialogBox.setStylePrimaryName("ode-DialogBox");
    dialogBox.setText(MESSAGES.createWelcomeDialogText());
    dialogBox.setHeight("200px");
    dialogBox.setWidth("600px");
    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(true);
    dialogBox.center();
    VerticalPanel DialogBoxContents = new VerticalPanel();
    HTML message = new HTML(MESSAGES.showSurveySplashMessage());
    message.setStyleName("DialogBox-message");
    FlowPanel holder = new FlowPanel();
    Button takesurvey = new Button(MESSAGES.showSurveySplashButtonNow());
    takesurvey.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            dialogBox.hide();
            // Update Splash Settings here
            userSettings.getSettings(SettingsConstants.SPLASH_SETTINGS).changePropertyValue(
                    SettingsConstants.SPLASH_SETTINGS_SHOWSURVEY, "" + YaVersion.SPLASH_SURVEY);
            userSettings.saveSettings(null);
            takeSurvey(); // Open survey in a new window
            maybeShowSplash();
        }
    });
    holder.add(takesurvey);
    Button latersurvey = new Button(MESSAGES.showSurveySplashButtonLater());
    latersurvey.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            dialogBox.hide();
            maybeShowSplash();
        }
    });
    holder.add(latersurvey);
    Button neversurvey = new Button(MESSAGES.showSurveySplashButtonNever());
    neversurvey.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            dialogBox.hide();
            // Update Splash Settings here
            Settings settings = userSettings.getSettings(SettingsConstants.SPLASH_SETTINGS);
            settings.changePropertyValue(SettingsConstants.SPLASH_SETTINGS_SHOWSURVEY,
                    "" + YaVersion.SPLASH_SURVEY);
            String declined = settings.getPropertyValue(SettingsConstants.SPLASH_SETTINGS_DECLINED);
            if (declined == null)
                declined = ""; // Shouldn't happen
            if (declined != "")
                declined += ",";
            declined += "" + YaVersion.SPLASH_SURVEY; // Record that we declined this survey
            settings.changePropertyValue(SettingsConstants.SPLASH_SETTINGS_DECLINED, declined);
            userSettings.saveSettings(null);
            maybeShowSplash();
        }
    });
    holder.add(neversurvey);
    DialogBoxContents.add(message);
    DialogBoxContents.add(holder);
    dialogBox.setWidget(DialogBoxContents);
    dialogBox.show();
}

From source file:com.google.appinventor.client.Ode.java

License:Open Source License

/**
 * Show a Dialog Box when we receive an SC_PRECONDITION_FAILED
 * response code to any Async RPC call. This is a signal that
 * either our session has expired, or our login cookie has otherwise
 * become invalid. This is a fatal error and the user should not
 * be permitted to continue (many ignore the red error bar and keep
 * working, in vain). So now when this happens, we put up this
 * modal dialog box which cannot be dismissed. Instead it presents
 * just one option, a "Reload" button which reloads the browser.
 * This should trigger a re-authentication (or in the case of an
 * App Inventor upgrade trigging the problem, the loading of newer
 * code)./*from ww  w.  ja  v a  2  s.co  m*/
 */

public void sessionDead() {
    // Create the UI elements of the DialogBox
    final DialogBox dialogBox = new DialogBox(false, true); // DialogBox(autohide, modal)
    dialogBox.setStylePrimaryName("ode-DialogBox");
    dialogBox.setText(MESSAGES.invalidSessionDialogText());
    dialogBox.setWidth("400px");
    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(true);
    dialogBox.center();
    VerticalPanel DialogBoxContents = new VerticalPanel();
    HTML message = new HTML(MESSAGES.sessionDead());
    message.setStyleName("DialogBox-message");
    FlowPanel holder = new FlowPanel();
    Button reloadSession = new Button(MESSAGES.reloadWindow());
    reloadSession.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            dialogBox.hide();
            reloadWindow(true);
        }
    });
    holder.add(reloadSession);
    DialogBoxContents.add(message);
    DialogBoxContents.add(holder);
    dialogBox.setWidget(DialogBoxContents);
    dialogBox.show();
}

From source file:com.google.appinventor.client.Ode.java

License:Open Source License

/**
 * Show a Warning Dialog box when another login session has been
 * created. The user is then given two choices. They can either
 * close this session of App Inventor, which will close the current
 * window, or they can click "Take Over" which will reload this
 * window effectively making it the latest login and invalidating
 * all other sessions.//from  w  ww  . j  a va 2 s  . c o m
 *
 * We are called from OdeAsyncCallback when we detect that our
 * session has been invalidated.
 */
public void invalidSessionDialog() {
    // Create the UI elements of the DialogBox
    final DialogBox dialogBox = new DialogBox(false, true); // DialogBox(autohide, modal)
    dialogBox.setStylePrimaryName("ode-DialogBox");
    dialogBox.setText(MESSAGES.invalidSessionDialogText());
    dialogBox.setHeight("200px");
    dialogBox.setWidth("800px");
    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(true);
    dialogBox.center();
    VerticalPanel DialogBoxContents = new VerticalPanel();
    HTML message = new HTML(MESSAGES.invalidSessionDialogMessage());
    message.setStyleName("DialogBox-message");
    FlowPanel holder = new FlowPanel();
    Button closeSession = new Button(MESSAGES.invalidSessionDialogButtonEnd());
    closeSession.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            dialogBox.hide();
            finalDialog();
        }
    });
    holder.add(closeSession);
    Button reloadSession = new Button(MESSAGES.invalidSessionDialogButtonCurrent());
    reloadSession.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            dialogBox.hide();
            reloadWindow(false);
        }
    });
    holder.add(reloadSession);
    Button continueSession = new Button(MESSAGES.invalidSessionDialogButtonContinue());
    continueSession.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            dialogBox.hide();
            bashWarningDialog();
        }
    });
    holder.add(continueSession);
    DialogBoxContents.add(message);
    DialogBoxContents.add(holder);
    dialogBox.setWidget(DialogBoxContents);
    dialogBox.show();
}

From source file:com.google.appinventor.client.Ode.java

License:Open Source License

/**
 * The user has chosen to continue a session even though
 * others are still active. This risks damaging (bashing) projects.
 * So before we proceed, we provide a stern warning. If they press
 * "Continue" we set their sessionId to "force" which is recognized
 * by the backend as a sessionId that should always match. This is
 * safe because normal sessionIds are UUIDs which are always longer
 * then the word "force." I know this is a bit kludgey, but by doing
 * it this way we don't have to change the RPC interface which makes
 * releasing this code non-disruptive to people using App Inventor
 * during the release./*  www  . ja v a 2s  .  co m*/
 *
 * If the user selects "Cancel" we take them back to the
 * invalidSessionDialog.
 */

private void bashWarningDialog() {
    // Create the UI elements of the DialogBox
    final DialogBox dialogBox = new DialogBox(false, true); // DialogBox(autohide, modal)
    dialogBox.setStylePrimaryName("ode-DialogBox");
    dialogBox.setText(MESSAGES.bashWarningDialogText());
    dialogBox.setHeight("200px");
    dialogBox.setWidth("800px");
    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(true);
    dialogBox.center();
    VerticalPanel DialogBoxContents = new VerticalPanel();
    HTML message = new HTML(MESSAGES.bashWarningDialogMessage());
    message.setStyleName("DialogBox-message");
    FlowPanel holder = new FlowPanel();
    Button continueSession = new Button(MESSAGES.bashWarningDialogButtonContinue());
    continueSession.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            dialogBox.hide();
            sessionId = "force"; // OK, over-ride in place!
            // Because we ultimately got here from a failure in the save function...
            ChainableCommand cmd = new SaveAllEditorsCommand(null);
            cmd.startExecuteChain(Tracking.PROJECT_ACTION_SAVE_YA, getCurrentYoungAndroidProjectRootNode());
            // Will now go back to our regularly scheduled main loop
        }
    });
    holder.add(continueSession);
    Button cancelSession = new Button(MESSAGES.bashWarningDialogButtonNo());
    cancelSession.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            dialogBox.hide();
            invalidSessionDialog();
        }
    });
    holder.add(cancelSession);
    DialogBoxContents.add(message);
    DialogBoxContents.add(holder);
    dialogBox.setWidget(DialogBoxContents);
    dialogBox.show();
}