forked from fredg02/extra-columns-plugin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge branch 'JENKINS-21037' of
https://github.com/krulls/extra-columns-plugin Conflicts: src/main/resources/jenkins/plugins/extracolumns/Messages.properties src/main/resources/jenkins/plugins/extracolumns/Messages_de.properties
- Loading branch information
Showing
7 changed files
with
144 additions
and
1 deletion.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
src/main/java/jenkins/plugins/extracolumns/SlaveOrLabelColumn.java
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,85 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2013, Stephan Krull | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package jenkins.plugins.extracolumns; | ||
|
||
import hudson.Extension; | ||
import hudson.model.AbstractProject; | ||
import hudson.model.Job; | ||
import hudson.model.Label; | ||
import hudson.views.ListViewColumnDescriptor; | ||
import hudson.views.ListViewColumn; | ||
|
||
import java.util.logging.Logger; | ||
|
||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
/** | ||
* View column that shows build processor or build processor label restriction | ||
* of a job. | ||
* | ||
* @author krulls | ||
*/ | ||
public class SlaveOrLabelColumn extends ListViewColumn { | ||
|
||
private static final Logger LOGGER = Logger | ||
.getLogger(SlaveOrLabelColumn.class.getName()); | ||
|
||
@DataBoundConstructor | ||
public SlaveOrLabelColumn() { | ||
} | ||
|
||
public String getInfo(Job<?, ?> job) { | ||
|
||
if(!(job instanceof AbstractProject)){ | ||
LOGGER.finest("Not an instance of " + AbstractProject.class.getCanonicalName() + ". Cannot get info."); | ||
return ""; | ||
} | ||
|
||
AbstractProject<?, ?> project = AbstractProject.class.cast(job); | ||
Label projectLabel = project.getAssignedLabel(); | ||
if (projectLabel == null || projectLabel.isEmpty()) | ||
return "N/A"; | ||
|
||
if (projectLabel.isSelfLabel()) | ||
return projectLabel.getName(); | ||
|
||
return projectLabel.getName() | ||
+ ((projectLabel.getDescription() == null || projectLabel | ||
.getDescription().length() < 1) ? "" : " (" | ||
+ projectLabel.getDescription() + ")"); | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends ListViewColumnDescriptor { | ||
@Override | ||
public String getDisplayName() { | ||
return Messages.SlaveOrLabelColumn_DisplayName(); | ||
} | ||
|
||
@Override | ||
public boolean shownByDefault() { | ||
return false; | ||
} | ||
} | ||
} |
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
27 changes: 27 additions & 0 deletions
27
src/main/resources/jenkins/plugins/extracolumns/SlaveOrLabelColumn/column.jelly
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 @@ | ||
<!-- | ||
The MIT License | ||
Copyright (c) 2013, Stephan Krull | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
--> | ||
|
||
<j:jelly xmlns:j="jelly:core"> | ||
<td data="${it.getInfo(job)}">${it.getInfo(job)}</td> | ||
</j:jelly> |
27 changes: 27 additions & 0 deletions
27
src/main/resources/jenkins/plugins/extracolumns/SlaveOrLabelColumn/columnHeader.jelly
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 @@ | ||
<!-- | ||
The MIT License | ||
Copyright (c) 2013, Stephan Krull | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
--> | ||
|
||
<j:jelly xmlns:j="jelly:core"> | ||
<th>${%SOL Column}</th> | ||
</j:jelly> |
1 change: 1 addition & 0 deletions
1
src/main/resources/jenkins/plugins/extracolumns/SlaveOrLabelColumn/columnHeader.properties
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 @@ | ||
SOL\ Column=Slave Allocation |
1 change: 1 addition & 0 deletions
1
...main/resources/jenkins/plugins/extracolumns/SlaveOrLabelColumn/columnHeader_de.properties
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 @@ | ||
SOL\ Column=Knotenzuordnung |