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

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

Introduction

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

Prototype

protected Button(com.google.gwt.dom.client.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

/**
 * Helper method called by constructor to initialize the remove button
 *///from  www.j av a  2  s  .co m
private void initRemoveButton() {
    removeButton = new Button(MESSAGES.galleryRemoveText());
    removeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            //popup confrim dialog
            if (!Window.confirm(MESSAGES.galleryRemoveConfirmText())) {
                return;
            }
            removeButton.setEnabled(false);
            removeButton.setText(MESSAGES.galleryAppRemoving());
            ;
            final OdeAsyncCallback<Void> callback = new OdeAsyncCallback<Void>(MESSAGES.galleryDeleteError()) {
                @Override
                public void onSuccess(Void result) {
                    // once we have deleted, set the project id back to not published
                    final OdeAsyncCallback<Void> projectCallback = new OdeAsyncCallback<Void>(
                            MESSAGES.gallerySetProjectIdError()) {
                        @Override
                        public void onSuccess(Void result) {
                            // this is called after deleted and after we've set the galleryid
                            Ode.getInstance().getProjectManager().UnpublishProject(app.getProjectId());
                            Ode.getInstance().switchToProjectsView();
                        }

                        @Override
                        public void onFailure(Throwable caught) {
                            super.onFailure(caught);
                            removeButton.setEnabled(true);
                            removeButton.setText(MESSAGES.galleryRemoveText());
                        }
                    };
                    GalleryClient client = GalleryClient.getInstance();
                    client.appWasChanged(); // tell views to update
                    Ode.getInstance().getProjectService().setGalleryId(app.getProjectId(),
                            UserProject.NOTPUBLISHED, projectCallback);
                }

                @Override
                public void onFailure(Throwable caught) {
                    super.onFailure(caught);
                    removeButton.setEnabled(true);
                    removeButton.setText(MESSAGES.galleryRemoveText());
                }
            };
            Ode.getInstance().getGalleryService().deleteApp(app.getGalleryAppId(), callback);
        }
    });
    removeButton.addStyleName("app-action-button");
    appAction.add(removeButton);
}

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

License:Open Source License

/**
 * Helper method called by constructor to initialize the cancel button
 *//*from   w  ww . ja  v a  2  s.  c  o m*/
private void initCancelButton() {
    cancelButton = new Button(MESSAGES.galleryCancelText());
    cancelButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (editStatus == NEWAPP) {
                Ode.getInstance().switchToProjectsView();
            } else if (editStatus == UPDATEAPP) {
                Ode.getInstance().switchToGalleryAppView(app, GalleryPage.VIEWAPP);
            }
        }
    });
    cancelButton.addStyleName("app-action-button");
    appAction.add(cancelButton);
}

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

License:Open Source License

/**
 * Initializes and assembles all commands into buttons in the toolbar.
 *///from   w  w  w  .ja  v  a 2 s.  c  o  m
public GalleryToolbar() {
    allSearchToolbars.add(this);
    HorizontalPanel toolbar = new HorizontalPanel();
    toolbar.setWidth("100%");
    toolbar.setStylePrimaryName("ya-GalleryToolbar");

    FlowPanel searchPanel = new FlowPanel();
    searchText = new TextBox();
    searchText.addStyleName("gallery-search-textarea");
    searchButton = new Button("Search for apps");
    searchButton.addStyleName("search-compontent");
    searchPanel.add(searchText);
    searchPanel.add(searchButton);
    searchPanel.addStyleName("gallery");
    toolbar.add(searchPanel);
    searchButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            GalleryClient.getInstance().FindApps(searchText.getText(), 0, GalleryList.NUMAPPSTOSHOW, 0, true);
            searchText.setFocus(true);
            Ode.getInstance().switchToGalleryView();
            GalleryListBox.getGalleryListBox().getGalleryList().setSelectTabIndex(SEARCHTAB);
            for (GalleryToolbar toolbar : allSearchToolbars) {
                toolbar.getSearchText().setText(searchText.getText());
            }
            //TODO in gallerylist.java --> findapps: create a way to grab keyword from this toolbar
            //this is just a temp solution.
            GalleryListBox.getGalleryListBox().getGalleryList().getSearchText().setText(searchText.getText());
        }
    });
    searchText.addKeyDownHandler(new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent e) {
            if (e.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                GalleryClient.getInstance().FindApps(searchText.getText(), 0, GalleryList.NUMAPPSTOSHOW, 0,
                        true);
                searchText.setFocus(true);
                Ode.getInstance().switchToGalleryView();
                GalleryListBox.getGalleryListBox().getGalleryList().setSelectTabIndex(SEARCHTAB);
                for (GalleryToolbar toolbar : allSearchToolbars) {
                    toolbar.getSearchText().setText(searchText.getText());
                }
                //TODO in gallerylist.java --> findapps: create a way to grab keyword from this toolbar
                //this is just a temp solution.
                GalleryListBox.getGalleryListBox().getGalleryList().getSearchText()
                        .setText(searchText.getText());
            }
        }
    });
    initWidget(toolbar);
}

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 w w  w .ja v  a  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 www  .ja va2s  . co m*/
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  w  w . j  a v a  2s  . co  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.Ode.java

