예제 #1
0
  private void setSourceRef(String refName) {
    String shortName = Repository.shortenRefName(refName);
    sourceNameLabel.setText(shortName);
    if (refName.startsWith(Constants.R_HEADS) || refName.startsWith(Constants.R_REMOTES))
      sourceIcon.setImage(UIIcons.getImage(resourceManager, UIIcons.BRANCH));
    else if (refName.startsWith(Constants.R_TAGS))
      sourceIcon.setImage(UIIcons.getImage(resourceManager, UIIcons.TAG));
    else sourceIcon.setImage(UIIcons.getImage(resourceManager, UIIcons.CHANGESET));

    sourceRefName = refName;

    suggestBranchName(refName);
    upstreamConfig = UpstreamConfig.getDefault(myRepository, refName);
    checkPage();
  }
예제 #2
0
  private void setSourceCommit(RevCommit commit) {
    sourceNameLabel.setText(commit.abbreviate(7).name());
    sourceIcon.setImage(UIIcons.getImage(resourceManager, UIIcons.CHANGESET));

    sourceRefName = commit.name();

    upstreamConfig = UpstreamConfig.NONE;
    checkPage();
  }
예제 #3
0
  @Override
  public void createControl(Composite parent) {
    Composite main = new Composite(parent, SWT.NONE);
    main.setLayout(new GridLayout(4, false));

    Label sourceLabel = new Label(main, SWT.NONE);
    sourceLabel.setText(UIText.CreateBranchPage_SourceLabel);
    sourceLabel.setToolTipText(UIText.CreateBranchPage_SourceTooltip);

    sourceIcon = new Label(main, SWT.NONE);
    sourceIcon.setImage(UIIcons.getImage(resourceManager, UIIcons.BRANCH));
    sourceIcon.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());

    sourceNameLabel = new Label(main, SWT.NONE);
    sourceNameLabel.setLayoutData(
        GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create());

    Button selectButton = new Button(main, SWT.NONE);
    selectButton.setText(UIText.CreateBranchPage_SourceSelectButton);
    selectButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            selectSource();
          }
        });
    UIUtils.setButtonLayoutData(selectButton);

    Label nameLabel = new Label(main, SWT.NONE);
    nameLabel.setText(UIText.CreateBranchPage_BranchNameLabel);
    nameLabel.setLayoutData(
        GridDataFactory.fillDefaults().span(1, 1).align(SWT.BEGINNING, SWT.CENTER).create());
    nameLabel.setToolTipText(UIText.CreateBranchPage_BranchNameToolTip);

    nameText = new Text(main, SWT.BORDER);
    // give focus to the nameText if label is activated using the mnemonic
    nameLabel.addTraverseListener(
        new TraverseListener() {
          @Override
          public void keyTraversed(TraverseEvent e) {
            nameText.setFocus();
          }
        });

    nameText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            nameIsSuggestion = false;
          }
        });
    // enable testing with SWTBot
    nameText.setData("org.eclipse.swtbot.widget.key", "BranchName"); // $NON-NLS-1$ //$NON-NLS-2$
    GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(nameText);

    upstreamConfigComponent = new UpstreamConfigComponent(main, SWT.NONE);
    GridDataFactory.fillDefaults()
        .grab(true, false)
        .span(4, 1)
        .applyTo(upstreamConfigComponent.getContainer());

    upstreamConfigComponent.addUpstreamConfigSelectionListener(
        new UpstreamConfigSelectionListener() {
          @Override
          public void upstreamConfigSelected(UpstreamConfig newUpstreamConfig) {
            upstreamConfig = newUpstreamConfig;
            checkPage();
          }
        });

    boolean isBare = myRepository.isBare();
    checkout = new Button(main, SWT.CHECK);
    checkout.setText(UIText.CreateBranchPage_CheckoutButton);
    // most of the time, we probably will check this out
    // unless we have a bare repository which doesn't allow
    // check out at all
    checkout.setSelection(!isBare);
    checkout.setEnabled(!isBare);
    checkout.setVisible(!isBare);
    GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(checkout);
    checkout.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            checkPage();
          }
        });

    Dialog.applyDialogFont(main);
    setControl(main);

    if (this.myBaseCommit != null) setSourceCommit(this.myBaseCommit);
    else if (myBaseRef != null) setSourceRef(myBaseRef);

    nameText.setFocus();
    // add the listener just now to avoid unneeded checkPage()
    nameText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            checkPage();
          }
        });
  }