Search in sources :

Example 61 with DataContext

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

the class LegacyNewAndroidComponentAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
    if (view == null) {
        return;
    }
    final Module module = LangDataKeys.MODULE.getData(dataContext);
    if (module == null)
        return;
    final AndroidFacet facet = AndroidFacet.getInstance(module);
    assert facet != null;
    final PsiDirectory dir = view.getOrChooseDirectory();
    if (dir == null)
        return;
    NewAndroidComponentDialog dialog = new NewAndroidComponentDialog(module, dir);
    dialog.show();
    if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
        return;
    }
    final PsiElement[] createdElements = dialog.getCreatedElements();
    for (PsiElement createdElement : createdElements) {
        view.selectElement(createdElement);
    }
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) NewAndroidComponentDialog(org.jetbrains.android.actions.NewAndroidComponentDialog) PsiDirectory(com.intellij.psi.PsiDirectory) IdeView(com.intellij.ide.IdeView) Module(com.intellij.openapi.module.Module) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) PsiElement(com.intellij.psi.PsiElement)

Example 62 with DataContext

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

the class OpenStringResourceEditorAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final DataContext context = e.getDataContext();
    final Project project = e.getProject();
    final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(context);
    if (project == null || file == null) {
        return;
    }
    StringResourceEditorProvider.openEditor(project, file);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext)

Example 63 with DataContext

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

the class MakeGradleModuleAction method updatePresentation.

public static void updatePresentation(@NotNull AnActionEvent e, @NotNull Project project) {
    DataContext dataContext = e.getDataContext();
    Module[] modules = getModulesToBuildFromSelection(project, dataContext);
    int moduleCount = modules.length;
    Presentation presentation = e.getPresentation();
    presentation.setEnabled(moduleCount > 0);
    String presentationText;
    if (moduleCount > 0) {
        String text = "Make Module";
        if (moduleCount > 1) {
            text += "s";
        }
        for (int i = 0; i < moduleCount; i++) {
            if (text.length() > 30) {
                text = "Make Selected Modules";
                break;
            }
            Module toMake = modules[i];
            if (i != 0) {
                text += ",";
            }
            text += " '" + toMake.getName() + "'";
        }
        presentationText = text;
    } else {
        presentationText = "Make";
    }
    presentation.setText(presentationText);
    presentation.setVisible(moduleCount > 0 || !PROJECT_VIEW_POPUP.equals(e.getPlace()));
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) Module(com.intellij.openapi.module.Module) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 64 with DataContext

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

the class LinkExternalCppProjectAction method doUpdate.

@Override
protected void doUpdate(@NotNull AnActionEvent e, @NotNull Project project) {
    DataContext dataContext = e.getDataContext();
    boolean enable = isValidAndroidGradleModuleSelected(dataContext);
    Presentation presentation = e.getPresentation();
    presentation.setEnabled(enable);
    presentation.setVisible(enable);
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 65 with DataContext

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

the class ConfigurationAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final ActionManagerEx manager = ActionManagerEx.getInstanceEx();
    final DataContext dataContext = e.getDataContext();
    // Regular actions invoke this method before performing the action. We do so as well since the analytics subsystem hooks into
    // this event to monitor invoked actions.
    manager.fireBeforeActionPerformed(this, dataContext, e);
    tryUpdateConfiguration();
    updatePresentation();
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) ActionManagerEx(com.intellij.openapi.actionSystem.ex.ActionManagerEx)

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