List of usage examples for com.google.gwt.user.client Window alert
public static void alert(String msg)
From source file:com.google.appinventor.client.explorer.commands.DownloadToPhoneCommand.java
License:Open Source License
@Override public void execute(final ProjectNode node) { final MessagesOutput messagesOutput = MessagesOutput.getMessagesOutput(); messagesOutput.addMessages(MESSAGES.downloadingToPhoneMessage()); final RpcStatusPopup rpcStatusPopup = Ode.getInstance().getRpcStatusPopup(); AsyncCallback<Void> callback = new AsyncCallback<Void>() { @Override/* w w w .j ava 2 s . com*/ public void onFailure(Throwable caught) { rpcStatusPopup.onFailure(FAKE_RPC_NAME, caught); ErrorReporter.reportError(MESSAGES.downloadToPhoneFailedMessage()); executionFailedOrCanceled(); } @Override public void onSuccess(Void result) { rpcStatusPopup.onSuccess(FAKE_RPC_NAME, result); Window.alert(MESSAGES.downloadToPhoneSucceededMessage()); executeNextCommand(node); } }; String packageName; if (node instanceof YoungAndroidProjectNode) { YoungAndroidProjectNode yaNode = (YoungAndroidProjectNode) node; packageName = yaNode.getPackageNode().getPackageName(); } else { ErrorReporter.reportError(MESSAGES.downloadToPhoneFailedMessage()); executionFailedOrCanceled(); return; } rpcStatusPopup.onStart(FAKE_RPC_NAME); String apkFilePath = BUILD_FOLDER + "/" + YoungAndroidProjectNode.YOUNG_ANDROID_TARGET_ANDROID + "/" + node.getName() + ".apk"; CodeblocksManager.getCodeblocksManager().installApplication(apkFilePath, node.getName(), packageName, callback); }
From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java
License:Open Source License
/** * Main method to validify and upload the app image *///www . ja v a2 s .c o m private void uploadImage() { String uploadFilename = upload.getFilename(); if (!uploadFilename.isEmpty()) { // Grab and validify the filename final String filename = makeValidFilename(uploadFilename); // Forge the request URL for gallery servlet // we used to send the gallery id to the servlet, now the project id as // the servlet just stores image temporarily before publish /* String uploadUrl = GWT.getModuleBaseURL() + ServerLayout.GALLERY_SERVLET + "/apps/" + String.valueOf(app.getGalleryAppId()) + "/"+ filename; */ // send the project id as the id, to store image temporarily until published String uploadUrl = GWT.getModuleBaseURL() + ServerLayout.GALLERY_SERVLET + "/apps/" + String.valueOf(app.getProjectId()) + "/" + filename; Uploader.getInstance().upload(upload, uploadUrl, new OdeAsyncCallback<UploadResponse>(MESSAGES.fileUploadError()) { @Override public void onSuccess(UploadResponse uploadResponse) { switch (uploadResponse.getStatus()) { case SUCCESS: // Update the app image preview after a success upload imageUploadBoxInner.clear(); // updateAppImage(app.getCloudImageURL(), imageUploadBoxInner); updateAppImage(gallery.getProjectImageURL(app.getProjectId()), imageUploadBoxInner); imageUploaded = true; ErrorReporter.hide(); break; case FILE_TOO_LARGE: // The user can resolve the problem by uploading a smaller file. ErrorReporter.reportInfo(MESSAGES.fileTooLargeError()); break; default: ErrorReporter.reportError(MESSAGES.fileUploadError()); break; } } }); } else { if (editStatus == NEWAPP) { Window.alert(MESSAGES.noFileSelected()); } } }
From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java
License:Open Source License
/** * Helper method called by constructor to initialize the publish button *//*from w ww .j a va 2s.c om*/ private void initPublishButton() { actionButton = new Button(MESSAGES.galleryPublishText()); actionButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (!checkIfReadyToPublishOrUpdateApp(app)) { return; } actionButton.setEnabled(false); actionButton.setText(MESSAGES.galleryAppPublishing()); final OdeAsyncCallback<GalleryApp> callback = new OdeAsyncCallback<GalleryApp>( MESSAGES.galleryError()) { @Override // When publish or update call returns public void onSuccess(final GalleryApp gApp) { // we only set the projectId to the gallery app if new app. If we // are updating its already set final OdeAsyncCallback<Void> projectCallback = new OdeAsyncCallback<Void>( MESSAGES.galleryError()) { @Override public void onSuccess(Void result) { // this is called after published and after we've set the gallery id // tell the project list to change project's button to "Update" Ode.getInstance().getProjectManager().publishProject(app.getProjectId(), gApp.getGalleryAppId()); Ode.getInstance().switchToGalleryAppView(gApp, GalleryPage.VIEWAPP); // above was app, switched to gApp which is the newly published thing final OdeAsyncCallback<Long> attributionCallback = new OdeAsyncCallback<Long>( MESSAGES.galleryError()) { @Override public void onSuccess(Long result) { } }; Ode.getInstance().getGalleryService().saveAttribution(gApp.getGalleryAppId(), app.getProjectAttributionId(), attributionCallback); }//end of projectCallback#onSuccess @Override public void onFailure(Throwable caught) { super.onFailure(caught); actionButton.setEnabled(true); actionButton.setText(MESSAGES.galleryPublishText()); } };//end of projectCallback Ode.getInstance().getProjectService().setGalleryId(gApp.getProjectId(), gApp.getGalleryAppId(), projectCallback); // we need to update the app object for this gallery page gallery.appWasChanged(); }//end of callback#onSuccess @Override public void onFailure(Throwable caught) { Window.alert(MESSAGES.galleryNoExtensionsPlease()); actionButton.setEnabled(true); actionButton.setText(MESSAGES.galleryPublishText()); } }; // call publish with the default app data... Ode.getInstance().getGalleryService().publishApp(app.getProjectId(), app.getTitle(), app.getProjectName(), app.getDescription(), app.getMoreInfo(), app.getCredit(), callback); } }); actionButton.addStyleName("app-action-button"); appAction.add(actionButton); }
From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java
License:Open Source License
/** * Helper method called by constructor to initialize the publish button *//*ww w . j a va 2 s. c o m*/ private void initUpdateButton() { actionButton = new Button(MESSAGES.galleryUpdateText()); actionButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (!checkIfReadyToPublishOrUpdateApp(app)) { return; } actionButton.setEnabled(false); actionButton.setText(MESSAGES.galleryAppUpdating()); final OdeAsyncCallback<Void> updateSourceCallback = new OdeAsyncCallback<Void>( MESSAGES.galleryError()) { @Override public void onSuccess(Void result) { gallery.appWasChanged(); // to update the gallery list and page Ode.getInstance().switchToGalleryAppView(app, GalleryPage.VIEWAPP); } @Override public void onFailure(Throwable caught) { Window.alert(MESSAGES.galleryNoExtensionsPlease()); actionButton.setEnabled(true); actionButton.setText(MESSAGES.galleryUpdateText()); } }; Ode.getInstance().getGalleryService().updateApp(app, imageUploaded, updateSourceCallback); } }); actionButton.addStyleName("app-action-button"); appAction.add(actionButton); }
From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java
License:Open Source License
/** * check if it is ready to publish or update GalleryApp * 1.The minimum length of Desc must be at least MIN_DESC_LENGTH * 2.User must upload an image first, in order to publish GaleryApp * @param app/*from w ww . j a va 2 s .c o m*/ * @return */ private boolean checkIfReadyToPublishOrUpdateApp(GalleryApp app) { if (app.getDescription().length() < MIN_DESC_LENGTH) { Window.alert(MESSAGES.galleryNotEnoughDescriptionMessage()); return false; } if (!imageUploaded && editStatus == NEWAPP) { /*we only need to check the image on the publish status*/ Window.alert(MESSAGES.galleryNoScreenShotMessage()); return false; } return true; }
From source file:com.google.appinventor.client.explorer.youngandroid.ProfilePage.java
License:Open Source License
/** * Creates a new ProfilePage, must take in parameters * * @param incomingUserId the string ID of user that we are about to render * @param editStatus the edit status (0 is private, 1 is public) * */// w w w .j a v a2 s .c o m public ProfilePage(final String incomingUserId, final int editStatus) { appCatalog = new FlowPanel(); appCatalogContent = new FlowPanel(); selectedApps = new ArrayList<GalleryApp>(); appTabs = new TabPanel(); // Replace the global variable if (incomingUserId.equalsIgnoreCase("-1")) { // this is user checking out own profile, thus we grab current user info // Get current user id final User currentUser = Ode.getInstance().getUser(); userId = currentUser.getUserId(); } else { // this is checking out an already existing user's profile... userId = incomingUserId; } profileStatus = editStatus; // If we're editing or updating, add input form for image if (editStatus == PRIVATE) { // This should only set up image after userId is returned above } else { // we are just viewing this page so setup the image initReadOnlyImage(); } if (editStatus == PRIVATE) { userContentHeader.setText(MESSAGES.labelEditYourProfile()); usernameLabel.setText(MESSAGES.labelYourDisplayName()); userLinkLabel.setText(MESSAGES.labelMoreInfoLink()); userEmailDescriptionLabel.setText(MESSAGES.labelEmailDescription()); userEmailFrequencyPrefixLabel.setText(MESSAGES.labelEmailFrequencyPrefix()); userEmailFrequencySuffixLabel.setText(MESSAGES.labelEmailFrequencySuffix()); editProfile.setVisible(false); profileSubmit.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { profileSubmit.setEnabled(false); if (!validEmailFrequency(userEmailFrequencyBox.getText())) { Window.alert(MESSAGES.errorEmailFrequency()); profileSubmit.setEnabled(true); return; } // Store the name value of user, modify database final OdeAsyncCallback<Void> userNameUpdateCallback = new OdeAsyncCallback<Void>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(Void arg0) { profileSubmit.setEnabled(true); } }; ode.getUserInfoService().storeUserName(userNameBox.getText(), userNameUpdateCallback); // Store the link value of user, modify database final OdeAsyncCallback<Void> userLinkUpdateCallback = new OdeAsyncCallback<Void>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(Void arg0) { } }; if (userLinkBox.getText().isEmpty()) { Ode.getInstance().getUserInfoService().storeUserLink("", userLinkUpdateCallback); } else { Ode.getInstance().getUserInfoService().storeUserLink(userLinkBox.getText(), userLinkUpdateCallback); } // Store the email notification frequency value of user, modofy database final OdeAsyncCallback<Void> userEmailFrequencyUpdateCallback = new OdeAsyncCallback<Void>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(Void arg0) { } }; Ode.getInstance().getUserInfoService().storeUserEmailFrequency( Integer.valueOf(userEmailFrequencyBox.getText()), userEmailFrequencyUpdateCallback); } }); profileInfo.add(userContentHeader); profileInfo.add(usernameLabel); profileInfo.add(userNameBox); profileInfo.add(userLinkLabel); profileInfo.add(userLinkBox); profileInfo.add(userEmailDescriptionLabel); profileInfo.add(userEmailFrequencyPrefixLabel); profileInfo.add(userEmailFrequencyBox); profileInfo.add(userEmailFrequencySuffixLabel); profileInfo.add(profileSubmit); } else { profileSingle.addStyleName("ode-Public"); // USER PROFILE IN PUBLIC (NON-EDITABLE) STATE // Set up the user info stuff userLinkLabel.setText("More info:"); profileInfo.add(userContentHeader); profileInfo.add(userLinkLabel); profileInfo.add(userLinkDisplay); profileInfo.add(editProfile); } // Add GUI layers in the "main content" container profileHeader.addStyleName("app-header"); //TODO: change a more contextual style name profilePrimaryWrapper.add(profileHeader); // profileImage profileInfo.addStyleName("app-info-container"); profilePrimaryWrapper.add(profileInfo); profilePrimaryWrapper.addStyleName("clearfix"); mainContent.add(profilePrimaryWrapper); // Add styling for user info detail components mainContent.addStyleName("gallery-container"); mainContent.addStyleName("gallery-content-details"); userContentHeader.addStyleName("app-title"); usernameLabel.addStyleName("profile-textlabel"); userNameBox.addStyleName("profile-textbox"); userNameDisplay.addStyleName("profile-textdisplay"); userLinkLabel.addStyleName("profile-textlabel"); userLinkBox.addStyleName("profile-textbox"); userLinkDisplay.addStyleName("profile-textdisplay"); userEmailDescriptionLabel.addStyleName("profile-textlabel-emaildescription"); userEmailFrequencyPrefixLabel.addStyleName("profile-textlabel"); userEmailFrequencySuffixLabel.addStyleName("profile-textlabel"); userEmailFrequencyBox.addStyleName("profile-textbox-small"); editProfile.addStyleName("profile-submit"); profileSubmit.addStyleName("profile-submit"); imageUpload.addStyleName("app-image-upload"); // Add sidebar if (editStatus == PUBLIC) { sidebarTabs.addStyleName("gallery-container"); sidebarTabs.addStyleName("gallery-app-showcase"); } // Setup top level containers // profileSingle is the actual container that components go in profileSingle.addStyleName("gallery-page-single"); // Add containers to the top-tier GUI, initialize profileSingle.add(mainContent); if (editStatus == PUBLIC) { profileSingle.add(appTabs); profileSingle.add(sidebarTabs); } // profileGUI is just the abstract top-level GUI container profileGUI.add(profileSingle); profileGUI.addStyleName("ode-UserProfileWrapper"); profileGUI.addStyleName("gallery"); initWidget(profileGUI); // Retrieve other user info right after GUI is initialized final OdeAsyncCallback<User> userInformationCallback = new OdeAsyncCallback<User>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(User user) { // Set associate GUI components of public states // In this case it'll return the user of [userId] userContentHeader.setText(user.getUserName()); makeValidLink(userLinkDisplay, user.getUserLink()); userEmailFrequencyBox.setText(String.valueOf(user.getUserEmailFrequency())); } }; if (editStatus == PRIVATE) { User currentUser = Ode.getInstance().getUser(); // In this case it'll return the current user userId = currentUser.getUserId(); userNameBox.setText(currentUser.getUserName()); userLinkBox.setText(currentUser.getUserLink()); userEmailFrequencyBox.setText(String.valueOf(currentUser.getUserEmailFrequency())); } else { // Public state Ode.getInstance().getUserInfoService().getUserInformationByUserId(userId, userInformationCallback); sidebarTabs.setVisible(false); appCatalogTab = new GalleryAppTab(appCatalog, appCatalogContent, userId); appTabs.add(appCatalog, "My Catalog"); appTabs.selectTab(0); appTabs.addStyleName("gallery-app-tabs"); } //TODO this callback should combine with previous ones. Leave it out for now final User user = Ode.getInstance().getUser(); if (incomingUserId.equals(user.getUserId())) { editProfile.setVisible(true); editProfile.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { ode.switchToPrivateUserProfileView(); PrivateUserProfileTabPanel.getPrivateUserProfileTabPanel().selectTab(0); } }); } else { editProfile.setVisible(false); } }
From source file:com.google.appinventor.client.explorer.youngandroid.ReportList.java
License:Open Source License
/** * Prepare gallery app report based on given GalleryAppReport * Setup the functionality of UI components. * @param r GalleryAppReport gallery app report * @param rw ReportWidgets report widgets */// w w w . ja v a 2s. c o m private void prepareGalleryAppReport(final GalleryAppReport r, final ReportWidgets rw) { rw.reportTextLabel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { } }); rw.appLabel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Ode.getInstance().switchToGalleryAppView(r.getApp(), GalleryPage.VIEWAPP); } }); rw.appAuthorlabel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Ode.getInstance().switchToUserProfileView(r.getOffender().getUserId(), 1 /* 1 for public view*/ ); } }); rw.reporterLabel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Ode.getInstance().switchToUserProfileView(r.getReporter().getUserId(), 1 /* 1 for public view*/ ); } }); rw.sendEmailButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { sendEmailPopup(r); } }); final OdeAsyncCallback<Boolean> isActivatedCallback = new OdeAsyncCallback<Boolean>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(Boolean active) { if (active) { rw.deactiveAppButton.setText(MESSAGES.labelDeactivateApp()); rw.appActive = true; } else { rw.deactiveAppButton.setText(MESSAGES.labelReactivateApp()); rw.appActive = false; } } }; Ode.getInstance().getGalleryService().isGalleryAppActivated(r.getApp().getGalleryAppId(), isActivatedCallback); rw.deactiveAppButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (rw.appActive == true) { deactivateAppPopup(r, rw); } else { final OdeAsyncCallback<Long> emailCallback = new OdeAsyncCallback<Long>( MESSAGES.galleryError()) { @Override public void onSuccess(Long emailId) { if (emailId == Email.NOTRECORDED) { Window.alert(MESSAGES.moderationErrorFailToSendEmail()); } else { final OdeAsyncCallback<Boolean> callback = new OdeAsyncCallback<Boolean>( MESSAGES.galleryError()) { @Override public void onSuccess(Boolean success) { if (!success) return; rw.deactiveAppButton.setText(MESSAGES.labelDeactivateApp());//revert button rw.appActive = true; storeModerationAction(r.getReportId(), r.getApp().getGalleryAppId(), GalleryModerationAction.NOTAVAILABLE, GalleryModerationAction.REACTIVATEAPP, null); //update gallery list galleryClient.appWasChanged(); } }; Ode.getInstance().getGalleryService() .deactivateGalleryApp(r.getApp().getGalleryAppId(), callback); } } }; String emailBody = MESSAGES.moderationAppReactivateBody(r.getApp().getTitle()) + MESSAGES.galleryVisitGalleryAppLinkLabel(Window.Location.getHost(), r.getApp().getGalleryAppId()); Ode.getInstance().getGalleryService().sendEmail(Ode.getInstance().getUser().getUserId(), r.getOffender().getUserId(), r.getOffender().getUserEmail(), MESSAGES.moderationAppReactivatedTitle(), emailBody, emailCallback); } } }); if (r.getResolved()) { //report was unresolved, now resolved rw.markAsResolvedButton.setText(MESSAGES.labelmarkAsUnresolved());//revert button rw.appResolved = true; } else { //report was resolved, now unresolved rw.markAsResolvedButton.setText(MESSAGES.labelmarkAsResolved()); //revert button rw.appResolved = false; } rw.markAsResolvedButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { final OdeAsyncCallback<Boolean> callback = new OdeAsyncCallback<Boolean>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(Boolean success) { if (success) { if (r.getResolved()) {//current status was resolved r.setResolved(false); rw.markAsResolvedButton.setText(MESSAGES.labelmarkAsResolved());//revert button rw.appResolved = false; storeModerationAction(r.getReportId(), r.getApp().getGalleryAppId(), GalleryModerationAction.NOTAVAILABLE, GalleryModerationAction.MARKASUNRESOLVED, null); } else {//current status was unResolved r.setResolved(true); rw.markAsResolvedButton.setText(MESSAGES.labelmarkAsUnresolved());//revert button rw.appResolved = true; storeModerationAction(r.getReportId(), r.getApp().getGalleryAppId(), GalleryModerationAction.NOTAVAILABLE, GalleryModerationAction.MARKASRESOLVED, null); } if (checkBox.getValue() == false) {//only unresolved reports, remove directly. onReportRemoved(r); } } } }; Ode.getInstance().getGalleryService().markReportAsResolved(r.getReportId(), r.getApp().getGalleryAppId(), callback); } }); rw.seeAllActions.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { //show actions seeAllActionsPopup(r); } }); }
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 . ja v a2s. 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 va 2s. c om*/ 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.Ode.java
License:Open Source License
public void openPreviousProject() { if (userSettings == null) { OdeLog.wlog("Ignoring openPreviousProject() since userSettings is null"); return;/*from w ww. j a va 2 s. c o m*/ } OdeLog.log("Ode.openPreviousProject called"); final String value = userSettings.getSettings(SettingsConstants.USER_GENERAL_SETTINGS) .getPropertyValue(SettingsConstants.GENERAL_SETTINGS_CURRENT_PROJECT_ID); // Retrieve the userTemplates String userTemplates = userSettings.getSettings(SettingsConstants.USER_GENERAL_SETTINGS) .getPropertyValue(SettingsConstants.USER_TEMPLATE_URLS); TemplateUploadWizard.setStoredTemplateUrls(userTemplates); if (templateLoadingFlag) { // We are loading a template, open it instead // of the last project NewProjectCommand callbackCommand = new NewProjectCommand() { @Override public void execute(Project project) { templateLoadingFlag = false; Ode.getInstance().openYoungAndroidProjectInDesigner(project); } }; TemplateUploadWizard.openProjectFromTemplate(templatePath, callbackCommand); } else if (galleryIdLoadingFlag) { try { long galleryId_Long = Long.valueOf(galleryId); final OdeAsyncCallback<GalleryApp> callback = new OdeAsyncCallback<GalleryApp>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(GalleryApp app) { if (app == null) { openProject(value); Window.alert(MESSAGES.galleryIdNotExist()); } else { Ode.getInstance().switchToGalleryAppView(app, GalleryPage.VIEWAPP); } } }; Ode.getInstance().getGalleryService().getApp(galleryId_Long, callback); } catch (NumberFormatException e) { openProject(value); Window.alert(MESSAGES.galleryIdNotExist()); } } else { openProject(value); } }