List of usage examples for com.google.gwt.user.client.ui Label addClickHandler
public HandlerRegistration addClickHandler(ClickHandler handler)
From source file:cc.kune.gspace.client.share.ShareToOthersPanel.java
License:Open Source License
@Inject public ShareToOthersPanel(final I18nUITranslationService i18n, final ShareToOthersDropController dropController) { this.dropController = dropController; final FlowPanel flow = new FlowPanel(); flow.addStyleName("k-share-others"); multivalueSBox = SearchBoxFactory.create(i18n, false, true, SEARCH_TEXTBOX_ID, new OnEntitySelectedInSearch() { @Override/*from w w w. j ava 2 s.com*/ public void onSeleted(final String shortName) { if (addListener != null) { addListener.onAdd(shortName); } } }); final SuggestBox suggestBox = multivalueSBox.getSuggestBox(); final ValueBoxBase<String> searchTextBox = suggestBox.getValueBox(); final Label suggestBoxIntro = new Label(I18n.t("drag and drop to add people or")); final Label suggestTextWhenEmpty = new Label(I18n.t("search to add")); flow.add(suggestBoxIntro); flow.add(multivalueSBox); flow.add(suggestTextWhenEmpty); multivalueSBox.addStyleName("k-share-searchbox"); suggestTextWhenEmpty.addStyleName("k-share-searchbox-text"); suggestTextWhenEmpty.addStyleName("k-clean"); initWidget(flow); // Search box settings suggestTextWhenEmpty.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { suggestBox.setFocus(true); } }); searchTextBox.addFocusHandler(new FocusHandler() { @Override public void onFocus(final FocusEvent event) { // searchLabel.setVisible(false); suggestTextWhenEmpty.getElement().getStyle().setVisibility(Visibility.HIDDEN); } }); searchTextBox.addBlurHandler(new BlurHandler() { @Override public void onBlur(final BlurEvent event) { if (searchTextBox.getValue().isEmpty()) { suggestTextWhenEmpty.getElement().getStyle().setVisibility(Visibility.VISIBLE); } } }); // Tooltips Tooltip.to(suggestBox, I18n.t(NOT_LIST_TOOLTIP)); Tooltip.to(suggestTextWhenEmpty, I18n.t(NOT_LIST_TOOLTIP)); Tooltip.to(suggestBoxIntro, I18n.t(NOT_LIST_TOOLTIP)); // D&D dropController.init(flow); }
From source file:cc.kune.gspace.client.tags.TagsSummaryPanel.java
License:GNU Affero Public License
@Override public void addTag(final String name, final Long count, final String style, final ClickHandler clickHandler) { final Label label = new Label(name); // i18n pluralization if (count > 1) { label.setTitle(i18n.t("There are [%d] items with this tag", count)); } else {/* ww w . j a va 2 s . com*/ label.setTitle(i18n.t("There are [%d] item with this tag", count)); } label.addClickHandler(clickHandler); label.addStyleName("k-tsp-tag"); label.addStyleName(style); flowPanel.add(label); }
From source file:ch.sebastienzurfluh.swissmuseum.parcours.client.view.infos.InfoPanel.java
License:Open Source License
public InfoPanel(String title, final Widget returnToIt, final AnimationHelper animationHelper) { setStyleName("infoPanel"); HorizontalPanel titleLine = new HorizontalPanel(); Label returnLabel = new Label("Retourner"); returnLabel.setStyleName("infoPanel-returnButton"); returnLabel.addClickHandler(new ClickHandler() { @Override/*from w w w . j a v a 2 s . c o m*/ public void onClick(ClickEvent event) { animationHelper.goTo(returnToIt, Animation.SLIDE_UP); } }); titleLine.add(returnLabel); Label titleLabel = new Label(title); titleLabel.setStyleName("infoPanel-title"); titleLine.add(titleLabel); this.add(titleLine); setContent(new Label("loading...")); this.add(contentPanel); }
From source file:cl.uai.client.rubric.CriterionHeader.java
License:Open Source License
public CriterionHeader(int idx, int cid, String cdesc, float b, int regrid, int regraccepted) { this.mainPanel = new FlowPanel(); this.mainPanel.addStyleName(Resources.INSTANCE.css().criterionrow()); this.criterionId = cid; this.criterionDescription = cdesc; this.index = idx; Label lbl = new Label(cdesc); lbl.addStyleName(Resources.INSTANCE.css().criterionheader()); lbl.addClickHandler(new ClickHandler() { @Override//ww w .j av a 2 s. com public void onClick(ClickEvent event) { if (commentId > 0 && commentPage > 0) EMarkingWeb.markingInterface.getMarkingPagesInterface().highlightRubricMark(commentId, commentPage); } }); mainPanel.add(lbl); bonusHtml = new HTML(); bonusHtml.addStyleName(Resources.INSTANCE.css().criterionheaderbonus()); setBonus(b); mainPanel.add(bonusHtml); regradeHtml = new HTML(); regradeHtml.setVisible(false); mainPanel.add(regradeHtml); this.setRegradeData(regrid, regraccepted); loadingIcon = new HTML(); loadingIcon.setVisible(false); Icon iconloading = new Icon(IconType.COG); loadingIcon.setHTML(iconloading.toString()); loadingIcon.addStyleName(Resources.INSTANCE.css().loadingicon()); loadingIcon.addStyleName("icon-spin"); mainPanel.add(loadingIcon); initWidget(mainPanel); }
From source file:com.ait.toolkit.clientio.uploader.client.Uploader.java
License:Apache License
@Override protected void onLoad() { // Make sure our entire panel fits the size that they wanted for the button if (this.buttonWidth >= 0) { this.setWidth(this.buttonWidth + "px"); }/*from w ww . j a v a 2 s . c o m*/ if (this.buttonHeight >= 0) { this.setHeight(this.buttonHeight + "px"); } if (ajaxUploadEnabled && isAjaxUploadWithProgressEventsSupported()) { // If the browser supports the XMLHttpRequest Level 2 type then we can avoid rendering the flash component // and just stick with a DOM/Ajax approach. // Use a hidden file input component to handle allowing the user to popup the file system dialog // (but keep it outside of the button itself so it doesn't interfere with the mouse events) this.add(createFileUpload()); // Create the main element that will hold all of the inner workings of the uploader component Label button = new Label(); button.setWidth("100%"); button.setHeight("100%"); if (this.buttonCursor != null) { switch (this.buttonCursor) { case ARROW: button.getElement().getStyle().setCursor(Style.Cursor.DEFAULT); break; case HAND: button.getElement().getStyle().setCursor(Style.Cursor.POINTER); break; } } // Setup what we want to happen when someone clicks anywhere on the button button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (buttonDisabled) { return; } switch (buttonAction) { case START_UPLOAD: startUpload(); break; case SELECT_FILES: openFileDialog(fileUpload, true); break; case SELECT_FILE: default: openFileDialog(fileUpload, false); break; } } }); button.addMouseOverHandler(new MouseOverHandler() { public void onMouseOver(MouseOverEvent event) { if (buttonImageURL != null && buttonHeight >= 0 && !buttonDisabled) { buttonImageElement.getStyle().setProperty("backgroundPosition", "0px -" + buttonHeight + "px"); } } }); button.addMouseOutHandler(new MouseOutHandler() { public void onMouseOut(MouseOutEvent event) { if (buttonImageURL != null && buttonHeight >= 0 && !buttonDisabled) { buttonImageElement.getStyle().setProperty("backgroundPosition", "0px 0px"); } } }); button.addMouseDownHandler(new MouseDownHandler() { public void onMouseDown(MouseDownEvent event) { if (buttonImageURL != null && buttonHeight >= 0 && !buttonDisabled) { buttonImageElement.getStyle().setProperty("backgroundPosition", "0px -" + (buttonHeight * 2) + "px"); } } }); button.addMouseUpHandler(new MouseUpHandler() { public void onMouseUp(MouseUpEvent event) { if (buttonImageURL != null && buttonHeight >= 0 && !buttonDisabled) { buttonImageElement.getStyle().setProperty("backgroundPosition", "0px 0px"); } } }); // Depending on the way they wanted the uploader button rendered, create the appropriate elements // in the DOM that the user will click on. if (this.buttonTextStyle != null) { buttonTextStyleElement = Document.get().createStyleElement(); buttonTextStyleElement.setInnerText(this.buttonTextStyle); button.getElement().appendChild(buttonTextStyleElement); } if (this.buttonText != null) { buttonTextElement = Document.get().createDivElement(); buttonTextElement.setInnerHTML(this.buttonText); buttonTextElement.getStyle().setWidth(100, Style.Unit.PCT); buttonTextElement.getStyle().setHeight(100, Style.Unit.PCT); if (this.buttonTextLeftPadding > Integer.MIN_VALUE) { buttonTextElement.getStyle().setPaddingLeft(this.buttonTextLeftPadding, Style.Unit.PX); } if (this.buttonTextTopPadding > Integer.MIN_VALUE) { buttonTextElement.getStyle().setPaddingTop(this.buttonTextTopPadding, Style.Unit.PX); } button.getElement().appendChild(buttonTextElement); } if (this.buttonImageURL != null) { buttonImageElement = Document.get().createDivElement(); buttonImageElement.getStyle().setBackgroundImage("url(\"" + this.buttonImageURL + "\")"); if (this.buttonDisabled) { buttonImageElement.getStyle().setProperty("backgroundPosition", "0px -" + (buttonHeight * 3) + "px"); } else { buttonImageElement.getStyle().setProperty("backgroundPosition", "0px 0px"); } buttonImageElement.getStyle().setWidth(100, Style.Unit.PCT); buttonImageElement.getStyle().setHeight(100, Style.Unit.PCT); button.getElement().appendChild(buttonImageElement); } // Add the entire button to the DOM this.add(button); } else { // If the browser doesn't support the XMLHttpRequest Level 2 type, then our only option is to use // the Flash/SWFUpload component. // The SWFUpload JS code completely replaces the DOM element that you give it as a target, // so we're creating an inner component that it can replace - leaving the outer component // for the caller to use as the GWT Widget that they can manage and style within the appropriate // container within their GWT application DivElement swfUploadElement = Document.get().createDivElement(); swfUploadElement.setId(Document.get().createUniqueId()); this.getElement().appendChild(swfUploadElement); JavaScriptObject nativeOptions = createNativeOptions(swfUploadElement.getId()); // Build a map that we'll use during the native creation process to setup // the necessary JSNI bridges to our Java event handlers... JSONObject eventHandlers = new JSONObject(); eventHandlers.put("swfupload_loaded_handler", JSONBoolean.getInstance(swfUploadLoadedHandler != null)); eventHandlers.put("file_dialog_start_handler", JSONBoolean.getInstance(fileDialogStartHandler != null)); eventHandlers.put("file_queued_handler", JSONBoolean.getInstance(fileQueuedHandler != null)); eventHandlers.put("file_queue_error_handler", JSONBoolean.getInstance(fileQueueErrorHandler != null)); eventHandlers.put("file_dialog_complete_handler", JSONBoolean.getInstance(fileDialogCompleteHandler != null)); eventHandlers.put("upload_start_handler", JSONBoolean.getInstance(uploadStartHandler != null)); eventHandlers.put("upload_progress_handler", JSONBoolean.getInstance(uploadProgressHandler != null)); eventHandlers.put("upload_error_handler", JSONBoolean.getInstance(uploadErrorHandler != null)); eventHandlers.put("upload_success_handler", JSONBoolean.getInstance(uploadSuccessHandler != null)); eventHandlers.put("upload_complete_handler", JSONBoolean.getInstance(uploadCompleteHandler != null)); swfUpload = nativeCreateSWFUpload(nativeOptions, eventHandlers.getJavaScriptObject()); } }
From source file:com.areahomeschoolers.baconbits.client.content.calendar.CalendarView.java
License:Open Source License
protected void addDayClickHandler(final Label dayLabel, final Date day) { dayLabel.addClickHandler(new ClickHandler() { @Override//from www . j a v a2 s . c om public void onClick(ClickEvent event) { fireSelectedDay(day); } }); }
From source file:com.areahomeschoolers.baconbits.client.content.calendar.CalendarView.java
License:Open Source License
protected void addWeekClickHandler(final Label weekLabel, final Date day) { weekLabel.addClickHandler(new ClickHandler() { @Override//from w w w . j av a 2s . c o m public void onClick(ClickEvent event) { fireSelectedWeek(day); } }); }
From source file:com.areahomeschoolers.baconbits.client.content.calendar.dayview.DayViewHeader.java
License:Open Source License
private void addDayClickHandler(final Label dayLabel, final Date day) { dayLabel.addClickHandler(new ClickHandler() { @Override//w ww . j ava 2 s . c om public void onClick(ClickEvent event) { fireSelectedDay(day); } }); }
From source file:com.areahomeschoolers.baconbits.client.content.calendar.dayview.DayViewHeader.java
License:Open Source License
private void addWeekClickHandler(final Label weekLabel, final Date day) { weekLabel.addClickHandler(new ClickHandler() { @Override// www .j a va2s .c o m public void onClick(ClickEvent event) { fireSelectedWeek(day); } }); }
From source file:com.bradrydzewski.gwt.calendar.client.agenda.AgendaView.java
License:Open Source License
@Override public void doLayout() { appointmentAdapterList.clear();/*from w ww.jav a 2 s .co m*/ appointmentGrid.clear(); for (int i = appointmentGrid.getRowCount() - 1; i >= 0; i--) { appointmentGrid.removeRow(i); } //Get the start date, make sure time is 0:00:00 AM Date startDate = (Date) calendarWidget.getDate().clone(); Date today = new Date(); Date endDate = (Date) calendarWidget.getDate().clone(); endDate.setDate(endDate.getDate() + 1); DateUtils.resetTime(today); DateUtils.resetTime(startDate); DateUtils.resetTime(endDate); int row = 0; for (int i = 0; i < calendarWidget.getDays(); i++) { // Filter the list by date List<Appointment> filteredList = AppointmentUtil.filterListByDate(calendarWidget.getAppointments(), startDate, endDate); if (filteredList != null && filteredList.size() > 0) { appointmentGrid.setText(row, 0, DEFAULT_DATE_FORMAT.format(startDate)); appointmentGrid.getCellFormatter().setVerticalAlignment(row, 0, HasVerticalAlignment.ALIGN_TOP); appointmentGrid.getFlexCellFormatter().setRowSpan(row, 0, filteredList.size()); appointmentGrid.getFlexCellFormatter().setStyleName(row, 0, "dateCell"); int startingCell = 1; //Row styles will alternate, so we set the style accordingly String rowStyle = (i % 2 == 0) ? "row" : "row-alt"; //If a Row represents the current date (Today) then we style it differently if (startDate.equals(today)) rowStyle += "-today"; for (Appointment appt : filteredList) { // add the time range String timeSpanString = DEFAULT_TIME_FORMAT.format(appt.getStart()) + " - " + DEFAULT_TIME_FORMAT.format(appt.getEnd()); Label timeSpanLabel = new Label(timeSpanString.toLowerCase()); appointmentGrid.setWidget(row, startingCell, timeSpanLabel); // add the title and description FlowPanel titleContainer = new FlowPanel(); InlineLabel titleLabel = new InlineLabel(appt.getTitle()); titleContainer.add(titleLabel); InlineLabel descLabel = new InlineLabel(" - " + appt.getDescription()); descLabel.setStyleName("descriptionLabel"); titleContainer.add(descLabel); appointmentGrid.setWidget(row, startingCell + 1, titleContainer); SimplePanel detailContainerPanel = new SimplePanel(); AppointmentDetailPanel detailContainer = new AppointmentDetailPanel(detailContainerPanel, appt); appointmentAdapterList.add(new AgendaViewAppointmentAdapter(titleLabel, timeSpanLabel, detailContainerPanel, detailContainer.getMoreDetailsLabel(), appt)); //add the detail container titleContainer.add(detailContainer); //add click handlers to title, date and details link timeSpanLabel.addClickHandler(appointmentClickHandler); titleLabel.addClickHandler(appointmentClickHandler); detailContainer.getMoreDetailsLabel().addClickHandler(appointmentClickHandler); // Format the Cells appointmentGrid.getCellFormatter().setVerticalAlignment(row, startingCell, HasVerticalAlignment.ALIGN_TOP); appointmentGrid.getCellFormatter().setVerticalAlignment(row, startingCell + 1, HasVerticalAlignment.ALIGN_TOP); appointmentGrid.getCellFormatter().setStyleName(row, startingCell, "timeCell"); appointmentGrid.getCellFormatter().setStyleName(row, startingCell + 1, "titleCell"); appointmentGrid.getRowFormatter().setStyleName(row, rowStyle); // increment the row // make sure the starting column is reset to 0 startingCell = 0; row++; } } // increment the date startDate.setDate(startDate.getDate() + 1); endDate.setDate(endDate.getDate() + 1); } }