Java 类com.intellij.openapi.actionSystem.PlatformDataKeys 实例源码

项目:CodeGenerate    文件:MainAction.java   
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);

    }
项目:idea-php-typo3-plugin    文件:ExtensionUtility.java   
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]);
}
项目:OpenInExplorer-idea    文件:RightAction.java   
@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());
    }
}
项目:Specflow.Rider    文件:SpecflowGenerateCodeTest.java   
@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());
}
项目:GoogleTranslation    文件:GoogleTranslation.java   
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();
}
项目:ReciteWords    文件:ReciteWords.java   
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();
}
项目:Android-ORM-ASPlugin    文件:NewProviderAction.java   
@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();
    }
}
项目:ApiCreator    文件:MainAction.java   
@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);


}
项目:intellij-ce-playground    文件:NavigatableRule.java   
@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;
}
项目:MissingInActions    文件:WordHighlightActionBase.java   
@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);
                }
            }
        }
    }
}
项目:intellij-ce-playground    文件:ResourceBundleGrouper.java   
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;
}
项目:DscTranslate    文件:DscTranslate.java   
@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();
            }
        }
    }
}
项目:intellij-ce-playground    文件:SearchBackAction.java   
@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
  );
}
项目:AndroidStudioPlugin    文件:CreateDialogAction.java   
@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();
}
项目:AndroidPixelDimenGenerator    文件:MainAnAction.java   
@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);
    }
