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


Java PlatformDataKeys类代码示例

本文整理汇总了Java中com.intellij.openapi.actionSystem.PlatformDataKeys的典型用法代码示例。如果您正苦于以下问题:Java PlatformDataKeys类的具体用法?Java PlatformDataKeys怎么用?Java PlatformDataKeys使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: actionPerformed

import com.intellij.openapi.actionSystem.PlatformDataKeys; //导入依赖的package包/类
public void actionPerformed(AnActionEvent event) {
        Project project = event.getData(PlatformDataKeys.PROJECT);
        Editor editor = event.getData(PlatformDataKeys.EDITOR);
        PsiFile mFile = PsiUtilBase.getPsiFileInEditor(editor, project);
        PsiClass psiClass = getTargetClass(editor, mFile);
        GridMain gridMain = new GridMain(psiClass,mFile,project);
        //DBConn dbConn = new DBConn(psiClass,mFile,project);
//        JsonDialog jsonD = new JsonDialog(psiClass, mFile, project);
//        jsonD.setClass(psiClass);
//        jsonD.setFile(mFile);
//        jsonD.setProject(project);
//        jsonD.setSize(600, 400);
//        jsonD.setLocationRelativeTo(null);
//        jsonD.setVisible(true);

    }
 
开发者ID:zeng198821,项目名称:CodeGenerate,代码行数:17,代码来源:MainAction.java

示例2: getExtensionDirectory

import com.intellij.openapi.actionSystem.PlatformDataKeys; //导入依赖的package包/类
public static PsiDirectory getExtensionDirectory(@NotNull AnActionEvent event) {
    Project project = event.getData(PlatformDataKeys.PROJECT);
    if (project == null) {
        return null;
    }

    DataContext dataContext = event.getDataContext();
    IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
    if (view == null) {
        return null;
    }

    PsiDirectory[] directories = view.getDirectories();
    if (directories.length == 0) {
        return null;
    }

    return FilesystemUtil.findParentExtensionDirectory(directories[0]);
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:20,代码来源:ExtensionUtility.java

示例3: actionPerformed

import com.intellij.openapi.actionSystem.PlatformDataKeys; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent event) {
    // TODO: insert action logic here
    Project project = event.getData(PlatformDataKeys.PROJECT);
    Object nav = event.getData(CommonDataKeys.NAVIGATABLE);
    String path;
    try {
        if (nav instanceof PsiDirectory) {
            PsiDirectory directory = (PsiDirectory) nav;
            path = directory.getVirtualFile().getPath();
        } else {
            PsiFile file = (PsiFile) nav;
            path = file.getVirtualFile().getPath();
        }
        Toast.make(project, MessageType.INFO, "Open: " + path);
        Runtime.getRuntime().exec("cmd /c start " + path);
    } catch (Exception e) {
        e.printStackTrace();
        if (nav instanceof PsiClass) {
            Toast.make(project, MessageType.ERROR, "Could not open the java file, double-click to open.");
            return;
        }

        Toast.make(project, MessageType.ERROR, e.getMessage());
    }
}
 
开发者ID:shenhuanet,项目名称:OpenInExplorer-idea,代码行数:27,代码来源:RightAction.java

示例4: actionFileReadFailDoesNotBubbleExcepted

import com.intellij.openapi.actionSystem.PlatformDataKeys; //导入依赖的package包/类
@Test
public void actionFileReadFailDoesNotBubbleExcepted() throws IOException {

    AnActionEvent action = mock(AnActionEvent.class);
    ISpecflowAnalyzer lexer = mock(ISpecflowAnalyzer.class);
    FileFactory fileFactory = mock(FileFactory.class);
    DirectoryFactory directoryFactory = mock(DirectoryFactory.class);
    VirtualFile file = mock(VirtualFile.class);

    when(action.getData(PlatformDataKeys.VIRTUAL_FILE)).thenReturn(file);
    when(file.contentsToByteArray()).thenThrow(new IOException());

    SpecflowGenerateCode generator = new SpecflowGenerateCode(lexer, fileFactory, directoryFactory);
    generator.actionPerformed(action);

    verify(lexer, never()).analyze(anyString(), anyString());
}
 
开发者ID:kanekotic,项目名称:Specflow.Rider,代码行数:18,代码来源:SpecflowGenerateCodeTest.java

示例5: getTranslation

import com.intellij.openapi.actionSystem.PlatformDataKeys; //导入依赖的package包/类
private void getTranslation(AnActionEvent event) {
    Editor editor = event.getData(PlatformDataKeys.EDITOR);
    if (editor == null) {
        return;
    }
    SelectionModel model = editor.getSelectionModel();
    String selectedText = model.getSelectedText();
    if (TextUtils.isEmpty(selectedText)) {
        selectedText = getCurrentWords(editor);
        if (TextUtils.isEmpty(selectedText)) {
            return;
        }
    }
    String queryText = strip(addBlanks(selectedText));
    new Thread(new RequestRunnable(mTranslator, editor, queryText)).start();
}
 
