private AnAction patch(final AnAction child) {
        if (child instanceof ActionGroup) {
          return new IconsFreeActionGroup((ActionGroup) child);
        }

        Presentation presentation = child.getTemplatePresentation();
        return new AnAction(presentation.getText(), presentation.getDescription(), null) {
          @Override
          public void actionPerformed(@NotNull AnActionEvent e) {
            child.actionPerformed(e);
            UsageTrigger.trigger("welcome.screen." + e.getActionManager().getId(child));
          }

          @Override
          public void update(@NotNull AnActionEvent e) {
            child.update(e);
            e.getPresentation().setIcon(null);
          }

          @Override
          public boolean isDumbAware() {
            return child.isDumbAware();
          }
        };
      }
 public void update(final AnActionEvent e) {
   final Presentation presentation = e.getPresentation();
   presentation.setEnabled(false);
   final PackageDependenciesNode leftNode = myLeftTree.getSelectedNode();
   final PackageDependenciesNode rightNode = myRightTree.getSelectedNode();
   if (leftNode != null && rightNode != null) {
     final PatternDialectProvider provider =
         PatternDialectProvider.getInstance(mySettings.SCOPE_TYPE);
     presentation.setEnabled(
         (provider.createPackageSet(leftNode, true) != null
                 || provider.createPackageSet(leftNode, false) != null)
             && (provider.createPackageSet(rightNode, true) != null
                 || provider.createPackageSet(rightNode, false) != null));
   }
 }
    private JComponent createActionPanel() {
      JPanel actions = new NonOpaquePanel();
      actions.setBorder(JBUI.Borders.emptyLeft(10));
      actions.setLayout(new BoxLayout(actions, BoxLayout.Y_AXIS));
      ActionManager actionManager = ActionManager.getInstance();
      ActionGroup quickStart =
          (ActionGroup) actionManager.getAction(IdeActions.GROUP_WELCOME_SCREEN_QUICKSTART);
      DefaultActionGroup group = new DefaultActionGroup();
      collectAllActions(group, quickStart);

      for (AnAction action : group.getChildren(null)) {
        JPanel button = new JPanel(new BorderLayout());
        button.setOpaque(false);
        button.setBorder(JBUI.Borders.empty(8, 20));
        AnActionEvent e =
            AnActionEvent.createFromAnAction(
                action,
                null,
                ActionPlaces.WELCOME_SCREEN,
                DataManager.getInstance().getDataContext(this));
        action.update(e);
        Presentation presentation = e.getPresentation();
        if (presentation.isVisible()) {
          String text = presentation.getText();
          if (text != null && text.endsWith("...")) {
            text = text.substring(0, text.length() - 3);
          }
          Icon icon = presentation.getIcon();
          if (icon.getIconHeight() != JBUI.scale(16) || icon.getIconWidth() != JBUI.scale(16)) {
            icon = JBUI.emptyIcon(16);
          }
          action = wrapGroups(action);
          ActionLink link = new ActionLink(text, icon, action, createUsageTracker(action));
          link.setPaintUnderline(false);
          link.setNormalColor(getLinkNormalColor());
          button.add(link);
          if (action instanceof WelcomePopupAction) {
            button.add(createArrow(link), BorderLayout.EAST);
          }
          installFocusable(button, action, KeyEvent.VK_UP, KeyEvent.VK_DOWN, true);
          actions.add(button);
        }
      }

      WelcomeScreenActionsPanel panel = new WelcomeScreenActionsPanel();
      panel.actions.add(actions);
      return panel.root;
    }
    private AnAction wrapGroups(AnAction action) {
      if (action instanceof ActionGroup && ((ActionGroup) action).isPopup()) {
        final Pair<JPanel, JBList> panel =
            createActionGroupPanel(
                (ActionGroup) action,
                mySlidingPanel,
                new Runnable() {
                  @Override
                  public void run() {
                    goBack();
                  }
                });
        final Runnable onDone =
            new Runnable() {
              @Override
              public void run() {
                final JBList list = panel.second;
                ScrollingUtil.ensureSelectionExists(list);
                final ListSelectionListener[] listeners =
                    ((DefaultListSelectionModel) list.getSelectionModel())
                        .getListeners(ListSelectionListener.class);

                // avoid component cashing. This helps in case of LaF change
                for (ListSelectionListener listener : listeners) {
                  listener.valueChanged(
                      new ListSelectionEvent(
                          list, list.getSelectedIndex(), list.getSelectedIndex(), true));
                }
                list.requestFocus();
              }
            };
        final String name = action.getClass().getName();
        mySlidingPanel.add(name, panel.first);
        final Presentation p = action.getTemplatePresentation();
        return new DumbAwareAction(p.getText(), p.getDescription(), p.getIcon()) {
          @Override
          public void actionPerformed(@NotNull AnActionEvent e) {
            mySlidingPanel
                .getLayout()
                .swipe(mySlidingPanel, name, JBCardLayout.SwipeDirection.FORWARD, onDone);
          }
        };
      }
      return action;
    }
 public void update(AnActionEvent e) {
   final Presentation presentation = e.getPresentation();
   presentation.setEnabled(false);
   final TreePath[] selectionPath = myTree.getSelectionPaths();
   if (selectionPath != null) {
     Object[] nodes =
         ContainerUtil.map2Array(
             selectionPath,
             new Function<TreePath, Object>() {
               @Override
               public Object fun(TreePath treePath) {
                 return treePath.getLastPathComponent();
               }
             });
     if (!myCondition.value(nodes)) return;
     presentation.setEnabled(true);
   }
 }
    private JComponent createSettingsAndDocs() {
      JPanel panel = new NonOpaquePanel(new BorderLayout());
      NonOpaquePanel toolbar = new NonOpaquePanel();
      AnAction register = ActionManager.getInstance().getAction("Register");
      boolean registeredVisible = false;
      if (register != null) {
        AnActionEvent e =
            AnActionEvent.createFromAnAction(
                register,
                null,
                ActionPlaces.WELCOME_SCREEN,
                DataManager.getInstance().getDataContext(this));
        register.update(e);
        Presentation presentation = e.getPresentation();
        if (presentation.isEnabled()) {
          ActionLink registerLink = new ActionLink("Register", register);
          registerLink.setNormalColor(getLinkNormalColor());
          NonOpaquePanel button = new NonOpaquePanel(new BorderLayout());
          button.setBorder(JBUI.Borders.empty(4, 10));
          button.add(registerLink);
          installFocusable(button, register, KeyEvent.VK_UP, KeyEvent.VK_RIGHT, true);
          NonOpaquePanel wrap = new NonOpaquePanel();
          wrap.setBorder(JBUI.Borders.emptyLeft(10));
          wrap.add(button);
          panel.add(wrap, BorderLayout.WEST);
          registeredVisible = true;
        }
      }

      toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.X_AXIS));
      toolbar.add(
          createActionLink(
              "Configure",
              IdeActions.GROUP_WELCOME_SCREEN_CONFIGURE,
              AllIcons.General.GearPlain,
              !registeredVisible));
      toolbar.add(createActionLink("Get Help", IdeActions.GROUP_WELCOME_SCREEN_DOC, null, false));

      panel.add(toolbar, BorderLayout.EAST);

      panel.setBorder(JBUI.Borders.empty(0, 0, 8, 11));
      return panel;
    }
 @Override
 public void update(AnActionEvent e) {
   super.update(e);
   Presentation presentation = e.getPresentation();
   presentation.setEnabled(myContainerNodes.size() > 1);
 }
 @Override
 public final void update(final AnActionEvent event) {
   final Presentation presentation = event.getPresentation();
   presentation.setEnabled(true);
 }
 @Override
 public void update(AnActionEvent e) {
   super.update(e);
   final Presentation presentation = e.getPresentation();
   presentation.setEnabled(allTargetsAreValid());
 }