List of usage examples for com.google.gwt.user.client.ui Button Button
protected Button(com.google.gwt.dom.client.Element element)
From source file:com.google.appinventor.client.editor.youngandroid.properties.YoungAndroidGeoJSONPropertyEditor.java
License:Open Source License
public YoungAndroidGeoJSONPropertyEditor(final YaFormEditor editor) { Project project = Ode.getInstance().getProjectManager().getProject(editor.getProjectId()); assetsFolder = ((YoungAndroidProjectNode) project.getRootNode()).getAssetsFolder(); project.addProjectChangeListener(this); VerticalPanel selectorPanel = new VerticalPanel(); assetsList = new ListBox(); assetsList.setVisibleItemCount(10);/*from w w w.j av a 2s . com*/ assetsList.setWidth("100%"); selectorPanel.add(assetsList); choices = new ListWithNone(MESSAGES.noneCaption(), new ListWithNone.ListBoxWrapper() { @Override public void setSelectedIndex(int index) { assetsList.setSelectedIndex(index); } @Override public void removeItem(int index) { assetsList.removeItem(index); } @Override public String getItem(int index) { return assetsList.getItemText(index); } @Override public void addItem(String item) { assetsList.addItem(item); } }); // Fill choices with assets. if (assetsFolder != null) { for (ProjectNode node : assetsFolder.getChildren()) { String lowerCaseName = node.getName(); if (lowerCaseName.endsWith(".json") || lowerCaseName.endsWith(".geojson")) { choices.addItem(node.getName()); } } } Button addButton = new Button(MESSAGES.addButton()); addButton.setWidth("100%"); addButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { FileUploadedCallback callback = new FileUploadedCallback() { @Override public void onFileUploaded(FolderNode folderNode, FileNode fileNode) { choices.selectValue(fileNode.getName()); closeAdditionalChoiceDialog(true); } }; FileUploadWizard uploader = new FileUploadWizard(assetsFolder, callback); uploader.show(); } }); Button urlButton = new Button(MESSAGES.fromUrlButton()); urlButton.setWidth("100%"); urlButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { UrlImportWizard.OnImportListener callback = new UrlImportWizard.OnImportListener() { @Override public void onSuccess(byte[] content) { } }; UrlImportWizard wizard = new UrlImportWizard(assetsFolder, callback); wizard.center(); wizard.show(); } }); selectorPanel.add(addButton); selectorPanel.add(urlButton); selectorPanel.setWidth("100%"); DeferredCommand.addCommand(new Command() { @Override public void execute() { if (editor.isLoadComplete()) { finishInitialization(); } else { DeferredCommand.addCommand(this); } } }); initAdditionalChoicePanel(selectorPanel); }
From source file:com.google.appinventor.client.editor.youngandroid.TutorialPanel.java
License:Open Source License
/** * Creates video on page!//w ww .j a v a 2 s .c om */ private static void createVideoDialog(String tutorialId) { // Create the UI elements of the DialogBox final DialogBox dialogBox = new DialogBox(true, true); // DialogBox(autohide, modal) dialogBox.setStylePrimaryName("ode-DialogBox"); dialogBox.setText("Tutorial Video"); dialogBox.setGlassEnabled(true); dialogBox.setAnimationEnabled(true); VerticalPanel DialogBoxContents = new VerticalPanel(); // Adds Youtube Video HTML message = new HTML("<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/" + tutorialId + "?rel=0&autoplay=1\" frameborder=\"0\" allowfullscreen></iframe>"); message.setStyleName("DialogBox-message"); FlowPanel holder = new FlowPanel(); Button ok = new Button("Close"); ok.addClickListener(new ClickListener() { public void onClick(Widget sender) { dialogBox.hide(); } }); ok.setStyleName("DialogBox-button"); holder.add(ok); DialogBoxContents.add(message); DialogBoxContents.add(holder); dialogBox.setWidget(DialogBoxContents); dialogBox.center(); dialogBox.show(); }
From source file:com.google.appinventor.client.editor.youngandroid.TutorialPanel.java
License:Open Source License
/** * Enlarges image on page/*from ww w .ja v a2 s .com*/ */ private static void createImageDialog(String img) { // Create the UI elements of the DialogBox final DialogBox dialogBox = new DialogBox(true, true); // DialogBox(autohide, modal) dialogBox.setStylePrimaryName("ode-DialogBox"); dialogBox.setGlassEnabled(true); dialogBox.setAnimationEnabled(true); VerticalPanel DialogBoxContents = new VerticalPanel(); FlowPanel holder = new FlowPanel(); Button ok = new Button("Close"); ok.addClickListener(new ClickListener() { public void onClick(Widget sender) { dialogBox.hide(); } }); ok.setStyleName("DialogBox-button"); // Adds Image Image image = new Image(img); image.addLoadHandler(new LoadHandler() { public void onLoad(LoadEvent evt) { dialogBox.center(); } }); image.setStyleName("DialogBox-image"); holder.add(ok); DialogBoxContents.add(image); DialogBoxContents.add(holder); dialogBox.setWidget(DialogBoxContents); dialogBox.center(); dialogBox.show(); }
From source file:com.google.appinventor.client.explorer.youngandroid.GalleryList.java
License:Open Source License
/** * Creates the GUI components for search tab. * * @param searchApp: the FlowPanel that search tab will reside. *///from ww w . j a va 2 s.co m private void addGallerySearchTab(FlowPanel searchApp) { // Add search GUI FlowPanel searchPanel = new FlowPanel(); final TextBox searchText = new TextBox(); searchText.addStyleName("gallery-search-textarea"); Button sb = new Button(MESSAGES.gallerySearchForAppsButton()); searchPanel.add(searchText); searchPanel.add(sb); searchPanel.addStyleName("gallery-search-panel"); searchApp.add(searchPanel); appSearchContent.addStyleName("gallery-search-results"); searchApp.add(appSearchContent); searchApp.addStyleName("gallery-search"); sb.addClickHandler(new ClickHandler() { // @Override public void onClick(ClickEvent event) { gallery.FindApps(searchText.getText(), 0, NUMAPPSTOSHOW, 0, true); } }); }
From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java
License:Open Source License
/** * Helper method called by constructor to initialize the app's comment area *//* w w w. ja va 2 s . com*/ private void initAppComments() { // App details - comments appDetails.add(appComments); appComments.addStyleName("app-comments-wrapper"); Label commentsHeader = new Label("Comments and Reviews"); commentsHeader.addStyleName("app-comments-header"); appComments.add(commentsHeader); final TextArea commentTextArea = new TextArea(); commentTextArea.addStyleName("app-comments-textarea"); appComments.add(commentTextArea); Button commentSubmit = new Button("Submit my comment"); commentSubmit.addStyleName("app-comments-submit"); commentSubmit.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { final OdeAsyncCallback<Long> commentPublishCallback = new OdeAsyncCallback<Long>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(Long date) { // get the new comment list so gui updates // note: we might modify the call to publishComment so it returns // the list instead, this would save one server call gallery.GetComments(app.getGalleryAppId(), 0, 100); } }; Ode.getInstance().getGalleryService().publishComment(app.getGalleryAppId(), commentTextArea.getText(), commentPublishCallback); } }); appComments.add(commentSubmit); // Add list of comments gallery.GetComments(app.getGalleryAppId(), 0, 100); appComments.add(appCommentsList); appCommentsList.addStyleName("app-comments"); }
From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java
License:Open Source License
/** * Helper method called by constructor to initialize the report section *///w w w. j av a 2s . c om private void initReportSection() { final HTML reportPrompt = new HTML(); reportPrompt.setHTML(MESSAGES.galleryReportPrompt()); reportPrompt.addStyleName("primary-prompt"); final TextArea reportText = new TextArea(); reportText.addStyleName("action-textarea"); final Button submitReport = new Button(MESSAGES.galleryReportButton()); submitReport.addStyleName("action-button"); appReportPanel.add(reportPrompt); appReportPanel.add(reportText); appReportPanel.add(submitReport); final OdeAsyncCallback<Boolean> isReportdByUserCallback = new OdeAsyncCallback<Boolean>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(Boolean isAlreadyReported) { if (isAlreadyReported) { //already reported, cannot report again reportPrompt.setHTML(MESSAGES.galleryAlreadyReportedPrompt()); reportText.setVisible(false); submitReport.setVisible(false); submitReport.setEnabled(false); } else { submitReport.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { final OdeAsyncCallback<Long> reportClickCallback = new OdeAsyncCallback<Long>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(Long id) { reportPrompt.setHTML(MESSAGES.galleryReportCompletionPrompt()); reportText.setVisible(false); submitReport.setVisible(false); submitReport.setEnabled(false); } }; Ode.getInstance().getGalleryService().addAppReport(app, reportText.getText(), reportClickCallback); } }); } } }; Ode.getInstance().getGalleryService().isReportedByUser(app.getGalleryAppId(), isReportdByUserCallback); }
From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java
License:Open Source License
/** * Helper method called by constructor to initialize the edit it button * Only seen by app owner.// w w w .ja v a 2 s. co m */ private void initEdititButton() { final User currentUser = Ode.getInstance().getUser(); if (app.getDeveloperId().equals(currentUser.getUserId())) { editButton = new Button(MESSAGES.galleryEditText()); editButton.addClickHandler(new ClickHandler() { // Open up source file if clicked the action button public void onClick(ClickEvent event) { editButton.setEnabled(false); Ode.getInstance().switchToGalleryAppView(app, GalleryPage.UPDATEAPP); } }); editButton.addStyleName("app-action-button"); appAction.add(editButton); } }
From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java
License:Open Source License
/** * Helper method called by constructor to initialize the try it button *//*from w w w . j a v a 2 s.c om*/ private void initTryitButton() { actionButton = new Button(MESSAGES.galleryOpenText()); actionButton.addClickHandler(new ClickHandler() { // Open up source file if clicked the action button public void onClick(ClickEvent event) { actionButton.setEnabled(false); /* * open a popup window that will prompt to ask user to enter * a new project name(if "new name" is not valid, user may need to * enter again). After that, "loadSourceFil" and "appWasDownloaded" * will be called. */ new RemixedYoungAndroidProjectWizard(app, actionButton).center(); } }); 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 2s . c o m*/ 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 *//*from w w w. j a v a 2 s. co 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); }