Skip to content

Commit

Permalink
Merge pull request #16 from jenkinsci/jenkins-38987
Browse files Browse the repository at this point in the history
[FIXED JENKINS-38987] Add getPronoun() to assist contextual naming
  • Loading branch information
stephenc committed Oct 14, 2016
2 parents f909068 + 7f70e0a commit 064fcfa
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/main/java/jenkins/scm/api/SCMHead.java
Expand Up @@ -31,6 +31,7 @@
import hudson.model.Actionable;
import hudson.model.Item;
import hudson.model.ItemGroup;
import hudson.util.AlternativeUiTextProvider;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -51,6 +52,17 @@
@ExportedBean
public class SCMHead implements Comparable<SCMHead>, Serializable {

/**
* Replaceable pronoun of that points to a {@link SCMHead}. Defaults to {@code null} depending on the context.
*
* @since FIXME
*/
public static final AlternativeUiTextProvider.Message<SCMHead> PRONOUN
= new AlternativeUiTextProvider.Message<SCMHead>();

/**
* Our logger.
*/
private static final Logger LOGGER = Logger.getLogger(SCMHead.class.getName());

/**
Expand Down Expand Up @@ -85,6 +97,17 @@ public String getName() {
return name;
}

/**
* Get the term used in the UI to represent this kind of {@link SCMHead}. Must start with a capital letter.
*
* @return the term or {@code null} to fall back to the calling context's default.
* @since FIXME
*/
@CheckForNull
public String getPronoun() {
return AlternativeUiTextProvider.get(PRONOUN, this, null);
}

/**
* {@inheritDoc}
*/
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/jenkins/scm/api/SCMNavigator.java
Expand Up @@ -24,9 +24,11 @@

package jenkins.scm.api;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.ExtensionPoint;
import hudson.model.AbstractDescribableImpl;
import hudson.util.AlternativeUiTextProvider;
import java.io.IOException;

/**
Expand All @@ -37,6 +39,14 @@
*/
public abstract class SCMNavigator extends AbstractDescribableImpl<SCMNavigator> implements ExtensionPoint {

/**
* Replaceable pronoun of that points to a {@link SCMNavigator}. Defaults to {@code null} depending on the context.
*
* @since FIXME
*/
public static final AlternativeUiTextProvider.Message<SCMNavigator> PRONOUN
= new AlternativeUiTextProvider.Message<SCMNavigator>();

protected SCMNavigator() {}

/**
Expand All @@ -53,4 +63,14 @@ public SCMNavigatorDescriptor getDescriptor() {
return (SCMNavigatorDescriptor) super.getDescriptor();
}

/**
* Get the term used in the UI to represent this kind of {@link SCMNavigator}. Must start with a capital letter.
*
* @return the term or {@code null} to fall back to the calling context's default.
* @since FIXME
*/
@CheckForNull
public String getPronoun() {
return AlternativeUiTextProvider.get(PRONOUN, this, getDescriptor().getPronoun());
}
}
17 changes: 17 additions & 0 deletions src/main/java/jenkins/scm/api/SCMNavigatorDescriptor.java
Expand Up @@ -84,11 +84,28 @@ public String getIconFilePathPattern() {
return null;
}

/**
* Get the Item's Icon class specification e.g. 'icon-notepad'.
* Note: do <strong>NOT</strong> include icon size specifications (such as 'icon-sm').
*
* @return The Icon class specification e.g. 'icon-notepad'.
*/
@CheckForNull
public String getIconClassName() {
return null;
}

/**
* Get the term used in the UI to represent this kind of {@link SCMNavigator}. Must start with a capital letter.
*
* @return the term or {@code null} to fall back to the calling context's default.
* @since FIXME
*/
@CheckForNull
public String getPronoun() {
return null;
}

/**
* Creates a default navigator, if there should be one displayed.
* May be interpreted by {@code jenkins.branch.CustomOrganizationFolderDescriptor}.
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/jenkins/scm/api/SCMSource.java
Expand Up @@ -27,8 +27,11 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.ExtensionPoint;
import hudson.model.AbstractDescribableImpl;
import hudson.model.AbstractItem;
import hudson.model.Descriptor;
import hudson.model.TaskListener;
import hudson.scm.SCM;
import hudson.util.AlternativeUiTextProvider;
import hudson.util.LogTaskListener;
import net.jcip.annotations.GuardedBy;

Expand Down Expand Up @@ -61,6 +64,13 @@
public abstract class SCMSource extends AbstractDescribableImpl<SCMSource>
implements ExtensionPoint {

/**
* Replaceable pronoun of that points to a {@link SCMSource}. Defaults to {@code null} depending on the context.
* @since FIXME
*/
public static final AlternativeUiTextProvider.Message<SCMSource> PRONOUN
= new AlternativeUiTextProvider.Message<SCMSource>();

/**
* The ID of this source.
*/
Expand Down Expand Up @@ -451,4 +461,23 @@ public String toString() {
return sb.toString();
}

/**
* {@inheritDoc}
*/
@Override
public SCMSourceDescriptor getDescriptor() {
return (SCMSourceDescriptor) super.getDescriptor();
}

/**
* Get the term used in the UI to represent this kind of {@link SCMSource}. Must start with a capital letter.
*
* @return the term or {@code null} to fall back to the calling context's default.
* @since FIXME
*/
@CheckForNull
public String getPronoun() {
return AlternativeUiTextProvider.get(PRONOUN, this, getDescriptor().getPronoun());
}

}
12 changes: 12 additions & 0 deletions src/main/java/jenkins/scm/api/SCMSourceDescriptor.java
Expand Up @@ -27,6 +27,7 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.ExtensionList;
import hudson.model.Descriptor;
import hudson.model.Item;
import org.jenkins.ui.icon.IconSpec;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
Expand Down Expand Up @@ -146,4 +147,15 @@ public static List<SCMSourceDescriptor> forOwner(Class<? extends SCMSourceOwner>
public String getIconClassName() {
return null;
}

/**
* Get the term used in the UI to represent this kind of {@link SCMSource}. Must start with a capital letter.
*
* @return the term or {@code null} to fall back to the calling context's default.
* @since FIXME
*/
@CheckForNull
public String getPronoun() {
return null;
}
}

0 comments on commit 064fcfa

Please sign in to comment.