Пример #1
0
  @Override
  public void create() {
    super.create();
    setTitle(UIText.BranchRenameDialog_Title);
    String oldName = branchToRename.getName();
    String prefix;
    if (oldName.startsWith(Constants.R_HEADS)) prefix = Constants.R_HEADS;
    else if (oldName.startsWith(Constants.R_REMOTES)) prefix = Constants.R_REMOTES;
    else prefix = null;
    String shortName = null;
    if (prefix != null) {
      shortName = Repository.shortenRefName(branchToRename.getName());
      setMessage(NLS.bind(UIText.BranchRenameDialog_Message, shortName));
    } else setErrorMessage(NLS.bind(UIText.BranchRenameDialog_WrongPrefixErrorMessage, oldName));

    if (shortName != null) {
      name.setText(shortName);
      name.setSelection(0, shortName.length());
    }

    final IInputValidator inputValidator =
        ValidationUtils.getRefNameInputValidator(repository, prefix, true);
    name.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            String error = inputValidator.isValid(name.getText());
            setErrorMessage(error);
            getButton(OK).setEnabled(error == null);
          }
        });

    getButton(OK).setEnabled(false);
  }
Пример #2
0
 /**
  * Constructs this page.
  *
  * <p>If a base branch is provided, the drop down will be selected accordingly
  *
  * @param repo the repository
  * @param baseCommit the commit to base the new branch on, may be null
  */
 public CreateBranchPage(Repository repo, RevCommit baseCommit) {
   super(CreateBranchPage.class.getName());
   this.myRepository = repo;
   this.myBaseRef = null;
   this.myBaseCommit = baseCommit;
   this.myValidator =
       ValidationUtils.getRefNameInputValidator(myRepository, Constants.R_HEADS, false);
   this.upstreamConfig = UpstreamConfig.NONE;
   setTitle(UIText.CreateBranchPage_Title);
   setMessage(UIText.CreateBranchPage_ChooseNameMessage);
 }
Пример #3
0
 /**
  * Constructs this page.
  *
  * <p>If a base branch is provided, the drop down will be selected accordingly
  *
  * @param repo the repository
  * @param baseRef the branch or tag to base the new branch on, may be null
  */
 public CreateBranchPage(Repository repo, Ref baseRef) {
   super(CreateBranchPage.class.getName());
   this.myRepository = repo;
   if (baseRef != null) this.myBaseRef = baseRef.getName();
   else this.myBaseRef = null;
   this.myBaseCommit = null;
   this.myValidator =
       ValidationUtils.getRefNameInputValidator(myRepository, Constants.R_HEADS, false);
   if (baseRef != null) this.upstreamConfig = UpstreamConfig.getDefault(repo, baseRef.getName());
   else this.upstreamConfig = UpstreamConfig.NONE;
   setTitle(UIText.CreateBranchPage_Title);
   setMessage(UIText.CreateBranchPage_ChooseBranchAndNameMessage);
 }