-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65f374c
commit 6f31aad
Showing
14 changed files
with
229 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package hudson.model; | ||
|
||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import hudson.Extension; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
/** | ||
* Renders {@link BallColor} as icon for a Job. | ||
* | ||
* @since TODO | ||
*/ | ||
public class BuildStatusIcon extends JobIcon { | ||
|
||
@DataBoundConstructor | ||
public BuildStatusIcon() { /* NOP */ } | ||
|
||
@Override | ||
public String getImageOf(String size) { | ||
return getBuildStatus().getImageOf(size); | ||
} | ||
|
||
@Override | ||
public String getIconClassName() { | ||
return "symbol-status-" + getBuildStatus().getIconName(); | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return getBuildStatus().getDescription(); | ||
} | ||
|
||
protected BallColor getBuildStatus() { | ||
Job<?, ?> job = getOwner(); | ||
if (job != null) { | ||
return job.getIconColor(); | ||
} | ||
|
||
return BallColor.NOTBUILT; | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends JobIconDescriptor { | ||
|
||
@Override | ||
@NonNull | ||
public String getDisplayName() { | ||
return Messages.BuildStatusIcon_DisplayName(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package hudson.model; | ||
|
||
import edu.umd.cs.findbugs.annotations.Nullable; | ||
import hudson.ExtensionPoint; | ||
import jenkins.model.Jenkins; | ||
import org.jenkins.ui.icon.IconSpec; | ||
|
||
/** | ||
* Renders {@link StatusIcon} for a Job. | ||
* | ||
* <p> | ||
* Possible subtypes can range from dumb icons that always render the same thing to smarter icons | ||
* that change its icon based on the state of the job. | ||
* | ||
* @since TODO | ||
*/ | ||
public abstract class JobIcon extends AbstractStatusIcon implements Describable<JobIcon>, ExtensionPoint, | ||
IconSpec { | ||
|
||
private Job<?, ?> owner; | ||
|
||
/** | ||
* Called by {@link Job} to set the owner that this icon is used for. | ||
* @param job the job. | ||
*/ | ||
protected void setOwner(@Nullable Job<?, ?> job) { | ||
owner = job; | ||
} | ||
|
||
/** | ||
* Get the owner. | ||
* @return the job. | ||
*/ | ||
protected @Nullable Job<?, ?> getOwner() { | ||
return owner; | ||
} | ||
|
||
@Override | ||
public String getIconClassName() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public JobIconDescriptor getDescriptor() { | ||
return (JobIconDescriptor) Jenkins.get().getDescriptorOrDie(getClass()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package hudson.model; | ||
|
||
import hudson.DescriptorExtensionList; | ||
import jenkins.model.Jenkins; | ||
|
||
/** | ||
* Job icon descriptor. | ||
* | ||
* @since TODO | ||
*/ | ||
public abstract class JobIconDescriptor extends Descriptor<JobIcon> { | ||
|
||
public static DescriptorExtensionList<JobIcon, JobIconDescriptor> all() { | ||
return Jenkins.get().getDescriptorList(JobIcon.class); | ||
} | ||
|
||
/** | ||
* Returns true if this {@link Job} type is applicable to the | ||
* given job type. | ||
* @param jobType the type of job. | ||
* @return true to indicate applicable, in which case the icon will be | ||
* displayed in the configuration screen of this job. | ||
*/ | ||
public boolean isApplicable(Class<? extends Job<?, ?>> jobType) { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package hudson.model; | ||
|
||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import hudson.Extension; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
/** | ||
* Renders a test icon for a Job. | ||
*/ | ||
public class TestIcon extends JobIcon { | ||
|
||
@DataBoundConstructor | ||
public TestIcon() { /* NOP */ } | ||
|
||
@Override | ||
public String getImageOf(String size) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getIconClassName() { | ||
return "symbol-edit"; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Testing"; | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends JobIconDescriptor { | ||
|
||
@Override | ||
@NonNull | ||
public String getDisplayName() { | ||
return "Test Icon"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters