当前位置: 首页>>代码示例>>Java>>正文


Java EventListener类代码示例

本文整理汇总了Java中com.google.gwt.user.client.EventListener的典型用法代码示例。如果您正苦于以下问题:Java EventListener类的具体用法?Java EventListener怎么用?Java EventListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EventListener类属于com.google.gwt.user.client包,在下文中一共展示了EventListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setEventHandler

import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
/**
 * Sets an event handler for an {@code Element}. All previous event handlers of this type of event are removed.
 * @param element The element to bind the event handler for
 * @param eventType The event type (e.g. {@code ClickEvent.getType()})
 * @param handler The handler that handler the event
 */
public static <H extends EventHandler> void setEventHandler(final Element element, DomEvent.Type<H> eventType, H handler) {
  if (element == null) {
    return;
  }
  HandlerManager hm = handlerManagers.get(element);
  if (hm == null) {
    handlerManagers.put(element, hm = new HandlerManager(element));
    DOM.setEventListener(element, new EventListener() {
      @Override
      public void onBrowserEvent(Event event) {
        DomEvent.fireNativeEvent(event, handlerManagers.get(element), element);
      }
    });
  }
  DOM.sinkBitlessEvent(element, eventType.getName());
  while (hm.getHandlerCount(eventType) > 0) {
    hm.removeHandler(eventType, hm.getHandler(eventType, 0));
  }
  hm.addHandler(eventType, handler);
}
 
开发者ID:turnsk,项目名称:gwtmvp,代码行数:27,代码来源:EventManager.java

示例2: updateEventHandler

