use of org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode in project egit by eclipse.
the class BranchConfigurationDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite main = new Composite(parent, SWT.NONE);
main.setLayout(new GridLayout(2, false));
GridDataFactory.fillDefaults().grab(true, true).applyTo(main);
Label remoteLabel = new Label(main, SWT.NONE);
remoteLabel.setText(UIText.BranchConfigurationDialog_RemoteLabel);
remoteText = new Combo(main, SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, false).applyTo(remoteText);
Label branchLabel = new Label(main, SWT.NONE);
branchLabel.setText(UIText.BranchConfigurationDialog_UpstreamBranchLabel);
branchText = new Combo(main, SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, false).applyTo(branchText);
// TODO do we have a constant somewhere?
// $NON-NLS-1$
remoteText.add(".");
for (String remote : myConfig.getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION)) remoteText.add(remote);
remoteText.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateBranchItems();
}
});
rebase = new BranchRebaseModeCombo(main);
BranchRebaseMode rebaseMode = PullCommand.getRebaseMode(myBranchName, myConfig);
rebase.setRebaseMode(rebaseMode);
GridDataFactory.fillDefaults().grab(true, false).align(SWT.BEGINNING, SWT.CENTER).applyTo(rebase.getViewer().getCombo());
String branch = myConfig.getString(ConfigConstants.CONFIG_BRANCH_SECTION, myBranchName, ConfigConstants.CONFIG_KEY_MERGE);
if (branch == null)
// $NON-NLS-1$
branch = "";
branchText.setText(branch);
String remote = myConfig.getString(ConfigConstants.CONFIG_BRANCH_SECTION, myBranchName, ConfigConstants.CONFIG_KEY_REMOTE);
if (remote == null)
// $NON-NLS-1$
remote = "";
remoteText.setText(remote);
updateBranchItems();
applyDialogFont(main);
return main;
}
use of org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode in project egit by eclipse.
the class RebaseTargetSelectionDialog method createCustomArea.
@Override
protected void createCustomArea(Composite parent) {
final Button interactiveButton = new Button(parent, SWT.CHECK);
interactiveButton.setText(UIText.RebaseTargetSelectionDialog_InteractiveButton);
interactiveButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
interactive = interactiveButton.getSelection();
}
});
final Button preserveMergesButton = new Button(parent, SWT.CHECK);
preserveMergesButton.setText(UIText.RebaseTargetSelectionDialog_PreserveMergesButton);
preserveMergesButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
preserveMerges = preserveMergesButton.getSelection();
}
});
String branchName = getCurrentBranch();
if (branchName == null) {
return;
}
Config cfg = repo.getConfig();
BranchRebaseMode rebase = cfg.getEnum(BranchRebaseMode.values(), ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_REBASE, BranchRebaseMode.NONE);
switch(rebase) {
case PRESERVE:
preserveMergesButton.setSelection(true);
preserveMerges = true;
break;
case INTERACTIVE:
interactiveButton.setSelection(true);
interactive = true;
break;
default:
break;
}
}
use of org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode in project egit by eclipse.
the class PushBranchPage method createControl.
@Override
public void createControl(Composite parent) {
parent.addDisposeListener(event -> {
for (CancelableFuture<Collection<Ref>> l : refs.values()) {
l.cancel(CancelableFuture.CancelMode.INTERRUPT);
}
refs.clear();
});
try {
this.remoteConfigs = RemoteConfig.getAllRemoteConfigs(repository.getConfig());
Collections.sort(remoteConfigs, new Comparator<RemoteConfig>() {
@Override
public int compare(RemoteConfig first, RemoteConfig second) {
return String.CASE_INSENSITIVE_ORDER.compare(first.getName(), second.getName());
}
});
} catch (URISyntaxException e) {
this.remoteConfigs = new ArrayList<>();
handleError(e);
}
Composite main = new Composite(parent, SWT.NONE);
main.setLayout(GridLayoutFactory.swtDefaults().create());
Composite inputPanel = new Composite(main, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, false).applyTo(inputPanel);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(inputPanel);
Label sourceLabel = new Label(inputPanel, SWT.NONE);
sourceLabel.setText(UIText.PushBranchPage_Source);
Composite sourceComposite = new Composite(inputPanel, SWT.NONE);
sourceComposite.setLayoutData(GridDataFactory.fillDefaults().indent(UIUtils.getControlIndent(), 0).create());
RowLayout rowLayout = RowLayoutFactory.fillDefaults().create();
rowLayout.center = true;
sourceComposite.setLayout(rowLayout);
if (this.ref != null) {
Image branchIcon = UIIcons.BRANCH.createImage();
this.disposables.add(branchIcon);
Label branchIconLabel = new Label(sourceComposite, SWT.NONE);
branchIconLabel.setLayoutData(new RowData(branchIcon.getBounds().width, branchIcon.getBounds().height));
branchIconLabel.setImage(branchIcon);
Label localBranchLabel = new Label(sourceComposite, SWT.NONE);
localBranchLabel.setText(Repository.shortenRefName(this.ref.getName()));
Label spacer = new Label(sourceComposite, SWT.NONE);
spacer.setLayoutData(new RowData(3, SWT.DEFAULT));
}
Image commitIcon = UIIcons.CHANGESET.createImage();
this.disposables.add(commitIcon);
Label commitIconLabel = new Label(sourceComposite, SWT.NONE);
commitIconLabel.setImage(commitIcon);
commitIconLabel.setLayoutData(new RowData(commitIcon.getBounds().width, commitIcon.getBounds().height));
Label commit = new Label(sourceComposite, SWT.NONE);
StringBuilder commitBuilder = new StringBuilder(this.commitToPush.abbreviate(7).name());
StringBuilder commitTooltipBuilder = new StringBuilder(this.commitToPush.getName());
try (RevWalk revWalk = new RevWalk(repository)) {
RevCommit revCommit = revWalk.parseCommit(this.commitToPush);
// $NON-NLS-1$
commitBuilder.append(" ");
commitBuilder.append(Utils.shortenText(revCommit.getShortMessage(), MAX_SHORTCOMMIT_MESSAGE_LENGTH));
// $NON-NLS-1$
commitTooltipBuilder.append("\n\n");
commitTooltipBuilder.append(revCommit.getFullMessage());
} catch (IOException ex) {
commitBuilder.append(UIText.PushBranchPage_CannotAccessCommitDescription);
commitTooltipBuilder.append(ex.getMessage());
Activator.handleError(ex.getLocalizedMessage(), ex, false);
}
commit.setText(commitBuilder.toString());
commit.setToolTipText(commitTooltipBuilder.toString());
Label destinationLabel = new Label(inputPanel, SWT.NONE);
destinationLabel.setText(UIText.PushBranchPage_Destination);
GridDataFactory.fillDefaults().applyTo(destinationLabel);
Composite remoteGroup = new Composite(inputPanel, SWT.NONE);
remoteGroup.setLayoutData(GridDataFactory.fillDefaults().indent(UIUtils.getControlIndent(), 0).create());
remoteGroup.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).create());
Label remoteLabel = new Label(remoteGroup, SWT.NONE);
remoteLabel.setText(UIText.PushBranchPage_RemoteLabel);
// Use full width in case "New Remote..." button is not shown
int remoteSelectionSpan = showNewRemoteButton ? 1 : 2;
remoteSelectionCombo = new RemoteSelectionCombo(remoteGroup, SWT.NONE, SelectionType.PUSH);
GridDataFactory.fillDefaults().grab(true, false).span(remoteSelectionSpan, 1).applyTo(remoteSelectionCombo);
setRemoteConfigs();
remoteSelectionCombo.addRemoteSelectionListener(new IRemoteSelectionListener() {
@Override
public void remoteSelected(RemoteConfig rc) {
remoteConfig = rc;
setRefAssist(rc);
checkPage();
}
});
if (showNewRemoteButton) {
Button newRemoteButton = new Button(remoteGroup, SWT.PUSH);
newRemoteButton.setText(UIText.PushBranchPage_NewRemoteButton);
GridDataFactory.fillDefaults().applyTo(newRemoteButton);
newRemoteButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
showNewRemoteDialog();
}
});
}
Label branchNameLabel = new Label(remoteGroup, SWT.NONE);
branchNameLabel.setText(UIText.PushBranchPage_RemoteBranchNameLabel);
remoteBranchNameText = new Text(remoteGroup, SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(remoteBranchNameText);
remoteBranchNameText.setText(getSuggestedBranchName());
AsynchronousRefProposalProvider candidateProvider = new AsynchronousRefProposalProvider(getContainer(), remoteBranchNameText, () -> {
RemoteConfig config = remoteSelectionCombo.getSelectedRemote();
if (config == null) {
return null;
}
List<URIish> uris = config.getURIs();
if (uris == null || uris.isEmpty()) {
return null;
}
return uris.get(0).toString();
}, uri -> {
FutureRefs list = refs.get(uri);
if (list == null) {
list = new FutureRefs(repository, uri, getLocalBranchName());
refs.put(uri, list);
}
return list;
});
candidateProvider.setContentProposalAdapter(UIUtils.addRefContentProposalToText(remoteBranchNameText, this.repository, candidateProvider, true));
if (this.ref != null) {
upstreamConfigComponent = new UpstreamConfigComponent(inputPanel, SWT.NONE);
upstreamConfigComponent.getContainer().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(3, 1).indent(SWT.NONE, 20).create());
upstreamConfigComponent.addUpstreamConfigSelectionListener(new UpstreamConfigSelectionListener() {
@Override
public void upstreamConfigSelected(BranchRebaseMode newUpstreamConfig) {
upstreamConfig = newUpstreamConfig;
checkPage();
}
});
setDefaultUpstreamConfig();
}
final Button forceUpdateButton = new Button(inputPanel, SWT.CHECK);
forceUpdateButton.setText(UIText.PushBranchPage_ForceUpdateButton);
forceUpdateButton.setSelection(false);
forceUpdateButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(3, 1).create());
forceUpdateButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
forceUpdateSelected = forceUpdateButton.getSelection();
}
});
Link advancedDialogLink = new Link(main, SWT.NONE);
advancedDialogLink.setText(UIText.PushBranchPage_advancedWizardLink);
advancedDialogLink.setToolTipText(UIText.PushBranchPage_advancedWizardLinkTooltip);
advancedDialogLink.setLayoutData(new GridData(SWT.END, SWT.END, false, true));
advancedDialogLink.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Shell parentShell = getShell().getParent().getShell();
PushWizard advancedWizard = null;
try {
advancedWizard = new PushWizard(repository);
getShell().close();
new WizardDialog(parentShell, advancedWizard).open();
} catch (URISyntaxException ex) {
Activator.logError(ex.getMessage(), ex);
}
}
});
setControl(main);
checkPage();
// Add listener now to avoid setText above to already trigger it.
remoteBranchNameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
checkPage();
}
});
// Do not use a tooltip since there is already a content proposal
// adapter on this field
BranchNameNormalizer normalizer = new BranchNameNormalizer(remoteBranchNameText, null);
normalizer.setVisible(false);
}
use of org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode in project egit by eclipse.
the class PullWizard method configureUpstream.
private void configureUpstream() throws IOException {
String fullBranch = this.repository.getFullBranch();
if (fullBranch == null || !fullBranch.startsWith(Constants.R_HEADS)) {
// Don't configure upstream for detached HEAD
return;
}
String remoteName = this.page.getRemoteConfig().getName();
String fullRemoteBranchName = this.page.getFullRemoteReference();
String localBranchName = this.repository.getBranch();
StoredConfig config = repository.getConfig();
config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, localBranchName, ConfigConstants.CONFIG_KEY_REMOTE, remoteName);
config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, localBranchName, ConfigConstants.CONFIG_KEY_MERGE, fullRemoteBranchName);
BranchRebaseMode rebaseMode = this.page.getUpstreamConfig();
if (rebaseMode != null) {
config.setEnum(ConfigConstants.CONFIG_BRANCH_SECTION, localBranchName, ConfigConstants.CONFIG_KEY_REBASE, rebaseMode);
}
config.save();
}
use of org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode in project egit by eclipse.
the class PullWizardPage method setDefaultUpstreamConfig.
private void setDefaultUpstreamConfig() {
String branchName = Repository.shortenRefName(this.fullBranch);
BranchConfig branchConfig = new BranchConfig(repository.getConfig(), branchName);
boolean alreadyConfigured = branchConfig.getMerge() != null;
BranchRebaseMode config;
if (alreadyConfigured) {
config = PullCommand.getRebaseMode(branchName, repository.getConfig());
} else {
config = CreateLocalBranchOperation.getDefaultUpstreamConfig(repository, Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + "/" + // $NON-NLS-1$
branchName);
}
this.upstreamConfig = config;
}
Aggregations