Search in sources :

Example 81 with Presentation

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

the class SyncProjectActionTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    initMocks(this);
    myPresentation = new Presentation();
    when(myEvent.getPresentation()).thenReturn(myPresentation);
    myAction = new SyncProjectAction("Test", mySyncInvoker);
}
Also used : Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 82 with Presentation

use of com.intellij.openapi.actionSystem.Presentation 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 83 with Presentation

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

the class SyncProjectAction method doPerform.

@Override
protected void doPerform(@NotNull AnActionEvent e, @NotNull Project project) {
    BuildVariantView.getInstance(project).projectImportStarted();
    Presentation presentation = e.getPresentation();
    presentation.setEnabled(false);
    try {
        mySyncInvoker.requestProjectSyncAndSourceGeneration(project, null);
    } finally {
        presentation.setEnabled(true);
    }
}
Also used : Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 84 with Presentation

use of com.intellij.openapi.actionSystem.Presentation 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 85 with Presentation

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

the class IncludeModuleForFileAction method update.

@Override
public void update(AnActionEvent e) {
    boolean show = false;
    VirtualFile file = null;
    Project project = e.getProject();
    if (project != null) {
        file = findTarget(e, project);
        if (file != null) {
            show = !isInSource(file, project);
        }
    }
    Presentation presentation = e.getPresentation();
    presentation.setVisible(show);
    if (file != null) {
        String type = file.isDirectory() ? "Directory" : "File";
        presentation.setText(String.format("Find and Add Module Containing Selected %1$s as Source", type));
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) Presentation(com.intellij.openapi.actionSystem.Presentation)

Aggregations

Presentation (com.intellij.openapi.actionSystem.Presentation)236 Project (com.intellij.openapi.project.Project)76 VirtualFile (com.intellij.openapi.vfs.VirtualFile)34 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)11 DataContext (com.intellij.openapi.actionSystem.DataContext)10 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)8 AnAction (com.intellij.openapi.actionSystem.AnAction)7 PsiFile (com.intellij.psi.PsiFile)6 IdeView (com.intellij.ide.IdeView)5 ActionManager (com.intellij.openapi.actionSystem.ActionManager)5 Editor (com.intellij.openapi.editor.Editor)5 File (java.io.File)5 Module (com.intellij.openapi.module.Module)4 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)4 PsiDirectory (com.intellij.psi.PsiDirectory)4 Course (com.jetbrains.edu.learning.courseFormat.Course)4 StudyEditor (com.jetbrains.edu.learning.editor.StudyEditor)4 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)3 NotNull (org.jetbrains.annotations.NotNull)3 Before (org.junit.Before)3