List of usage examples for com.google.gwt.user.client.ui Label addClickHandler
public HandlerRegistration addClickHandler(ClickHandler handler)
From source file:com.github.gwtcannonjs.demo.client.TabPanel.java
License:Open Source License
public void add(Widget widget, String text) { final int index = container.getWidgetCount(); Label tabWidget = new Label(text); tabWidget.addStyleName("tab"); tabWidget.addClickHandler(new ClickHandler() { @Override/*from w w w. j a v a2s .c o m*/ public void onClick(ClickEvent event) { selectTab(index, true); } }); tabBar.add(tabWidget); container.add(widget); if (index == 0) { selectTab(0, false); } }
From source file:com.github.hwestphal.gxt3.miglayout.ExampleBrowser.java
License:Open Source License
public void addExample(final ExampleItem example) { final String token = example.getToken(); exampleItems.put(token, example);// w w w .j a v a 2 s .c om final Label label = new Label(example.getTitle(), false); label.setLayoutData(new MarginData(5)); label.addMouseOverHandler(new MouseOverHandler() { @Override public void onMouseOver(MouseOverEvent event) { label.getElement().getStyle().setCursor(Cursor.POINTER); } }); label.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { History.newItem(token); } }); exampleBrowser.add(label); exampleLabels.put(token, label); }
From source file:com.google.api.explorer.client.auth.AuthView.java
License:Apache License
/** * Add an editor row in the form of a textbox, that will allow an arbitrary scope to be added. *//*www. java 2 s.co m*/ private FocusWidget addFreeFormEditorRow(String name, boolean showRemoveLink) { final FlowPanel newRow = new FlowPanel(); // Create the new editor and do the appropriate bookkeeping. final TextBox scopeText = new TextBox(); scopeText.setValue(name); newRow.add(scopeText); freeFormEditors.add(scopeText); final Label removeLink = new InlineLabel("X"); removeLink.addStyleName(style.clickable()); removeLink.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { freeFormEditors.remove(scopeText); additionalScopePanel.remove(newRow); if (freeFormEditors.isEmpty()) { addFreeFormEditorRow("", false); } } }); newRow.add(removeLink); removeLink.setVisible(showRemoveLink); // Add a handler to add a new editor when there is text in the existing editor. scopeText.addKeyDownHandler(new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { TextBox editor = (TextBox) event.getSource(); boolean isLastEditor = editor.equals(Iterables.getLast(freeFormEditors)); if (isLastEditor && !editor.getValue().isEmpty()) { presenter.addNewScope(); removeLink.setVisible(true); } } }); additionalScopePanel.add(newRow); return scopeText; }
From source file:com.google.api.explorer.client.embedded.EmbeddedParameterForm.java
License:Apache License
/** * Adds a row to the table to edit the partial fields mask. * * @param responseSchema Definition of the response object being described. * @param row Row index to begin adding rows to the parameter form table. *///ww w . j a v a 2 s. co m private void addEmbeddedFieldsRow(ApiService service, @Nullable Schema responseSchema, int row) { fieldsPlaceholder.clear(); table.setText(row, 0, "fields"); // Reset the fields textbox's value to empty and add it to the table (with // appropriate styling) fieldsTextBox.setText(""); // All inputs must be wrapped in a container to simplify the CSS. Widget container = new SimplePanel(fieldsTextBox); container.addStyleName(style.parameterInput()); table.setWidget(row, 1, container); // Start adding the next cell which will have the description of this param, // and potentially a link to open the fields editor. HTMLPanel panel = new HTMLPanel(""); service.getParameters().get("fields").getDescription(); panel.add(new Label(getFieldsDescription(service))); // If a response schema is provided, add a link to the fields editor and // tell the fields editor about this method's response schema. if (responseSchema != null && responseSchema.getProperties() != null) { Label openFieldsEditor = new InlineLabel("Use fields editor"); openFieldsEditor.addStyleName(Resources.INSTANCE.style().clickable()); openFieldsEditor.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { fieldsPopupPanel.show(); fieldsPopupPanel.center(); } }); panel.add(openFieldsEditor); fieldsEditor = new FieldsEditor(service, /* This is the root, no field name req'd */""); fieldsEditor.setProperties(responseSchema.getProperties()); fieldsPlaceholder.add(fieldsEditor); } // Add the description (and maybe fields editor link) to the table. table.setWidget(row, 2, panel); cellFormatter.addStyleName(row, 0, EmbeddedResources.INSTANCE.style().parameterFormNameCell()); cellFormatter.addStyleName(row, 1, EmbeddedResources.INSTANCE.style().parameterFormEditorCell()); cellFormatter.addStyleName(row, 2, EmbeddedResources.INSTANCE.style().parameterFormDescriptionCell()); }
From source file:com.google.api.explorer.client.history.JsonPrettifier.java
License:Apache License
/** * Iterate through an object or array adding the widgets generated for all children *//* w ww.jav a 2 s . c o m*/ private static FlowPanel formatGroup(Iterable<Widget> objIterable, String title, int depth, String openGroup, String closeGroup, boolean hasSeparator, @Nullable Widget menuButtonForReuse) { FlowPanel object = new FlowPanel(); FlowPanel titlePanel = new FlowPanel(); Label paddingSpaces = new InlineLabel(indentation(depth)); titlePanel.add(paddingSpaces); Label titleLabel = new InlineLabel(title + openGroup); titleLabel.addStyleName(style.jsonKey()); Collapser.decorateCollapserControl(titleLabel, true); titlePanel.add(titleLabel); object.add(titlePanel); FlowPanel objectContents = new FlowPanel(); if (menuButtonForReuse != null) { objectContents.addStyleName(style.reusableResource()); objectContents.add(menuButtonForReuse); } for (Widget child : objIterable) { objectContents.add(child); } object.add(objectContents); InlineLabel placeholder = new InlineLabel(indentation(depth + 1) + PLACEHOLDER_TEXT); ClickHandler collapsingHandler = new Collapser(objectContents, placeholder, titleLabel); placeholder.setVisible(false); placeholder.addClickHandler(collapsingHandler); object.add(placeholder); titleLabel.addClickHandler(collapsingHandler); StringBuilder closingLabelText = new StringBuilder(indentation(depth)).append(closeGroup); if (hasSeparator) { closingLabelText.append(SEPARATOR_TEXT); } object.add(new Label(closingLabelText.toString())); return object; }
From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java
License:Open Source License
/** * Helper method called by constructor to initialize the author's info * @param container The container that author's info resides *//*from w w w . j av a 2 s.c o m*/ private void initAppAuthor(Panel container) { // Add author's image - not when creating a new app if (editStatus != NEWAPP) { final Image authorAvatar = new Image(); authorAvatar.addStyleName("app-userimage"); authorAvatar.setUrl(gallery.getUserImageURL(app.getDeveloperId())); // If the user has provided a gallery app image, we'll load it. But if not // the error will occur and we'll load default image authorAvatar.addErrorHandler(new ErrorHandler() { public void onError(ErrorEvent event) { authorAvatar.setUrl(GalleryApp.DEFAULTUSERIMAGE); } }); authorAvatar.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Ode.getInstance().switchToUserProfileView(app.getDeveloperId(), 1 /* 1 for public view */ ); } }); appInfo.add(authorAvatar); } // Add author's name final Label authorName = new Label(); if (editStatus == NEWAPP) { // App doesn't have author info yet, grab current user info final User currentUser = Ode.getInstance().getUser(); authorName.setText(currentUser.getUserName()); } else { authorName.setText(app.getDeveloperName()); authorName.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Ode.getInstance().switchToUserProfileView(app.getDeveloperId(), 1 /* 1 for public view*/ ); } }); } authorName.addStyleName("app-username"); authorName.addStyleName("app-subtitle"); appInfo.add(authorName); }
From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java
License:Open Source License
/** * Helper method called by constructor to initialize the app action tabs *///from w ww. j av a 2s . c o m private void initActionTabs() { // Add a bunch of tabs for executable actions regarding the app appSecondaryWrapper.addStyleName("clearfix"); appSecondaryWrapper.add(appActionTabs); appActionTabs.addStyleName("app-actions"); appActionTabs.add(appDescPanel, "Description"); appActionTabs.add(appSharePanel, "Share"); appActionTabs.add(appReportPanel, "Report"); appActionTabs.selectTab(0); appActionTabs.addStyleName("app-actions-tabs"); appDetails.add(appSecondaryWrapper); // Return to Gallery link Label returnLabel = new Label("Back to Gallery"); returnLabel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { ode.switchToGalleryView(); } }); returnToGallery.add(returnLabel); returnToGallery.addStyleName("gallery-nav-return"); returnToGallery.addStyleName("primary-link"); appSecondaryWrapper.add(returnToGallery); // }
From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java
License:Open Source License
/** * Helper method called by constructor to initialize the remix button *///from www. j av a2 s.com private FlowPanel initRemixFromButton() { FlowPanel container = new FlowPanel(); final Label remixedFrom = new Label(MESSAGES.galleryRemixedFrom()); remixedFrom.addStyleName("app-meta-label"); final Label parentApp = new Label(); //gwt-Label use fixed width which will case border-underline-dot //be longer than text link. //gwt-Label-auto use auto width parentApp.removeStyleName("gwt-Label"); parentApp.addStyleName("gwt-Label-auto"); parentApp.addStyleName("primary-link"); container.add(remixedFrom); container.add(parentApp); remixedFrom.setVisible(false); parentApp.setVisible(false); final Result<GalleryApp> attributionGalleryApp = new Result<GalleryApp>(); final OdeAsyncCallback<Long> remixedFromCallback = new OdeAsyncCallback<Long>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(final Long attributionId) { if (attributionId != UserProject.FROMSCRATCH) { remixedFrom.setVisible(true); parentApp.setVisible(true); final OdeAsyncCallback<GalleryApp> callback = new OdeAsyncCallback<GalleryApp>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(GalleryApp AppRemixedFrom) { parentApp.setText(AppRemixedFrom.getTitle()); attributionGalleryApp.t = AppRemixedFrom; } }; Ode.getInstance().getGalleryService().getApp(attributionId, callback); } else { attributionGalleryApp.t = null; } } }; Ode.getInstance().getGalleryService().remixedFrom(app.getGalleryAppId(), remixedFromCallback); parentApp.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (attributionGalleryApp.t == null) { } else { Ode.getInstance().switchToGalleryAppView(attributionGalleryApp.t, GalleryPage.VIEWAPP); } } }); final OdeAsyncCallback<List<GalleryApp>> callback = new OdeAsyncCallback<List<GalleryApp>>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(final List<GalleryApp> apps) { if (apps.size() != 0) { // Display remixes at the sidebar on the same page galleryGF.generateSidebar(apps, sidebarTabs, appsRemixes, "Remixes", MESSAGES.galleryAppsRemixesSidebar() + app.getTitle(), false, false); } } }; Ode.getInstance().getGalleryService().remixedTo(app.getGalleryAppId(), callback); return container; }
From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java
License:Open Source License
/** * Helper method called by constructor to initialize the like section * @param container The container that like label & image reside *//* w ww .j a v a2 s. co m*/ private void initLikeSection(Panel container) { //TODO: Update the location of this button final Image likeButton = new Image(); likeButton.setUrl(HOLLOW_HEART_ICON_URL); container.add(likeButton); likeCount = new Label(MESSAGES.galleryEmptyText()); container.add(likeCount); final Label likePrompt = new Label(MESSAGES.galleryEmptyText()); likePrompt.addStyleName("primary-link"); container.add(likePrompt); likePrompt.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { final OdeAsyncCallback<Integer> changeLikeCallback = new OdeAsyncCallback<Integer>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(Integer num) { // TODO: deal with/discuss server data sync later; now is updating locally. final OdeAsyncCallback<Boolean> checkCallback = new OdeAsyncCallback<Boolean>( MESSAGES.galleryError()) { @Override public void onSuccess(Boolean b) { //email will be send automatically if condition matches (in ObjectifyGalleryStorageIo) } }; Ode.getInstance().getGalleryService().checkIfSendAppStats(app.getDeveloperId(), app.getGalleryAppId(), gallery.getGallerySettings().getAdminEmail(), Window.Location.getHost(), checkCallback); } }; final OdeAsyncCallback<Boolean> isLikedByUserCallback = new OdeAsyncCallback<Boolean>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(Boolean bool) { if (bool) { // If the app is already liked before, and user clicks again, that means unlike Ode.getInstance().getGalleryService().decreaseLikes(app.getGalleryAppId(), changeLikeCallback); likePrompt.setText(MESSAGES.galleryAppsLike()); // Old code likeCount.setText(String.valueOf(Integer.valueOf(likeCount.getText()) - 1)); likeButton.setUrl(HOLLOW_HEART_ICON_URL); // Unliked } else { // If the app is not yet liked, and user clicks like, that means add a like Ode.getInstance().getGalleryService().increaseLikes(app.getGalleryAppId(), changeLikeCallback); likePrompt.setText(MESSAGES.galleryAppsAlreadyLike()); // Old code likeCount.setText(String.valueOf(Integer.valueOf(likeCount.getText()) + 1)); likeButton.setUrl(RED_HEART_ICON_URL); // Liked } } }; Ode.getInstance().getGalleryService().isLikedByUser(app.getGalleryAppId(), isLikedByUserCallback); // This happens when user click on like, we need to check if it's already liked } }); final OdeAsyncCallback<Integer> likeNumCallback = new OdeAsyncCallback<Integer>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(Integer num) { likeCount.setText(String.valueOf(num)); } }; Ode.getInstance().getGalleryService().getNumLikes(app.getGalleryAppId(), likeNumCallback); final OdeAsyncCallback<Boolean> isLikedCallback = new OdeAsyncCallback<Boolean>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(Boolean bool) { if (!bool) { likePrompt.setText(MESSAGES.galleryAppsLike()); likeButton.setUrl(HOLLOW_HEART_ICON_URL);//unliked } else { likePrompt.setText(MESSAGES.galleryAppsAlreadyLike()); likeButton.setUrl(RED_HEART_ICON_URL);//liked } } }; Ode.getInstance().getGalleryService().isLikedByUser(app.getGalleryAppId(), isLikedCallback); }
From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java
License:Open Source License
/** * Helper method called by constructor to initialize the salvage section * @param container The container that salvage label reside *///from ww w .ja v a 2 s.c om private void initSalvageSection(Panel container) { //TODO: Update the location of this button if (!canSalvage()) { // Permitted to salvage? return; } final Label salvagePrompt = new Label("salvage"); salvagePrompt.addStyleName("primary-link"); container.add(salvagePrompt); salvagePrompt.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { final OdeAsyncCallback<Void> callback = new OdeAsyncCallback<Void>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(Void bool) { salvagePrompt.setText("done"); } }; Ode.getInstance().getGalleryService().salvageGalleryApp(app.getGalleryAppId(), callback); } }); }