开发者ID:a483210,项目名称:GoogleTranslation,代码行数:17,代码来源:GoogleTranslation.java

示例6: getTranslation

import com.intellij.openapi.actionSystem.PlatformDataKeys; //导入依赖的package包/类
private void getTranslation(AnActionEvent event) {
    Editor mEditor = event.getData(PlatformDataKeys.EDITOR);
    Project project = event.getData(PlatformDataKeys.PROJECT);
    String basePath = project.getBasePath();

    if (null == mEditor) {
        return;
    }
    SelectionModel model = mEditor.getSelectionModel();
    String selectedText = model.getSelectedText();
    if (TextUtils.isEmpty(selectedText)) {
        selectedText = getCurrentWords(mEditor);
        if (TextUtils.isEmpty(selectedText)) {
            return;
        }
    }
    String queryText = strip(addBlanks(selectedText));
    new Thread(new RequestRunnable(mEditor, queryText,basePath)).start();
}
 
开发者ID:BolexLiu,项目名称:ReciteWords,代码行数:20,代码来源:ReciteWords.java

示例7: actionPerformed

import com.intellij.openapi.actionSystem.PlatformDataKeys; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
    Project project = e.getData(PlatformDataKeys.PROJECT);
    List<VirtualFile> javaFiles = Utils.getSelectJavaFiles(e, true);
    int size = javaFiles.size();
    for (int i = 0; i < javaFiles.size(); i++) {
        VirtualFile vf = javaFiles.get(i);
        if (!Utils.hasOrm(project, vf)) {
            javaFiles.remove(i);
            i--;
        }
    }

    // if (!javaFiles.isEmpty())
    {
        NewProviderDialog dialog = new NewProviderDialog();
        dialog.init(project, e.getData(PlatformDataKeys.VIRTUAL_FILE), javaFiles);
        dialog.pack();
        dialog.setLocationRelativeTo(null);
        dialog.setVisible(true);
        dialog.dispose();
    }
}
 
开发者ID:Jamling,项目名称:Android-ORM-ASPlugin,代码行数:24,代码来源:NewProviderAction.java

示例8: actionPerformed

import com.intellij.openapi.actionSystem.PlatformDataKeys; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
    // TODO: insert action logic here

    VirtualFile data = e.getData(PlatformDataKeys.VIRTUAL_FILE);
    String path = data.getPath();
    String packagename = path.substring(path.indexOf("main/java") + 10, path.length()).replaceAll("/", ".");

    System.out.println(path);
    System.out.println(packagename);

    JsonDialog jsonDialog = new JsonDialog(path, packagename, e);
    jsonDialog.setSize(620, 440);
    jsonDialog.setAlwaysOnTop(true);
    jsonDialog.setVisible(true);


}
 
开发者ID:zhouzhuo810,项目名称:ApiCreator,代码行数:19,代码来源:MainAction.java

示例9: getData