import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
private void updateEventHandler(final ContentElement element, String eventHandlerId) {
  Element implNodelet = element.getImplNodelet();
  final EventHandler handler =
      eventHandlerId == null ? null : AnnotationPaint.eventHandlerRegistry.get(eventHandlerId);
  if (handler != null) {
    DOM.sinkEvents(DomHelper.castToOld(implNodelet), MOUSE_LISTENER_EVENTS);
    DOM.setEventListener(DomHelper.castToOld(implNodelet), new EventListener() {
        @Override
        public void onBrowserEvent(Event event) {
          handler.onEvent(element, event);
        }
      });
  } else {
    removeListener(DomHelper.castToOld(implNodelet));
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:17,代码来源:AnnotationSpreadRenderer.java

示例3: addActivityTimer

import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
protected void addActivityTimer() {
	if (CMDBSession.get().getConfig().getDesktopLockTimeout() < 0) {
		return;
	}
	lastActivityTime = System.currentTimeMillis();
	
	//add event capture to detect user activity and reset idle timeout
    DOM.setEventListener(RootPanel.get().getElement(), new EventListener() {


		public void onBrowserEvent(Event event) {
			
			lastActivityTime = System.currentTimeMillis();
		}
    });
    DOM.sinkEvents(RootPanel.get().getElement(), Event.ONMOUSEDOWN);
}
 
开发者ID:luox12,项目名称:onecmdb,代码行数:18,代码来源:DesktopContoller.java

示例4: onLoad

import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
@Override
protected void onLoad() {
    super.onLoad();

    // Set page title & description
    setLayoutTitle(cons.sideMenuTitle());
    setLayoutDescription(cons.sideMenuDescription());

    // Inject layout stylesheet
    res.sideMenuLayoutCssResource().ensureInjected();

    // Bind click event to menu button
    DOM.setEventListener(menuLink, new EventListener() {

        @Override public void onBrowserEvent(Event event) {
            if (event.getTypeInt() == Event.ONCLICK) {
                toggleClass(layout.getElement(), res.sideMenuLayoutCssResource().active());
                toggleClass(menu, res.sideMenuLayoutCssResource().active());
                toggleClass(menuLink, res.sideMenuLayoutCssResource().active());
                event.preventDefault();
            }
        }
    });
    DOM.sinkEvents(menuLink, Event.ONCLICK);
}
 
开发者ID:MNCC,项目名称:showcase,代码行数:26,代码来源:SideMenu.java

示例5: addConnectivityHandler

import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
@Override
public final HandlerRegistration addConnectivityHandler(final ConnectivityEvent.Handler handler) {
	EventListener el = new EventListener() {
		@Override
		public void onBrowserEvent(Event event) {
			handler.onConnectivity((ConnectivityEventJsoImpl) event.cast());
		}
	};
	
	final HandlerRegistration hr1 = register(this, "online", el);
	final HandlerRegistration hr2 = register(this, "offline", el);
	
	return new HandlerRegistration() {
		
		@Override
		public void removeHandler() {
			hr1.removeHandler();
			hr2.removeHandler();
		}
	};
}
 
开发者ID:metteo,项目名称:gwt-worker,代码行数:22,代码来源:AbstractWorkerScopeJsoImpl.java

示例6: convertItemToOpenable

import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
private Element convertItemToOpenable (String key, SafeHtml title) {
	activateItem(key, false);
	Element element = getItem(key);
	ensureItems().remove(key);
	element.setClassName("dropdown");
	final AnchorElement a = AnchorElement
			.as(element.getFirstChildElement());
	a.removeAttribute("href");
	Event.sinkEvents(a, Event.ONCLICK);
	Event.setEventListener(a, new EventListener() {

		@Override
		public void onBrowserEvent (Event event) {
			openableClick(a);
			event.stopPropagation();
		}
	});
	a.addClassName("dropdown-toggle");
	a.setInnerSafeHtml(title);
	Element ul = Document.get().createULElement();
	ul.addClassName("dropdown-menu");
	element.appendChild(ul);
	ensureOpenables().put(key, element);

	return element;
}
 
开发者ID:billy1380,项目名称:blogwt,代码行数:27,代码来源:HeaderPart.java

示例7: acquireLockOnDemand

import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
public EventListener acquireLockOnDemand(final Element element) {
    Event.sinkEvents(element,
                     lockDemandDetector.getLockDemandEventTypes());

    EventListener lockDemandListener = new EventListener() {

        @Override
        public void onBrowserEvent(Event event) {
            if (isLockedByCurrentUser()) {
                return;
            }

            if (lockDemandDetector.isLockRequired(event)) {
                acquireLock();
            }
        }
    };

    Event.setEventListener(element,
                           lockDemandListener);

    return lockDemandListener;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:24,代码来源:LockManagerImpl.java

示例8: addButton

import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
private void addButton(String id, final Image image, VerticalPanel iconsPanel) {
	Element element = layout.getElement(id);
	image.setStyleName(STYLE_CLICKABLE);
	if (element==null) {
		image.addClickHandler(mainClickHandler);
		iconsPanel.add(image);
		iconsPanel.setCellHeight(image, "1%");
		iconsPanel.setCellWidth(image, "100%");
	} else {
		com.google.gwt.user.client.Element el = (com.google.gwt.user.client.Element) element;
		DOM.sinkEvents(el,Event.ONCLICK);
		DOM.setEventListener(el, new EventListener(){
			public void onBrowserEvent(Event event) {
				processClick(image);
			}
		});
		layout.addStyle(id, PlayerLayout.BUTTON_ON_STYLE);
	}
}
 
开发者ID:Antokolos,项目名称:iambookmaster,代码行数:20,代码来源:Player.java

示例9: appendInSpan

import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
private void appendInSpan(final Widget widget, boolean wordWrap) {
	Element el = DOM.createSpan();
	Element oldEl = widget.getElement();
	DOM.setInnerHTML(el, DOM.getInnerHTML(oldEl));
	String style = widget.getStyleName();
	if (style != null && style.length()>0) {
		DOM.setElementProperty(el, "className", style);
	}
	if (wordWrap) {
		DOM.setStyleAttribute(el, "whiteSpace", "normal");
	} else {
		DOM.setStyleAttribute(el, "whiteSpace", "nowrap");
	}
	EventListener eventListener = new EventListener() {

		public void onBrowserEvent(Event event) {
			widget.onBrowserEvent(event);
		}
		
	};
	DOM.setEventListener(el, eventListener);
	DOM.sinkEvents(el, DOM.getEventsSunk(oldEl));
	DOM.appendChild(getElement(), el);
}
 
开发者ID:Antokolos,项目名称:iambookmaster,代码行数:25,代码来源:WidgetsLine.java

示例10: onLoad

import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
@Override
protected void onLoad() {
    super.onLoad();

    // Set page title & description
    setLayoutTitle(cons.sideMenuTitle());
    setLayoutDescription(cons.sideMenuDescription());

    // Inject layout stylesheet
    SandboxResourceBundle.INSTANCE.sideMenuLayoutCssResource().ensureInjected();

    // Bind click event to menu button
    DOM.setEventListener(menuLink, new EventListener() {

        @Override public void onBrowserEvent(Event event) {
            if (event.getTypeInt() == Event.ONCLICK) {
                toggleClass(layout.getElement(), res.sideMenuLayoutCssResource().active());
                toggleClass(menu, res.sideMenuLayoutCssResource().active());
                toggleClass(menuLink, res.sideMenuLayoutCssResource().active());
                event.preventDefault();
            }
        }
    });
    DOM.sinkEvents(menuLink, Event.ONCLICK);
}
 
开发者ID:csavelief,项目名称:gwt-sandbox,代码行数:26,代码来源:SideMenuLayout.java

示例11: ImageTracker

import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
public ImageTracker(String imageUrl) {
    m_image = new Image(imageUrl);
    Event.setEventListener(m_image.getElement(), new EventListener() {

        @Override
        public void onBrowserEvent(Event event) {
            if(Event.ONLOAD == event.getTypeInt()) {
                callHandlers();
                m_loadComplete = true;
            }
            
        }
        
    });
    
    Element div = Document.get().getElementById(m_trackerDivId);
    div.appendChild(m_image.getElement());
    //Document.get().getBody().appendChild(m_image.getElement());
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:20,代码来源:LoadTracker.java

示例12: upload

import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
public void upload(final Renderer3d renderer3d, final Texture texture, final int activeTexture) {
	if ((texture.status & GpuObjectStatus.TEXTURE_UPLOADING) == 0) {
		texture.status |= GpuObjectStatus.TEXTURE_UPLOADING;

		Integer Integer = gl.createTexture();
		textures.put(texture, Integer);

		ImageElement textureImage = resourceLoader.getImage(texture.image);
		if (textureImage == null) {
			Window.alert("Texture image not found in resources: " + texture.image);
		} else {
			textureImages.put(texture, textureImage);

			Event.setEventListener(textureImage, new EventListener() {
				@Override
				public void onBrowserEvent(Event event) {
					textureLoaded(renderer3d, texture, activeTexture);
				}
			});
			Event.sinkEvents(textureImage, Event.ONLOAD);
		}
	}
}
 
开发者ID:mobialia,项目名称:jmini3d,代码行数:24,代码来源:GpuUploader.java

示例13: updateEventHandler

import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
private void updateEventHandler(final ContentElement element, String eventHandlerId) {
  Element implNodelet = element.getImplNodelet();
  final EventHandler handler =
      eventHandlerId == null ? null : AnnotationPaint.eventHandlerRegistry.get(eventHandlerId);
  if (handler != null) {
    DOM.sinkEvents(DomHelper.castToOld(implNodelet), MOUSE_LISTENER_EVENTS);
    DOM.setEventListener(DomHelper.castToOld(implNodelet), new EventListener() {
      @Override
      public void onBrowserEvent(Event event) {
        handler.onEvent(element, event);
      }
    });
  } else {
    removeListener(DomHelper.castToOld(implNodelet));
  }
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:17,代码来源:AnnotationSpreadRenderer.java

示例14: addModule

import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
public void addModule(final String entered) {
  if (modules.add(entered)) {
    final Element clone = Element.as(moduleTemplate.getElement().cloneNode(true));
    clone.removeClassName(res.css().hidden());
    Element el = clone.getFirstChildElement().getNextSiblingElement();
    el.setInnerText(entered);
    com.google.gwt.user.client.Element image = el.getNextSiblingElement().cast();
    DOM.setEventListener(image, new EventListener() {
      @Override
      public void onBrowserEvent(Event event) {
        modules.remove(entered);
        clone.removeFromParent();
      }
    });
    DOM.sinkEvents(image, Event.ONCLICK | Event.ONKEYDOWN);
    selectedModules.appendChild(clone);
  }
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:19,代码来源:ModuleSelectorView.java

示例15: WebcamConnector

import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
public WebcamConnector() {
    getWidget().setClickListener(new EventListener() {

        @Override
        public void onBrowserEvent(Event event) {
            // Commanded by the user clicking the client-side widget.
            captureNow();
        }
    });

    registerRpc(WebcamClientRpc.class, new WebcamClientRpc() {

        @Override
        public void capture() {
            // Commanded by the server-side component.
            captureNow();
        }
    });
}
 
开发者ID:tehapo,项目名称:webcam,代码行数:20,代码来源:WebcamConnector.java


注:本文中的com.google.gwt.user.client.EventListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。