com.intellij.idea.ActionsBundle Java Examples

The following examples show how to use com.intellij.idea.ActionsBundle. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlutterProjectCreator.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private VirtualFile getLocationFromModel(@Nullable Project projectToClose, boolean saveLocation) {
  final File location = new File(FileUtil.toSystemDependentName(myModel.projectLocation().get()));
  if (!location.exists() && !location.mkdirs()) {
    String message = ActionsBundle.message("action.NewDirectoryProject.cannot.create.dir", location.getAbsolutePath());
    Messages.showErrorDialog(projectToClose, message, ActionsBundle.message("action.NewDirectoryProject.title"));
    return null;
  }
  final File baseFile = new File(location, myModel.projectName().get());
  //noinspection ResultOfMethodCallIgnored
  baseFile.mkdirs();
  final VirtualFile baseDir = ApplicationManager.getApplication().runWriteAction(
    (Computable<VirtualFile>)() -> LocalFileSystem.getInstance().refreshAndFindFileByIoFile(baseFile));
  if (baseDir == null) {
    FlutterUtils.warn(LOG, "Couldn't find '" + location + "' in VFS");
    return null;
  }
  if (saveLocation) {
    RecentProjectsManager.getInstance().setLastProjectCreationLocation(location.getPath());
  }
  return baseDir;
}
 
Example #2
Source File: FlutterProjectCreator.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private VirtualFile getLocationFromModel(@Nullable Project projectToClose, boolean saveLocation) {
  final File location = new File(FileUtil.toSystemDependentName(myModel.projectLocation().get()));
  if (!location.exists() && !location.mkdirs()) {
    String message = ActionsBundle.message("action.NewDirectoryProject.cannot.create.dir", location.getAbsolutePath());
    Messages.showErrorDialog(projectToClose, message, ActionsBundle.message("action.NewDirectoryProject.title"));
    return null;
  }
  final File baseFile = new File(location, myModel.projectName().get());
  //noinspection ResultOfMethodCallIgnored
  baseFile.mkdirs();
  final VirtualFile baseDir = ApplicationManager.getApplication().runWriteAction(
    (Computable<VirtualFile>)() -> LocalFileSystem.getInstance().refreshAndFindFileByIoFile(baseFile));
  if (baseDir == null) {
    FlutterUtils.warn(LOG, "Couldn't find '" + location + "' in VFS");
    return null;
  }
  if (saveLocation) {
    RecentProjectsManager.getInstance().setLastProjectCreationLocation(location.getPath());
  }
  return baseDir;
}
 
Example #3
Source File: VcsRootProblemNotifier.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void hyperlinkActivated(@Nonnull Notification notification, @Nonnull HyperlinkEvent event) {
  if (event.getDescription().equals("configure") && !myProject.isDisposed()) {
    ShowSettingsUtil.getInstance().showSettingsDialog(myProject, ActionsBundle.message("group.VcsGroup.text"));
    Collection<VcsRootError> errorsAfterPossibleFix = getInstance(myProject).scan();
    if (errorsAfterPossibleFix.isEmpty() && !notification.isExpired()) {
      notification.expire();
    }
  }
  else if (event.getDescription().equals("ignore")) {
    mySettings.addIgnoredUnregisteredRoots(ContainerUtil.map(myImportantUnregisteredRoots, PATH_FROM_ROOT_ERROR));
    notification.expire();
  }
  else if (event.getDescription().equals("add")) {
    List<VcsDirectoryMapping> mappings = myVcsManager.getDirectoryMappings();
    for (VcsRootError root : myImportantUnregisteredRoots) {
      mappings = VcsUtil.addMapping(mappings, root.getMapping(), root.getVcsKey().getName());
    }
    myVcsManager.setDirectoryMappings(mappings);
  }
}
 