项目:deltahex-intellij-plugin    文件:OpenAsHexAction.java   
@Override
public void actionPerformed(AnActionEvent event) {
    final Project project = event.getProject();
    if (project == null) {
        return;
    }
    VirtualFile virtualFile = event.getData(PlatformDataKeys.VIRTUAL_FILE);
    if (virtualFile != null && virtualFile.isValid() && !virtualFile.isDirectory()) {
        DeltaHexVirtualFile deltaHexVirtualFile = new DeltaHexVirtualFile(virtualFile);
        OpenFileDescriptor descriptor = new OpenFileDescriptor(project, deltaHexVirtualFile, 0);
        FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
        List<FileEditor> editors = fileEditorManager.openEditor(descriptor, true);
        fileEditorManager.setSelectedEditor(virtualFile, DeltaHexWindowProvider.DELTAHEX_EDITOR_TYPE_ID);
        for (FileEditor fileEditor : editors) {
            if (fileEditor instanceof DeltaHexFileEditor) {
                ((DeltaHexFileEditor) fileEditor).openFile(deltaHexVirtualFile);
            }
        }
    }
}
项目:phpstorm-plugin    文件:Run.java   
@Nullable
protected PhpClass getCurrentTestClass(AnActionEvent e) {
    Object psiFile = e.getData(PlatformDataKeys.PSI_FILE);

    if (null == psiFile) {
        return null;
    }

    if (!(psiFile instanceof PhpFile)) {
        return null;
    }
    PhpFile phpFile = ((PhpFile) psiFile);

    PhpClass currentClass = Utils.getFirstClassFromFile(phpFile);
    if (null == currentClass) {
        return null;
    }

    if (!Utils.isClassAtoumTest(currentClass)) {
        return Utils.locateTestClass(e.getProject(), currentClass);
    }

    return currentClass;
}
项目:intellij-ce-playground    文件:ResourceBundleFromEditorRenameHandler.java   
@Override
public boolean isAvailableOnDataContext(DataContext dataContext) {
  final Project project = CommonDataKeys.PROJECT.getData(dataContext);
  if (project == null) {
    return false;
  }
  final ResourceBundle bundle = ResourceBundleUtil.getResourceBundleFromDataContext(dataContext);
  if (bundle == null) {
    return false;
  }
  final FileEditor fileEditor = PlatformDataKeys.FILE_EDITOR.getData(dataContext);
  if (fileEditor == null || !(fileEditor instanceof ResourceBundleEditor)) {
    return false;
  }
  final VirtualFile virtualFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
  return !(virtualFile == null || !(virtualFile instanceof ResourceBundleAsVirtualFile));
}
项目:android-xml-sorter    文件:XmlInstantSorterAction.java   
@Override
public void actionPerformed(AnActionEvent event) {

    final Project project = getEventProject(event);
    final Editor editor = event.getData(PlatformDataKeys.EDITOR);
    XmlSorterDialog dialog = new XmlSorterDialog(project);

    PropertiesComponent pc = PropertiesComponent.getInstance();
    execute(project,
            editor,
            pc.getInt(PC_KEY_INPUT_CASE, 0) == 0,
            dialog.getPrefixSpacePositionValueAt(pc.getInt(PC_KEY_PREFIX_SPACE_POS, 0)),
            pc.getBoolean(PC_KEY_SPACE_BETWEEN_PREFIX, true),
            pc.getBoolean(PC_KEY_INSERT_XML_INFO, true),
            pc.getBoolean(PC_KEY_DELETE_COMMENT, false),
            dialog.getCodeIndentValueAt(pc.getInt(PC_KEY_CODE_INDENT, 1)));
}
项目:intellij-ce-playground    文件:PsiElementFromSelectionsRule.java   
@Override
public Object getData(DataProvider dataProvider) {
  final Object[] objects = (Object[])dataProvider.getData(PlatformDataKeys.SELECTED_ITEMS.getName());
  if (objects != null) {
    final PsiElement[] elements = new PsiElement[objects.length];
    for (int i = 0, objectsLength = objects.length; i < objectsLength; i++) {
      Object object = objects[i];
      if (!(object instanceof PsiElement)) return null;
      if (!((PsiElement)object).isValid()) return null;
      elements[i] = (PsiElement)object;
    }

    return elements;
  }
  return null;
}
项目:intellij-ce-playground    文件:MaximizeToolWindowAction.java   
@Override
public void update(@NotNull AnActionEvent e) {
  e.getPresentation().setEnabled(true);
  Project project = e.getProject();
  if (project == null || project.isDisposed()) {
    e.getPresentation().setEnabled(false);
    return;
  }
  ToolWindow toolWindow = e.getData(PlatformDataKeys.TOOL_WINDOW);
  if (toolWindow == null) {
    e.getPresentation().setEnabled(false);
    return;
  }
  ToolWindowManager manager = ToolWindowManager.getInstance(project);
  e.getPresentation().setText(manager.isMaximized(toolWindow) ?
                              ActionsBundle.message("action.ResizeToolWindowMaximize.text.alternative") :
                              ActionsBundle.message("action.ResizeToolWindowMaximize.text"));
}
项目:intellij-ce-playground    文件:EditorComposite.java   
@Override
public final Object getData(String dataId){
  if (PlatformDataKeys.FILE_EDITOR.is(dataId)) {
    return getSelectedEditor();
  }
  else if(CommonDataKeys.VIRTUAL_FILE.is(dataId)){
    return myFile.isValid() ? myFile : null;
  }
  else if(CommonDataKeys.VIRTUAL_FILE_ARRAY.is(dataId)){
    return myFile.isValid() ? new VirtualFile[] {myFile} : null;
  }
  else{
    JComponent component = getPreferredFocusedComponent();
    if(component instanceof DataProvider && component != this){
      return ((DataProvider)component).getData(dataId);
    }
    else{
      return null;
    }
  }
}
项目:intellij-ce-playground    文件:IpnbMoveCellUpAction.java   
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
  final DataContext context = event.getDataContext();
  final FileEditor editor = PlatformDataKeys.FILE_EDITOR.getData(context);
  if (editor instanceof IpnbFileEditor) {
    final IpnbFilePanel ipnbFilePanel = ((IpnbFileEditor)editor).getIpnbFilePanel();
    CommandProcessor.getInstance().executeCommand(ipnbFilePanel.getProject(), new Runnable() {
      public void run() {
        ApplicationManager.getApplication().runWriteAction(new Runnable() {
          public void run() {
            ipnbFilePanel.moveCell(false);
          }
        });
      }
    }, "Ipnb.moveCell", new Object());

  }
}
项目:intellij-ce-playground    文件:MergePanel2.java   
public Object getData(String dataId) {
  if (FocusDiffSide.DATA_KEY.is(dataId)) {
    int index = getFocusedEditorIndex();
    if (index < 0) return null;
    switch (index) {
      case 0:
        return new BranchFocusedSide(FragmentSide.SIDE1);
      case 1:
        return new MergeFocusedSide();
      case 2:
        return new BranchFocusedSide(FragmentSide.SIDE2);
    }
  }
  else if (PlatformDataKeys.DIFF_VIEWER.is(dataId)) return MergePanel2.this;
  return super.getData(dataId);
}
项目:intellij-ce-playground    文件:DiffPanelOuterComponent.java   
public Object getData(String dataId) {
  if (PlatformDataKeys.SOURCE_NAVIGATION_LOCKED.is(dataId)) {
    return Boolean.TRUE;
  }
  if (myDataProvider == null) {
    return null;
  }
  if (CommonDataKeys.EDITOR.is(dataId)) {
    if (myBottomComponent != null) {
      // we don't want editor actions to be executed when the bottom component has focus
      final Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
      if (myBottomComponent.isAncestorOf(focusOwner)) {
        return null;
      }
    }
    final FocusDiffSide side = (FocusDiffSide)myDataProvider.getData(FocusDiffSide.DATA_KEY.getName());
    if (side != null) {
      final Editor editor = side.getEditor();
      return editor != null && editor.getComponent().hasFocus() ? editor : null;
    }
  }
  return myDataProvider.getData(dataId);
}
项目:intellij-ce-playground    文件:MacroManager.java   
private static DataContext getCorrectContext(DataContext dataContext) {
  if (PlatformDataKeys.FILE_EDITOR.getData(dataContext) != null) {
    return dataContext;
  }
  Project project = CommonDataKeys.PROJECT.getData(dataContext);
  if (project == null) {
    return dataContext;
  }
  FileEditorManager editorManager = FileEditorManager.getInstance(project);
  VirtualFile[] files = editorManager.getSelectedFiles();
  if (files.length == 0) {
    return dataContext;
  }
  FileEditor fileEditor = editorManager.getSelectedEditor(files[0]);
  return fileEditor == null ? dataContext : DataManager.getInstance().getDataContext(fileEditor.getComponent());
}
项目:intellij-ce-playground    文件:ContentManagerUtil.java   
/**
 * This is utility method. It returns <code>ContentManager</code> from the current context.
 */