License:Open Source License

private void initializeUi() {
    BlocklyPanel.initUi();//from  www .  j a  va  2 s .com

    rpcStatusPopup = new RpcStatusPopup();

    // Register services with RPC status popup
    rpcStatusPopup.register((ExtendedServiceProxy<?>) helpService);
    rpcStatusPopup.register((ExtendedServiceProxy<?>) projectService);
    rpcStatusPopup.register((ExtendedServiceProxy<?>) galleryService);
    rpcStatusPopup.register((ExtendedServiceProxy<?>) userInfoService);

    Window.setTitle(MESSAGES.titleYoungAndroid());
    Window.enableScrolling(true);

    topPanel = new TopPanel();
    statusPanel = new StatusPanel();

    DockPanel mainPanel = new DockPanel();
    mainPanel.add(topPanel, DockPanel.NORTH);

    // Create tab panel for subsequent tabs
    deckPanel = new DeckPanel() {
        @Override
        public final void onBrowserEvent(Event event) {
            switch (event.getTypeInt()) {
            case Event.ONCONTEXTMENU:
                event.preventDefault();
                break;
            }
        }
    };

    deckPanel.setAnimationEnabled(true);
    deckPanel.sinkEvents(Event.ONCONTEXTMENU);
    deckPanel.setStyleName("ode-DeckPanel");

    // Projects tab
    VerticalPanel pVertPanel = new VerticalPanel();
    pVertPanel.setWidth("100%");
    pVertPanel.setSpacing(0);
    HorizontalPanel projectListPanel = new HorizontalPanel();
    projectListPanel.setWidth("100%");
    projectToolbar = new ProjectToolbar();
    projectListPanel.add(ProjectListBox.getProjectListBox());
    pVertPanel.add(projectToolbar);
    pVertPanel.add(projectListPanel);
    projectsTabIndex = deckPanel.getWidgetCount();
    deckPanel.add(pVertPanel);

    // Design tab
    VerticalPanel dVertPanel = new VerticalPanel();
    dVertPanel.setWidth("100%");
    dVertPanel.setHeight("100%");

    // Add the Code Navigation arrow
    //    switchToBlocksButton = new VerticalPanel();
    //    switchToBlocksButton.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE);
    //    switchToBlocksButton.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    //    switchToBlocksButton.setStyleName("ode-NavArrow");
    //    switchToBlocksButton.add(new Image(RIGHT_ARROW_IMAGE_URL));
    //    switchToBlocksButton.setWidth("25px");
    //    switchToBlocksButton.setHeight("100%");

    // Add the Code Navigation arrow
    //    switchToDesignerButton = new VerticalPanel();
    //    switchToDesignerButton.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE);
    //    switchToDesignerButton.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    //    switchToDesignerButton.setStyleName("ode-NavArrow");
    //    switchToDesignerButton.add(new Image(LEFT_ARROW_IMAGE_URL));
    //    switchToDesignerButton.setWidth("25px");
    //    switchToDesignerButton.setHeight("100%");

    designToolbar = new DesignToolbar();
    dVertPanel.add(designToolbar);

    workColumns = new HorizontalPanel();
    workColumns.setWidth("100%");

    //workColumns.add(switchToDesignerButton);

    Box palletebox = PaletteBox.getPaletteBox();
    palletebox.setWidth("222px");
    workColumns.add(palletebox);

    Box viewerbox = ViewerBox.getViewerBox();
    workColumns.add(viewerbox);
    workColumns.setCellWidth(viewerbox, "97%");
    workColumns.setCellHeight(viewerbox, "97%");

    structureAndAssets = new VerticalPanel();
    structureAndAssets.setVerticalAlignment(VerticalPanel.ALIGN_TOP);
    // Only one of the SourceStructureBox and the BlockSelectorBox is visible
    // at any given time, according to whether we are showing the form editor
    // or the blocks editor. They share the same screen real estate.
    structureAndAssets.add(SourceStructureBox.getSourceStructureBox());
    structureAndAssets.add(BlockSelectorBox.getBlockSelectorBox()); // initially not visible
    structureAndAssets.add(AssetListBox.getAssetListBox());
    workColumns.add(structureAndAssets);

    Box propertiesbox = PropertiesBox.getPropertiesBox();
    propertiesbox.setWidth("222px");
    workColumns.add(propertiesbox);
    //switchToBlocksButton.setHeight("650px");
    //workColumns.add(switchToBlocksButton);
    dVertPanel.add(workColumns);
    designTabIndex = deckPanel.getWidgetCount();
    deckPanel.add(dVertPanel);

    // Gallery list tab
    VerticalPanel gVertPanel = new VerticalPanel();
    gVertPanel.setWidth("100%");
    gVertPanel.setSpacing(0);
    galleryListToolbar = new GalleryToolbar();
    gVertPanel.add(galleryListToolbar);
    HorizontalPanel appListPanel = new HorizontalPanel();
    appListPanel.setWidth("100%");
    appListPanel.add(GalleryListBox.getGalleryListBox());

    gVertPanel.add(appListPanel);
    galleryTabIndex = deckPanel.getWidgetCount();
    deckPanel.add(gVertPanel);

    // Gallery app tab
    VerticalPanel aVertPanel = new VerticalPanel();
    aVertPanel.setWidth("100%");
    aVertPanel.setSpacing(0);
    galleryPageToolbar = new GalleryToolbar();
    aVertPanel.add(galleryPageToolbar);
    HorizontalPanel appPanel = new HorizontalPanel();
    appPanel.setWidth("100%");
    appPanel.add(GalleryAppBox.getGalleryAppBox());

    aVertPanel.add(appPanel);
    galleryAppTabIndex = deckPanel.getWidgetCount();
    deckPanel.add(aVertPanel);

    // User Admin Panel
    VerticalPanel uaVertPanel = new VerticalPanel();
    uaVertPanel.setWidth("100%");
    uaVertPanel.setSpacing(0);
    HorizontalPanel adminUserListPanel = new HorizontalPanel();
    adminUserListPanel.setWidth("100%");
    adminUserListPanel.add(AdminUserListBox.getAdminUserListBox());
    uaVertPanel.add(adminUserListPanel);
    userAdminTabIndex = deckPanel.getWidgetCount();
    deckPanel.add(uaVertPanel);

    // KM: DEBUGGING BEGIN
    // User profile tab
    VerticalPanel uVertPanel = new VerticalPanel();
    uVertPanel.setWidth("100%");
    uVertPanel.setSpacing(0);
    HorizontalPanel userProfilePanel = new HorizontalPanel();
    userProfilePanel.setWidth("100%");
    userProfilePanel.add(ProfileBox.getUserProfileBox());

    uVertPanel.add(userProfilePanel);
    userProfileTabIndex = deckPanel.getWidgetCount();
    deckPanel.add(uVertPanel);
    // KM: DEBUGGING END

    // Private User Profile TabPanel
    VerticalPanel ppVertPanel = new VerticalPanel();
    ppVertPanel.setWidth("100%");
    ppVertPanel.setSpacing(0);
    HorizontalPanel privateUserProfileTabPanel = new HorizontalPanel();
    privateUserProfileTabPanel.setWidth("100%");
    privateUserProfileTabPanel.add(PrivateUserProfileTabPanel.getPrivateUserProfileTabPanel());
    ppVertPanel.add(privateUserProfileTabPanel);
    privateUserProfileIndex = deckPanel.getWidgetCount();
    deckPanel.add(ppVertPanel);

    // Moderation Page tab
    VerticalPanel mPVertPanel = new VerticalPanel();
    mPVertPanel.setWidth("100%");
    mPVertPanel.setSpacing(0);
    HorizontalPanel moderationPagePanel = new HorizontalPanel();
    moderationPagePanel.setWidth("100%");

    moderationPagePanel.add(ModerationPageBox.getModerationPageBox());

    mPVertPanel.add(moderationPagePanel);
    moderationPageTabIndex = deckPanel.getWidgetCount();
    deckPanel.add(mPVertPanel);

    // Debugging tab
    if (AppInventorFeatures.hasDebuggingView()) {

        Button dismissButton = new Button(MESSAGES.dismissButton());
        dismissButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                if (currentView == DESIGNER)
                    switchToDesignView();
                else
                    switchToProjectsView();
            }
        });

        ColumnLayout defaultLayout = new ColumnLayout("Default");
        Column column = defaultLayout.addColumn(100);
        column.add(MessagesOutputBox.class, 300, false);
        column.add(OdeLogBox.class, 300, false);
        final WorkAreaPanel debuggingTab = new WorkAreaPanel(new OdeBoxRegistry(), defaultLayout);

        debuggingTab.add(dismissButton);

        debuggingTabIndex = deckPanel.getWidgetCount();
        deckPanel.add(debuggingTab);

        // Hook the window resize event, so that we can adjust the UI.
        Window.addResizeHandler(new ResizeHandler() {
            @Override
            public void onResize(ResizeEvent event) {
                resizeWorkArea(debuggingTab);
            }
        });

        // Call the window resized handler to get the initial sizes setup. Doing this in a deferred
        // command causes it to occur after all widgets' sizes have been computed by the browser.
        DeferredCommand.addCommand(new Command() {
            @Override
            public void execute() {
                resizeWorkArea(debuggingTab);
            }
        });

        resizeWorkArea(debuggingTab);
    }

    // We do not select the designer tab here because at this point there is no current project.
    // Instead, we select the projects tab. If the user has a previously opened project, we will
    // open it and switch to the designer after the user settings are loaded.
    // Remember, the user may not have any projects at all yet.
    // Or, the user may have deleted their previously opened project.
    // ***** THE DESIGNER TAB DOES NOT DISPLAY CORRECTLY IF THERE IS NO CURRENT PROJECT. *****
    deckPanel.showWidget(projectsTabIndex);

    mainPanel.add(deckPanel, DockPanel.CENTER);
    mainPanel.setCellHeight(deckPanel, "100%");
    mainPanel.setCellWidth(deckPanel, "100%");

    //    mainPanel.add(switchToDesignerButton, DockPanel.WEST);
    //    mainPanel.add(switchToBlocksButton, DockPanel.EAST);

    //Commenting out for now to gain more space for the blocks editor
    mainPanel.add(statusPanel, DockPanel.SOUTH);
    mainPanel.setSize("100%", "100%");
    RootPanel.get().add(mainPanel);

    // Add a handler to the RootPanel to keep track of Google Chrome Pinch Zooming and
    // handle relevant bugs. Chrome maps a Pinch Zoom to a MouseWheelEvent with the
    // control key pressed.
    RootPanel.get().addDomHandler(new MouseWheelHandler() {
        @Override
        public void onMouseWheel(MouseWheelEvent event) {
            if (event.isControlKeyDown()) {
                // Trip the appropriate flag in PZAwarePositionCallback when the page
                // is Pinch Zoomed. Note that this flag does not need to be removed when
                // the browser is un-zoomed because the patched function for determining
                // absolute position works in all circumstances.
                PZAwarePositionCallback.setPinchZoomed(true);
            }
        }
    }, MouseWheelEvent.getType());

    // There is no sure-fire way of preventing people from accidentally navigating away from ODE
    // (e.g. by hitting the Backspace key). What we do need though is to make sure that people will
    // not lose any work because of this. We hook into the window closing  event to detect the
    // situation.
    Window.addWindowClosingHandler(new Window.ClosingHandler() {
        @Override
        public void onWindowClosing(Window.ClosingEvent event) {
            onClosing();
        }
    });

    setupMotd();
}

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
 *//*w  w w.  j av  a 2 s .co  m*/
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.//from w w  w  .j ava  2s  .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)./*  w  ww  . j  a  v  a  2s .  c o 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();
}