Java 类com.intellij.util.ui.TextTransferable 实例源码

项目:intellij-ce-playground    文件:XDebuggerTree.java   
@Override
protected Transferable createTransferable(JComponent c) {
  if (!(c instanceof XDebuggerTree)) {
    return null;
  }
  XDebuggerTree tree = (XDebuggerTree)c;
  //noinspection deprecation
  TreePath[] selectedPaths = tree.getSelectionPaths();
  if (selectedPaths == null || selectedPaths.length == 0) {
    return null;
  }

  StringBuilder plainBuf = new StringBuilder();
  StringBuilder htmlBuf = new StringBuilder();
  htmlBuf.append("<html>\n<body>\n<ul>\n");
  TextTransferable.ColoredStringBuilder coloredTextContainer = new TextTransferable.ColoredStringBuilder();
  for (TreePath path : selectedPaths) {
    htmlBuf.append("  <li>");
    Object node = path.getLastPathComponent();
    if (node != null) {
      if (node instanceof XDebuggerTreeNode) {
        ((XDebuggerTreeNode)node).appendToComponent(coloredTextContainer);
        coloredTextContainer.appendTo(plainBuf, htmlBuf);
      }
      else {
        String text = node.toString();
        plainBuf.append(text);
        htmlBuf.append(text);
      }
    }
    plainBuf.append('\n');
    htmlBuf.append("</li>\n");
  }

  // remove the last newline
  plainBuf.setLength(plainBuf.length() - 1);
  htmlBuf.append("</ul>\n</body>\n</html>");
  return new TextTransferable(htmlBuf.toString(), plainBuf.toString());
}
项目:intellij-ce-playground    文件:XDebuggerFramesList.java   
@Override
protected Transferable createTransferable(JComponent c) {
  if (!(c instanceof XDebuggerFramesList)) {
    return null;
  }
  XDebuggerFramesList list = (XDebuggerFramesList)c;
  //noinspection deprecation
  Object[] values = list.getSelectedValues();
  if (values == null || values.length == 0) {
    return null;
  }

  StringBuilder plainBuf = new StringBuilder();
  StringBuilder htmlBuf = new StringBuilder();
  TextTransferable.ColoredStringBuilder coloredTextContainer = new TextTransferable.ColoredStringBuilder();
  htmlBuf.append("<html>\n<body>\n<ul>\n");
  for (Object value : values) {
    htmlBuf.append("  <li>");
    if (value != null) {
      if (value instanceof XStackFrame) {
        ((XStackFrame)value).customizePresentation(coloredTextContainer);
        coloredTextContainer.appendTo(plainBuf, htmlBuf);
      }
      else {
        String text = value.toString();
        plainBuf.append(text);
        htmlBuf.append(text);
      }
    }
    plainBuf.append('\n');
    htmlBuf.append("</li>\n");
  }

  // remove the last newline
  plainBuf.setLength(plainBuf.length() - 1);
  htmlBuf.append("</ul>\n</body>\n</html>");
  return new TextTransferable(htmlBuf.toString(), plainBuf.toString());
}
项目:intellij-ce-playground    文件:CopyRevisionNumberFromAnnotateAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  if (myLineNumber < 0) return;
  final VcsRevisionNumber revisionNumber = myAnnotation.getLineRevisionNumber(myLineNumber);
  if (revisionNumber != null) {
    final String revision = revisionNumber.asString();
    CopyPasteManager.getInstance().setContents(new TextTransferable(revision));
  }
}
项目:intellij-ce-playground    文件:DisposerDebugger.java   
@Override
public void actionPerformed(AnActionEvent e) {
  try {
    CopyPasteManager.getInstance().setContents(new TextTransferable(myAllocation.getText()));
  }
  catch (HeadlessException e1) {
    LOG.error(e1);
  }
}
项目:AndroidDrawableViewer    文件:DrawableViewer.java   
private void copyDrawableId() {
    DrawableModel drawableModel = drawableModelList.get(itemList.getMinSelectionIndex());
    String fileName = drawableModel.getFileName();
    int position = fileName.lastIndexOf(".");
    if (position >= 0) {
        fileName = fileName.substring(0, position);
    }
    final String fileNameWithoutExtension = fileName;
    CopyPasteManager.getInstance().setContents(new TextTransferable("R.drawable." + fileNameWithoutExtension));
}
项目:consulo    文件:XDebuggerTree.java   
@Override
protected Transferable createTransferable(JComponent c) {
  if (!(c instanceof XDebuggerTree)) {
    return null;
  }
  XDebuggerTree tree = (XDebuggerTree)c;
  //noinspection deprecation
  TreePath[] selectedPaths = tree.getSelectionPaths();
  if (selectedPaths == null || selectedPaths.length == 0) {
    return null;
  }

  StringBuilder plainBuf = new StringBuilder();
  StringBuilder htmlBuf = new StringBuilder();
  htmlBuf.append("<html>\n<body>\n<ul>\n");
  TextTransferable.ColoredStringBuilder coloredTextContainer = new TextTransferable.ColoredStringBuilder();
  for (TreePath path : selectedPaths) {
    htmlBuf.append("  <li>");
    Object node = path.getLastPathComponent();
    if (node != null) {
      if (node instanceof XDebuggerTreeNode) {
        ((XDebuggerTreeNode)node).appendToComponent(coloredTextContainer);
        coloredTextContainer.appendTo(plainBuf, htmlBuf);
      }
      else {
        String text = node.toString();
        plainBuf.append(text);
        htmlBuf.append(text);
      }
    }
    plainBuf.append('\n');
    htmlBuf.append("</li>\n");
  }

  // remove the last newline
  plainBuf.setLength(plainBuf.length() - 1);
  htmlBuf.append("</ul>\n</body>\n</html>");
  return new TextTransferable(htmlBuf.toString(), plainBuf.toString());
}
项目:consulo    文件:XDebuggerFramesList.java   
@Override
protected Transferable createTransferable(JComponent c) {
  if (!(c instanceof XDebuggerFramesList)) {
    return null;
  }
  XDebuggerFramesList list = (XDebuggerFramesList)c;
  //noinspection deprecation
  Object[] values = list.getSelectedValues();
  if (values == null || values.length == 0) {
    return null;
  }

  StringBuilder plainBuf = new StringBuilder();
  StringBuilder htmlBuf = new StringBuilder();
  TextTransferable.ColoredStringBuilder coloredTextContainer = new TextTransferable.ColoredStringBuilder();
  htmlBuf.append("<html>\n<body>\n<ul>\n");
  for (Object value : values) {
    htmlBuf.append("  <li>");
    if (value != null) {
      if (value instanceof XStackFrame) {
        ((XStackFrame)value).customizePresentation(coloredTextContainer);
        coloredTextContainer.appendTo(plainBuf, htmlBuf);
      }
      else {
        String text = value.toString();
        plainBuf.append(text);
        htmlBuf.append(text);
      }
    }
    plainBuf.append('\n');
    htmlBuf.append("</li>\n");
  }

  // remove the last newline
  plainBuf.setLength(plainBuf.length() - 1);
  htmlBuf.append("</ul>\n</body>\n</html>");
  return new TextTransferable(htmlBuf.toString(), plainBuf.toString());
}
项目:consulo    文件:CopyRevisionNumberFromAnnotateAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  if (myLineNumber < 0) return;
  final VcsRevisionNumber revisionNumber = myAnnotation.getLineRevisionNumber(myLineNumber);
  if (revisionNumber != null) {
    final String revision = revisionNumber.asString();
    CopyPasteManager.getInstance().setContents(new TextTransferable(revision));
  }
}
项目:consulo    文件:DisposerDebugger.java   
@Override
public void actionPerformed(AnActionEvent e) {
  try {
    CopyPasteManager.getInstance().setContents(new TextTransferable(myAllocation.getText()));
  }
  catch (HeadlessException e1) {
    LOG.error(e1);
  }
}
项目:intellij-ce-playground    文件:Property.java   
@NotNull
public Transferable doCopy(@NotNull T container, @NotNull Object commonValue) {
  return new TextTransferable(commonValue.toString());
}
项目:dbunit-extractor    文件:CopyToDbUnit.java   
private void copyOutput(XmlOutput xmlOutput) {
    CopyPasteManager.getInstance().setContents(new TextTransferable(xmlOutput.getText()));
}