public static ContentManager getContentManagerFromContext(DataContext dataContext, boolean requiresVisibleToolWindow){
  Project project = CommonDataKeys.PROJECT.getData(dataContext);
  if (project == null) {
    return null;
  }

  ToolWindowManagerEx mgr=ToolWindowManagerEx.getInstanceEx(project);

  String id = mgr.getActiveToolWindowId();
  if (id == null) {
    if(mgr.isEditorComponentActive()){
      id = mgr.getLastActiveToolWindowId();
    }
  }

  ToolWindowEx toolWindow = id != null ? (ToolWindowEx)mgr.getToolWindow(id) : null;
  if (requiresVisibleToolWindow && (toolWindow == null || !toolWindow.isVisible())) {
    return null;
  }

  ContentManager fromToolWindow = toolWindow != null ? toolWindow.getContentManager() : null;
  ContentManager fromContext = PlatformDataKeys.CONTENT_MANAGER.getData(dataContext);
  return ObjectUtils.chooseNotNull(fromContext, fromToolWindow);
}
项目:intellij-ce-playground    文件:SearchAgainAction.java   
@Override
public void actionPerformed(final AnActionEvent e) {
  final Project project = e.getData(CommonDataKeys.PROJECT);
  final FileEditor editor = e.getData(PlatformDataKeys.FILE_EDITOR);
  if (editor == null || project == null) return;
  CommandProcessor commandProcessor = CommandProcessor.getInstance();
  commandProcessor.executeCommand(
      project, new Runnable() {
      @Override
      public void run() {
        PsiDocumentManager.getInstance(project).commitAllDocuments();
        IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
        FindManager findManager = FindManager.getInstance(project);
        if(!findManager.selectNextOccurrenceWasPerformed() && findManager.findNextUsageInEditor(editor)) {
          return;
        }

        FindUtil.searchAgain(project, editor, e.getDataContext());
      }
    },
    IdeBundle.message("command.find.next"),
    null
  );
}
项目:intellij-ce-playground    文件:ShowContentAction.java   
@Nullable
private ToolWindow getWindow(AnActionEvent event) {
  if (myWindow != null) return myWindow;

  Project project = CommonDataKeys.PROJECT.getData(event.getDataContext());
  if (project == null) return null;

  ToolWindowManager manager = ToolWindowManager.getInstance(project);

  final ToolWindow window = manager.getToolWindow(manager.getActiveToolWindowId());
  if (window == null) return null;

  final Component context = PlatformDataKeys.CONTEXT_COMPONENT.getData(event.getDataContext());
  if (context == null) return null;

  return SwingUtilities.isDescendingFrom(window.getComponent(), context) ? window : null;
}
项目:intellij-ce-playground    文件:UndoRedoAction.java   
public void update(AnActionEvent event) {
  Presentation presentation = event.getPresentation();
  DataContext dataContext = event.getDataContext();
  FileEditor editor = PlatformDataKeys.FILE_EDITOR.getData(dataContext);

  // do not allow global undo in dialogs
  if (editor == null) {
    final Boolean isModalContext = PlatformDataKeys.IS_MODAL_CONTEXT.getData(dataContext);
    if (isModalContext != null && isModalContext) {
      presentation.setEnabled(false);
      return;
    }
  }

  UndoManager undoManager = getUndoManager(editor, dataContext);
  if (undoManager == null) {
    presentation.setEnabled(false);
    return;
  }
  presentation.setEnabled(isAvailable(editor, undoManager));

  Pair<String, String> pair = getActionNameAndDescription(editor, undoManager);

  presentation.setText(pair.first);
  presentation.setDescription(pair.second);
}
项目:intellij-ce-playground    文件:IpnbMoveCellDownAction.java   
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
  final DataContext context = event.getDataContext();
  final FileEditor editor = PlatformDataKeys.FILE_EDITOR.getData(context);
  if (editor instanceof IpnbFileEditor) {
    final IpnbFilePanel ipnbFilePanel = ((IpnbFileEditor)editor).getIpnbFilePanel();
    CommandProcessor.getInstance().executeCommand(ipnbFilePanel.getProject(), new Runnable() {
      public void run() {
        ApplicationManager.getApplication().runWriteAction(new Runnable() {
          public void run() {
            ipnbFilePanel.moveCell(true);
          }
        });
      }
    }, "Ipnb.moveCell", new Object());

  }
}
项目:intellij-ce-playground    文件:AnnotateRevisionAction.java   
@Override
public void update(@NotNull AnActionEvent e) {
  if (Boolean.TRUE.equals(e.getData(PlatformDataKeys.IS_MODAL_CONTEXT))) {
    e.getPresentation().setEnabledAndVisible(false);
    return;
  }

  if (myAnnotation.getFile() == null) {
    e.getPresentation().setEnabledAndVisible(false);
    return;
  }

  if (getRevisions() == null) {
    e.getPresentation().setEnabledAndVisible(false);
    return;
  }
  e.getPresentation().setVisible(true);

  super.update(e);
}
项目:intellij-ce-playground    文件:ShowChangeAbstractAction.java   
public void actionPerformed(AnActionEvent e) {
  final Project project = e.getData(CommonDataKeys.PROJECT);
  final ChangeRequestChain chain = e.getData(VcsDataKeys.DIFF_REQUEST_CHAIN);
  if (project == null || chain == null || !isEnabled(chain)) {
    return;
  }

  DiffViewer diffViewer = e.getData(PlatformDataKeys.COMPOSITE_DIFF_VIEWER);
  if (diffViewer == null) {
    diffViewer = e.getData(PlatformDataKeys.DIFF_VIEWER);
  }
  if (diffViewer == null) {
    return;
  }

  actionPerformed(e, project, chain, diffViewer);
}
项目:intellij-ce-playground    文件:IgnoreIncompletePropertyPropertiesFilesAction.java   
@Override
public void update(AnActionEvent e) {
  final FileEditor fileEditor = PlatformDataKeys.FILE_EDITOR.getData(e.getDataContext());
  if (fileEditor instanceof ResourceBundleEditor) {
    ResourceBundleEditor resourceBundleEditor = (ResourceBundleEditor)fileEditor;
    final Project project = getEventProject(e);
    if (project != null) {
      if (!processSelectedIncompleteProperties(new Processor<IProperty>() {
        @Override
        public boolean process(IProperty property) {
          return false;
        }
      }, resourceBundleEditor, project)) {
        e.getPresentation().setEnabledAndVisible(true);
        return;
      }
    }
  }
  e.getPresentation().setEnabledAndVisible(false);
}
项目:OkHttpParamsGet    文件:GetParamsAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
    // TODO: insert action logic here
    PsiFile psiFile = e.getData(LangDataKeys.PSI_FILE);
    Project project = e.getProject();
    Editor editor = e.getData(PlatformDataKeys.EDITOR);
    TypePickDialog dialog = new TypePickDialog();
    dialog.setListener(type -> {build(type, psiFile, project, editor);});
    dialog.pack();
    dialog.setVisible(true);
}
项目:react-native-console    文件:BaseAction.java   
@Override
    public void actionPerformed(AnActionEvent anActionEvent) {
//        DocumentUtil.saveDocument();
        this.anActionEvent = anActionEvent;
        this.currentProject = PlatformDataKeys.PROJECT.getData(anActionEvent.getDataContext());
        this.projectDir = new File(currentProject.getBasePath());
        actionPerformed();
    }
