Search in sources :

Example 76 with Presentation

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

the class AndroidInlineStyleTest method performAction.

private Pair<Presentation, AndroidInlineTestConfig> performAction(boolean inlineThisOnly, String dirToCopy) {
    final String testName = getTestName(true);
    final VirtualFile f = myFixture.copyFileToProject(BASE_PATH + testName + ".xml", dirToCopy + "/test" + testName + "_" + Boolean.toString(inlineThisOnly) + ".xml");
    myFixture.configureFromExistingVirtualFile(f);
    final AndroidInlineTestConfig config = new AndroidInlineTestConfig(inlineThisOnly);
    final Presentation presentation = myFixture.testAction(new AndroidInlineStyleReferenceAction(config));
    return Pair.create(presentation, config);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 77 with Presentation

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

the class ConvertToConstraintLayoutAction method update.

@Override
public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    ScreenView screenView = mySurface.getCurrentScreenView();
    NlComponent target = findTarget(screenView);
    if (target != null) {
        String tagName = target.getTagName();
        // Don't show action if it's already a ConstraintLayout
        if (target.isOrHasSuperclass(CONSTRAINT_LAYOUT)) {
            presentation.setVisible(false);
            return;
        }
        presentation.setVisible(true);
        tagName = tagName.substring(tagName.lastIndexOf('.') + 1);
        presentation.setText("Convert " + tagName + " to ConstraintLayout");
        presentation.setEnabled(true);
    } else {
        presentation.setText(TITLE);
        presentation.setEnabled(false);
        presentation.setVisible(true);
    }
}
Also used : ScreenView(com.android.tools.idea.uibuilder.surface.ScreenView) NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 78 with Presentation

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

the class RunSdkConfigAction method update.

@Override
public void update(AnActionEvent e) {
    if (e == null || ActionPlaces.WELCOME_SCREEN.equals(e.getPlace()) || IdeInfo.getInstance().isAndroidStudio()) {
        Presentation presentation = e == null ? getTemplatePresentation() : e.getPresentation();
        presentation.setEnabledAndVisible(isAndroidSdkManagerEnabled());
    } else {
        Project project = e.getProject();
        e.getPresentation().setEnabled(project != null && !ProjectFacetManager.getInstance(project).getFacets(AndroidFacet.ID).isEmpty());
    }
}
Also used : Project(com.intellij.openapi.project.Project) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 79 with Presentation

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

the class CreateLibraryFromFilesAction method update.

@Override
public void update(@NotNull AnActionEvent e) {
    final Project project = getEventProject(e);
    boolean visible = false;
    if (project != null && ModuleManager.getInstance(project).getModules().length > 0) {
        final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
        for (VirtualFile root : getRoots(e)) {
            if (!root.isInLocalFileSystem() && FileUtilRt.extensionEquals(root.getName(), "jar") && !fileIndex.isInLibraryClasses(root)) {
                visible = true;
                break;
            }
        }
    }
    Presentation presentation = e.getPresentation();
    presentation.setVisible(visible);
    presentation.setEnabled(visible);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 80 with Presentation

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

the class AndroidStudioGradleActionTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    initMocks(this);
    myPresentation = new Presentation();
    when(myEvent.getPresentation()).thenReturn(myPresentation);
    when(myEvent.getProject()).thenReturn(myProject);
    myProjectInfo = IdeComponents.replaceServiceWithMock(getProject(), GradleProjectInfo.class);
}
Also used : GradleProjectInfo(com.android.tools.idea.gradle.project.GradleProjectInfo) 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