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


Java EventListener类代码示例

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


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

示例1: preventExcessiveScrollingPropagation

import elemental.events.EventListener; //导入依赖的package包/类
/**
 * Prevent propagation of scrolling to parent containers on mouse wheeling, when target container
 * can not be scrolled anymore.
 */
public static void preventExcessiveScrollingPropagation(final Element container) {
  // The MOUSEWHEEL does not exist on FF, so in FF the common browser behavior won't be canceled
  // and the parent container will be scrolled.
  container.addEventListener(
      Event.MOUSEWHEEL,
      new EventListener() {
        @Override
        public void handleEvent(Event evt) {
          int deltaY = DOM.eventGetMouseWheelVelocityY((com.google.gwt.user.client.Event) evt);
          int scrollTop = container.getScrollTop();
          if (deltaY < 0 && scrollTop == 0) {
            evt.preventDefault();
          } else if (deltaY > 0
              && scrollTop == (container.getScrollHeight() - container.getClientHeight())) {
            evt.preventDefault();
          }
          evt.stopPropagation();
        }
      },
      false);
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:DomUtils.java

示例2: animatePropertySet

import elemental.events.EventListener; //导入依赖的package包/类
/**
 * Enables animations prior to setting the value for the specified style property on the supplied
 * element. The end result is that there property is transitioned to.
 *
 * @param elem the {@link Element} we want to set the style property on.
 * @param property the name of the style property we want to set.
 * @param value the target value of the style property.
 * @param duration the time in seconds we want the transition to last.
 * @param animationCallback callback that is invoked when the animation completes. It will be
 *     passed a {@code null} event if the animation was pre-empted by some other animation on the
 *     same element.
 */
public static void animatePropertySet(
    final Element elem,
    String property,
    String value,
    double duration,
    final EventListener animationCallback) {
  final CSSStyleDeclaration style = elem.getStyle();
  enableTransitions(style, duration);

  if (UserAgent.isFirefox()) {
    // For FF4.
    new TransitionEndHandler(animationCallback).handleEndFor(elem, "transitionend");
  } else {
    // For webkit based browsers.
    // TODO: Keep an eye on whether or not webkit supports the
    // vendor prefix free version. If they ever do we should remove this.
    new TransitionEndHandler(animationCallback).handleEndFor(elem, Event.WEBKITTRANSITIONEND);
  }

  style.setProperty(property, value);
}
 
开发者ID:eclipse,项目名称:che,代码行数:34,代码来源:AnimationUtils.java

示例3: renderAction

import elemental.events.EventListener; //导入依赖的package包/类
private Node renderAction(String title, final Action action) {
  final Presentation presentation = presentationFactory.getPresentation(action);
  Element divElement = Elements.createDivElement(style.listElement());
  divElement.addEventListener(
      "click",
      new EventListener() {
        @Override
        public void handleEvent(Event evt) {
          ActionEvent event = new ActionEvent(presentation, actionManager);
          action.actionPerformed(event);
        }
      },
      true);
  divElement.getStyle().setCursor("pointer");
  divElement.getStyle().setColor(Style.getOutputLinkColor());
  Element label = Elements.createDivElement(style.actionLabel());
  label.setInnerText(title);
  divElement.appendChild(label);

  String hotKey =
      KeyMapUtil.getShortcutText(keyBindingAgent.getKeyBinding(actionManager.getId(action)));
  if (hotKey == null) {
    hotKey = "&nbsp;";
  } else {
    hotKey = "<nobr>&nbsp;" + hotKey + "&nbsp;</nobr>";
  }
  SpanElement hotKeyElement = Elements.createSpanElement(style.hotKey());
  hotKeyElement.setInnerHTML(hotKey);
  divElement.appendChild(hotKeyElement);
  return divElement;
}
 
开发者ID:eclipse,项目名称:che,代码行数:32,代码来源:EmptyEditorsPanel.java

示例4: createItem

import elemental.events.EventListener; //导入依赖的package包/类
public Element createItem(final CompletionProposal proposal) {
  final Element element = Elements.createLiElement(popupResources.popupStyle().item());

  final Element icon = Elements.createDivElement(popupResources.popupStyle().icon());
  if (proposal.getIcon() != null && proposal.getIcon().getSVGImage() != null) {
    icon.appendChild((Node) proposal.getIcon().getSVGImage().getElement());
  } else if (proposal.getIcon() != null && proposal.getIcon().getImage() != null) {
    icon.appendChild((Node) proposal.getIcon().getImage().getElement());
  }
  element.appendChild(icon);

  final SpanElement label = Elements.createSpanElement(popupResources.popupStyle().label());
  label.setInnerHTML(proposal.getDisplayString());
  element.appendChild(label);

  final EventListener validateListener =
      new EventListener() {
        @Override
        public void handleEvent(final Event evt) {
          proposal.getCompletion(
              new CompletionProposal.CompletionCallback() {
                @Override
                public void onCompletion(final Completion completion) {
                  HandlesUndoRedo undoRedo = null;
                  if (textEditor instanceof UndoableEditor) {
                    UndoableEditor undoableEditor =
                        (UndoableEditor) QuickAssistWidget.this.textEditor;
                    undoRedo = undoableEditor.getUndoRedo();
                  }
                  try {
                    if (undoRedo != null) {
                      undoRedo.beginCompoundChange();
                    }
                    completion.apply(textEditor.getDocument());
                    final LinearRange selection =
                        completion.getSelection(textEditor.getDocument());
                    if (selection != null) {
                      textEditor.getDocument().setSelectedRange(selection, true);
                    }
                  } catch (final Exception e) {
                    Log.error(getClass(), e);
                  } finally {
                    if (undoRedo != null) {
                      undoRedo.endCompoundChange();
                    }
                  }
                }
              });
          hide();
        }
      };

  element.addEventListener(Event.DBLCLICK, validateListener, false);
  element.addEventListener(CUSTOM_EVT_TYPE_VALIDATE, validateListener, false);

  return element;
}
 
开发者ID:eclipse,项目名称:che,代码行数:58,代码来源:QuickAssistWidget.java

示例5: loadChunk

import elemental.events.EventListener; //导入依赖的package包/类
/**
 * Triggers an async request to load the chunk. The chunk is forwarded to all workers to be processed before being returned to the client
 *
 * @param x
 *         The chunk x position
 * @param z
 *         The chunk z position
 */
private void loadChunk(final int x, final int z) {
    final String key = chunkKey(x, z);
    if (loadingChunks.contains(key) || isLoaded(x, z)) {
        return;
    }
    final XMLHttpRequest xmlHttpRequest = Browser.getWindow().newXMLHttpRequest();
    xmlHttpRequest.open("POST", "http://" + mapViewer.getConnection().getAddress() + "/server/chunk", true);
    xmlHttpRequest.setResponseType("arraybuffer");
    xmlHttpRequest.setOnreadystatechange(new EventListener() {
        @Override
        public void handleEvent(Event evt) {
            if (xmlHttpRequest.getReadyState() != 4) return;
            if (xmlHttpRequest.getStatus() == 200) {
                // Got the chunk successfully, move on
                // to processing the chunk
                ArrayBuffer data = (ArrayBuffer) xmlHttpRequest.getResponse();
                ViewBuffer dataStream = JavascriptViewBuffer.create(data, false, 0, data.getByteLength());
                if (dataStream.getInt8(0) == 0) {
                    loadingChunks.remove(key);
                    return;
                }
                UByteBuffer sendableData = JavascriptUByteBuffer.create(data, 0, data.getByteLength());
                mapViewer.getWorkerPool().sendMessage(new ChunkLoadMessage(x, z, sendableData), true);
            } else {
                // Request failed (e.g. non-existing chunk)
                // remove from the loadingChunks set so
                // that it may be tried again
                loadingChunks.remove(key);
            }
        }
    });
    xmlHttpRequest.send(key);
}
 
开发者ID:Thinkofname,项目名称:ThinkMap,代码行数:42,代码来源:ClientWorld.java

示例6: Connection

import elemental.events.EventListener; //导入依赖的package包/类
/**
 * Creates a connect to the plugin at the address. Calls the callback once the connection succeeds.
 *
 * @param address
 *         The address to connect to, may include the port
 * @param handler
 *         The handler to handle received events
 * @param callback
 *         The Runnable to call once the connection is completed
 */
public Connection(String address, ServerPacketHandler handler, final Runnable callback) {
    this.address = address;
    this.handler = handler;
    webSocket = Browser.getWindow().newWebSocket("ws://" + address + "/server/ws");
    // Work in binary instead of strings
    webSocket.setBinaryType("arraybuffer");
    webSocket.setOnopen(new EventListener() {
        @Override
        public void handleEvent(Event evt) {
            System.out.println("Connected to server");
            send(new InitConnection());
            if (callback != null) callback.run();
        }
    });
    webSocket.setOnmessage(this);
}
 
开发者ID:Thinkofname,项目名称:ThinkMap,代码行数:27,代码来源:Connection.java

示例7: compareApplyRemove

import elemental.events.EventListener; //导入依赖的package包/类
private static <T, V> void compareApplyRemove(Node element, T name, V value, What what) {
	// Fluent.console.log("removing " + name + " with " + value);
	switch (what) {
	case Attributes:
		switch ((Att) name) {
		case checked:
			((InputElement) element).setChecked(false);
			break;
		case value:
			((InputElement) element).setValue(null);
			break;
		case selectedIndex:
			// nothing to do
			// ((SelectElement) element).);
			break;
		default:
			((Element) element).removeAttribute(((Att) name).nameValid());
			break;
		}
		break;
	case Styles:
		((Element) element).getStyle().removeProperty(((Css) name).nameValid());
		break;
	case Listeners:
		element.removeEventListener((String) name, (EventListener) value);
		break;
	default:
		throw new IllegalArgumentException("Not possible");
	}
}
 
开发者ID:nielsbaloe,项目名称:vertxui,代码行数:31,代码来源:Renderer.java

示例8: compareApplySet

import elemental.events.EventListener; //导入依赖的package包/类
private static <T, V> void compareApplySet(Node element, T name, V value, What what) {
	// Fluent.console.log("setting " + name + " with " + value);
	switch (what) {
	case Attributes:
		switch ((Att) name) {
		case checked:
			((InputElement) element).setChecked(true);
			break;
		case value:
			((InputElement) element).setValue((String) value);
			break;
		case selectedIndex:
			((SelectElement) element).setSelectedIndex(Integer.parseInt((String) value));
		default:
			((Element) element).setAttribute(((Att) name).nameValid(), (String) value);
			break;
		}
		break;
	case Styles:
		((Element) element).getStyle().setProperty(((Css) name).nameValid(), (String) value);
		break;
	case Listeners:
		element.addEventListener((String) name, (EventListener) value);
		break;
	default:
		throw new IllegalArgumentException("Not possible");
	}
}
 
开发者ID:nielsbaloe,项目名称:vertxui,代码行数:29,代码来源:Renderer.java

示例9: listen

import elemental.events.EventListener; //导入依赖的package包/类
/**
 * Add or remove (by value null) an eventlistener.
 * 
 * @param name
 *            the name that should be listening too
 * @param value
 *            the low level eventlistener
 * @return this
 */
public Fluent listen(String name, EventListener value) {
	if (listeners == null) {
		listeners = new TreeMap<>();
	}
	EventListener oldValue = listeners.get(name);

	if (value != null) { // set it

		// if does not exist yet or has a different value
		if (oldValue == null || !oldValue.equals(value)) {
			listeners.put(name, value);
			if (element != null) { // if visual
				element.addEventListener(name, value);
			}
		}

	} else { // remove it

		// if old value exists
		if (oldValue != null) {
			listeners.remove(name);
			if (element != null) { // if visual
				element.removeEventListener(name, oldValue);
			}
		}
	}
	return (Fluent) this;
}
 
开发者ID:nielsbaloe,项目名称:vertxui,代码行数:38,代码来源:FluentBase.java

示例10: onopen

import elemental.events.EventListener; //导入依赖的package包/类
public final native void onopen(EventListener listener)/*-{
this.onopen = @elemental.js.dom.JsElementalMixinBase::getHandlerFor(Lelemental/events/EventListener;)(listener);		
}-*/;
 
开发者ID:nielsbaloe,项目名称:vertxui,代码行数:4,代码来源:EventBus.java

示例11: onerror

import elemental.events.EventListener; //导入依赖的package包/类
public final native void onerror(EventListener listener) /*-{
this.onerror = @elemental.js.dom.JsElementalMixinBase::getHandlerFor(Lelemental/events/EventListener;)(listener);
}-*/;
 
开发者ID:nielsbaloe,项目名称:vertxui,代码行数:4,代码来源:EventBus.java

示例12: addAnnotationItem

import elemental.events.EventListener; //导入依赖的package包/类
private void addAnnotationItem(final AnnotationModel model, final Annotation annotation) {
  final Position position = model.getPosition(annotation);
  if (position == null) {
    Log.warn(GutterAnnotationRenderer.class, "No position for annotation " + annotation);
    return;
  }
  final TextPosition textPosition = this.document.getPositionFromIndex(position.getOffset());

  final Element annotationItem =
      this.hasGutter.getGutterItem(textPosition.getLine(), ANNOTATION_GUTTER);

  AnnotationGroup annotationGroup;
  if (!AnnotationGroupImpl.isAnnotation(annotationItem)) {
    LOG.fine("Create new annotation group for line " + textPosition.getLine());
    final AnnotationGroup newGroup = AnnotationGroupImpl.create();
    newGroup
        .getElement()
        .addEventListener(
            Event.MOUSEOVER,
            new EventListener() {
              @Override
              public void handleEvent(final Event evt) {
                showToolTip(newGroup, textPosition.getLine());
              }
            },
            false);

    this.hasGutter.addGutterItem(
        textPosition.getLine(), ANNOTATION_GUTTER, newGroup.getElement());
    annotationGroup = newGroup;
  } else {
    LOG.fine("Reuse annotation group for line " + textPosition.getLine());
    annotationGroup = AnnotationGroupImpl.create(annotationItem);
  }
  annotationGroup.addAnnotation(annotation, position.getOffset());
}
 
开发者ID:eclipse,项目名称:che,代码行数:37,代码来源:GutterAnnotationRenderer.java

示例13: addCaptureEventListener

import elemental.events.EventListener; //导入依赖的package包/类
private static Remover addCaptureEventListener(
    final String type, final EventTarget source, final EventListener listener) {
  source.addEventListener(type, listener, true);
  return new Remover() {
    @Override
    public void remove() {
      source.removeEventListener(type, listener, true);
    }
  };
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:MouseEventCapture.java

示例14: TransitionEndHandler

import elemental.events.EventListener; //导入依赖的package包/类
private TransitionEndHandler(EventListener animationCallback) {
  this.animationCallback = animationCallback;
}
 
开发者ID:eclipse,项目名称:che,代码行数:4,代码来源:AnimationUtils.java

示例15: fadeOut

import elemental.events.EventListener; //导入依赖的package包/类
public static void fadeOut(final Element elem) {
  animatePropertySet(
      elem,
      "opacity",
      "0",
      SHORT_TRANSITION_DURATION,
      new EventListener() {
        @Override
        public void handleEvent(Event evt) {
          elem.getStyle().setDisplay("none");
        }
      });
}
 
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:AnimationUtils.java


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