Example #4
Source File: UndoManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private Pair<String, String> getUndoOrRedoActionNameAndDescription(FileEditor editor, boolean undo) {
  String desc = isUndoOrRedoAvailable(editor, undo) ? doFormatAvailableUndoRedoAction(editor, undo) : null;
  if (desc == null) desc = "";
  String shortActionName = StringUtil.first(desc, 30, true);

  if (desc.isEmpty()) {
    desc = undo
           ? ActionsBundle.message("action.undo.description.empty")
           : ActionsBundle.message("action.redo.description.empty");
  }

  return Pair.create((undo ? ActionsBundle.message("action.undo.text", shortActionName)
                           : ActionsBundle.message("action.redo.text", shortActionName)).trim(),
                     (undo ? ActionsBundle.message("action.undo.description", desc)
                           : ActionsBundle.message("action.redo.description", desc)).trim());
}
 
Example #5
Source File: DiffPanelImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private DiffRequest.ToolbarAddons createToolbar() {
  return new DiffRequest.ToolbarAddons() {
    public void customize(DiffToolbar toolbar) {
      ActionManager actionManager = ActionManager.getInstance();
      toolbar.addAction(actionManager.getAction("DiffPanel.Toolbar"));
      toolbar.addSeparator();
      toolbar.addAction(new ToggleAutoScrollAction());
      toolbar.addSeparator();
      toolbar.addAction(actionManager.getAction("ContextHelp"));
      toolbar.addAction(getEditSourceAction());
      toolbar.addSeparator();
      toolbar.addAction(new DiffMergeSettingsAction(Arrays.asList(getEditor1(), getEditor2()), ServiceManager.getService(myProject, DiffToolSettings.class)));
    }

    @Nonnull
    private AnAction getEditSourceAction() {
      AnAction editSourceAction = new EditSourceAction();
      editSourceAction.getTemplatePresentation().setIcon(AllIcons.Actions.EditSource);
      editSourceAction.getTemplatePresentation().setText(ActionsBundle.actionText("EditSource"));
      editSourceAction.getTemplatePresentation().setDescription(ActionsBundle.actionText("EditSource"));
      editSourceAction.registerCustomShortcutSet(CommonShortcuts.getEditSource(), myPanel, DiffPanelImpl.this);
      return editSourceAction;
    }
  };
}
 
Example #6
Source File: MaximizeToolWindowAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent e) {
  e.getPresentation().setEnabled(true);
  Project project = e.getProject();
  if (project == null || project.isDisposed()) {
    e.getPresentation().setEnabled(false);
    return;
  }
  ToolWindow toolWindow = e.getData(PlatformDataKeys.TOOL_WINDOW);
  if (toolWindow == null) {
    e.getPresentation().setEnabled(false);
    return;
  }
  ToolWindowManager manager = ToolWindowManager.getInstance(project);
  e.getPresentation().setText(manager.isMaximized(toolWindow) ?
                              ActionsBundle.message("action.ResizeToolWindowMaximize.text.alternative") :
                              ActionsBundle.message("action.ResizeToolWindowMaximize.text"));
}
 
Example #7
Source File: OptimizeImportsAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void updatePresentation(Presentation presentation, List<ImportOptimizer> importOptimizers) {
  Set<String> actionNames = new LinkedHashSet<>();
  Set<String> actionDescriptions = new LinkedHashSet<>();
  for (ImportOptimizer importOptimizer : importOptimizers) {
    actionNames.add(importOptimizer.getActionName());
    actionDescriptions.add(importOptimizer.getActionDescription());
  }

  if (!actionNames.isEmpty() && !actionDescriptions.isEmpty()) {
    presentation.setText(StringUtil.join(actionNames, " | "));
    presentation.setDescription(StringUtil.join(actionDescriptions, " | "));
  }
  else {
    presentation.setText(ActionsBundle.message("not.action.OptimizeImports.text"));
    presentation.setDescription(ActionsBundle.message("not.action.OptimizeImports.description"));
  }
}
 
