@Override
 public void update(final AnActionEvent e) {
   e.getPresentation().setIcon(myTabs.isEditorTabs() ? myNewIcon : myIcon);
   e.getPresentation().setHoveredIcon(myTabs.isEditorTabs() ? myNewHoveredIcon : myHoveredIcon);
   e.getPresentation().setVisible(UISettings.getInstance().SHOW_CLOSE_BUTTON);
   e.getPresentation().setText("Close. Alt-click to close others.");
 }
Пример #2
0
  public void update(AnActionEvent e) {
    super.update(e);

    final Project project = e.getData(DataKeys.PROJECT);
    final VirtualFile file = e.getData(DataKeys.VIRTUAL_FILE);

    boolean visible =
        project != null
            && file != null
            && !file.isDirectory()
            && file.getFileType() == CppSupportLoader.CPP_FILETYPE
            && !Communicator.isHeaderFile(file);
    boolean enabled = visible;

    if (!visible) {
      visible = ActionPlaces.MAIN_MENU.equals(e.getPlace());
    }

    e.getPresentation().setEnabled(enabled);
    e.getPresentation().setVisible(visible);

    if (visible) {
      final String s =
          "Do c&ompile for " + (file != null ? file.getName() : "selected c/c++ fileToCompile");
      e.getPresentation().setText(s);
      e.getPresentation().setDescription(s);
    }
  }
 public void update(AnActionEvent e) {
   super.update(e);
   if (e != null) {
     if (e.getPresentation().isVisible() && findActions(e).length == 0) {
       e.getPresentation().setVisible(false);
     }
   }
 }
  public static boolean isFirstStart(final AnActionEvent event) {
    //noinspection HardCodedStringLiteral
    String key = "initalized";
    if (event.getPresentation().getClientProperty(key) != null) return false;

    event.getPresentation().putClientProperty(key, key);
    return true;
  }
Пример #5
0
 public void update(AnActionEvent e) {
   boolean active = getHandler(e) != null;
   if (ActionPlaces.isPopupPlace(e.getPlace())) {
     e.getPresentation().setVisible(active);
   } else {
     e.getPresentation().setEnabled(active);
   }
 }
 @Override
 public void update(AnActionEvent e) {
   if (mySession != null) {
     e.getPresentation().setEnabled(false);
   } else {
     e.getPresentation().setEnabled(true);
   }
 }
 public void update(AnActionEvent e) {
   if (!running) {
     e.getPresentation().setEnabled(true);
     e.getPresentation().setIcon(RESOLVEIcons.CHECKMARK);
   } else {
     e.getPresentation().setEnabled(false);
   }
 }
Пример #8
0
  public void update(final AnActionEvent e) {
    final FileGroupInfo fileGroupInfo = new FileGroupInfo();

    myHelperAction.setFileIterationListener(fileGroupInfo);
    myHelperAction.update(e);

    myGetterStub.setDelegate(fileGroupInfo);

    if ((e.getPresentation().isEnabled())) {
      removeAll();
      if (myHelperAction.allAreIgnored()) {
        final DataContext dataContext = e.getDataContext();
        final Project project = CommonDataKeys.PROJECT.getData(dataContext);
        SvnVcs vcs = SvnVcs.getInstance(project);

        final Ref<Boolean> filesOk = new Ref<Boolean>(Boolean.FALSE);
        final Ref<Boolean> extensionOk = new Ref<Boolean>(Boolean.FALSE);

        // virtual files parameter is not used -> can pass null
        SvnPropertyService.doCheckIgnoreProperty(
            vcs,
            project,
            null,
            fileGroupInfo,
            fileGroupInfo.getExtensionMask(),
            filesOk,
            extensionOk);

        if (Boolean.TRUE.equals(filesOk.get())) {
          myRemoveExactAction.setActionText(
              fileGroupInfo.oneFileSelected()
                  ? fileGroupInfo.getFileName()
                  : SvnBundle.message("action.Subversion.UndoIgnore.text"));
          add(myRemoveExactAction);
        }

        if (Boolean.TRUE.equals(extensionOk.get())) {
          myRemoveExtensionAction.setActionText(fileGroupInfo.getExtensionMask());
          add(myRemoveExtensionAction);
        }

        e.getPresentation().setText(SvnBundle.message("group.RevertIgnoreChoicesGroup.text"));
      } else if (myHelperAction.allCanBeIgnored()) {
        final String ignoreExactlyName =
            (fileGroupInfo.oneFileSelected())
                ? fileGroupInfo.getFileName()
                : SvnBundle.message("action.Subversion.Ignore.ExactMatch.text");
        myAddExactAction.setActionText(ignoreExactlyName);
        add(myAddExactAction);
        if (fileGroupInfo.sameExtension()) {
          myAddExtensionAction.setActionText(fileGroupInfo.getExtensionMask());
          add(myAddExtensionAction);
        }
        e.getPresentation().setText(SvnBundle.message("group.IgnoreChoicesGroup.text"));
      }
    }
  }
 @Override
 public void update(AnActionEvent e) {
   super.update(e);
   e.getPresentation().setVisible(!UpdateSettings.getInstance().myPluginHosts.isEmpty());
   String repository = ((AvailablePluginsTableModel) pluginsModel).getRepository();
   if (repository.length() > LENGTH) {
     repository = repository.substring(0, LENGTH) + "...";
   }
   e.getPresentation().setText("Repository: " + repository);
 }
 @Override
 public void update(AnActionEvent e) {
   // e.getPresentation()
   if (pl.vcIsProved.containsKey(vcNum) && pl.vcIsProved.get(vcNum)) {
     e.getPresentation().setIcon(RESOLVEIcons.PROVED);
     isProved = true;
   } else {
     e.getPresentation().setIcon(RESOLVEIcons.NOT_PROVED);
   }
 }
