Package com.intellij.openapi.actionSystem

Examples of com.intellij.openapi.actionSystem.Presentation


        handler.runExecuteAction(console, true);
    }

    @Override
    public void update(AnActionEvent e) {
        Presentation presentation = e.getPresentation();

        Editor editor = e.getData(DataKeys.EDITOR);

        if (editor == null) {
            presentation.setEnabled(false);
            return;
        }
        Project project = editor.getProject();
        if (project == null) {
            presentation.setEnabled(false);
            return;
        }

        Document document = editor.getDocument();
        PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document);
        if (psiFile == null || !(psiFile instanceof HaskellFile)) {
            presentation.setEnabled(false);
            return;
        }

        VirtualFile virtualFile = psiFile.getVirtualFile();
        if (virtualFile == null || virtualFile instanceof LightVirtualFile) {
            presentation.setEnabled(false);
            return;
        }
        String filePath = virtualFile.getPath();
        if (filePath == null) {
            presentation.setEnabled(false);
            return;
        }

        HaskellConsoleProcessHandler handler = findRunningHaskellConsole(project);
        if (handler == null) {
            presentation.setEnabled(false);
            return;
        }

        LanguageConsoleImpl console = handler.getLanguageConsole();
        if (!(console instanceof HaskellConsole)) {
            presentation.setEnabled(false);
            return;
        }

        presentation.setEnabled(true);
    }
View Full Code Here


        return virtualFile.getPath();
    }

    @Override
    public void update(AnActionEvent e) {
        Presentation presentation = e.getPresentation();
        String filePath = getActionFile(e);
        if (filePath == null) {
            presentation.setVisible(false);
        } else {
            File f = new File(filePath);
            presentation.setVisible(true);
            presentation.setText(String.format("Load \"%s\" in Haskell REPL", f.getName()));
        }
    }
View Full Code Here

public final class RunHaskellConsoleAction extends AnAction implements DumbAware {

    @Override
    public void update(AnActionEvent e) {
        Module m = getModule(e);
        Presentation presentation = e.getPresentation();
        if (m == null) {
            presentation.setEnabled(false);
            return;
        }
        presentation.setEnabled(true);
        super.update(e);
    }
View Full Code Here

    try {
      _actionEvent = event;
      _dataContext = event.getDataContext();

      final Project project = DataKeys.PROJECT.getData(_dataContext);
      final Presentation presentation = event.getPresentation();

      // check a project is loaded
      if (isProjectNotLoaded(project, presentation)) {
        return;
      }

      isPluginAccessible(project);

      // check if tool window is registered
      final ToolWindow toolWindow = isToolWindowRegistered(project);
      if (toolWindow == null) {
        presentation.setEnabled(false);
        presentation.setVisible(false);

        return;
      }

      // enable ?
      final Content content = toolWindow.getContentManager().getContent(0);

      if (content != null) {
        final ToolWindowPanel panel = (ToolWindowPanel) content.getComponent();
        final BugTree tree = panel.getBugTreePanel().getBugTree();
        _enabled = tree.hasPreviousOccurence();
        presentation.setEnabled(toolWindow.isAvailable() && isEnabled());
        presentation.setVisible(true);
      }
    } catch (final Throwable e) {
      final FindBugsPluginException processed = FindBugsPluginImpl.processError("Action update failed", e);
      LOGGER.error("Action update failed", processed);
    }
View Full Code Here

    _actionEvent = e;
    _dataContext = e.getDataContext();
    //final Presentation presentation = e.getPresentation();

    final com.intellij.openapi.project.Project project = DataKeys.PROJECT.getData(_dataContext);
    final Presentation presentation = e.getPresentation();

