com.intellij.openapi.actionSystem.DataConstants Java Examples
The following examples show how to use
com.intellij.openapi.actionSystem.DataConstants.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PushAction.java From ADB-Duang with MIT License | 6 votes |
@Override protected boolean runEnable(AnActionEvent anActionEvent) { Object o = anActionEvent.getDataContext().getData(DataConstants.PSI_FILE); if (o instanceof XmlFileImpl) { parentFileName = ((XmlFileImpl) o).getVirtualFile().getParent().getName(); if (isPreference(parentFileName)) { return true; } } else if (o instanceof PsiFile) { parentFileName = ((PsiFile) o).getVirtualFile().getParent().getName(); if (isDataBase(parentFileName)) { return true; } } return false; }
Example #2
Source File: SwitchViewAction.java From react-templates-plugin with MIT License | 6 votes |
@Override public void actionPerformed(@NotNull final AnActionEvent e) { final Project project = e.getProject(); if (project == null) return; final VirtualFile file = (VirtualFile) e.getDataContext().getData(DataConstants.VIRTUAL_FILE); if (file == null) { RTFile[] rtFiles = RTFile.DATA_KEY.getData(e.getDataContext()); if (rtFiles == null || rtFiles.length == 0) { System.out.println("No file for rt compile"); return; } // handle all files for (RTFile rtFile : rtFiles) { FileEditorManager.getInstance(project).openFile(rtFile.getController().getVirtualFile(), true, true); } } else { VirtualFile vfs = file.getParent().findChild(RTMergerTreeStructureProvider.getJSControllerName(file)); if (vfs != null) { FileEditorManager.getInstance(project).openFile(vfs, true, true); } } }
Example #3
Source File: RefreshActionBase.java From KodeBeagle with Apache License 2.0 | 6 votes |
public final void init() throws IOException { DataContext dataContext = DataManager.getInstance().getDataContext(); Project project = (Project) dataContext.getData(DataConstants.PROJECT); Settings currentSettings = new Settings(); if (project != null) { windowObjects.setProject(project); windowObjects.setDistance(currentSettings.getLimits().getLinesFromCursor()); windowObjects.setSize(currentSettings.getLimits().getResultSize()); windowObjects.setKbAPIURL(currentSettings.getSearch().getSelectedApiURL()); windowObjects.setMaxTinyEditors(currentSettings.getLimits().getTopCount()); windowObjects.retrieveIncludeMethods(); windowEditorOps.writeToDocument("", windowObjects.getWindowEditor().getDocument()); final Editor editor = getEditor(); if (editor != null) { windowObjects.getFileNameContentsMap().clear(); windowObjects.getFileNameNumbersMap().clear(); windowObjects.getSpotlightPaneTinyEditorsJPanel().removeAll(); } else { uiUtils.showHelpInfo(EDITOR_ERROR); } runAction(); } else { uiUtils.showHelpInfo(PROJECT_ERROR); uiUtils.goToAllPane(); } }
Example #4
Source File: GotoBaseAction.java From CppTools with Apache License 2.0 | 6 votes |
protected void gotoActionPerformed(AnActionEvent anActionEvent) { final Project project = (Project) anActionEvent.getDataContext().getData(DataConstants.PROJECT); final ChooseByNamePopup byNamePopup = ChooseByNamePopup.createPopup( project, new MyContributorsBasedGotoByModel(project, getNameContributor()), (PsiElement)null ); byNamePopup.invoke(new ChooseByNamePopupComponent.Callback() { public void elementChosen(Object element) { ((NavigationItem)element).navigate(true); } public void onClose() { if (GotoBaseAction.this.getClass().equals(myInAction)) myInAction = null; } }, ModalityState.current(), false); }
Example #5
Source File: JscsFixAction.java From jscs-plugin with MIT License | 6 votes |
public void actionPerformed(AnActionEvent e) { final Project project = e.getProject(); if (project == null) return; final VirtualFile file = (VirtualFile) e.getDataContext().getData(DataConstants.VIRTUAL_FILE); JscsProjectComponent component = project.getComponent(JscsProjectComponent.class); // JscsConfigFileListener.start(collectedInfo.project); // actualFile = ActualFile2.getOrCreateActualFile(JSCS_TEMP_FILE_KEY, file, collectedInfo.fileContent); // if (actualFile == null || actualFile.getActualFile() == null) { // return null; // } // File cwd = new File(project.getBasePath()); // if (actualFile instanceof ActualFile2.TempActualFile) { // cwd = ((ActualFile2.TempActualFile) actualFile).getTempFile().file.getParentFile(); // } // String relativeFile = actualFile.getActualFile().getName(); // File cwd = actualFile.getActualFile().getParentFile(); // String relativeFile = FileUtils.makeRelative(cwd, actualFile.getActualFile()); String rc = JscsExternalAnnotator.getRC(project, component.jscsRcFile); LintResult result = JscsRunner.fix(project.getBasePath(), file.getPath(), component.nodeInterpreter, component.jscsExecutable, rc, component.preset, component.settings.esnext, component.settings.esprima); file.refresh(true, false); }
Example #6
Source File: BuildCppAction.java From CppTools with Apache License 2.0 | 6 votes |
public void update(AnActionEvent e) { super.update(e); final DataContext dataContext = e.getDataContext(); final Project project = (Project) dataContext.getData(DataConstants.PROJECT); final VirtualFile file = (VirtualFile) dataContext.getData(DataConstants.VIRTUAL_FILE); BaseBuildHandler buildHandler = null; if (project != null && file != null && !file.isDirectory() ) { buildHandler = BaseBuildHandler.getBuildHandler(project, file); } final boolean enabled = buildHandler != null; e.getPresentation().setEnabled(enabled); e.getPresentation().setVisible(enabled); final String s = "Do &build for " + (buildHandler != null ? file.getName():"makefile/dsp/dsw file"); e.getPresentation().setText(s); e.getPresentation().setDescription(s); }
Example #7
Source File: SwitchViewAction.java From react-templates-plugin with MIT License | 6 votes |
@Override public void actionPerformed(@NotNull final AnActionEvent e) { final Project project = e.getProject(); if (project == null) return; final VirtualFile file = (VirtualFile) e.getDataContext().getData(DataConstants.VIRTUAL_FILE); if (file == null) { RTFile[] rtFiles = RTFile.DATA_KEY.getData(e.getDataContext()); if (rtFiles == null || rtFiles.length == 0) { System.out.println("No file for rt compile"); return; } // handle all files for (RTFile rtFile : rtFiles) { FileEditorManager.getInstance(project).openFile(rtFile.getController().getVirtualFile(), true, true); } } else { VirtualFile vfs = file.getParent().findChild(RTMergerTreeStructureProvider.getJSControllerName(file)); if (vfs != null) { FileEditorManager.getInstance(project).openFile(vfs, true, true); } } }
Example #8
Source File: AddOrRemoveCppFileFromAnalysisScopeAction.java From CppTools with Apache License 2.0 | 6 votes |
public void update(AnActionEvent anActionEvent) { final VirtualFile file = (VirtualFile) anActionEvent.getDataContext().getData(DataConstants.VIRTUAL_FILE); final Project project = (Project) anActionEvent.getDataContext().getData(DataConstants.PROJECT); final Presentation presentation = anActionEvent.getPresentation(); if (project == null || file == null || file.getFileType() != CppSupportLoader.CPP_FILETYPE || Communicator.isHeaderFile(file) ) { presentation.setVisible(false); } else { String url = file.getPresentableUrl().replace(File.separatorChar,'/'); final Set<String> ignoredFiles = CppSupportLoader.getInstance(project).getIgnoredFilesSet(); presentation.setVisible(true); final String fileName = file.getName(); final String term = "Cpp Support Analysis Scope"; presentation.setText(ignoredFiles.contains(url) ? "Add " + fileName + " to "+ term :"Remove " + fileName + " from " + term); } }
Example #9
Source File: ExtractFunctionDialog.java From CppTools with Apache License 2.0 | 5 votes |
private void createUIComponents() { functionMethodNameTextField = new NameSuggestionsField( new String[] {"fun"}, (Project) DataManager.getInstance().getDataContext().getData(DataConstants.PROJECT), CppSupportLoader.CPP_FILETYPE ); }
Example #10
Source File: PushAction.java From ADB-Duang with MIT License | 5 votes |
@Override protected String getAndroidFacetName(AnActionEvent anActionEvent) { Object o = anActionEvent.getDataContext().getData(DataConstants.PSI_FILE); if (o instanceof XmlFileImpl) { return ((XmlFileImpl) o).getVirtualFile().getParent().getParent().getName(); } else if (o instanceof PsiFile) { return parentFileName = ((PsiFile) o).getVirtualFile().getParent().getParent().getName(); } return super.getAndroidFacetName(anActionEvent); }
Example #11
Source File: IntroduceVariableDialog.java From CppTools with Apache License 2.0 | 5 votes |
private void createUIComponents() { myNewVarName = new NameSuggestionsField( calcVariants(), (Project) DataManager.getInstance().getDataContext().getData(DataConstants.PROJECT), CppSupportLoader.CPP_FILETYPE ); }
Example #12
Source File: BuildCppAction.java From CppTools with Apache License 2.0 | 5 votes |
public void actionPerformed(AnActionEvent anActionEvent) { final DataContext dataContext = anActionEvent.getDataContext(); final Project project = (Project) dataContext.getData(DataConstants.PROJECT); final VirtualFile file = (VirtualFile) dataContext.getData(DataConstants.VIRTUAL_FILE); doRun(file, project); }
Example #13
Source File: BaseEditorAction.java From CppTools with Apache License 2.0 | 5 votes |
static PsiFile findFileFromDataContext(DataContext context) { PsiFile file = (PsiFile)context.getData(DataConstants.PSI_FILE); final Project project = (Project) context.getData(DataConstants.PROJECT); final Editor editor = findEditorFromDataContext(context); if (file == null && editor != null) { file = PsiDocumentManager.getInstance(project).getPsiFile( editor.getDocument() ); } return file; }
Example #14
Source File: BaseEditorAction.java From CppTools with Apache License 2.0 | 5 votes |
static Editor findEditorFromDataContext(DataContext context) { Editor editor = (Editor) context.getData(DataConstants.EDITOR); final Project project = (Project) context.getData(DataConstants.PROJECT); if (editor == null && project != null) { editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); } return editor; }
Example #15
Source File: ESLintFixAction.java From eslint-plugin with MIT License | 5 votes |
public void actionPerformed(AnActionEvent e) { final Project project = e.getProject(); if (project == null) return; final VirtualFile file = (VirtualFile) e.getDataContext().getData(DataConstants.VIRTUAL_FILE); // TODO handle multiple selection if (file == null) { // File[] rtFiles = RTFile.DATA_KEY.getData(e.getDataContext()); // if (rtFiles == null || rtFiles.length == 0) { // System.out.println("No file for rt compile"); // return; // } // // handle all files // for (RTFile rtFile : rtFiles) { // RTFileListener.compile(rtFile.getRtFile().getVirtualFile(), project); // } } else { ESLintProjectComponent component = project.getComponent(ESLintProjectComponent.class); if (!component.isSettingsValid() || !component.isEnabled()) { return; } // Result result = ESLintRunner.lint(project.getBasePath(), relativeFile, component.nodeInterpreter, component.eslintExecutable, component.eslintRcFile, component.customRulesPath); if (project.getBasePath() != null) { ESLintRunner.ESLintSettings settings = ESLintRunner.buildSettings(project.getBasePath(), file.getPath(), component); try { ESLintRunner.fix(settings); file.refresh(false, false); } catch (ExecutionException e1) { e1.printStackTrace(); } } } }
Example #16
Source File: SwitchViewAction.java From react-templates-plugin with MIT License | 5 votes |
@Override public void update(@NotNull AnActionEvent e) { boolean enabled = false; Project project = CommonDataKeys.PROJECT.getData(e.getDataContext()); boolean rtEnabled = RTActionUtil.isRTEnabled(project); if (project != null) { final VirtualFile file = (VirtualFile) e.getDataContext().getData(DataConstants.VIRTUAL_FILE); enabled = rtEnabled && (RTFileUtil.isRTFile(file) || BuildTemplateAction.isRtFileContext(e.getDataContext())); // if (file != null) { // e.getPresentation().setText("Switch to Code Behind file '" + file.getName() + '\''); // } } e.getPresentation().setVisible(enabled); }
Example #17
Source File: JscsFixAction.java From jscs-plugin with MIT License | 5 votes |
@Override public void update(@NotNull AnActionEvent e) { boolean enabled = false; Project project = CommonDataKeys.PROJECT.getData(e.getDataContext()); boolean pluginEnabled = isJscsEnabled(project); if (project != null) { final VirtualFile file = (VirtualFile) e.getDataContext().getData(DataConstants.VIRTUAL_FILE); enabled = pluginEnabled && isJSFile(file); // || isRtFileContext(e.getDataContext())); if (file != null) { e.getPresentation().setText("JSCS Fix '" + file.getName() + '\''); } } e.getPresentation().setVisible(enabled); }
Example #18
Source File: SwitchViewAction.java From react-templates-plugin with MIT License | 5 votes |
@Override public void update(@NotNull AnActionEvent e) { boolean enabled = false; Project project = CommonDataKeys.PROJECT.getData(e.getDataContext()); boolean rtEnabled = RTActionUtil.isRTEnabled(project); if (project != null) { final VirtualFile file = (VirtualFile) e.getDataContext().getData(DataConstants.VIRTUAL_FILE); enabled = rtEnabled && (RTFileUtil.isRTFile(file) || BuildTemplateAction.isRtFileContext(e.getDataContext())); // if (file != null) { // e.getPresentation().setText("Switch to Code Behind file '" + file.getName() + '\''); // } } e.getPresentation().setVisible(enabled); }
Example #19
Source File: EditDbAction.java From ADB-Duang with MIT License | 5 votes |
protected boolean runEnable(AnActionEvent anActionEvent) { Object o = anActionEvent.getDataContext().getData(DataConstants.PSI_FILE); if (o instanceof PsiFile) { targetFilePath = ((PsiFile) o).getVirtualFile().getPath(); if (isDataBase(((PsiFile) o).getVirtualFile().getParent().getName())) { if (isMacOs()) return true; } } return false; }
Example #20
Source File: BaseEditorAction.java From CppTools with Apache License 2.0 | 4 votes |
public void actionPerformed(AnActionEvent e) { final DataContext dataContext = e.getDataContext(); final Editor editor = findEditorFromDataContext(dataContext); PsiFile file = findFileFromDataContext(dataContext); execute(editor, file, (Project) dataContext.getData(DataConstants.PROJECT)); }
Example #21
Source File: SendSomeTextToServerAction.java From CppTools with Apache License 2.0 | 4 votes |
public void actionPerformed(AnActionEvent anActionEvent) { final DataContext dataContext = anActionEvent.getDataContext(); final Project project = (Project) dataContext.getData(DataConstants.PROJECT); new SendDialog(project).show(); }
Example #22
Source File: LM.java From CppTools with Apache License 2.0 | 4 votes |
public static void showAboutDialog(DataContext dataContext) { new LMDialog((Project) dataContext.getData(DataConstants.PROJECT)).show(); }
Example #23
Source File: CppSupportSettings.java From CppTools with Apache License 2.0 | 4 votes |
public boolean canDoSomething(DataContext dataContext) { VirtualFile file = (VirtualFile) dataContext.getData(DataConstants.VIRTUAL_FILE); if (file == null || file.getFileType() != CppSupportLoader.CPP_FILETYPE) return false; return true; }