Пример #11
0
 @Override
 public void update(AnActionEvent e) {
   final ToolWindow window = getWindow(e);
   e.getPresentation()
       .setEnabled(window != null && window.getContentManager().getContentCount() > 1);
   e.getPresentation()
       .setText(
           window == null || window.getContentUiType() == ToolWindowContentUiType.TABBED
               ? "Show List of Tabs"
               : "Show List of Views");
 }
Пример #12
0
    @Override
    public void update(AnActionEvent e) {
      e.getPresentation().setEnabled(!myTable.isEditing() && myTable.getSelectedRow() >= 0);
      e.getPresentation().setText("Revert to Default");
      e.getPresentation().setIcon(IconLoader.getIcon("/general/remove.png"));

      if (e.getPresentation().isEnabled()) {
        final RegistryValue rv = myModel.getRegistryValue(myTable.getSelectedRow());
        e.getPresentation().setEnabled(rv.isChangedFromDefault());
      }
    }
Пример #13
0
  @Override
  public void update(final AnActionEvent e) {
    if (!e.getPresentation().isVisible()) {
      return;
    }
    final DataContext dataContext = e.getDataContext();
    final Presentation presentation = e.getPresentation();

    final boolean enabled = isAvailable(dataContext);

    presentation.setVisible(enabled);
    presentation.setEnabled(enabled);
  }
 public void update(AnActionEvent e) {
   DataContext dataContext = e.getDataContext();
   Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
   boolean enabled =
       (editor != null && FileDocumentManager.getInstance().getFile(editor.getDocument()) != null)
           || getElementToCopy(editor, dataContext) != null;
   e.getPresentation().setEnabled(enabled);
   if (ActionPlaces.isPopupPlace(e.getPlace())) {
     e.getPresentation().setVisible(enabled);
   } else {
     e.getPresentation().setVisible(true);
   }
 }
 public void update(AnActionEvent e) {
   Module module = LangDataKeys.MODULE.getData(e.getDataContext());
   if (module == null) {
     e.getPresentation().setEnabledAndVisible(false);
   } else {
     VirtualFile selectedFile = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
     e.getPresentation()
         .setEnabledAndVisible(
             PluginUtil.isModuleRoot(selectedFile, module)
                     && AzureModuleType.AZURE_MODULE.equals(
                         module.getOptionValue(Module.ELEMENT_TYPE))
                 || PluginUtil.isRoleFolder(selectedFile, module) /* ||
                   ModuleTypeId.JAVA_MODULE.equals(module.getOptionValue(Module.ELEMENT_TYPE))*/);
   }
 }
