private void updateComponents() {
   boolean archetypesEnabled = myUseArchetypeCheckBox.isSelected();
   myAddArchetypeButton.setEnabled(archetypesEnabled);
   myArchetypesTree.setEnabled(archetypesEnabled);
   myArchetypesTree.setBackground(
       archetypesEnabled ? UIUtil.getListBackground() : UIUtil.getPanelBackground());
 }
    @Override
    protected void customizeCellRenderer(
        JList list, Object value, int index, boolean selected, boolean hasFocus) {
      setIcon(myListEntryIcon);
      if (myUseIdeaEditor) {
        int max = list.getModel().getSize();
        String indexString = String.valueOf(index + 1);
        int count = String.valueOf(max).length() - indexString.length();
        char[] spaces = new char[count];
        Arrays.fill(spaces, ' ');
        String prefix = indexString + new String(spaces) + "  ";
        append(prefix, SimpleTextAttributes.GRAYED_ATTRIBUTES);
      } else if (UIUtil.isUnderGTKLookAndFeel()) {
        // Fix GTK background
        Color background =
            selected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground();
        UIUtil.changeBackGround(this, background);
      }
      String text = ((Item) value).shortText;

      FontMetrics metrics = list.getFontMetrics(list.getFont());
      int charWidth = metrics.charWidth('m');
      int maxLength = list.getParent().getParent().getWidth() * 3 / charWidth / 2;
      text = StringUtil.first(text, maxLength, true); // do not paint long strings
      append(text, SimpleTextAttributes.REGULAR_ATTRIBUTES);
    }
  private void init(@NotNull ArrangementStandardSettingsManager settingsManager) {
    setLayout(new GridBagLayout());
    setBorder(IdeBorderFactory.createEmptyBorder(5));

    List<CompositeArrangementSettingsToken> tokens = settingsManager.getSupportedMatchingTokens();
    if (tokens != null) {
      for (CompositeArrangementSettingsToken token : tokens) {
        addToken(token);
      }
    }

    applyBackground(UIUtil.getListBackground());
  }
 public ArrangementEditorComponent(
     @NotNull ArrangementMatchingRulesControl list,
     int row,
     @NotNull ArrangementMatchingRuleEditor editor) {
   myList = list;
   myRow = row;
   myEditor = editor;
   JPanel borderPanel =
       new JPanel(new BorderLayout()) {
         @Override
         public String toString() {
           return "callout border panel for " + myEditor;
         }
       };
   borderPanel.setBackground(UIUtil.getListBackground());
   borderPanel.add(editor);
   CalloutBorder border = new CalloutBorder();
   borderPanel.setBorder(border);
   myBorderInsets = border.getBorderInsets(borderPanel);
   myComponent = new ArrangementAnimationPanel(borderPanel, true, false);
 }
  public CommitLegendPanel(InfoCalculator infoCalculator) {
    myInfoCalculator = infoCalculator;
    final Color background = UIUtil.getListBackground();
    myModifiedPanel.setBackground(background);
    myNewPanel.setBackground(background);
    myDeletedPanel.setBackground(background);
    if (UIUtil.isUnderDarcula()) {
      final Color color = UIUtil.getSeparatorColor();
      final TitledBorder border = new TitledBorder(new LineBorder(color, 1));
      myModifiedPanel.setBorder(border);
      myNewPanel.setBorder(border);
      myDeletedPanel.setBorder(border);
    }

    myModifiedLabel.setForeground(FileStatus.MODIFIED.getColor());
    myNewLabel.setForeground(FileStatus.ADDED.getColor());
    myDeletedLabel.setForeground(FileStatus.DELETED.getColor());

    boldLabel(myModifiedLabel, true);
    boldLabel(myNewLabel, true);
    boldLabel(myDeletedLabel, true);
  }
  @Override
  protected JComponent createCenterPanel() {
    final int selectionMode =
        myAllowMultipleSelections
            ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
            : ListSelectionModel.SINGLE_SELECTION;
    myList.setSelectionMode(selectionMode);
    if (myUseIdeaEditor) {
      EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
      myList.setFont(scheme.getFont(EditorFontType.PLAIN));
      Color fg =
          ObjectUtils.chooseNotNull(scheme.getDefaultForeground(), UIUtil.getListForeground());
      Color bg =
          ObjectUtils.chooseNotNull(scheme.getDefaultBackground(), UIUtil.getListBackground());
      myList.setForeground(fg);
      myList.setBackground(bg);
    }

    new DoubleClickListener() {
      @Override
      protected boolean onDoubleClick(MouseEvent e) {
        close(OK_EXIT_CODE);
        return true;
      }
    }.installOn(myList);

    myList.setCellRenderer(new MyListCellRenderer());
    myList.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
              int newSelectionIndex = -1;
              for (Object o : myList.getSelectedValues()) {
                int i = ((Item) o).index;
                removeContentAt(myAllContents.get(i));
                if (newSelectionIndex < 0) {
                  newSelectionIndex = i;
                }
              }

              rebuildListContent();
              if (myAllContents.isEmpty()) {
                close(CANCEL_EXIT_CODE);
                return;
              }
              newSelectionIndex = Math.min(newSelectionIndex, myAllContents.size() - 1);
              myList.setSelectedIndex(newSelectionIndex);
            } else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
              doOKAction();
            } else {
              final char aChar = e.getKeyChar();
              if (aChar >= '0' && aChar <= '9') {
                int idx = aChar == '0' ? 9 : aChar - '1';
                if (idx < myAllContents.size()) {
                  myList.setSelectedIndex(idx);
                  e.consume();
                  doOKAction();
                }
              }
            }
          }
        });

    mySplitter.setFirstComponent(
        ListWithFilter.wrap(
            myList,
            ScrollPaneFactory.createScrollPane(myList),
            new Function<Object, String>() {
              @Override
              public String fun(Object o) {
                return ((Item) o).longText;
              }
            }));
    mySplitter.setSecondComponent(new JPanel());
    rebuildListContent();

    ScrollingUtil.installActions(myList);
    ScrollingUtil.ensureSelectionExists(myList);
    updateViewerForSelection();
    myList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent e) {
            myUpdateAlarm.cancelAllRequests();
            myUpdateAlarm.addRequest(
                new Runnable() {
                  @Override
                  public void run() {
                    updateViewerForSelection();
                  }
                },
                100);
          }
        });

    mySplitter.setPreferredSize(JBUI.size(500, 500));

    SplitterProportionsData d = new SplitterProportionsDataImpl();
    d.externalizeToDimensionService(getClass().getName());
    d.restoreSplitterProportions(mySplitter);

    return mySplitter;
  }
  public ExternalSystemTasksPanel(
      @NotNull Project project,
      @NotNull ProjectSystemId externalSystemId,
      @NotNull NotificationGroup notificationGroup) {
    super(true);
    myExternalSystemId = externalSystemId;
    myNotificationGroup = notificationGroup;
    myProject = project;

    ExternalSystemManager<?, ?, ?, ?, ?> manager =
        ExternalSystemApiUtil.getManager(externalSystemId);
    assert manager != null;
    AbstractExternalSystemLocalSettings settings = manager.getLocalSettingsProvider().fun(project);

    ExternalSystemRecentTaskListModel recentTasksModel =
        new ExternalSystemRecentTaskListModel(externalSystemId, project);
    recentTasksModel.setTasks(settings.getRecentTasks());
    myRecentTasksList =
        new ExternalSystemRecentTasksList(recentTasksModel, externalSystemId, project) {
          @Override
          protected void processMouseEvent(MouseEvent e) {
            if (e.getClickCount() > 0) {
              mySelectedTaskProvider = myRecentTasksList;
              myAllTasksTree.getSelectionModel().clearSelection();
            }
            super.processMouseEvent(e);
          }
        };

    myAllTasksModel = new ExternalSystemTasksTreeModel(externalSystemId);
    myAllTasksTree =
        new ExternalSystemTasksTree(
            myAllTasksModel, settings.getExpandStates(), project, externalSystemId) {
          @Override
          protected void processMouseEvent(MouseEvent e) {
            if (e.getClickCount() > 0) {
              mySelectedTaskProvider = myAllTasksTree;
              myRecentTasksList.getSelectionModel().clearSelection();
            }
            super.processMouseEvent(e);
          }
        };
    final String actionIdToUseForDoubleClick =
        DefaultRunExecutor.getRunExecutorInstance().getContextActionId();
    myAllTasksTree.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() >= 2 && !e.isPopupTrigger()) {
              ExternalSystemUiUtil.executeAction(actionIdToUseForDoubleClick, e);
            }
          }
        });
    ExternalSystemUiUtil.apply(settings, myAllTasksModel);
    CustomizationUtil.installPopupHandler(
        myAllTasksTree, TREE_ACTIONS_GROUP_ID, TREE_CONTEXT_MENU_PLACE);

    ActionManager actionManager = ActionManager.getInstance();
    ActionGroup group = (ActionGroup) actionManager.getAction(TOOL_WINDOW_TOOLBAR_ACTIONS_GROUP_ID);
    ActionToolbar toolbar = actionManager.createActionToolbar(TOOL_WINDOW_PLACE, group, true);
    toolbar.setTargetComponent(this);
    setToolbar(toolbar.getComponent());

    JPanel content = new JPanel(new GridBagLayout());
    content.setOpaque(true);
    content.setBackground(UIUtil.getListBackground());
    JComponent recentTasksWithTitle =
        wrap(myRecentTasksList, ExternalSystemBundle.message("tasks.recent.title"));
    content.add(recentTasksWithTitle, ExternalSystemUiUtil.getFillLineConstraints(0));
    JBScrollPane scrollPane = new JBScrollPane(myAllTasksTree);
    scrollPane.setBorder(null);
    JComponent allTasksWithTitle =
        wrap(scrollPane, ExternalSystemBundle.message("tasks.all.title"));
    content.add(
        allTasksWithTitle, ExternalSystemUiUtil.getFillLineConstraints(0).weighty(1).fillCell());
    setContent(content);
  }