本文整理汇总了Java中com.intellij.openapi.ide.CopyPasteManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java CopyPasteManager.getInstance方法的具体用法?Java CopyPasteManager.getInstance怎么用?Java CopyPasteManager.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.ide.CopyPasteManager
的用法示例。
在下文中一共展示了CopyPasteManager.getInstance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: actionPerformed
import com.intellij.openapi.ide.CopyPasteManager; //导入方法依赖的package包/类
/**
* execute sql generation and copy task
*
* @param e action event
*/
public void actionPerformed(AnActionEvent e) {
PsiFile psiFile = e.getData(DataKeys.PSI_FILE);
Editor editor = e.getData(DataKeys.EDITOR);
if ((psiFile != null && psiFile instanceof XmlFile) && editor != null) {
PsiElement psiElement = psiFile.findElementAt(editor.getCaretModel().getOffset());
if (psiElement != null) {
XmlTag xmlTag = getResultMapTag(psiElement);
if (xmlTag != null) {
DomElement domElement = DomManager.getDomManager(psiFile.getProject()).getDomElement(xmlTag);
if (domElement != null && domElement instanceof ResultMap) {
List<String> columns = new ArrayList<String>();
ResultMap resultMap = (ResultMap) domElement;
List<Result> allResults = resultMap.getAllResults();
for (Result result : allResults) {
String columnName = result.getColumn().getValue();
if (columnName != null && columnName.length() > 0 && !columns.contains(columnName)) {
columns.add(columnName);
}
}
PsiClass psiClass = resultMap.getClazz().getValue();
if (psiClass != null) {
String tableName = "table_name_here";
String select = "*";
DatabaseTableData tableData = TableColumnReferenceProvider.getDatabaseTableData(psiClass);
if (tableData != null) {
tableName = tableData.getName();
}
if (columns.size() > 0) {
select = StringUtil.join(columns, ", ");
}
String sentenceSQL = "select " + select + " from " + tableName;
CopyPasteManager copyPasteManager = CopyPasteManager.getInstance();
copyPasteManager.setContents(new StringSelection(sentenceSQL));
}
}
}
}
}
}
示例7: 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;
}
示例8: actionPerformed
import com.intellij.openapi.ide.CopyPasteManager; //导入方法依赖的package包/类
public void actionPerformed(AnActionEvent e) {
PsiFile psiFile = e.getData(DataKeys.PSI_FILE);
Editor editor = e.getData(DataKeys.EDITOR);
if ((psiFile != null && psiFile instanceof XmlFile) && editor != null) {
PsiElement psiElement = psiFile.findElementAt(editor.getCaretModel().getOffset());
if (psiElement != null) {
XmlTag xmlTag = SqlMapSymbolCompletionData.getXmlTagForSQLCompletion(psiElement, psiFile);
if (xmlTag != null) {
DomElement domElement = DomManager.getDomManager(e.getData(DataKeys.PROJECT)).getDomElement(xmlTag);
if (domElement != null && domElement instanceof BaseStatement) {
BaseStatement baseStatement = (BaseStatement) domElement;
PsiClass parameterClass = baseStatement.getParameterClass().getValue();
String SQLCode = IbatisUtil.getSQLForXmlTag(xmlTag);
String pattern = "#[\\w:\\.]*#";
if (parameterClass == null) { //type is unknown
SQLCode = SQLCode.replaceAll(pattern, "''");
} else
if (IbatisClassShortcutsReferenceProvider.isDomain(parameterClass.getName())) // domain class
{
List<String> inlineParameters = IbatisUtil.grep(SQLCode, pattern);
for (String parameter : inlineParameters) {
PsiClass referencedClass = parameterClass;
String fieldName = parameter.replaceAll("#", "").replaceAll(":\\w*", "");
String[] referencePath = fieldName.split("\\.");
for (String part : referencePath) {
referencedClass = FieldAccessMethodReferenceProvider.findGetterMethodReturnType(referencedClass, "get" + StringUtil.capitalize(part));
if (referencedClass == null) break;
}
SQLCode = SQLCode.replaceAll(parameter, getDefaultValueForType(referencedClass == null ? "" : referencedClass.getQualifiedName()));
}
} else //domain class
{
SQLCode = SQLCode.replaceAll(pattern, getDefaultValueForType(parameterClass.getQualifiedName()));
}
CopyPasteManager copyPasteManager = CopyPasteManager.getInstance();
copyPasteManager.setContents(new StringSelection(SQLCode.trim()));
}
}
}
}
}