本文整理汇总了Java中com.intellij.openapi.ide.CopyPasteManager.getContents方法的典型用法代码示例。如果您正苦于以下问题:Java CopyPasteManager.getContents方法的具体用法?Java CopyPasteManager.getContents怎么用?Java CopyPasteManager.getContents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.ide.CopyPasteManager
的用法示例。
在下文中一共展示了CopyPasteManager.getContents方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSerializedComponents
import com.intellij.openapi.ide.CopyPasteManager; //导入方法依赖的package包/类
@Nullable
private static String getSerializedComponents() {
try {
final CopyPasteManager copyPasteManager = CopyPasteManager.getInstance();
if (!copyPasteManager.isDataFlavorAvailable(ourDataFlavor)) {
return null;
}
final Transferable content = copyPasteManager.getContents();
if (content == null) {
return null;
}
final Object transferData = content.getTransferData(ourDataFlavor);
if (!(transferData instanceof SerializedComponentData)) {
return null;
}
final SerializedComponentData dataProxy = (SerializedComponentData)transferData;
return dataProxy.getSerializedComponents();
}
catch (Exception e) {
return null;
}
}
示例2: getContentsToPasteToEditor
import com.intellij.openapi.ide.CopyPasteManager; //导入方法依赖的package包/类
@Nullable
public static Transferable getContentsToPasteToEditor(@Nullable Producer<Transferable> producer) {
if (producer == null) {
CopyPasteManager manager = CopyPasteManager.getInstance();
return manager.areDataFlavorsAvailable(DataFlavor.stringFlavor) ? manager.getContents() : null;
}
else {
return producer.produce();
}
}
示例3: getTransferable
import com.intellij.openapi.ide.CopyPasteManager; //导入方法依赖的package包/类
private static Transferable getTransferable(Producer<Transferable> producer) {
Transferable content = null;
if (producer != null) {
content = producer.produce();
}
else {
CopyPasteManager manager = CopyPasteManager.getInstance();
if (manager.areDataFlavorsAvailable(DataFlavor.stringFlavor)) {
content = manager.getContents();
}
}
return content;
}
示例4: getTextInClipboard
import com.intellij.openapi.ide.CopyPasteManager; //导入方法依赖的package包/类
@Nullable
public static String getTextInClipboard() {
final CopyPasteManager copyPasteManager = CopyPasteManager.getInstance();
if (copyPasteManager.isDataFlavorAvailable(DataFlavor.stringFlavor)) {
final Transferable contents = copyPasteManager.getContents();
if (contents != null) {
try {
return (String)contents.getTransferData(DataFlavor.stringFlavor);
} catch (Exception ignore) { }
}
}
return null;
}
示例5: getSerializedComponentData
import com.intellij.openapi.ide.CopyPasteManager; //导入方法依赖的package包/类
@Nullable
private String getSerializedComponentData() {
try {
CopyPasteManager copyPasteManager = CopyPasteManager.getInstance();
if (!copyPasteManager.isDataFlavorAvailable(DATA_FLAVOR)) {
return null;
}
Transferable content = copyPasteManager.getContents();
if (content == null) {
return null;
}
Object transferData = content.getTransferData(DATA_FLAVOR);
if (transferData instanceof SerializedComponentData) {
SerializedComponentData data = (SerializedComponentData)transferData;
String xmlComponents = data.getSerializedComponents();
if (xmlComponents.startsWith("<designer target=\"" + myDesigner.getPlatformTarget() + "\">")) {
return xmlComponents;
}
}
}
catch (Throwable e) {
}
return null;
}
示例6: pasteFromClipboard
import com.intellij.openapi.ide.CopyPasteManager; //导入方法依赖的package包/类
@Nullable
@Override
public TextRange[] pasteFromClipboard(@Nonnull Editor editor) {
CopyPasteManager manager = CopyPasteManager.getInstance();
if (manager.areDataFlavorsAvailable(DataFlavor.stringFlavor)) {
Transferable clipboardContents = manager.getContents();
if (clipboardContents != null) {
return pasteTransferable(editor, clipboardContents);
}
}
return null;
}