项目:mybatis-log-plugin    文件:GoogleTranslateAction.java   
public void actionPerformed(AnActionEvent var1) {
    DataContext var2 = var1.getDataContext();
    CopyProvider var3 = (CopyProvider) PlatformDataKeys.COPY_PROVIDER.getData(var2);
    if (var3 != null) {
        var3.performCopy(var2);
        String var4 = (String) CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor);
        if (StringUtil.isNotEmpty(var4)) {
            BrowserUtil.browse("https://translate.google.com/#en/zh-CN/" + URLEncoder.encode(var4));
        }
    }
}
项目:mybatis-log-plugin    文件:GoogleTranslateAction.java   
public void update(AnActionEvent var1) {
    Presentation var2 = var1.getPresentation();
    DataContext var3 = var1.getDataContext();
    CopyProvider var4 = (CopyProvider) PlatformDataKeys.COPY_PROVIDER.getData(var3);
    boolean var5 = var4 != null && var4.isCopyEnabled(var3) && var4.isCopyVisible(var3);
    var2.setEnabled(var5);
    var2.setVisible(var5);
}
项目:mybatis-log-plugin    文件:BaiduSearchAction.java   
public void actionPerformed(AnActionEvent var1) {
    DataContext var2 = var1.getDataContext();
    CopyProvider var3 = (CopyProvider) PlatformDataKeys.COPY_PROVIDER.getData(var2);
    if (var3 != null) {
        var3.performCopy(var2);
        String var4 = (String) CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor);
        if (StringUtil.isNotEmpty(var4)) {
            BrowserUtil.browse("https://www.baidu.com/s?wd=" + URLEncoder.encode(var4));
        }
    }
}
项目:mybatis-log-plugin    文件:BaiduSearchAction.java   
public void update(AnActionEvent var1) {
    Presentation var2 = var1.getPresentation();
    DataContext var3 = var1.getDataContext();
    CopyProvider var4 = (CopyProvider) PlatformDataKeys.COPY_PROVIDER.getData(var3);
    boolean var5 = var4 != null && var4.isCopyEnabled(var3) && var4.isCopyVisible(var3);
    var2.setEnabled(var5);
    var2.setVisible(var5);
}