/
ProblemsView.java
103 lines (88 loc) · 2.97 KB
/
ProblemsView.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*******************************************************************************
* Copyright (c) 2017 Red Hat, Inc and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc - initial API and implementation
*******************************************************************************/
package org.eclipse.reddeer.eclipse.ui.views.markers;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.reddeer.common.wait.TimePeriod;
import org.eclipse.reddeer.common.wait.WaitUntil;
import org.eclipse.reddeer.common.wait.WaitWhile;
import org.eclipse.reddeer.eclipse.condition.AbstractExtendedMarkersViewIsUpdating;
import org.eclipse.reddeer.eclipse.ui.markers.matcher.AbstractMarkerMatcher;
import org.eclipse.reddeer.eclipse.ui.problems.Problem;
/**
* Represents the Problems view.
*
* @author mlabuda@redhat.com
*
*/
public class ProblemsView extends AbstractMarkersSupportView {
/**
* Constructs the view with "Problems".
*/
public ProblemsView() {
super("Problems");
}
/**
* Returns a list of problems that are of a specific type or any and that are matching specified matchers.
*
* @param problemType type of a problem
* @param matchers matchers of columns
* @return list of problem
*/
public List<Problem> getProblems(ProblemType problemType, AbstractMarkerMatcher... matchers) {
activate();
new WaitUntil(new ProblemsViewMarkerIsUpdating(),TimePeriod.SHORT,false);
new WaitWhile(new ProblemsViewMarkerIsUpdating());
List<Problem> result = new ArrayList<Problem>();
if (problemType.equals(ProblemType.ERROR) || problemType.equals(ProblemType.ALL)) {
result.addAll(getMarkers(Problem.class, ProblemType.ERROR.toString(), matchers));
}
if (problemType.equals(ProblemType.WARNING) || problemType.equals(ProblemType.ALL)) {
result.addAll(getMarkers(Problem.class, ProblemType.WARNING.toString(), matchers));
}
return result;
}
/**
* Enum for type of a problem. Currently only warning and errors are supported although there is also info type.
*
* @author mlabuda@redhat.com
* @since 0.7
*/
public enum ProblemType {
WARNING("Warnings"),
ERROR("Errors"),
ALL("ALL");
String text;
private ProblemType(String text) {
this.text = text;
}
public String toString() {
return text;
}
public static ProblemType fromString(String type) {
if (type.equals("Warnings")) {
return ProblemType.WARNING;
} else {
return ProblemType.ERROR;
}
}
}
/**
* Returns true if Problems view marker is updating its UI.
*/
@SuppressWarnings("restriction")
private class ProblemsViewMarkerIsUpdating extends AbstractExtendedMarkersViewIsUpdating {
public ProblemsViewMarkerIsUpdating() {
super(ProblemsView.this, org.eclipse.ui.internal.views.markers.ProblemsView.class);
}
}
}