Example #8
Source File: RunConfigurationsComboBoxAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void updatePresentation(@Nullable ExecutionTarget target, @Nullable RunnerAndConfigurationSettings settings, @Nullable Project project, @Nonnull Presentation presentation) {
  if (project != null && target != null && settings != null) {
    String name = settings.getName();
    if (target != DefaultExecutionTarget.INSTANCE) {
      name += " | " + target.getDisplayName();
    }
    else {
      if (!settings.canRunOn(target)) {
        name += " | Nothing to run on";
      }
    }
    presentation.setText(name, false);
    presentation.putClientProperty(ComboBoxButton.LIKE_BUTTON, null);
    setConfigurationIcon(presentation, settings, project);
  }
  else {
    presentation.setText("Add Configuration...");
    presentation.putClientProperty(ComboBoxButton.LIKE_BUTTON, (Runnable)() -> {
      ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_RUN_CONFIGURATIONS).actionPerformed(AnActionEvent.createFromDataContext("", null, DataManager.getInstance().getDataContext()));
    });
    presentation.setDescription(ActionsBundle.actionDescription(IdeActions.ACTION_EDIT_RUN_CONFIGURATIONS));
    presentation.setIcon(null);
  }
}
 
Example #9
Source File: CompileAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static String createPresentationText(String elementDescription) {
  StringBuilder buffer = new StringBuilder(40);
  buffer.append(ActionsBundle.actionText(IdeActions.ACTION_COMPILE)).append(" ");
  int length = elementDescription.length();
  if (length > 23) {
    if (StringUtil.startsWithChar(elementDescription, '\'')) {
      buffer.append("'");
    }
    buffer.append("...");
    buffer.append(elementDescription.substring(length - 20, length));
  }
  else {
    buffer.append(elementDescription);
  }
  return buffer.toString();
}
 
Example #10
Source File: ScratchFileActions.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  Project project = e.getProject();
  if (project == null) return;

  ScratchFileCreationHelper.Context context = createContext(e, project);
  Consumer<Language> consumer = l -> {
    context.language = l;
    ScratchFileCreationHelper.EXTENSION.forLanguage(context.language).prepareText(project, context, DataContext.EMPTY_CONTEXT);
    doCreateNewScratch(project, context);
  };
  if (context.language != null) {
    consumer.consume(context.language);
  }
  else {
    LRUPopupBuilder.forFileLanguages(project, ActionsBundle.message("action.NewScratchFile.text.with.new"), null, consumer).showCenteredInCurrentWindow(project);
  }
}
 
Example #11
Source File: MarkAsOriginalTypeAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  final VirtualFile[] selectedFiles = dataContext.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY);
  final Presentation presentation = e.getPresentation();
  final EnforcedPlainTextFileTypeManager typeManager = EnforcedPlainTextFileTypeManager.getInstance();
  presentation.setVisible(false);
  if (typeManager == null || selectedFiles == null || selectedFiles.length == 0) {
    return;
  }
  FileType originalType = null;
  for (VirtualFile file : selectedFiles) {
    if (typeManager.isMarkedAsPlainText(file)) {
      FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(file.getName());
      if (originalType == null) {
        originalType = fileType;
      }
      else if (fileType != originalType) {
        return;
      }
    }
    else {
      return;
    }
  }
  if (originalType == null) return;
  presentation.setVisible(true);
  presentation.setText(ActionsBundle.actionText("MarkAsOriginalTypeAction") + " " + originalType.getName());
  presentation.setIcon(originalType.getIcon());
}
 
Example #12
Source File: ShowQuickDocAtPinnedWindowFromTooltipAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ShowQuickDocAtPinnedWindowFromTooltipAction() {
  String className = getClass().getSimpleName();
  String actionId = className.substring(0, className.lastIndexOf("Action"));
  getTemplatePresentation().setText(ActionsBundle.actionText(actionId));
  getTemplatePresentation().setDescription(ActionsBundle.actionDescription(actionId));
  getTemplatePresentation().setIcon(AllIcons.General.Pin_tab);
}
 
Example #13
Source File: RestoreViewAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(final AnActionEvent e) {
  Presentation p = e.getPresentation();
  p.setText(ActionsBundle.message("action.Runner.RestoreView.text", myContent.getDisplayName()));
  p.setDescription(ActionsBundle.message("action.Runner.RestoreView.description"));
  p.setIcon(myContent.getIcon());
}
 
