Search in sources :

Example 41 with DataContext

use of com.intellij.openapi.actionSystem.DataContext in project intellij-community by JetBrains.

the class AntBuildFileImpl method getExternalProperties.

@NotNull
public Map<String, String> getExternalProperties() {
    Map<String, String> result = myCachedExternalProperties;
    if (result == null) {
        synchronized (myOptionsLock) {
            result = myCachedExternalProperties;
            if (result == null) {
                result = new HashMap<>();
                final DataContext context = SimpleDataContext.getProjectContext(myProject);
                final MacroManager macroManager = MacroManager.getInstance();
                Iterator<BuildFileProperty> properties = ANT_PROPERTIES.getIterator(myAllOptions);
                while (properties.hasNext()) {
                    BuildFileProperty property = properties.next();
                    try {
                        String value = property.getPropertyValue();
                        value = macroManager.expandSilentMarcos(value, true, context);
                        value = macroManager.expandSilentMarcos(value, false, context);
                        result.put(property.getPropertyName(), value);
                    } catch (Macro.ExecutionCancelledException e) {
                        LOG.debug(e);
                    }
                }
                myCachedExternalProperties = result;
            }
        }
    }
    return result;
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) SimpleDataContext(com.intellij.openapi.actionSystem.impl.SimpleDataContext) Macro(com.intellij.ide.macro.Macro) MacroManager(com.intellij.ide.macro.MacroManager) NotNull(org.jetbrains.annotations.NotNull)

Example 42 with DataContext

use of com.intellij.openapi.actionSystem.DataContext in project intellij-community by JetBrains.

the class GenerateCoverageReportAction method actionPerformed.

public void actionPerformed(final AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final Project project = e.getProject();
    assert project != null;
    final CoverageDataManager coverageDataManager = CoverageDataManager.getInstance(project);
    final CoverageSuitesBundle currentSuite = coverageDataManager.getCurrentSuitesBundle();
    final CoverageEngine coverageEngine = currentSuite.getCoverageEngine();
    final ExportToHTMLDialog dialog = coverageEngine.createGenerateReportDialog(project, dataContext, currentSuite);
    dialog.reset();
    if (!dialog.showAndGet()) {
        return;
    }
    dialog.apply();
    coverageEngine.generateReport(project, dataContext, currentSuite);
}
Also used : Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) ExportToHTMLDialog(com.intellij.codeInspection.export.ExportToHTMLDialog) CoverageDataManager(com.intellij.coverage.CoverageDataManager) CoverageEngine(com.intellij.coverage.CoverageEngine) CoverageSuitesBundle(com.intellij.coverage.CoverageSuitesBundle)

Example 43 with DataContext

use of com.intellij.openapi.actionSystem.DataContext in project intellij-community by JetBrains.

the class GenerateCoverageReportAction method update.

public void update(final AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final Presentation presentation = e.getPresentation();
    presentation.setEnabled(false);
    presentation.setVisible(false);
    final Project project = e.getProject();
    if (project != null) {
        final CoverageSuitesBundle currentSuite = CoverageDataManager.getInstance(project).getCurrentSuitesBundle();
        if (currentSuite != null) {
            final CoverageEngine coverageEngine = currentSuite.getCoverageEngine();
            if (coverageEngine.isReportGenerationAvailable(project, dataContext, currentSuite)) {
                presentation.setEnabled(true);
                presentation.setVisible(true);
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) Presentation(com.intellij.openapi.actionSystem.Presentation) CoverageEngine(com.intellij.coverage.CoverageEngine) CoverageSuitesBundle(com.intellij.coverage.CoverageSuitesBundle)

Example 44 with DataContext

use of com.intellij.openapi.actionSystem.DataContext in project intellij-community by JetBrains.

the class XDebuggerEditorBase method createLanguagePopup.

private ListPopup createLanguagePopup() {
    DefaultActionGroup actions = new DefaultActionGroup();
    for (Language language : getSupportedLanguages()) {
        //noinspection ConstantConditions
        actions.add(new AnAction(language.getDisplayName(), null, language.getAssociatedFileType().getIcon()) {

            @Override
            public void actionPerformed(@NotNull AnActionEvent e) {
                XExpression currentExpression = getExpression();
                setExpression(new XExpressionImpl(currentExpression.getExpression(), language, currentExpression.getCustomInfo()));
                requestFocusInEditor();
            }
        });
    }
    DataContext dataContext = DataManager.getInstance().getDataContext(getComponent());
    return JBPopupFactory.getInstance().createActionGroupPopup("Choose Language", actions, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false);
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) Language(com.intellij.lang.Language) XExpressionImpl(com.intellij.xdebugger.impl.breakpoints.XExpressionImpl) XExpression(com.intellij.xdebugger.XExpression) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 45 with DataContext

use of com.intellij.openapi.actionSystem.DataContext in project intellij-community by JetBrains.

the class RecentTestRunnerImpl method run.

private void run(@NotNull String url) {
    Location location = myTestLocator.getLocation(url);
    if (location == null) {
        return;
    }
    DataContext data = new DataContext() {

        @Nullable
        @Override
        public Object getData(@NonNls String dataId) {
            if (Location.DATA_KEY.is(dataId)) {
                return location;
            }
            return null;
        }
    };
    myCurrentAction.actionPerformed(AnActionEvent.createFromAnAction(myCurrentAction, null, "", data));
}
Also used : NonNls(org.jetbrains.annotations.NonNls) DataContext(com.intellij.openapi.actionSystem.DataContext) Location(com.intellij.execution.Location)

Aggregations

DataContext (com.intellij.openapi.actionSystem.DataContext)204 Project (com.intellij.openapi.project.Project)73 VirtualFile (com.intellij.openapi.vfs.VirtualFile)29 NotNull (org.jetbrains.annotations.NotNull)23 IpnbFileEditor (org.jetbrains.plugins.ipnb.editor.IpnbFileEditor)23 Editor (com.intellij.openapi.editor.Editor)22 Nullable (org.jetbrains.annotations.Nullable)21 FileEditor (com.intellij.openapi.fileEditor.FileEditor)20 PsiFile (com.intellij.psi.PsiFile)17 IpnbFilePanel (org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel)16 Module (com.intellij.openapi.module.Module)13 PsiElement (com.intellij.psi.PsiElement)13 SimpleDataContext (com.intellij.openapi.actionSystem.impl.SimpleDataContext)11 Presentation (com.intellij.openapi.actionSystem.Presentation)10 DataManager (com.intellij.ide.DataManager)9 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)9 List (java.util.List)9 Consumer (com.intellij.util.Consumer)7 AnAction (com.intellij.openapi.actionSystem.AnAction)6 Transferable (java.awt.datatransfer.Transferable)6