コード例 #1
0
 private void updateEnabledItems() {
   if (myRbExisting.isSelected()) {
     myExistingListsCombo.setEnabled(true);
     UIUtil.setEnabled(myNewListPanel, false, true);
     myExistingListsCombo.requestFocus();
   } else {
     myExistingListsCombo.setEnabled(false);
     UIUtil.setEnabled(myNewListPanel, true, true);
     myNewListPanel.requestFocus();
   }
   if (myProject != null) {
     myNewListPanel.nameChangedImpl(myProject, null);
   }
 }
コード例 #2
0
  @Nullable
  public LocalChangeList getSelectedList(Project project) {
    ChangeListManager manager = ChangeListManager.getInstance(project);
    if (myRbNew.isSelected()) {
      String newText = myNewListPanel.getChangeListName();
      if (manager.findChangeList(newText) != null) {
        Messages.showErrorDialog(
            project,
            VcsBundle.message("changes.newchangelist.warning.already.exists.text", newText),
            VcsBundle.message("changes.newchangelist.warning.already.exists.title"));
        return null;
      }
    }
    final boolean existingSelected = myRbExisting.isSelected();
    VcsConfiguration.getInstance(myProject).PRESELECT_EXISTING_CHANGELIST = existingSelected;

    if (existingSelected) {
      return (LocalChangeList) myExistingListsCombo.getSelectedItem();
    } else {
      LocalChangeList changeList =
          manager.addChangeList(
              myNewListPanel.getChangeListName(), myNewListPanel.getDescription());
      myNewListPanel.changelistCreatedOrChanged(changeList);
      if (myNewListPanel.getMakeActiveCheckBox().isSelected()) {
        manager.setDefaultChangeList(changeList);
      }
      VcsConfiguration.getInstance(project).MAKE_NEW_CHANGELIST_ACTIVE =
          myNewListPanel.getMakeActiveCheckBox().isSelected();

      return changeList;
    }
  }
コード例 #3
0
  public void init() {
    myExistingListsCombo.setRenderer(
        new ColoredListCellRendererWrapper() {
          private final IssueLinkRenderer myLinkRenderer = new IssueLinkRenderer(myProject, this);

          @Override
          protected void doCustomize(
              JList list, Object value, int index, boolean selected, boolean hasFocus) {
            if (value instanceof LocalChangeList) {
              String name = ((LocalChangeList) value).getName();

              if (myExistingListsCombo.getWidth() == 0) {
                name = name.length() > 10 ? name.substring(0, 7) + " .." : name;
              } else {
                final FontMetrics fm = list.getFontMetrics(list.getFont());
                final int width = fm.stringWidth(name);
                final int listWidth = myExistingListsCombo.getWidth();
                if ((listWidth > 0) && (width > listWidth)) {
                  final String truncated =
                      CommittedChangeListRenderer.truncateDescription(
                          name, fm, listWidth - fm.stringWidth(" ..") - 7);
                  if (truncated.length() > 5) {
                    name = truncated + " ..";
                  }
                }
              }
              myLinkRenderer.appendTextWithLinks(
                  name,
                  ((LocalChangeList) value).isDefault()
                      ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES
                      : SimpleTextAttributes.REGULAR_ATTRIBUTES);
            }
          }
        });
    myNewListPanel.init(null);
    myRbNew.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            getPreferredFocusedComponent().requestFocusInWindow();
          }
        });
    final ComboboxSpeedSearch search = new ComboboxSpeedSearch(myExistingListsCombo);
    search.setComparator(new SpeedSearchComparator(true, false));
  }
コード例 #4
0
 public JComponent getPreferredFocusedComponent() {
   return myRbExisting.isSelected()
       ? myExistingListsCombo
       : myNewListPanel.getPreferredFocusedComponent();
 }
コード例 #5
0
 public void setDefaultName(String name) {
   if (!StringUtil.isEmptyOrSpaces(name)) {
     myNewListPanel.setChangeListName(name);
   }
 }