import com.intellij.openapi.actionSystem.PlatformDataKeys; //导入依赖的package包/类
@Override
public Object getData(DataProvider dataProvider) {
  final Navigatable navigatable = CommonDataKeys.NAVIGATABLE.getData(dataProvider);
  if (navigatable != null && navigatable instanceof OpenFileDescriptor) {
    final OpenFileDescriptor openFileDescriptor = (OpenFileDescriptor)navigatable;

    if (openFileDescriptor.getFile().isValid()) {
      return openFileDescriptor;
    }
  }
  final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataProvider);
  if (element instanceof Navigatable) {
    return element;
  }
  if (element != null) {
    return EditSourceUtil.getDescriptor(element);
  }

  final Object selection = PlatformDataKeys.SELECTED_ITEM.getData(dataProvider);
  if (selection instanceof Navigatable) {
    return selection;
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:NavigatableRule.java

示例10: actionPerformed

import com.intellij.openapi.actionSystem.PlatformDataKeys; //导入依赖的package包/类
@Override
public void actionPerformed(final AnActionEvent e) {
    Editor editor = e.getData(PlatformDataKeys.EDITOR);
    if (editor != null) {
        Document document = editor.getDocument();
        CharSequence chars = document.getCharsSequence();
        Plugin plugin = Plugin.getInstance();

        for (Caret caret : editor.getCaretModel().getAllCarets()) {
            if (caret.hasSelection()) {
                boolean startWord = EditHelpers.isWordStart(chars, caret.getSelectionStart(),false);
                boolean endWord = EditHelpers.isWordEnd(chars, caret.getSelectionEnd(),false);
                if (myIsRemoveWord) {
                    plugin.removeHighlightWord(chars.subSequence(caret.getSelectionStart(), caret.getSelectionEnd()));
                } else {
                    plugin.addHighlightWord(chars.subSequence(caret.getSelectionStart(), caret.getSelectionEnd()), startWord, endWord, null);
                }
            }
        }
    }
}
 
开发者ID:vsch,项目名称:MissingInActions,代码行数:22,代码来源:WordHighlightActionBase.java

示例11: getData

import com.intellij.openapi.actionSystem.PlatformDataKeys; //导入依赖的package包/类
public Object getData(Collection<AbstractTreeNode> selected, String dataName) {
  if (selected == null) return null;
  if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataName)) {
    for (AbstractTreeNode selectedElement : selected) {
      Object element = selectedElement.getValue();
      if (element instanceof ResourceBundle) {
        return new ResourceBundleDeleteProvider();
      }
    }
  } else if (ResourceBundle.ARRAY_DATA_KEY.is(dataName)) {
    final List<ResourceBundle> selectedElements = new ArrayList<ResourceBundle>();
    for (AbstractTreeNode node : selected) {
      final Object value = node.getValue();
      if (value instanceof ResourceBundle) {
        selectedElements.add((ResourceBundle)value);
      }
    }
    return selectedElements.isEmpty() ? null : selectedElements.toArray(new ResourceBundle[selectedElements.size()]);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ResourceBundleGrouper.java

示例12: actionPerformed

import com.intellij.openapi.actionSystem.PlatformDataKeys; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
    //获取编辑器
    Editor editor = e.getData(PlatformDataKeys.EDITOR);
    if (editor != null){
        SelectionModel model = editor.getSelectionModel();
        //获取选中文本
        String selectedText = model.getSelectedText().toString();
        if (selectedText!=null){
            selectedText = addBlanks(selectedText);
            try {
                getTranslation(selectedText);
            } catch (JSONException e1) {
                e1.printStackTrace();
            }
        }
    }
}
 
开发者ID:shicaiD,项目名称:DscTranslate,代码行数:19,代码来源:DscTranslate.java

示例13: actionPerformed

import com.intellij.openapi.actionSystem.PlatformDataKeys; //导入依赖的package包/类
@Override
public void actionPerformed(final AnActionEvent e) {
  final Project project = e.getData(CommonDataKeys.PROJECT);
  final FileEditor editor = e.getData(PlatformDataKeys.FILE_EDITOR);
  CommandProcessor commandProcessor = CommandProcessor.getInstance();
  commandProcessor.executeCommand(
      project, new Runnable() {
      @Override
      public void run() {
        PsiDocumentManager.getInstance(project).commitAllDocuments();
        FindManager findManager = FindManager.getInstance(project);
        if(!findManager.selectNextOccurrenceWasPerformed() && findManager.findPreviousUsageInEditor(editor)) {
          return;
        }
        FindUtil.searchBack(project, editor, e.getDataContext());
      }
    },
    IdeBundle.message("command.find.previous"),
    null
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SearchBackAction.java

示例14: actionPerformed

import com.intellij.openapi.actionSystem.PlatformDataKeys; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {

    // 获取编辑器中的文件
    Project project = e.getData(PlatformDataKeys.PROJECT);
    Editor editor = e.getData(PlatformDataKeys.EDITOR);
    PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project);

    // 获取当前类
    PsiClass targetClass = getTargetClass(editor, file);
    // 获取元素操作的工厂类
    PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);

    // 生成代码
    new LayoutCreator(project, targetClass, factory, file).execute();
}
 
开发者ID:alidili,项目名称:AndroidStudioPlugin,代码行数:17,代码来源:CreateDialogAction.java

示例15: actionPerformed

import com.intellij.openapi.actionSystem.PlatformDataKeys; //导入依赖的package包/类
@Override
    public void actionPerformed(AnActionEvent anActionEvent) {
        Project project = anActionEvent.getData(PlatformDataKeys.PROJECT);

//        PsiFile psiFile = anActionEvent.getData(LangDataKeys.PSI_FILE);
//        Editor editor = anActionEvent.getData(PlatformDataKeys.EDITOR);
//        Application application = ApplicationManager.getApplication();
//        MyApplicationComponent myApplicationComponent = application.getComponent(MyApplicationComponent.class);

        MyDialog myDialog = new MyDialog(project);
        myDialog.show();
        if (myDialog.isOK()) {
            Messages.showMessageDialog(project, "生成像素dimen文件成功\nGenerate pixel dimen file success",
                    PROJECT_NAME, Messages.getInformationIcon());
        }
//        String txt = Messages.showMultilineInputDialog(project,
//                "请按照示例添加所需的分辨率",
//                "AutoGeneratePixelDimen",
//                "1920 1080\n1280 720", Messages.getQuestionIcon(), null);
    }
 
开发者ID:succlz123,项目名称:AndroidPixelDimenGenerator,代码行数:21,代码来源:MainAnAction.java


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