Пример #16
0
  // Async update
  @Override
  public final void update(AnActionEvent e) {
    final T data = prepareDataFromContext(e);
    final Presentation originalPresentation = e.getPresentation();
    if (!forceSyncUpdate(e) && isDumbAware()) {
      final Presentation realPresentation = (Presentation) originalPresentation.clone();
      ourUpdaterService.submit(
          new Runnable() {
            @Override
            public void run() {
              performUpdate(realPresentation, data);
              SwingUtilities.invokeLater(
                  new Runnable() {
                    @Override
                    public void run() {
                      if (originalPresentation.isVisible() != realPresentation.isVisible()) {
                        LOG.error(
                            "Async update is not supported for actions that change their visibility."
                                + "Either stop extending AsyncUpdateAction or override forceSyncUpdate() to return true."
                                + "Action class is: "
                                + AsyncUpdateAction.this.getClass().getName());
                      }
                      originalPresentation.copyFrom(realPresentation);
                    }
                  });
            }
          });

      originalPresentation.setVisible(true);
      originalPresentation.setEnabled(false);
    } else {
      performUpdate(originalPresentation, data);
    }
  }
 @Override
 public void update(@NotNull AnActionEvent e) {
   super.update(e);
   if (SystemInfo.isMac) {
     e.getPresentation().setEnabledAndVisible(false);
   }
 }
 @Override
 public void update(@NotNull AnActionEvent e) {
   myHadSeveralContents =
       myHadSeveralContents || myToolWindow.getContentManager().getContentCount() > 1;
   super.update(e);
   e.getPresentation().setVisible(myHadSeveralContents);
 }
Пример #19
0
 @Override
 public void update(final AnActionEvent e) {
   e.getPresentation()
       .setEnabled(
           getEditorSearchComponent().hasMatches()
               && !StringUtil.isEmpty(myTextField.get().getText()));
 }
 @Override
 public void update(AnActionEvent e) {
   final Presentation presentation = e.getPresentation();
   presentation.setVisible(false);
   final DataContext dataContext = e.getDataContext();
   final Project project = CommonDataKeys.PROJECT.getData(dataContext);
   if (project != null) {
     final RunConfiguration configuration = RunConfiguration.DATA_KEY.getData(dataContext);
     if (isPatternBasedConfiguration(configuration)) {
       final AbstractTestProxy testProxy = AbstractTestProxy.DATA_KEY.getData(dataContext);
       if (testProxy != null) {
         final Location location =
             testProxy.getLocation(
                 project, ((T) configuration).getConfigurationModule().getSearchScope());
         if (location != null) {
           final PsiElement psiElement = location.getPsiElement();
           if (psiElement instanceof PsiClass
               && getPattern((T) configuration)
                   .contains(((PsiClass) psiElement).getQualifiedName())) {
             presentation.setVisible(true);
           }
         }
       }
     }
   }
 }
  public void update(final AnActionEvent event) {
    super.update(event);

    final Presentation presentation = event.getPresentation();
    final DataContext context = event.getDataContext();
    Module module = (Module) context.getData(LangDataKeys.MODULE.getName());
    PsiFile currentFile = (PsiFile) context.getData(LangDataKeys.PSI_FILE.getName());
    Editor editor = (Editor) context.getData(PlatformDataKeys.EDITOR.getName());
    // VirtualFile currentFile = (VirtualFile)
    // context.getData(PlatformDataKeys.VIRTUAL_FILE.getName());
    if (currentFile != null && editor != null) {
      boolean isSSFile =
          currentFile
              .getFileType()
              .getDefaultExtension()
              .equals(SilverStripeFileType.DEFAULT_EXTENSION);
      SelectionModel selectionModel = editor.getSelectionModel();
      String selectedText = selectionModel.getSelectedText();
      this.selectedText = selectedText;
      this.selectonModel = selectionModel;
      this.editor = editor;
      this.currentFile = currentFile;
      if (selectedText == null) {
        presentation.setEnabled(false);
      }
      if (!isSSFile) {
        presentation.setEnabled(false);
        presentation.setVisible(false);
      }
    } else {
      presentation.setEnabled(false);
      presentation.setVisible(false);
    }
  }
  @Override
  public void actionPerformed(AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    DataContext dataContext = event.getDataContext();
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
    if (project == null || editor == null) {
      presentation.setEnabled(false);
      return;
    }

    PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
    if (file == null || file.getVirtualFile() == null) {
      presentation.setEnabled(false);
      return;
    }

    boolean hasSelection = editor.getSelectionModel().hasSelection();
    LayoutCodeDialog dialog = new LayoutCodeDialog(project, file, hasSelection, HELP_ID);
    dialog.show();

    if (dialog.isOK()) {
      new FileInEditorProcessor(file, editor, dialog.getRunOptions()).processCode();
    }
  }
