예제 #1
0
 private static Presentation wrapIcon(Presentation presentation) {
   Icon original = presentation.getIcon();
   CenteredIcon centered =
       new CenteredIcon(original != null ? original : DEFAULT_ICON, 40, 40, false);
   presentation.setIcon(centered);
   return presentation;
 }
  @Override
  public void update(@NotNull AnActionEvent e) {
    Presentation presentation = e.getPresentation();

    OpenInBrowserRequest result = BaseOpenInBrowserAction.doUpdate(e);
    if (result == null) {
      return;
    }

    String description = getTemplatePresentation().getDescription();
    if (HtmlUtil.isHtmlFile(result.getFile())) {
      description += " (hold Shift to open URL of local file)";
    }

    presentation.setText(getTemplatePresentation().getText());
    presentation.setDescription(description);

    WebBrowser browser = findUsingBrowser();
    if (browser != null) {
      presentation.setIcon(browser.getIcon());
    }

    if (ActionPlaces.isPopupPlace(e.getPlace())) {
      presentation.setVisible(presentation.isEnabled());
    }
  }
예제 #3
0
 protected void updateIcon(final Presentation presentation, final ConfigurationContext context) {
   final RunnerAndConfigurationSettingsImpl configuration = context.findExisting();
   if (configuration != null) {
     presentation.setIcon(configuration.getType().getIcon());
   } else {
     super.updateIcon(presentation, context);
   }
 }
 public ToggleSourcesStateAction(
     JTree tree, ContentEntryTreeEditor entryEditor, boolean editTestSources) {
   super(tree);
   myEntryTreeEditor = entryEditor;
   myEditTestSources = editTestSources;
   final Presentation templatePresentation = getTemplatePresentation();
   if (editTestSources) {
     templatePresentation.setText(ProjectBundle.message("module.toggle.test.sources.action"));
     templatePresentation.setDescription(
         ProjectBundle.message("module.toggle.test.sources.action.description"));
     templatePresentation.setIcon(IconSet.TEST_ROOT_FOLDER);
   } else {
     templatePresentation.setText(ProjectBundle.message("module.toggle.sources.action"));
     templatePresentation.setDescription(
         ProjectBundle.message("module.toggle.sources.action.description"));
     templatePresentation.setIcon(IconSet.SOURCE_ROOT_FOLDER);
   }
 }
 private static void setConfigurationIcon(
     final Presentation presentation,
     final RunnerAndConfigurationSettings settings,
     final Project project) {
   try {
     presentation.setIcon(RunManagerEx.getInstanceEx(project).getConfigurationIcon(settings));
   } catch (IndexNotReadyException ignored) {
   }
 }
예제 #6
0
 protected void updateIcon(final Presentation presentation, final ConfigurationContext context) {
   final List<RuntimeConfigurationProducer> producers =
       PreferedProducerFind.findPreferredProducers(context.getLocation(), context, true);
   if (producers != null
       && producers.size()
           == 1) { // hide fuzzy icon when multiple run configurations are possible
     presentation.setIcon(context.getConfiguration().getFactory().getIcon());
   }
 }
    public ExternalSystemTaskAction(Project project, String group, TaskData taskData) {
      myGroup = group;
      myTaskData = taskData;
      myId = getActionPrefix(project, taskData.getLinkedExternalProjectPath()) + taskData.getName();

      Presentation template = getTemplatePresentation();
      template.setText(myTaskData.getName() + " (" + group + ")", false);
      template.setIcon(ExternalSystemIcons.Task);
    }
 @Override
 public void update(final AnActionEvent e) {
   super.update(e);
   final Presentation presentation = e.getPresentation();
   presentation.setIcon(SvnIcons.ShowIntegratedFrom);
   presentation.setText(SvnBundle.message("committed.changes.action.enable.merge.highlighting"));
   presentation.setDescription(
       SvnBundle.message("committed.changes.action.enable.merge.highlighting.description.text"));
 }
예제 #9
0
  @Override
  public void update(final AnActionEvent event) {
    final Presentation presentation = event.getPresentation();
    String name = myEnvironment.getRunProfile().getName();
    ProcessHandler processHandler = myDescriptor.getProcessHandler();
    final boolean isRunning = processHandler != null && !processHandler.isProcessTerminated();

    presentation.setText(ExecutionBundle.message("rerun.configuration.action.name", name));
    presentation.setIcon(isRunning ? AllIcons.Actions.Restart : myExecutor.getIcon());
    presentation.setEnabled(isEnabled());
  }
