List of usage examples for org.eclipse.jgit.lib Constants R_HEADS
String R_HEADS
To view the source code for org.eclipse.jgit.lib Constants R_HEADS.
Click Source Link
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;/* w w w.ja v a 2s.c o 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);//from w ww . ja v a2s . c om 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 creating a new branch. * * @param parent// w w w . ja v a2s . com * @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; }
From source file:org.eclipse.egit.ui.internal.dialogs.BranchSelectionAndEditDialog.java
License:Open Source License
/** * Creates button for renaming a branch. * * @param parent//from www. ja v a 2 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 ww .ja v a 2 s .c o 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);/*from w w w . j a va2 s . c om*/ 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);//from ww w.ja v a2 s . co 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.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 {/*from ww w .j a va2 s . c om*/ currentSelected = refName != null && refName.equals(repo.getFullBranch()); } catch (IOException e) { currentSelected = false; } getButton(Window.OK).setEnabled(!currentSelected && (branchSelected || tagSelected)); }
From source file:org.eclipse.egit.ui.internal.dialogs.RenameBranchDialog.java
License:Open Source License
@Override protected void okPressed() { String refName = refNameFromDialog(); String refPrefix;//from w ww . j av a 2s .c o m 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.RenameBranchDialog_NewNameInputDialogPrompt, 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.RenameBranchDialog_RenameErrorMessage, refName, newRefName, e1.getMessage()); } } super.okPressed(); }