| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
package sk.baka.webvm; |
| 20 | |
|
| 21 | |
import sk.baka.webvm.analyzer.ProblemReport; |
| 22 | |
import java.util.List; |
| 23 | |
import org.apache.wicket.behavior.SimpleAttributeModifier; |
| 24 | |
import org.apache.wicket.markup.html.basic.Label; |
| 25 | |
import org.apache.wicket.markup.html.list.ListItem; |
| 26 | |
import org.apache.wicket.markup.html.list.ListView; |
| 27 | |
import org.apache.wicket.model.IModel; |
| 28 | |
import org.apache.wicket.model.LoadableDetachableModel; |
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
public final class Problems extends WebVMPage { |
| 35 | |
|
| 36 | |
private static final long serialVersionUID = 1L; |
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | 0 | public Problems() { |
| 42 | 0 | final IModel<List<ProblemReport>> model = new ProblemsModel(); |
| 43 | 0 | final ListView<ProblemReport> list = new ProblemsListView("problemList", model); |
| 44 | 0 | border.add(list); |
| 45 | 0 | } |
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | 0 | private static class ProblemsModel extends LoadableDetachableModel<List<ProblemReport>> { |
| 51 | |
|
| 52 | |
private static final long serialVersionUID = 1L; |
| 53 | |
|
| 54 | |
@Override |
| 55 | |
protected List<ProblemReport> load() { |
| 56 | 0 | return WicketApplication.getAnalyzer().getProblems(WicketApplication.getHistory().getVmstatHistory()); |
| 57 | |
} |
| 58 | |
} |
| 59 | |
public static final String DARK_GREEN = "#28cb17"; |
| 60 | |
public static final String LIGHT_RED = "#d24343"; |
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
private static class ProblemsListView extends ListView<ProblemReport> { |
| 66 | |
|
| 67 | |
public ProblemsListView(String id, IModel<? extends List<? extends ProblemReport>> model) { |
| 68 | 0 | super(id, model); |
| 69 | 0 | } |
| 70 | |
private static final long serialVersionUID = 1L; |
| 71 | |
|
| 72 | |
@Override |
| 73 | |
protected void populateItem(ListItem<ProblemReport> item) { |
| 74 | 0 | final ProblemReport pr = item.getModelObject(); |
| 75 | 0 | item.add(new Label("problemClass", pr.pclass)); |
| 76 | 0 | final Label l = new Label("problemSeverity", pr.isProblem ? "WARN" : "OK"); |
| 77 | 0 | l.add(new SimpleAttributeModifier("bgcolor", pr.isProblem ? LIGHT_RED : DARK_GREEN)); |
| 78 | 0 | item.add(l); |
| 79 | 0 | final Label desc = new Label("problemDesc", pr.desc); |
| 80 | 0 | desc.setEscapeModelStrings(false); |
| 81 | 0 | item.add(desc); |
| 82 | 0 | item.add(new Label("problemDiagnosis", pr.diagnosis)); |
| 83 | 0 | } |
| 84 | |
} |
| 85 | |
} |
| 86 | |
|