예제 #10
0
 public AddNewRootAction(
     @NotNull SModel model, @NotNull SConcept concept, @Nullable Setter<SNode> newRootCallback) {
   myModel = model;
   myConcept = concept;
   myNewRootCallback = newRootCallback;
   setExecuteOutsideCommand(false);
   final Presentation tp = getTemplatePresentation();
   tp.setText(
       concept.getConceptAlias().isEmpty() ? concept.getName() : concept.getConceptAlias());
   tp.setIcon(IconManager.getIcon(concept));
 }
    protected AbstractAddGroup(String text, Icon icon) {
      super(text, true);

      final Presentation presentation = getTemplatePresentation();
      presentation.setIcon(icon);

      final Keymap active = KeymapManager.getInstance().getActiveKeymap();
      if (active != null) {
        final Shortcut[] shortcuts = active.getShortcuts("NewElement");
        setShortcutSet(new CustomShortcutSet(shortcuts));
      }
    }
    public SelectTargetAction(
        final Project project, final ExecutionTarget target, boolean selected) {
      myProject = project;
      myTarget = target;

      String name = target.getDisplayName();
      Presentation presentation = getTemplatePresentation();
      presentation.setText(name, false);
      presentation.setDescription("Select " + name);

      presentation.setIcon(selected ? CHECKED_ICON : EMPTY_ICON);
      presentation.setSelectedIcon(selected ? CHECKED_SELECTED_ICON : EMPTY_ICON);
    }
    @Override
    public void dragOutStarted(MouseEvent mouseEvent, TabInfo info) {
      final TabInfo previousSelection = info.getPreviousSelection();
      final Image img = myTabs.getComponentImage(info);
      info.setHidden(true);
      if (previousSelection != null) {
        myTabs.select(previousSelection, true);
      }

      myFile = (VirtualFile) info.getObject();
      Presentation presentation = new Presentation(info.getText());
      presentation.setIcon(info.getIcon());
      mySession =
          getDockManager()
              .createDragSession(
                  mouseEvent, new DockableEditor(img, myFile, presentation, myWindow));
    }
    public ExternalSystemRunConfigurationAction(
        Project project, RunnerAndConfigurationSettings configurationSettings) {
      myConfigurationSettings = configurationSettings;
      ExternalSystemRunConfiguration runConfiguration =
          (ExternalSystemRunConfiguration) configurationSettings.getConfiguration();
      systemId = runConfiguration.getSettings().getExternalSystemId();

      ExternalSystemUiAware uiAware = ExternalSystemUiUtil.getUiAware(systemId);
      myGroup =
          uiAware.getProjectRepresentationName(
              runConfiguration.getSettings().getExternalProjectPath(), null);
      String actionIdPrefix =
          getActionPrefix(project, runConfiguration.getSettings().getExternalProjectPath());
      myId = actionIdPrefix + configurationSettings.getName();

      Presentation template = getTemplatePresentation();
      template.setText(myConfigurationSettings.getName(), false);
      template.setIcon(runConfiguration.getIcon());
    }
 private static void updatePresentation(
     @Nullable ExecutionTarget target,
     @Nullable RunnerAndConfigurationSettings settings,
     @Nullable Project project,
     @NotNull 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);
     setConfigurationIcon(presentation, settings, project);
   } else {
     presentation.setText(""); // IDEA-21657
     presentation.setIcon(null);
   }
 }
예제 #16
0
  private void createCardForGroup(ActionGroup group, String cardId, final String parentId) {
    JPanel card = new JPanel(new BorderLayout());
    if (!USE_ICONS) {
      card.setOpaque(false);
    }

    JPanel withBottomFiller = new JPanel(new BorderLayout());
    if (!USE_ICONS) {
      withBottomFiller.setOpaque(true);
      withBottomFiller.setBackground(Color.white);
    }
    withBottomFiller.add(card, BorderLayout.NORTH);
    myContent.add(withBottomFiller, cardId);

    List<Button> buttons = buildButtons(group, cardId);
    if (parentId != null) {
      AnAction back =
          new AnAction(null, null, null) {
            @Override
            public void actionPerformed(AnActionEvent e) {
              myLayout.swipe(myContent, parentId, JBCardLayout.SwipeDirection.BACKWARD);
            }
          };

      Presentation p = new Presentation("Back");
      p.setIcon(AllIcons.Actions.Back);
      buttons.add(0, new Button(back, p));
    }

    JPanel buttonsPanel = new JPanel(new GridLayout(buttons.size(), 1, 5, 5));
    if (!USE_ICONS) {
      buttonsPanel.setOpaque(false);
    }
    buttonsPanel.setBorder(new EmptyBorder(15, 15, 15, 15));
    for (Button button : buttons) {
      buttonsPanel.add(button);
    }
    card.add(buttonsPanel, BorderLayout.CENTER);
  }
예제 #17
0
  private List<Button> buildButtons(ActionGroup group, String parentId) {
    AnAction[] actions = group.getChildren(null);

    List<Button> buttons = new ArrayList<Button>();

    for (AnAction action : actions) {
      Presentation presentation = action.getTemplatePresentation();
      if (!USE_ICONS) {
        presentation.setIcon(null);
      }
      if (action instanceof ActionGroup) {
        ActionGroup childGroup = (ActionGroup) action;
        if (childGroup.isPopup()) {
          final String id = String.valueOf(++nCards);
          createCardForGroup(childGroup, id, parentId);

          buttons.add(new Button(new ActivateCard(id), presentation));
        } else {
          buttons.addAll(buildButtons(childGroup, parentId));
        }
      } else {
        action.update(
            new AnActionEvent(
                null,
                DataManager.getInstance().getDataContext(this),
                ActionPlaces.WELCOME_SCREEN,
                presentation,
                ActionManager.getInstance(),
                0));
        if (presentation.isVisible()) {
          buttons.add(new Button(action, presentation));
        }
      }
    }
    return buttons;
  }
 public SaveTemporaryAction() {
   Presentation presentation = getTemplatePresentation();
   presentation.setIcon(AllIcons.Actions.Menu_saveall);
 }