• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java EventListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: KeyBindingManager

import elemental.events.EventListener; //导入依赖的package包/类
@Inject
public KeyBindingManager(ActionManager actionManager) {
  this.actionManager = actionManager;

  addScheme(new SchemeImpl(SCHEME_GLOBAL_ID, "Global"));
  addScheme(new SchemeImpl(SCHEME_ECLIPSE_ID, "Eclipse Scheme"));

  // TODO check user settings
  activeScheme = SCHEME_GLOBAL_ID;

  presentationFactory = new PresentationFactory();

  // Attach the listeners.
  final Element documentElement = Elements.getDocument().getDocumentElement();
  EventListener downListener =
      new EventListener() {
        @Override
        public void handleEvent(Event event) {
          SignalEvent signalEvent = SignalEventUtils.create(event, false);
          if (signalEvent == null) {
            return;
          }

          /*
          Temporary solution to prevent calling actions if focus is in input element.
          The problem in that, some actions, may be bound to Ctrl+C/X/V/Z or Delete so
          We should allow browser to process event natively instead of calling actions.
          Need to be reworked in nearest future. */
          final JavaScriptObject jso = (JavaScriptObject) event.getTarget();
          if (InputElement.is(jso) || AreaElement.is(jso)) {
            return;
          }

          // handle event in active scheme
          int digest = CharCodeWithModifiers.computeKeyDigest(signalEvent);
          preventDefaultBrowserAction((KeyboardEvent) event, digest);

          List<String> actionIds = getActive().getActionIds(digest);

          if (!actionIds.isEmpty()) {
            runActions(actionIds, event);
          }
          // else handle event in global scheme
          else if (!(actionIds = getGlobal().getActionIds(digest)).isEmpty()) {
            runActions(actionIds, event);
          }

          // default, lets this event handle other part of the IDE
        }
      };
  if (UserAgent.isFirefox()) {
    // firefox fires keypress events
    documentElement.addEventListener(Event.KEYPRESS, downListener, true);
  } else {
    // webkit fires keydown events
    documentElement.addEventListener(Event.KEYDOWN, downListener, true);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:59,代码来源:KeyBindingManager.java


示例17: createItem

import elemental.events.EventListener; //导入依赖的package包/类
@Override
public Element createItem(final Type itemModel) {
  final Element element = Elements.createLiElement(popupResources.popupStyle().item());
  final Element iconElement = Elements.createDivElement(popupResources.popupStyle().icon());

  int flag = itemModel.getFlags();
  if (flag == -1) {
    element.setInnerText(getEmptyMessage());
    return element;
  }

  SVGImage svgImage = getSvgImage(flag);
  iconElement.appendChild((Node) svgImage.getElement());

  element.appendChild(iconElement);
  element.appendChild(createTitleOfElement(itemModel));

  final EventListener validateListener =
      new EventListener() {
        @Override
        public void handleEvent(final Event evt) {
          openImplementationPresenter.actionPerformed(itemModel);
          hide();
        }
      };

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

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


示例18: onEditorOpened

import elemental.events.EventListener; //导入依赖的package包/类
@Override
public void onEditorOpened(EditorOpenedEvent event) {
  EditorPartPresenter editor = event.getEditor();
  VirtualFile file = editor.getEditorInput().getFile();
  if (file instanceof JarFileNode) {
    final JarFileNode jarFileNode = (JarFileNode) file;
    if (jarFileNode.isContentGenerated()) {
      if (editor instanceof TextEditor) {
        final TextEditor presenter = (TextEditor) editor;
        TextEditorPartView view = presenter.getView();
        final DivElement divElement = Elements.createDivElement();
        divElement.setClassName(resources.css().editorInfoPanel());
        Text textNode = Elements.createTextNode(constant.mavenClassDecompiled());
        DivElement decompiledElement = Elements.createDivElement();
        decompiledElement.appendChild(textNode);
        decompiledElement.setClassName(resources.css().editorMessage());
        divElement.appendChild(decompiledElement);
        AnchorElement anchorElement = Elements.createAnchorElement();
        anchorElement.appendChild(Elements.createTextNode(constant.mavenDownloadSources()));
        anchorElement.setHref("#");
        anchorElement.setClassName(resources.css().downloadLink());

        divElement.appendChild(anchorElement);
        final HasNotificationPanel.NotificationRemover remover =
            view.addNotification((Element) divElement);
        anchorElement.setOnclick(
            new EventListener() {
              @Override
              public void handleEvent(Event evt) {
                downloadSources(jarFileNode, remover);
              }
            });
      }
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:37,代码来源:ClassFileSourcesDownloader.java


示例19: onclose

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


示例20: PopupWidget

import elemental.events.EventListener; //导入依赖的package包/类
public PopupWidget(final PopupResources popupResources, String title) {
  this.popupResources = popupResources;

  popupElement = Elements.createDivElement(popupResources.popupStyle().popup());

  Element headerElement = Elements.createDivElement(popupResources.popupStyle().header());
  headerElement.setInnerText(title);
  popupElement.appendChild(headerElement);

  popupBodyElement = Elements.createDivElement(popupResources.popupStyle().body());
  popupElement.appendChild(popupBodyElement);

  listElement = Elements.createUListElement();
  popupBodyElement.appendChild(listElement);

  popupListener =
      new EventListener() {
        @Override
        public void handleEvent(final Event evt) {
          if (evt instanceof MouseEvent) {
            final MouseEvent mouseEvent = (MouseEvent) evt;
            final EventTarget target = mouseEvent.getTarget();
            if (target instanceof Element) {
              final Element elementTarget = (Element) target;
              if (!PopupWidget.this.popupElement.contains(elementTarget)) {
                hide();
                evt.preventDefault();
              }
            }
          }
          // else won't happen
        }
      };

  keyboardListener = new PopupKeyDownListener(this, this.listElement);
}
 
开发者ID:eclipse,项目名称:che,代码行数:37,代码来源:PopupWidget.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IntStack类代码示例发布时间:2022-05-23
下一篇:
Java TypesWriter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap