List of usage examples for com.google.gwt.user.client.ui Label addMouseUpHandler
public HandlerRegistration addMouseUpHandler(MouseUpHandler handler)
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"); }//ww w.java 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:io.apiman.manager.ui.client.local.pages.common.PolicyList.java
License:Apache License
/** * Creates a single policy row./*from ww w .j av a2 s. co m*/ * @param bean */ private Widget createPolicyRow(final PolicyBean bean) { PolicyRow container = new PolicyRow(bean); final FlowPanel row = new FlowPanel(); row.getElement().setClassName("row"); //$NON-NLS-1$ // Grabber Label grabber = new Label(); grabber.getElement().setDraggable(Element.DRAGGABLE_TRUE); grabber.getElement().setClassName("grabber"); //$NON-NLS-1$ grabber.getElement().getStyle().setHeight(48, Unit.PX); row.add(grabber); createIconColumn(bean, row); createSummaryColumn(bean, row); createActionColumn(bean, row); container.add(new HTMLPanel("<hr/>")); //$NON-NLS-1$ container.add(row); PolicyDragHandler handler = new PolicyDragHandler(grabber, container); grabber.addMouseDownHandler(handler); grabber.addMouseUpHandler(handler); grabber.addMouseMoveHandler(handler); return container; }
From source file:org.raccoon.hit.client.ui.player.skin.AviaSeekBar.java
License:Apache License
/** * Constructs <code>MediaSeekBar</code> of the specified height. * * @param height the height of the seek bar in pixels *///from www. j a v a2 s . co m public @UiConstructor AviaSeekBar(int seekHeight) { seekTrack = new AbsolutePanel(); seekTrack.setSize("100%", seekHeight + "px"); super.initWidget(seekTrack); Label playing, loading, thumb; playing = new Label(); playing.setSize("100%", seekHeight + "px"); playing.addMouseUpHandler(this); loading = new Label(); loading.setSize("100%", seekHeight + "px"); loading.addMouseUpHandler(this); thumb = new Label(); playing.setStyleName("playing"); loading.setStyleName("loading"); thumb.setStyleName("thumb"); initSeekBar(loading, playing, thumb); setStylePrimaryName("player-CSSSeekBar"); }
From source file:org.waveprotocol.wave.client.widget.button.icon.IconButtonTemplate.java
License:Apache License
@UiConstructor public IconButtonTemplate() { Label label = new Label(); initWidget(label);/*from www . ja v a 2 s . com*/ label.addClickHandler(this); label.addMouseOverHandler(this); label.addMouseOutHandler(this); label.addMouseUpHandler(this); label.addMouseDownHandler(this); }
From source file:org.wisepersist.gwt.uploader.client.Uploader.java
License:Apache License
@Override protected void onLoad() { if (loaded) { return;/*from w w w . j av a 2 s.c om*/ } loaded = true; // Make sure our entire panel fits the size that they wanted for the button if (this.buttonWidth >= 0) { this.setWidth(this.buttonWidth + "px"); } 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()); } }