This repository has been archived by the owner on Apr 6, 2022. It is now read-only.
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
[JENKINS-12307] Added describables for all parser and pattern selection.
- Loading branch information
Showing
20 changed files
with
346 additions
and
204 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,92 @@ | ||
package hudson.plugins.warnings; | ||
|
||
import hudson.Extension; | ||
import hudson.model.AbstractDescribableImpl; | ||
import hudson.model.Descriptor; | ||
import hudson.plugins.warnings.parser.ParserDescription; | ||
import hudson.plugins.warnings.parser.ParserRegistry; | ||
import hudson.util.ListBoxModel; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
import com.google.common.collect.Lists; | ||
|
||
/** | ||
* Defines the configuration to parse a set of files using a predefined parser. | ||
* | ||
* @author Ulli Hafner | ||
*/ | ||
public class ConsoleParser extends AbstractDescribableImpl<ConsoleParser> { | ||
private final String parserName; | ||
|
||
/** | ||
* Creates a new instance of {@link ConsoleParser}. | ||
* | ||
* @param parserName | ||
* the name of the parser to use | ||
*/ | ||
@DataBoundConstructor | ||
public ConsoleParser(final String parserName) { | ||
super(); | ||
|
||
this.parserName = parserName; | ||
} | ||
|
||
/** | ||
* Returns the name of the parser. | ||
* | ||
* @return the parser name | ||
*/ | ||
public String getParserName() { | ||
return parserName; | ||
} | ||
|
||
/** | ||
* Removes non-existing parsers from the specified list. | ||
* | ||
* @param parsers | ||
* the parsers | ||
* @return a new list containing the filtered parsers | ||
*/ | ||
public static ConsoleParser[] filterExisting(final Collection<? extends ConsoleParser> parsers) { | ||
List<ConsoleParser> existing = Lists.newArrayList(); | ||
for (ConsoleParser parser : parsers) { | ||
if (ParserRegistry.exists(parser.getParserName())) { | ||
existing.add(parser); | ||
} | ||
} | ||
return existing.toArray(new ConsoleParser[existing.size()]); | ||
} | ||
|
||
/** | ||
* Dummy descriptor for {@link ConsoleParser}. | ||
* | ||
* @author Ulli Hafner | ||
*/ | ||
@Extension | ||
public static class DescriptorImpl extends Descriptor<ConsoleParser> { | ||
/** | ||
* Returns the available parsers. These values will be shown in the list | ||
* box of the config.jelly view part. | ||
* | ||
* @return the model of the list box | ||
*/ | ||
public ListBoxModel doFillParserNameItems() { | ||
ListBoxModel items = new ListBoxModel(); | ||
for (ParserDescription parser : ParserRegistry.getAvailableParsers()) { | ||
items.add(parser.getGroup()); | ||
} | ||
return items; | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return StringUtils.EMPTY; | ||
} | ||
} | ||
|
||
} |
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
Oops, something went wrong.