Example #14
Source File: HighlightUsagesAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  final Editor editor = e.getDataContext().getData(PlatformDataKeys.EDITOR);
  final Project project = e.getDataContext().getData(CommonDataKeys.PROJECT);
  if (editor == null || project == null) return;
  String commandName = getTemplatePresentation().getText();
  if (commandName == null) commandName = "";

  CommandProcessor.getInstance().executeCommand(
    project,
    new Runnable() {
      @Override
      @RequiredUIAccess
      public void run() {
        PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
        try {
          HighlightUsagesHandler.invoke(project, editor, psiFile);
        }
        catch (IndexNotReadyException ex) {
          DumbService.getInstance(project).showDumbModeNotification(ActionsBundle.message("action.HighlightUsagesInFile.not.ready"));
        }
      }
    },
    commandName,
    null
  );
}
 
Example #15
Source File: GotoTestOrCodeAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void update(AnActionEvent event) {
  Presentation p = event.getPresentation();
  if (TestFinderHelper.getFinders().length == 0) {
    p.setVisible(false);
    return;
  }
  p.setEnabled(false);
  Project project = event.getData(CommonDataKeys.PROJECT);
  Editor editor = event.getData(PlatformDataKeys.EDITOR);
  if (editor == null || project == null) return;

  PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(editor, project);
  if (psiFile == null) return;

  PsiElement element = GotoTestOrCodeHandler.getSelectedElement(editor, psiFile);

  if (TestFinderHelper.findSourceElement(element) == null) return;

  p.setEnabled(true);
  if (TestFinderHelper.isTest(element)) {
    p.setText(ActionsBundle.message("action.GotoTestSubject.text"));
    p.setDescription(ActionsBundle.message("action.GotoTestSubject.description"));
  } else {
    p.setText(ActionsBundle.message("action.GotoTest.text"));
    p.setDescription(ActionsBundle.message("action.GotoTest.description"));
  }
}
 
Example #16
Source File: EditSourceForDialogAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public EditSourceForDialogAction(@Nonnull Component component) {
  super();
  Presentation presentation = getTemplatePresentation();
  presentation.setText(ActionsBundle.actionText("EditSource"));
  presentation.setIcon(AllIcons.Actions.EditSource);
  presentation.setDescription(ActionsBundle.actionDescription("EditSource"));
  mySourceComponent = component;
}
 
Example #17
Source File: RemoveChangeListAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent e) {
  ChangeList[] changeLists = e.getData(VcsDataKeys.CHANGE_LISTS);
  boolean visible = canRemoveChangeLists(e.getProject(), changeLists);

  Presentation presentation = e.getPresentation();
  presentation.setEnabled(visible);
  presentation
          .setText(ActionsBundle.message("action.ChangesView.RemoveChangeList.text", changeLists != null && changeLists.length > 1 ? 1 : 0));
  if (e.getPlace().equals(ActionPlaces.CHANGES_VIEW_POPUP)) {
    presentation.setVisible(visible);
  }
  presentation.setDescription(ArrayUtil.isEmpty(e.getData(VcsDataKeys.CHANGES)) ? presentation.getText() : getDescription(changeLists));
}
 
Example #18
Source File: MoveChangesToAnotherListAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@javax.annotation.Nullable
private static LocalChangeList askTargetList(@Nonnull Project project, @Nonnull Collection<Change> changes) {
  ChangeListManagerImpl listManager = ChangeListManagerImpl.getInstanceImpl(project);
  List<LocalChangeList> preferredLists = getPreferredLists(listManager.getChangeListsCopy(), changes);
  List<LocalChangeList> listsForChooser =
          preferredLists.isEmpty() ? Collections.singletonList(listManager.getDefaultChangeList()) : preferredLists;
  ChangeListChooser chooser = new ChangeListChooser(project, listsForChooser, guessPreferredList(preferredLists),
                                                    ActionsBundle.message("action.ChangesView.Move.text"), null);
  chooser.show();

  return chooser.getSelectedList();
}
 
