List of usage examples for org.eclipse.jgit.transport RefSpec isWildcard
public static boolean isWildcard(String s)
From source file:org.eclipse.egit.ui.internal.components.RefSpecPanel.java
License:Open Source License
private static boolean isValidRefExpression(final String s) { if (RefSpec.isWildcard(s)) { // replace wildcard with some legal name just for checking return Repository.isValidRefName(s.substring(0, s.length() - 1) + 'X'); } else/* ww w . ja va2 s . c o m*/ return Repository.isValidRefName(s); }
From source file:org.eclipse.egit.ui.internal.components.RefSpecPanel.java
License:Open Source License
private static RefSpec setRefSpecSource(final RefSpec spec, final String src) { final String dst; if (RefSpec.isWildcard(src)) dst = wildcardSpecComponent(spec.getDestination()); else/* www.ja va 2 s. c o m*/ dst = unwildcardSpecComponent(spec.getDestination(), src); return spec.setSourceDestination(src, dst); }
From source file:org.eclipse.egit.ui.internal.components.RefSpecPanel.java
License:Open Source License
private static RefSpec setRefSpecDestination(final RefSpec spec, final String dst) { final String src; if (RefSpec.isWildcard(dst)) src = wildcardSpecComponent(spec.getSource()); else// w ww . jav a 2 s.com src = unwildcardSpecComponent(spec.getSource(), dst); return spec.setSourceDestination(src, dst); }
From source file:org.eclipse.egit.ui.internal.components.RefSpecPanel.java
License:Open Source License
private static String wildcardSpecComponent(final String comp) { final int i; if (RefSpec.isWildcard(comp)) return comp; if (comp == null || (i = comp.lastIndexOf('/')) == -1) { // That's somewhat ugly. What better can we do here? return UIText.RefSpecPanel_refChooseSomeWildcard; }// w ww. j a v a 2s .co m return comp.substring(0, i + 1) + '*'; }
From source file:org.eclipse.egit.ui.internal.components.RefSpecPanel.java
License:Open Source License
private static String unwildcardSpecComponent(final String comp, final String other) { if (!RefSpec.isWildcard(comp)) return comp; if (other == null || other.length() == 0) return ""; //$NON-NLS-1$ final int i = other.lastIndexOf('/'); return comp.substring(0, comp.length() - 1) + other.substring(i + 1); }
From source file:org.eclipse.egit.ui.internal.components.RefSpecPanel.java
License:Open Source License
private void tryAutoCompleteSrcToDst() { final String src = creationSrcCombo.getText(); final String dst = creationDstCombo.getText(); if (src == null || src.length() == 0) return;/* w ww .j a va2 s . c om*/ if (dst != null && dst.length() > 0) { // dst is already there, just fix wildcards if needed final String newDst; if (RefSpec.isWildcard(src)) newDst = wildcardSpecComponent(dst); else newDst = unwildcardSpecComponent(dst, src); creationDstCombo.setText(newDst); return; } if (!isValidRefExpression(src)) { // no way to be smarter than user here return; } // dst is empty, src is ref or wildcard, so we can rewrite it as user // would perhaps if (pushSpecs) creationDstCombo.setText(src); else { for (final RefSpec spec : predefinedConfigured) { if (spec.matchSource(src)) { final String newDst = spec.expandFromSource(src).getDestination(); creationDstCombo.setText(newDst); return; } } if (remoteName != null && src.startsWith(Constants.R_HEADS)) { final String newDst = Constants.R_REMOTES + remoteName + '/' + src.substring(Constants.R_HEADS.length()); creationDstCombo.setText(newDst); } } }
From source file:org.eclipse.egit.ui.internal.components.RefSpecPanel.java
License:Open Source License
private void tryAutoCompleteDstToSrc() { final String src = creationSrcCombo.getText(); final String dst = creationDstCombo.getText(); if (dst == null || dst.length() == 0) return;/*from ww w . ja v a2 s . co m*/ if (src != null && src.length() > 0) { // src is already there, fix wildcards if needed final String newSrc; if (RefSpec.isWildcard(dst)) newSrc = wildcardSpecComponent(src); else newSrc = unwildcardSpecComponent(src, dst); creationSrcCombo.setText(newSrc); return; } }
From source file:org.eclipse.egit.ui.internal.components.RefSpecPanel.java
License:Open Source License
private void validateCreationPanel() { final String src = creationSrcCombo.getText(); final String dst = creationDstCombo.getText(); // check src ref field boolean srcOk = false; final boolean srcWildcard = RefSpec.isWildcard(src); if (src == null || src.length() == 0) setControlDecoration(creationSrcDecoration, FieldDecorationRegistry.DEC_REQUIRED, UIText.RefSpecPanel_validationSrcUpdateRequired); else if (pushSpecs) { if (!srcWildcard && !isLocalRef(src)) setControlDecoration(creationSrcDecoration, FieldDecorationRegistry.DEC_ERROR, NLS.bind(UIText.RefSpecPanel_validationRefInvalidLocal, src)); else if (srcWildcard && !isValidRefExpression(src)) setControlDecoration(creationSrcDecoration, FieldDecorationRegistry.DEC_ERROR, NLS.bind(UIText.RefSpecPanel_validationRefInvalidExpression, src)); else {//from w w w.ja v a2 s . co m srcOk = true; if (srcWildcard && !isMatchingAny(src, localRefNames)) setControlDecoration(creationSrcDecoration, FieldDecorationRegistry.DEC_WARNING, NLS.bind(UIText.RefSpecPanel_validationRefNonMatchingLocal, src)); else creationSrcDecoration.hide(); } } else { if (!srcWildcard && !isRemoteRef(src)) setControlDecoration(creationSrcDecoration, FieldDecorationRegistry.DEC_ERROR, NLS.bind(UIText.RefSpecPanel_validationRefNonExistingRemote, src)); else if (srcWildcard && !isMatchingAny(src, remoteRefNames)) { setControlDecoration(creationSrcDecoration, FieldDecorationRegistry.DEC_WARNING, NLS.bind(UIText.RefSpecPanel_validationRefNonMatchingRemote, src)); srcOk = true; } else { srcOk = true; creationSrcDecoration.hide(); } } // check dst ref field boolean dstOk = false; if (dst == null || dst.length() == 0) setControlDecoration(creationDstDecoration, FieldDecorationRegistry.DEC_REQUIRED, UIText.RefSpecPanel_validationDstRequired); else if (!isValidRefExpression(dst)) setControlDecoration(creationDstDecoration, FieldDecorationRegistry.DEC_ERROR, NLS.bind(UIText.RefSpecPanel_validationDstInvalidExpression, dst)); else { creationDstDecoration.hide(); dstOk = true; } // leave duplicates dst checking for validateSpecs() // check the wildcard synergy boolean wildcardOk = true; if (srcOk && dstOk && (srcWildcard ^ RefSpec.isWildcard(dst))) { setControlDecoration(creationSrcDecoration, FieldDecorationRegistry.DEC_ERROR, UIText.RefSpecPanel_validationWildcardInconsistent); setControlDecoration(creationDstDecoration, FieldDecorationRegistry.DEC_ERROR, UIText.RefSpecPanel_validationWildcardInconsistent); wildcardOk = false; } creationButton.setEnabled(srcOk && dstOk && wildcardOk); }
From source file:org.eclipse.egit.ui.internal.components.RefSpecPanel.java
License:Open Source License
private void validateDeleteCreationPanel() { final String ref = deleteRefCombo.getText(); deleteButton.setEnabled(false);/*from www .ja va 2 s . c om*/ if (ref == null || ref.length() == 0) setControlDecoration(deleteRefDecoration, FieldDecorationRegistry.DEC_REQUIRED, UIText.RefSpecPanel_validationRefDeleteRequired); else if (!isValidRefExpression(ref)) setControlDecoration(deleteRefDecoration, FieldDecorationRegistry.DEC_ERROR, NLS.bind(UIText.RefSpecPanel_validationRefInvalidExpression, ref)); else if (RefSpec.isWildcard(ref)) setControlDecoration(deleteRefDecoration, FieldDecorationRegistry.DEC_ERROR, UIText.RefSpecPanel_validationRefDeleteWildcard); else if (!isRemoteRef(ref)) setControlDecoration(deleteRefDecoration, FieldDecorationRegistry.DEC_ERROR, NLS.bind(UIText.RefSpecPanel_validationRefNonExistingRemoteDelete, ref)); else { deleteRefDecoration.hide(); deleteButton.setEnabled(true); } }