List of usage examples for org.eclipse.jgit.lib Constants R_REMOTES
String R_REMOTES
To view the source code for org.eclipse.jgit.lib Constants R_REMOTES.
Click Source Link
From source file:org.eclipse.egit.ui.internal.dialogs.BranchConfigurationDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite main = new Composite(parent, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(main); GridDataFactory.fillDefaults().grab(true, false).indent(5, 5).applyTo(main); 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); try {/*from ww w. j a v a2 s .c o m*/ for (Ref ref : myRepository.getRefDatabase().getRefs(Constants.R_HEADS).values()) branchText.add(ref.getName()); for (Ref ref : myRepository.getRefDatabase().getRefs(Constants.R_REMOTES).values()) branchText.add(ref.getName()); } catch (IOException e) { Activator.logError(UIText.BranchConfigurationDialog_ExceptionGettingRefs, e); } 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); // TODO do we have a constant somewhere? remoteText.add("."); //$NON-NLS-1$ for (String remote : myConfig.getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION)) remoteText.add(remote); rebase = new Button(main, SWT.CHECK); GridDataFactory.fillDefaults().span(2, 1).applyTo(rebase); rebase.setText(UIText.BranchConfigurationDialog_RebaseLabel); String branch = myConfig.getString(ConfigConstants.CONFIG_BRANCH_SECTION, myBranchName, ConfigConstants.CONFIG_KEY_MERGE); if (branch == null) branch = ""; //$NON-NLS-1$ branchText.setText(branch); String remote = myConfig.getString(ConfigConstants.CONFIG_BRANCH_SECTION, myBranchName, ConfigConstants.CONFIG_KEY_REMOTE); if (remote == null) remote = ""; //$NON-NLS-1$ remoteText.setText(remote); boolean rebaseFlag = myConfig.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, myBranchName, ConfigConstants.CONFIG_KEY_REBASE, false); rebase.setSelection(rebaseFlag); applyDialogFont(main); // return result; return main; }
From source file:org.eclipse.egit.ui.internal.dialogs.BranchRenameDialog.java
License:Open Source License
@Override public void create() { super.create(); setTitle(UIText.BranchRenameDialog_Title); String oldName = branchToRename.getName(); String prefix;/*from ww w. j av a 2 s . co m*/ 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)); 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); } }); } else setErrorMessage(NLS.bind(UIText.BranchRenameDialog_WrongPrefixErrorMessage, oldName)); if (shortName != null) { name.setText(shortName); name.setSelection(0, shortName.length()); } getButton(OK).setEnabled(false); }
From source file:org.eclipse.egit.ui.internal.dialogs.BranchSelectionAndEditDialog.java
License:Open Source License
@Override protected void refNameSelected(String refName) { boolean tagSelected = refName != null && refName.startsWith(Constants.R_TAGS); boolean branchSelected = refName != null && (refName.startsWith(Constants.R_HEADS) || refName.startsWith(Constants.R_REMOTES)); // handle multiple selection if (((TreeSelection) branchTree.getSelection()).size() > 1) { TreeSelection selection = (TreeSelection) branchTree.getSelection(); deleteButton.setEnabled(onlyBranchesExcludingCurrentAreSelected(selection)); renameButton.setEnabled(false);//ww w.j a va 2s . c o m if (newButton != null) newButton.setEnabled(false); setOkButtonEnabled(false); } else { // we don't support rename on tags renameButton.setEnabled(branchSelected && !tagSelected); deleteButton.setEnabled(branchSelected && !tagSelected && !isCurrentBranch(refName)); // new button should be always enabled if (newButton != null) newButton.setEnabled(true); setOkButtonEnabled((branchSelected || tagSelected) && !isCurrentBranch(refName)); } Button okButton = getButton(Window.OK); if (okButton != null) { if (BranchOperationUI.checkoutWillShowQuestionDialog(refName)) okButton.setText(UIText.CheckoutDialog_OkCheckoutWithQuestion); else okButton.setText(UIText.CheckoutDialog_OkCheckout); } }
From source file:org.eclipse.egit.ui.internal.dialogs.BranchSelectionAndEditDialog.java
License:Open Source License
/** * Creates button for renaming a branch. * * @param parent/*w w w .ja v a2 s . c o m*/ * @return button */ protected Button createRenameButton(Composite parent) { ((GridLayout) parent.getLayout()).numColumns++; renameButton = new Button(parent, SWT.PUSH); renameButton.setFont(JFaceResources.getDialogFont()); renameButton.setText(UIText.BranchSelectionAndEditDialog_Rename); setButtonLayoutData(renameButton); renameButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Ref selectedRef = refFromDialog(); String namePrefix = selectedRef.getName().startsWith(Constants.R_REMOTES) ? Constants.R_REMOTES : Constants.R_HEADS; BranchRenameDialog dialog = new BranchRenameDialog(getShell(), repo, selectedRef); if (dialog.open() == Window.OK) { branchTree.refresh(); markRef(namePrefix + dialog.getNewName()); } } }); renameButton.setEnabled(false); return renameButton; }
From source file:org.eclipse.egit.ui.internal.dialogs.BranchSelectionDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { newButton = new Button(parent, SWT.PUSH); newButton.setFont(JFaceResources.getDialogFont()); newButton.setText(UIText.BranchSelectionDialog_NewBranch); setButtonLayoutData(newButton);/*from w w w .j a v a2 s . co m*/ ((GridLayout) parent.getLayout()).numColumns++; renameButton = new Button(parent, SWT.PUSH); renameButton.setFont(JFaceResources.getDialogFont()); renameButton.setText(UIText.BranchSelectionDialog_Rename); setButtonLayoutData(renameButton); ((GridLayout) parent.getLayout()).numColumns++; renameButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { String refName = refNameFromDialog(); String refPrefix; if (refName.startsWith(Constants.R_HEADS)) refPrefix = Constants.R_HEADS; else if (refName.startsWith(Constants.R_REMOTES)) refPrefix = Constants.R_REMOTES; else if (refName.startsWith(Constants.R_TAGS)) refPrefix = Constants.R_TAGS; else { // the button should be disabled anyway, but we check again return; } String branchName = refName.substring(refPrefix.length()); InputDialog labelDialog = getRefNameInputDialog( NLS .bind( UIText.BranchSelectionDialog_QuestionNewBranchNameMessage, branchName, refPrefix), refPrefix, branchName); if (labelDialog.open() == Window.OK) { String newRefName = refPrefix + labelDialog.getValue(); try { new Git(repo).branchRename().setOldName(refName) .setNewName(labelDialog.getValue()).call(); branchTree.refresh(); markRef(newRefName); } catch (Throwable e1) { reportError( e1, UIText.BranchSelectionDialog_ErrorCouldNotRenameRef, refName, newRefName, e1.getMessage()); } } } }); newButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { // check what Ref the user selected if any Ref ref = refFromDialog(); InputDialog labelDialog = getRefNameInputDialog(NLS.bind( UIText.BranchSelectionDialog_QuestionNewBranchMessage, ref.getName(), Constants.R_HEADS), Constants.R_HEADS, null); if (labelDialog.open() == Window.OK) { String newRefName = labelDialog.getValue(); CreateLocalBranchOperation cbop = new CreateLocalBranchOperation( repo, newRefName, ref); try { cbop.execute(null); branchTree.refresh(); markRef(Constants.R_HEADS + newRefName); } catch (Throwable e1) { reportError( e1, UIText.BranchSelectionDialog_ErrorCouldNotCreateNewRef, newRefName); } } } }); super.createButtonsForButtonBar(parent); getButton(Window.OK).setText(UIText.BranchSelectionDialog_OkCheckout); // createButton(parent, IDialogConstants.OK_ID, // UIText.BranchSelectionDialog_OkCheckout, true); // createButton(parent, IDialogConstants.CANCEL_ID, // IDialogConstants.CANCEL_LABEL, false); // can't advance without a selection getButton(Window.OK).setEnabled(!branchTree.getSelection().isEmpty()); }
From source file:org.eclipse.egit.ui.internal.dialogs.BranchSelectionDialog.java
License:Open Source License
@Override protected void refNameSelected(String refName) { boolean tagSelected = refName != null && refName.startsWith(Constants.R_TAGS); boolean branchSelected = refName != null && (refName.startsWith(Constants.R_HEADS) || refName .startsWith(Constants.R_REMOTES)); getButton(Window.OK).setEnabled(branchSelected || tagSelected); newButton.setEnabled(branchSelected || tagSelected); // we don't support rename on tags renameButton.setEnabled(branchSelected && !tagSelected); }
From source file:org.eclipse.egit.ui.internal.dialogs.CheckoutDialog.java
License:Open Source License
@Override protected void refNameSelected(String refName) { boolean tagSelected = refName != null && refName.startsWith(Constants.R_TAGS); boolean branchSelected = refName != null && (refName.startsWith(Constants.R_HEADS) || refName.startsWith(Constants.R_REMOTES)); // handle multiple selection if (((TreeSelection) branchTree.getSelection()).size() > 1) { TreeSelection selection = (TreeSelection) branchTree.getSelection(); boolean onlyBranchesAreSelected = onlyBranchesAreSelected(selection); // enable/disable buttons deleteteButton.setEnabled(onlyBranchesAreSelected); renameButton.setEnabled(false);/*ww w .j a va 2 s .c o m*/ newButton.setEnabled(false); } else { getButton(Window.OK).setEnabled(branchSelected || tagSelected); // we don't support rename on tags renameButton.setEnabled(branchSelected && !tagSelected); deleteteButton.setEnabled(branchSelected && !tagSelected); // new button should be always enabled newButton.setEnabled(true); } getButton(Window.OK).setEnabled(refName != null && !refName.equals(currentBranch)); }
From source file:org.eclipse.egit.ui.internal.dialogs.CheckoutDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { newButton = new Button(parent, SWT.PUSH); newButton.setFont(JFaceResources.getDialogFont()); newButton.setText(UIText.CheckoutDialog_NewBranch); setButtonLayoutData(newButton);/*www . ja va 2s .c o m*/ ((GridLayout) parent.getLayout()).numColumns++; renameButton = new Button(parent, SWT.PUSH); renameButton.setFont(JFaceResources.getDialogFont()); renameButton.setText(UIText.CheckoutDialog_Rename); setButtonLayoutData(renameButton); ((GridLayout) parent.getLayout()).numColumns++; deleteteButton = new Button(parent, SWT.PUSH); deleteteButton.setFont(JFaceResources.getDialogFont()); deleteteButton.setText(UIText.CheckoutDialog_Delete); setButtonLayoutData(deleteteButton); ((GridLayout) parent.getLayout()).numColumns++; renameButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { String refName = refNameFromDialog(); String refPrefix; if (refName.startsWith(Constants.R_HEADS)) refPrefix = Constants.R_HEADS; else if (refName.startsWith(Constants.R_REMOTES)) refPrefix = Constants.R_REMOTES; else if (refName.startsWith(Constants.R_TAGS)) refPrefix = Constants.R_TAGS; else { // the button should be disabled anyway, but we check again return; } String branchName = refName.substring(refPrefix.length()); InputDialog labelDialog = getRefNameInputDialog( NLS.bind(UIText.CheckoutDialog_QuestionNewBranchNameMessage, branchName, refPrefix), refPrefix, branchName); if (labelDialog.open() == Window.OK) { String newRefName = refPrefix + labelDialog.getValue(); try { new Git(repo).branchRename().setOldName(refName).setNewName(labelDialog.getValue()).call(); branchTree.refresh(); markRef(newRefName); } catch (Throwable e1) { reportError(e1, UIText.CheckoutDialog_ErrorCouldNotRenameRef, refName, newRefName, e1.getMessage()); } } } }); newButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { CreateBranchWizard wiz = new CreateBranchWizard(repo, refNameFromDialog()); if (new WizardDialog(getShell(), wiz).open() == Window.OK) { String newRefName = wiz.getNewBranchName(); try { branchTree.refresh(); markRef(Constants.R_HEADS + newRefName); if (repo.getBranch().equals(newRefName)) // close branch selection dialog when new branch was // already checked out from new branch wizard CheckoutDialog.this.okPressed(); } catch (Throwable e1) { reportError(e1, UIText.CheckoutDialog_ErrorCouldNotCreateNewRef, newRefName); } } } }); deleteteButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent selectionEvent) { try { CommonUtils.runCommand(IWorkbenchCommandConstants.EDIT_DELETE, (IStructuredSelection) branchTree.getSelection()); branchTree.refresh(); } catch (Throwable e) { reportError(e, UIText.CheckoutDialog_ErrorCouldNotDeleteRef, refNameFromDialog()); } } }); super.createButtonsForButtonBar(parent); getButton(Window.OK).setText(UIText.CheckoutDialog_OkCheckout); // can't advance without a selection getButton(Window.OK).setEnabled(!branchTree.getSelection().isEmpty()); }
From source file:org.eclipse.egit.ui.internal.dialogs.CommitMessageComponent.java
License:Open Source License
private boolean isContainedInAnyRemoteBranch(RevCommit commit) { try {// w w w . ja v a2 s . co m Collection<Ref> refs = repository.getRefDatabase().getRefs(Constants.R_REMOTES).values(); return RevUtils.isContainedInAnyRef(repository, commit, refs); } catch (IOException e) { // The result only affects a warning, so pretend there was no // problem. return false; } }
From source file:org.eclipse.egit.ui.internal.dialogs.MergeTargetSelectionDialog.java
License:Open Source License
@Override protected void refNameSelected(String refName) { boolean tagSelected = refName != null && refName.startsWith(Constants.R_TAGS); boolean branchSelected = refName != null && (refName.startsWith(Constants.R_HEADS) || refName.startsWith(Constants.R_REMOTES)); boolean currentSelected; try {/*w ww . j a v a 2s. c o m*/ currentSelected = refName != null && refName.equals(repo.getFullBranch()); } catch (IOException e) { currentSelected = false; } getButton(Window.OK).setEnabled(!currentSelected && (branchSelected || tagSelected)); }