| | |
| | | import org.wicketstuff.googlecharts.IChartData;
|
| | |
|
| | | import com.gitblit.Constants;
|
| | | import com.gitblit.Constants.AccessPermission;
|
| | | import com.gitblit.Constants.FederationPullStatus;
|
| | | import com.gitblit.GitBlit;
|
| | | import com.gitblit.Keys;
|
| | |
| | |
|
| | | public class WicketUtils {
|
| | |
|
| | | public static Component setCssClass(Component container, String value) {
|
| | | public static void setCssClass(Component container, String value) {
|
| | | container.add(new SimpleAttributeModifier("class", value));
|
| | | return container;
|
| | | }
|
| | |
|
| | | public static Component setCssStyle(Component container, String value) {
|
| | | public static void setCssStyle(Component container, String value) {
|
| | | container.add(new SimpleAttributeModifier("style", value));
|
| | | return container;
|
| | | }
|
| | |
|
| | | public static Component setCssBackground(Component container, String value) {
|
| | | public static void setCssBackground(Component container, String value) {
|
| | | String background = MessageFormat.format("background-color:{0};",
|
| | | StringUtils.getColor(value));
|
| | | container.add(new SimpleAttributeModifier("style", background));
|
| | | return container;
|
| | | }
|
| | |
|
| | | public static Component setHtmlTooltip(Component container, String value) {
|
| | | public static void setHtmlTooltip(Component container, String value) {
|
| | | container.add(new SimpleAttributeModifier("title", value));
|
| | | return container;
|
| | | }
|
| | |
|
| | | public static Component setInputPlaceholder(Component container, String value) {
|
| | | public static void setInputPlaceholder(Component container, String value) {
|
| | | container.add(new SimpleAttributeModifier("placeholder", value));
|
| | | return container;
|
| | | }
|
| | |
|
| | | public static Component setChangeTypeCssClass(Component container, ChangeType type) {
|
| | | public static void setChangeTypeCssClass(Component container, ChangeType type) {
|
| | | switch (type) {
|
| | | case ADD:
|
| | | setCssClass(container, "addition");
|
| | |
| | | setCssClass(container, "modification");
|
| | | break;
|
| | | }
|
| | | return container;
|
| | | }
|
| | |
|
| | | public static Component setTicketCssClass(Component container, String state) {
|
| | | public static void setTicketCssClass(Component container, String state) {
|
| | | String css = null;
|
| | | if (state.equals("open")) {
|
| | | css = "label label-important";
|
| | |
| | | if (css != null) {
|
| | | setCssClass(container, css);
|
| | | }
|
| | | return container;
|
| | | }
|
| | | |
| | | public static void setPermissionClass(Component container, AccessPermission permission) {
|
| | | if (permission == null) {
|
| | | setCssClass(container, "badge");
|
| | | return;
|
| | | }
|
| | | switch (permission) {
|
| | | case REWIND:
|
| | | case DELETE:
|
| | | case CREATE:
|
| | | setCssClass(container, "badge badge-success");
|
| | | break;
|
| | | case PUSH:
|
| | | setCssClass(container, "badge badge-info");
|
| | | break;
|
| | | case CLONE:
|
| | | setCssClass(container, "badge badge-inverse");
|
| | | break;
|
| | | default:
|
| | | setCssClass(container, "badge");
|
| | | break;
|
| | | } |
| | | }
|
| | |
|
| | | public static Component setAlternatingBackground(Component c, int i) {
|
| | | public static void setAlternatingBackground(Component c, int i) {
|
| | | String clazz = i % 2 == 0 ? "light" : "dark";
|
| | | setCssClass(c, clazz);
|
| | | return c;
|
| | | }
|
| | |
|
| | | public static Label createAuthorLabel(String wicketId, String author) {
|
| | |
| | | return new PageParameters("r=" + repositoryName + ",h=" + objectId);
|
| | | }
|
| | |
|
| | | public static PageParameters newRangeParameter(String repositoryName, String startRange, String endRange) {
|
| | | return new PageParameters("r=" + repositoryName + ",h=" + startRange + ".." + endRange);
|
| | | }
|
| | |
|
| | | public static PageParameters newPathParameter(String repositoryName, String objectId,
|
| | | String path) {
|
| | | if (StringUtils.isEmpty(path)) {
|
| | |
| | | }
|
| | |
|
| | | public static int getDaysBack(PageParameters params) {
|
| | | return params.getInt("db", 14);
|
| | | return params.getInt("db", 0);
|
| | | }
|
| | |
|
| | | public static String getUsername(PageParameters params) {
|
| | |
| | | dateString = df.format(date);
|
| | | }
|
| | | String title = null;
|
| | | if (TimeUtils.isToday(date)) {
|
| | | if (TimeUtils.isToday(date, timeZone)) {
|
| | | title = timeUtils.today();
|
| | | } else if (TimeUtils.isYesterday(date)) {
|
| | | } else if (TimeUtils.isYesterday(date, timeZone)) {
|
| | | title = timeUtils.yesterday();
|
| | | } else if (date.getTime() <= System.currentTimeMillis()) {
|
| | | // past
|