    // check a project is loaded
    if (isProjectNotLoaded(project, presentation)) {
      Messages.showWarningDialog("Project not loaded.", "FindBugs");
      return;
View Full Code Here

  public void update(final AnActionEvent event) {
    try {
      _actionEvent = event;
      _dataContext = event.getDataContext();
      final Project project = DataKeys.PROJECT.getData(_dataContext);
      final Presentation presentation = event.getPresentation();

      // check a project is loaded
      if (isProjectNotLoaded(project, presentation)) {
        return;
      }

      isPluginAccessible(project);

      // check if tool window is registered
      final ToolWindow toolWindow = isToolWindowRegistered(project);
      if (toolWindow == null) {
        presentation.setEnabled(false);
        presentation.setVisible(false);

        return;
      }

      registerEventListener(project);

      final VirtualFile[] selectedSourceFiles = IdeaUtilImpl.getVirtualFiles(_dataContext);

      // enable ?
      if (!_running) {
        _enabled = selectedSourceFiles != null && selectedSourceFiles.length > 0 && !selectedSourceFiles[0].isDirectory() && IdeaUtilImpl.isValidFileType(selectedSourceFiles[0].getFileType());
      }
      presentation.setEnabled(toolWindow.isAvailable() && isEnabled());
      presentation.setVisible(true);

    } catch (final Throwable e) {
      final FindBugsPluginException processed = FindBugsPluginImpl.processError("Action update failed", e);
      LOGGER.error("Action update failed", processed);
    }
View Full Code Here

  public void actionPerformed(final AnActionEvent e) {
    _actionEvent = e;
    _dataContext = e.getDataContext();

    final com.intellij.openapi.project.Project project = DataKeys.PROJECT.getData(_dataContext);
    final Presentation presentation = e.getPresentation();

    // check a project is loaded
    if (isProjectNotLoaded(project, presentation)) {
      Messages.showWarningDialog("Project not loaded.", getPluginInterface(project).getInternalToolWindowId());
      return;
View Full Code Here

  public void update(final AnActionEvent event) {
    try {
      _actionEvent = event;
      _dataContext = event.getDataContext();
      final com.intellij.openapi.project.Project project = DataKeys.PROJECT.getData(_dataContext);
      final Presentation presentation = event.getPresentation();

      // check a project is loaded
      if (isProjectNotLoaded(project, presentation)) {
        return;
      }

      isPluginAccessible(project);

      // check if tool window is registered
      final ToolWindow toolWindow = isToolWindowRegistered(project);
      if (toolWindow == null) {
        presentation.setEnabled(false);
        presentation.setVisible(false);

        return;
      }

      registerEventListener(project);

      final VirtualFile[] selectedSourceFiles = IdeaUtilImpl.getVirtualFiles(_dataContext);

      if (!_running) {
        _enabled = selectedSourceFiles != null && selectedSourceFiles.length > 0 && selectedSourceFiles[0].isValid() && IdeaUtilImpl.isValidFileType(selectedSourceFiles[0].getFileType());
      }

      presentation.setEnabled(toolWindow.isAvailable() && isEnabled());
      presentation.setVisible(true);

    } catch (final Throwable e) {
      final FindBugsPluginException processed = FindBugsPluginImpl.processError("Action update failed", e);
      LOGGER.error("Action update failed", processed);
    }
View Full Code Here

  @Override
  public void update(final AnActionEvent event) {
    try {
      final DataContext dataContext = event.getDataContext();
      final Project project = DataKeys.PROJECT.getData(dataContext);
      final Presentation presentation = event.getPresentation();

      if (isProjectNotLoaded(project, presentation)) {
        return;
      }

      isPluginAccessible(project);

      // check if tool window is registered
      final ToolWindow toolWindow = isToolWindowRegistered(project);
      if (toolWindow == null) {
        presentation.setEnabled(false);
        presentation.setVisible(false);

        return;
      }

      // enable ?
      presentation.setEnabled(toolWindow.isAvailable() && isEnabled());
      presentation.setVisible(true);

    } catch (final Throwable e) {
      final FindBugsPluginException processed = FindBugsPluginImpl.processError("Action update failed", e);
      LOGGER.error("Action update failed", processed);
    }
View Full Code Here

  @SuppressWarnings({"AssignmentToStaticFieldFromInstanceMethod"})
  @Override
  public void actionPerformed(final AnActionEvent e) {
    final Project project = IdeaUtilImpl.getProject(e.getDataContext());
    assert project != null;
    final Presentation presentation = e.getPresentation();

    // check a project is loaded
    if (isProjectNotLoaded(project, presentation)) {
      Messages.showWarningDialog("Project not loaded.", "FindBugs")// NON-NLS
      return;
View Full Code Here

TOP

Related Classes of com.intellij.openapi.actionSystem.Presentation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.