Example usage for org.eclipse.jgit.lib ConfigConstants CONFIG_WORKFLOW_SECTION

List of usage examples for org.eclipse.jgit.lib ConfigConstants CONFIG_WORKFLOW_SECTION

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib ConfigConstants CONFIG_WORKFLOW_SECTION.

Prototype

String CONFIG_WORKFLOW_SECTION

To view the source code for org.eclipse.jgit.lib ConfigConstants CONFIG_WORKFLOW_SECTION.

Click Source Link

Document

The "workflow" section

Usage

From source file:org.eclipse.egit.ui.internal.dialogs.BranchSelectionAndEditDialog.java

License:Open Source License

/**
 * Creates button for creating a new branch.
 *
 * @param parent//from  w w  w. j  a  va2 s.  c  om
 * @return button
 */
protected Button createNewButton(Composite parent) {
    newButton = createButton(parent, NEW, UIText.BranchSelectionAndEditDialog_NewBranch, false);
    setButtonLayoutData(newButton);
    newButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            // try to read default source ref from git config
            // in the case that no base is selected in dialog
            String base = refNameFromDialog();
            if (base == null) {
                String sourceRef = repo.getConfig().getString(ConfigConstants.CONFIG_WORKFLOW_SECTION, null,
                        ConfigConstants.CONFIG_KEY_DEFBRANCHSTARTPOINT);
                try {
                    Ref ref = repo.findRef(sourceRef);
                    if (ref != null) {
                        base = ref.getName();
                    }
                } catch (IOException e1) {
                    // base = null;
                }
            }
            CreateBranchWizard wiz = new CreateBranchWizard(repo, base);
            if (new WizardDialog(getShell(), wiz).open() == Window.OK) {
                String newRefName = wiz.getNewBranchName();
                try {
                    branchTree.refresh();
                    markRef(Constants.R_HEADS + newRefName);
                    if (newRefName.equals(repo.getBranch()))
                        // close branch selection dialog when new branch was
                        // already checked out from new branch wizard
                        BranchSelectionAndEditDialog.this.okPressed();
                } catch (Throwable e1) {
                    reportError(e1, UIText.BranchSelectionAndEditDialog_ErrorCouldNotCreateNewRef, newRefName);
                }
            }
        }
    });
    return newButton;
}