Пример #23
0
  public final void update(final AnActionEvent e) {
    super.update(e);

    ActionPlace place = e.getData(MPSDataKeys.PLACE);

    if (e.getInputEvent() instanceof KeyEvent) {
      if (!getPlaces().contains(null)) {
        if (!getPlaces().contains(place)) {
          disable(e.getPresentation());
          return;
        }
      }
    }

    // TODO rewrite! do not start read action in EDT directly (to avoid UI freeze)
    ModelAccess.instance()
        .runReadAction(
            new Runnable() {
              public void run() {
                if (myDisableOnNoProject && e.getData(PlatformDataKeys.PROJECT) == null) {
                  disable(e.getPresentation());
                  return;
                }
                THashMap<String, Object> params = new THashMap<String, Object>();
                if (!collectActionData(e, params)) {
                  disable(e.getPresentation());
                  return;
                }
                doUpdate(e, params);
              }
            });
  }
  @Override
  public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();

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

    final DataContext dataContext = e.getDataContext();
    Editor editor = getEditor(dataContext, project, true);
    if (editor == null) {
      presentation.setEnabled(false);
      return;
    }

    final PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project);
    if (file == null) {
      presentation.setEnabled(false);
      return;
    }

    update(presentation, project, editor, file, dataContext, e.getPlace());
  }
    @Override
    public void update(@NotNull AnActionEvent e) {
      if (!ActionPlaces.DIFF_TOOLBAR.equals(e.getPlace())) {
        e.getPresentation().setEnabled(true);
        return;
      }

      PrevNextDifferenceIterable iterable =
          DiffDataKeys.PREV_NEXT_DIFFERENCE_ITERABLE.getData(e.getDataContext());
      if (iterable != null && iterable.canGoPrev()) {
        e.getPresentation().setEnabled(true);
        return;
      }

      e.getPresentation().setEnabled(false);
    }
  @Override
  public void update(@NotNull AnActionEvent e) {
    super.update(e);

    Presentation presentation = e.getPresentation();
    DataContext context = e.getDataContext();
    EditorWindow window = getEditorWindow(context);
    if (window == null || window.getOwner().isPreview()) {
      presentation.setEnabledAndVisible(false);
    } else {
      if (getFile(context) != null) {
        presentation.setEnabledAndVisible(true);
      } else {
        Content content = getContent(context);
        presentation.setEnabledAndVisible(content != null && content.isPinnable());
      }
    }

    if (ActionPlaces.EDITOR_TAB_POPUP.equals(e.getPlace())
        || ViewContext.CELL_POPUP_PLACE.equals(e.getPlace())) {
      presentation.setText(
          isSelected(e)
              ? IdeBundle.message("action.unpin.tab")
              : IdeBundle.message("action.pin.tab"));
    } else {
      presentation.setText(
          isSelected(e)
              ? IdeBundle.message("action.unpin.active.tab")
              : IdeBundle.message("action.pin.active.tab"));
    }
  }
 public void update(AnActionEvent e) {
   boolean enabled = true;
   for (DependenciesBuilder builder : myBuilders) {
     enabled &= builder.getScope().isValid();
   }
   e.getPresentation().setEnabled(enabled);
 }
    @Override
    public final void update(final AnActionEvent event) {
      final Presentation presentation = event.getPresentation();

      final DataContext dataContext = event.getDataContext();
      final HierarchyBrowserBaseEx browser =
          (HierarchyBrowserBaseEx) dataContext.getData(myBrowserDataKey);
      if (browser == null) {
        presentation.setVisible(false);
        presentation.setEnabled(false);
        return;
      }

      presentation.setVisible(true);

      final PsiElement selectedElement = browser.getSelectedElement();
      if (selectedElement == null || !browser.isApplicableElement(selectedElement)) {
        presentation.setEnabled(false);
        presentation.setVisible(false);
        return;
      }

      presentation.setEnabled(isEnabled(browser, selectedElement));
      String nonDefaultText = getNonDefaultText(browser, selectedElement);
      if (nonDefaultText != null) {
        presentation.setText(nonDefaultText);
      }
    }
 public void update(final AnActionEvent e) {
   super.update(e);
   final PatternDialectProvider provider =
       PatternDialectProvider.getInstance(DependencyUISettings.getInstance().SCOPE_TYPE);
   e.getPresentation().setText(provider.getDisplayName());
   e.getPresentation().setIcon(provider.getIcon());
 }
 @Override
 public void update(AnActionEvent e) {
   super.update(e);
   if (myFilter != null) {
     e.getPresentation().setEnabled(!myFilter.isEmpty());
   }
 }