Example #19
Source File: ShowDiffFromAnnotation.java    From consulo with Apache License 2.0 5 votes vote down vote up
ShowDiffFromAnnotation(final FileAnnotation fileAnnotation, final AbstractVcs vcs, final VirtualFile file) {
  super(ActionsBundle.message("action.Diff.UpdatedFiles.text"),
        ActionsBundle.message("action.Diff.UpdatedFiles.description"),
        AllIcons.Actions.Diff);
  myFileAnnotation = fileAnnotation;
  myVcs = vcs;
  myFile = file;
  currentLine = -1;
  myEnabled = ProjectLevelVcsManager.getInstance(vcs.getProject()).getVcsFor(myFile) != null;
}
 
Example #20
Source File: MarkObjectAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(AnActionEvent event) {
  Project project = event.getData(CommonDataKeys.PROJECT);
  boolean enabled = false;
  Presentation presentation = event.getPresentation();
  boolean hidden = true;
  if (project != null) {
    for (DebuggerSupport support : DebuggerSupport.getDebuggerSupports()) {
      MarkObjectActionHandler handler = support.getMarkObjectHandler();
      hidden &= handler.isHidden(project, event);
      if (handler.isEnabled(project, event)) {
        enabled = true;
        String text;
        if (handler.isMarked(project, event)) {
          text = ActionsBundle.message("action.Debugger.MarkObject.unmark.text");
        }
        else {
          text = ActionsBundle.message("action.Debugger.MarkObject.text");
        }
        presentation.setText(text);
        break;
      }
    }
  }
  presentation.setVisible(!hidden && (!ActionPlaces.isPopupPlace(event.getPlace()) || enabled));
  presentation.setEnabled(enabled);
}
 
Example #21
Source File: ToggleReadOnlyAttributePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public String getTooltipText() {
  VirtualFile virtualFile = getCurrentFile();
  int writable = virtualFile == null || virtualFile.isWritable() ? 1 : 0;
  int readonly = writable == 1 ? 0 : 1;
  return ActionsBundle.message("action.ToggleReadOnlyAttribute.files", readonly, writable, 1, 0);
}
 
Example #22
Source File: DiffMergeSettingsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private DiffMergeToggleAction(@Nonnull String actionId, @Nonnull DiffMergeEditorSetting setting, @Nonnull Collection<Editor> editors,
                              @Nonnull DiffMergeSettings settings) {
  super(ActionsBundle.actionText(actionId), ActionsBundle.actionDescription(actionId), null);
  mySetting = setting;
  myEditors = editors;
  mySettings = settings;
}
 
Example #23
Source File: RecentProjectsGroup.java    From consulo with Apache License 2.0 5 votes vote down vote up
public RecentProjectsGroup() {
  super();

  final Presentation templatePresentation = getTemplatePresentation();
  // Let's make tile more macish
  if (SystemInfo.isMac) {
    templatePresentation.setText(ActionsBundle.message("group.reopen.mac.text"));
  } else {
    templatePresentation.setText(ActionsBundle.message("group.reopen.win.text"));
  }
}
 
Example #24
Source File: ScrollToTheEndToolbarAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ScrollToTheEndToolbarAction(@Nonnull final Editor editor) {
  super();
  myEditor = editor;
  final String message = ActionsBundle.message("action.EditorConsoleScrollToTheEnd.text");
  getTemplatePresentation().setDescription(message);
  getTemplatePresentation().setText(message);
  getTemplatePresentation().setIcon(AllIcons.RunConfigurations.Scroll_down);
}
 
Example #25
Source File: SearchWebAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void update(@Nonnull AnActionEvent e) {
  Presentation presentation = e.getPresentation();
  DataContext dataContext = e.getDataContext();
  CopyProvider provider = e.getData(PlatformDataKeys.COPY_PROVIDER);
  boolean available = provider != null && provider.isCopyEnabled(dataContext) && provider.isCopyVisible(dataContext);
  presentation.setEnabled(available);
  presentation.setVisible(available);

  WebSearchEngine engine = myWebSearchOptions.getEngine();

  presentation.setText(BundleBase.format(ActionsBundle.message("action.$SearchWeb.0.text", engine.getPresentableName())));
  presentation.setDescription(BundleBase.format(ActionsBundle.message("action.$SearchWeb.0.description", engine.getPresentableName())));
}
 
