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


Java UserAgent类代码示例

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


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

示例1: getStreamFilter

import org.waveprotocol.wave.client.common.util.UserAgent; //导入依赖的package包/类
/**
 * Gets the filter for a stream, creating one if one does not already exist.
 */
private FilterButton getStreamFilter(final String stream) {
  FilterButton filter = streamFilters.get(stream);
  if (filter == null) {
    // Just in case a user can cause a stream to be called "'><script
    // src='evil.js'></script><pre '", we only use safe values for CSS
    // classes. There's no need for the class names to be human readable.
    int streamId = streamFilters.countEntries();
    String itemClass = "w-s-" + streamId;
    String containerClass = STREAM_FILTER_PREFIX + streamId;
    filter = new FilterButton(new DoubleClickHandler() {
      @Override
      public void onDoubleClick(DoubleClickEvent event) {
        enableOnlyOneStream(stream);
      }
    }, entries, containerClass, itemClass, stream, css.stream());
    self.add(filter, streamsContainer);
    streamFilters.put(stream, filter);
    // TODO(ohler): Make styles work in IE.
    if (!UserAgent.isIE()) {
      // Replace stylesheet to make the new filter work.
      style.setInnerText(style.getInnerText() + filter.getCssRule());
    }
  }
  return filter;
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:29,代码来源:LogPanel.java

示例2: getSelectionGuarded

import org.waveprotocol.wave.client.common.util.UserAgent; //导入依赖的package包/类
/**
 * Gets the current selection, trying to place it in correspond actual DOM when the selection
 * itself is reported as not being in the actual document.
 * @return The selection in the page's DOM document, or null if it cannot be calculated.
 */
public static SelectionW3CNative getSelectionGuarded() {
  SelectionW3CNative selection = getSelectionUnsafe();
  // NOTE(patcoleman) -
  // It is possible for the selection to be in a node in the shadow, which
  //   causes errors whenever you try to read attributes.
  if (selection != null && DomHelper.isUnreadable(selection.anchorNode())) {
    if (UserAgent.isFirefox()) {
      // In firefox, the focus can be practically anywhere, so we give up:
      return null;
    } else if (UserAgent.isWebkit()) {
      // In webkit, the focus should be on the element the shadow dom comes from:
      selection.setCaret(NativeSelectionUtil.getActiveElement(), 0);
      return selection;
    }
    return null; // not sure what anything else does, so be safe and assume we're beyond repair.
  }
  return selection;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:24,代码来源:SelectionW3CNative.java

示例3: setFocusElement

import org.waveprotocol.wave.client.common.util.UserAgent; //导入依赖的package包/类
/**
 * Ensure that the rendered content view's DOM has focus
 *
 * NOTE(patcoleman): Fixes firefox bug that causes invalid selections while
 * mutating DOM that doesn't have focus - fixed by finding the next parent element directly
 * editable, and forcing this to have the focus.
 */
private static void setFocusElement(Node node) {
  if (UserAgent.isFirefox()) {
    // adjust to parent if node is a text node
    Element toFocus;
    if (DomHelper.isTextNode(node)) {
      toFocus = node.getParentElement();
    } else {
      toFocus = node.<Element>cast();
    }

    // traverse up until we have a concretely editable element:
    while (toFocus != null &&
        DomHelper.getContentEditability(toFocus) != ElementEditability.EDITABLE) {
      toFocus = toFocus.getParentElement();
    }
    // then focus it:
    if (toFocus != null) {
      DomHelper.focus(toFocus);
    }
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:29,代码来源:SelectionW3CNative.java

示例4: handleDOMMutation

import org.waveprotocol.wave.client.common.util.UserAgent; //导入依赖的package包/类
/**
 * Handles DOM mutation events.
 * @param event
 * @param contentRange  last known selection
 */
public void handleDOMMutation(SignalEvent event, ContentRange contentRange) {
  // Early exit if non-safari or non-mac
  if (!(UserAgent.isSafari() && UserAgent.isMac())) {
    return;
  }

  // We don't care about DOMMutations that we generate while we are reverting.
  if (isReverting) {
    return;
  }

  previousContentRange = contentRange;

  Node n = event.getTarget();
  if (n.getNodeType() == Node.ELEMENT_NODE) {
    Element e = Element.as(event.getTarget());
    if (DOM_EVENTS_IGNORE.contains(event.getType())) {
      // ignore
    } else if (event.getType().equals(JsEvents.DOM_NODE_INSERTED) && handleDOMNodeInserted(e)) {
    } else if (event.getType().equals(JsEvents.DOM_NODE_REMOVED) && handleDOMNodeRemoved(e)) {
    }
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:29,代码来源:DOMMutationExtractor.java

示例5: setCollapsed

import org.waveprotocol.wave.client.common.util.UserAgent; //导入依赖的package包/类
public void setCollapsed(boolean collapsed) {
  if (collapsed) {
    self.setAttribute(COLLAPSED_ATTRIBUTE, COLLAPSED_VALUE);

    // Webkit's incremental layout is incorrect, so we have to kick it a bit.
    if (UserAgent.isWebkit()) {
      self.getStyle().setDisplay(Display.INLINE_BLOCK);
      // Force layout.
      self.getOffsetParent();
      // Revert to CSS display property (layed out correctly now).
      self.getStyle().clearDisplay();
    }
  } else {
    self.removeAttribute("c");
  }
  updatedCssClassNames();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:18,代码来源:CollapsibleDomImpl.java

示例6: create

import org.waveprotocol.wave.client.common.util.UserAgent; //导入依赖的package包/类
/**
 * Factory constructor, creates and attaches the buffer to the DOM.
 *
 * @return Browser specific implementation of a paste buffer.
 */
static PasteBufferImpl create() {
  PasteBufferImpl pasteBuffer;

  if (UserAgent.isSafari() || QuirksConstants.FIREFOX_GREATER_THAN_VER_15) {
    pasteBuffer = new PasteBufferImplSafariAndNewFirefox();
  } else if (UserAgent.isFirefox() && !QuirksConstants.SANITIZES_PASTED_CONTENT) {
    // Older versions of firefox doesn't sanitize pasted content and requires the
    // paste buffer to be an iframe to prevent XSS.
    pasteBuffer = new PasteBufferImplOldFirefox();
  } else {
    pasteBuffer = new PasteBufferImpl();
  }

  pasteBuffer.setupDom();
  return pasteBuffer;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:22,代码来源:PasteBufferImpl.java

示例7: testUnhandledAcceleratorKeys

import org.waveprotocol.wave.client.common.util.UserAgent; //导入依赖的package包/类
/**
 * Tests that an unhandled accelerator should trigger subhandlers and cancel
 * browser default if unhandled and non-whitelisted.
 */
public void testUnhandledAcceleratorKeys() {
  // Always cancel INS key
  EditorEvent insKeyEvent = FakeEditorEvent.create(
      KeySignalType.NOEFFECT, EventWrapper.KEY_INSERT);
  testUnhandledAcceleratorHelper(insKeyEvent, true, true);

  // test tab, a non-metesque accelerator
  EditorEvent tabPressEvent = createTabSignal();
  testUnhandledAcceleratorHelper(tabPressEvent, true, true);

  // test an allowable combo
  EditorEvent ctrlInsert = createCtrlComboKeyPress(KeySignalType.NOEFFECT,
      EventWrapper.KEY_INSERT);
  if (UserAgent.isLinux() || UserAgent.isWin()) {
    testUnhandledAcceleratorHelper(ctrlInsert, true, false);
  } else {
    testUnhandledAcceleratorHelper(ctrlInsert, true, true);
  }

  // test something that is not whitelisted
  EditorEvent ctrlY = createCtrlComboKeyPress(KeySignalType.INPUT, 'Y');
  testUnhandledAcceleratorHelper(ctrlY, true, true);
  testUnhandledAcceleratorHelper(ctrlY, false, false);
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:29,代码来源:EditorEventHandlerGwtTest.java

示例8: waveEnable

import org.waveprotocol.wave.client.common.util.UserAgent; //导入依赖的package包/类
@Override
public void waveEnable(String waveApiVersion) {
  if (!isActive()) {
    return;
  }

  // HACK: See substituteIframeId() description.
  // TODO(user): Remove when the Firefox bug is fixed.
  if (UserAgent.isFirefox()) {
    substituteIframeId();
  }

  waveEnabled = true;
  this.waveApiVersion = waveApiVersion;
  log("Wave-enabled gadget registered with API version ", waveApiVersion);
  sendWaveGadgetInitialization();
  setupModePolling();
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:19,代码来源:GadgetWidget.java

示例9: setFocusElement

import org.waveprotocol.wave.client.common.util.UserAgent; //导入依赖的package包/类
/**
 * Ensure that the rendered content view's DOM has focus
 *
 * NOTE(patcoleman): Fixes firefox bug that causes invalid selections while
 * mutating DOM that doesn't have focus - fixed by finding the next parent element directly
 * editable, and forcing this to have the focus.
 */
private static void setFocusElement(Node node) {
  if (UserAgent.isFirefox()) {
    // adjust to parent if node is a text node
    Element toFocus = null;
    if (DomHelper.isTextNode(node)) {
      toFocus = node.getParentElement();
    } else {
      toFocus = node.<Element>cast();
    }

    // traverse up until we have a concretely editable element:
    while (toFocus != null &&
        DomHelper.getContentEditability(toFocus) != ElementEditability.EDITABLE) {
      toFocus = toFocus.getParentElement();
    }
    // then focus it:
    if (toFocus != null) {
      DomHelper.focus(toFocus);
    }
  }
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:29,代码来源:SelectionW3CNative.java

示例10: append

import org.waveprotocol.wave.client.common.util.UserAgent; //导入依赖的package包/类
@Override
public ParticipantView append(
    ParticipantsDomImpl impl, Conversation conv, ParticipantId participant) {
  Element t = getRenderer().render(conv, participant);
  DomViewHelper.attachBefore(impl.getParticipantContainer(), impl.getSimpleMenu(), t);
  // Kick Webkit, because of its incremental layout bugs.
  if (UserAgent.isWebkit()) {

    String oldDisplay = impl.getElement().getStyle().getDisplay();

    // Erase layout. Querying getOffsetParent() forces layout.
    impl.getElement().getStyle().setDisplay(Display.NONE);
    impl.getElement().getOffsetParent();

    // Restore layout.
    impl.getElement().getStyle().setProperty("display", oldDisplay);
  }
  return asParticipant(t);
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:20,代码来源:FullStructure.java

示例11: LogPanel

import org.waveprotocol.wave.client.common.util.UserAgent; //导入依赖的package包/类
private LogPanel(Logs log) {
  this.log = log;
  initWidget(BINDER.createAndBindUi(this));

  // Add filter buttons. Global filter, then log-level filters.
  StringBuilder rules = new StringBuilder();
  rules.append(css.getText());

  for (final Level level : Level.values()) {
    String itemClass = LEVEL_CLASSES.get(level);
    String containerClass = LEVEL_FILTER_PREFIX + itemClass;
    FilterButton levelFilter = new FilterButton(new DoubleClickHandler() {
      @Override
      public void onDoubleClick(DoubleClickEvent event) {
        enableOnlyMoreImportantLevels(level);
      }
    }, entries, containerClass, itemClass, level.name(), css.level());
    levelFilters.put(level, levelFilter);
    self.add(levelFilter, levelsContainer);
    rules.append(levelFilter.getCssRule());
  }

  // TODO(ohler): Make styles work in IE; the log panel consumes the entire
  // screen without them.  In IE8, I've seen this crash in setInnerText().
  if (!UserAgent.isIE()) {
    // Inject style.
    style.setInnerText(rules.toString());
    Document.get().getBody().appendChild(style);
  }

  setActive(true);
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:33,代码来源:LogPanel.java

示例12: DoubleBufferImage

import org.waveprotocol.wave.client.common.util.UserAgent; //导入依赖的package包/类
/**
 * Create a double buffer loader for a given image widget
 *
 * @param spinner
 * @param imageToLoad
 */
public DoubleBufferImage(Widget spinner, Widget error, Image imageToLoad) {
  if (UserAgent.isIE()) {
    DomHelper.makeUnselectable(doubleLoadedImage.getElement());
  }
  this.spinner = spinner;
  this.error = error;
  this.imageToLoad = imageToLoad;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:15,代码来源:ImageThumbnailWidget.java

示例13: waveEnable

import org.waveprotocol.wave.client.common.util.UserAgent; //导入依赖的package包/类
@Override
public void waveEnable(String waveApiVersion) {    
  if (!isActive()) {
    return;
  }
  log("GW.waveEnable: waveApiVersion=" + waveApiVersion);

  waveEnabled = true;      

  // HACK: See substituteIframeId() description.
  // TODO(user): Remove when the Firefox bug is fixed.
  if (UserAgent.isFirefox()) {
    substituteIframeId();
  }

  sendWaveGadgetInitialization();

  GadgetWidget.this.element.getMutableDoc().addListener(
      new CMutableDocument.EditingModeChangeListener() {

    @Override
    public void onEditingModeChanged(boolean editingMode) {
      sendMode();
    }
  });

  ui.showAsLoaded();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:29,代码来源:GadgetWidget.java

示例14: createHtml

import org.waveprotocol.wave.client.common.util.UserAgent; //导入依赖的package包/类
private static Element createHtml(boolean isAnchor) {
  Element e = isAnchor
      ? Document.get().createAnchorElement()
      : Document.get().createSpanElement();

  // Prevents some browsers (to my knowledge, currently just Webkit)
  // from removing empty elements from the dom too much
  if (UserAgent.isWebkit()) {
    e.setAttribute("x", "y");
  }

  return e;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:14,代码来源:AnnotationSpreadRenderer.java

示例15: createTokenizer

import org.waveprotocol.wave.client.common.util.UserAgent; //导入依赖的package包/类
/** Utility for creating tokenizer based on UA. */
private RichTextTokenizer createTokenizer(Element container) {
  if (UserAgent.isFirefox()) {
    return new RichTextTokenizerImplFirefox<Node, Element, Text>(new HtmlViewImpl(container));
  } else {
    return new RichTextTokenizerImpl<Node, Element, Text>(new HtmlViewImpl(container));
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:9,代码来源:PasteExtractor.java


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