Java 类com.sun.jna.IntegerType 实例源码

项目:intellij-ce-playground    文件:ClipboardSynchronizer.java   
@Nullable
private static Transferable getClipboardContentNatively() {
  String plainText = "public.utf8-plain-text";

  ID pasteboard = Foundation.invoke("NSPasteboard", "generalPasteboard");
  ID types = Foundation.invoke(pasteboard, "types");
  IntegerType count = Foundation.invoke(types, "count");

  ID plainTextType = null;

  for (int i = 0; i < count.intValue(); i++) {
    ID each = Foundation.invoke(types, "objectAtIndex:", i);
    String eachType = Foundation.toStringViaUTF8(each);
    if (plainText.equals(eachType)) {
      plainTextType = each;
      break;
    }
  }

  // will put string value even if we doesn't found java object. this is needed because java caches clipboard value internally and
  // will reset it ONLY IF we'll put jvm-object into clipboard (see our setContent optimizations which avoids putting jvm-objects
  // into clipboard)

  Transferable result = null;
  if (plainTextType != null) {
    ID text = Foundation.invoke(pasteboard, "stringForType:", plainTextType);
    String value = Foundation.toStringViaUTF8(text);
    if (value == null) {
      LOG.info(String.format("[Clipboard] Strange string value (null?) for type: %s", plainTextType));
    }
    else {
      result = new StringSelection(value);
    }
  }

  return result;
}
项目:tools-idea    文件:ClipboardSynchronizer.java   
@Nullable
private static Transferable getClipboardContentNatively() {
  String plainText = "public.utf8-plain-text";

  ID pasteboard = Foundation.invoke("NSPasteboard", "generalPasteboard");
  ID types = Foundation.invoke(pasteboard, "types");
  IntegerType count = Foundation.invoke(types, "count");

  ID plainTextType = null;

  for (int i = 0; i < count.intValue(); i++) {
    ID each = Foundation.invoke(types, "objectAtIndex:", i);
    String eachType = Foundation.toStringViaUTF8(each);
    if (plainText.equals(eachType)) {
      plainTextType = each;
      break;
    }
  }

  // will put string value even if we doesn't found java object. this is needed because java caches clipboard value internally and
  // will reset it ONLY IF we'll put jvm-object into clipboard (see our setContent optimizations which avoids putting jvm-objects 
  // into clipboard) 

  Transferable result = null;
  if (plainTextType != null) {
    ID text = Foundation.invoke(pasteboard, "stringForType:", plainTextType);
    String value = Foundation.toStringViaUTF8(text);
    if (value == null) {
      LOG.info(String.format("[Clipboard] Strange string value (null?) for type: %s", plainTextType));
    }
    else {
      result = new StringSelection(value);
    }
  }

  return result;
}
项目:consulo    文件:ClipboardSynchronizer.java   
@Nullable
private static Transferable getClipboardContentNatively() {
  String plainText = "public.utf8-plain-text";

  ID pasteboard = Foundation.invoke("NSPasteboard", "generalPasteboard");
  ID types = Foundation.invoke(pasteboard, "types");
  IntegerType count = Foundation.invoke(types, "count");

  ID plainTextType = null;

  for (int i = 0; i < count.intValue(); i++) {
    ID each = Foundation.invoke(types, "objectAtIndex:", i);
    String eachType = Foundation.toStringViaUTF8(each);
    if (plainText.equals(eachType)) {
      plainTextType = each;
      break;
    }
  }

  // will put string value even if we doesn't found java object. this is needed because java caches clipboard value internally and
  // will reset it ONLY IF we'll put jvm-object into clipboard (see our setContent optimizations which avoids putting jvm-objects
  // into clipboard)

  Transferable result = null;
  if (plainTextType != null) {
    ID text = Foundation.invoke(pasteboard, "stringForType:", plainTextType);
    String value = Foundation.toStringViaUTF8(text);
    if (value == null) {
      LOG.info(String.format("[Clipboard] Strange string value (null?) for type: %s", plainTextType));
    }
    else {
      result = new StringSelection(value);
    }
  }

  return result;
}