Example #26
Source File: ShowFilePathAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void update(@Nonnull AnActionEvent e) {
  boolean visible = !SystemInfo.isMac && isSupported();
  e.getPresentation().setVisible(visible);
  if (visible) {
    VirtualFile file = getFile(e);
    e.getPresentation().setEnabled(file != null);
    e.getPresentation().setText(ActionsBundle.message("action.ShowFilePath.tuned", file != null && file.isDirectory() ? 1 : 0));
  }
}
 
Example #27
Source File: UnmarkRootAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public UnmarkRootAction() {
  super(ActionsBundle.message("action.UnmarkRoot.text"), null, AllIcons.Actions.Delete, null);
}
 
Example #28
Source File: LocalizeHelper.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public String getText(String key) {
  return StringUtil.notNullize(ActionsBundle.message(key), key);
}
 
Example #29
Source File: CompileAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@RequiredUIAccess
public void update(@Nonnull AnActionEvent event) {
  super.update(event);
  Presentation presentation = event.getPresentation();
  if (!presentation.isEnabled()) {
    return;
  }
  DataContext dataContext = event.getDataContext();

  presentation.setText(ActionsBundle.actionText(IdeActions.ACTION_COMPILE));
  presentation.setVisible(true);

  Project project = dataContext.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    presentation.setEnabled(false);
    return;
  }

  final Module module = dataContext.getData(LangDataKeys.MODULE_CONTEXT);

  final VirtualFile[] files = getCompilableFiles(project, dataContext.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY));
  if (module == null && files.length == 0) {
    presentation.setEnabled(false);
    presentation.setVisible(!ActionPlaces.isPopupPlace(event.getPlace()));
    return;
  }

  String elementDescription = null;
  if (module != null) {
    elementDescription = CompilerBundle.message("action.compile.description.module", module.getName());
  }
  else {
    PsiPackage aPackage = null;
    if (files.length == 1) {
      final PsiDirectory directory = PsiManager.getInstance(project).findDirectory(files[0]);
      if (directory != null) {
        aPackage = PsiPackageManager.getInstance(project).findAnyPackage(directory);
      }
    }
    else {
      PsiElement element = dataContext.getData(LangDataKeys.PSI_ELEMENT);
      if (element instanceof PsiPackage) {
        aPackage = (PsiPackage)element;
      }
    }

    if (aPackage != null) {
      String name = aPackage.getQualifiedName();
      if (name.length() == 0) {
        //noinspection HardCodedStringLiteral
        name = "<default>";
      }
      elementDescription = "'" + name + "'";
    }
    else if (files.length == 1) {
      final VirtualFile file = files[0];
      FileType fileType = file.getFileType();
      if (CompilerManager.getInstance(project).isCompilableFileType(fileType) || isCompilableResourceFile(project, file)) {
        elementDescription = "'" + file.getName() + "'";
      }
      else {
        if (!ActionPlaces.MAIN_MENU.equals(event.getPlace())) {
          // the action should be invisible in popups for non-java files
          presentation.setEnabled(false);
          presentation.setVisible(false);
          return;
        }
      }
    }
    else {
      elementDescription = CompilerBundle.message("action.compile.description.selected.files");
    }
  }

  if (elementDescription == null) {
    presentation.setEnabled(false);
    return;
  }

  presentation.setText(createPresentationText(elementDescription), true);
  presentation.setEnabled(true);
}
 
Example #30
Source File: AbstractRerunFailedTestsAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public MyRunProfile(RunConfigurationBase configuration) {
  super(configuration.getProject(), configuration.getFactory(), ActionsBundle.message("action.RerunFailedTests.text"));
  myConfiguration = configuration;
}