Skip to content

Commit 02f6f59

Browse files
committed
vectorial enabled/disabled icons
1 parent 5a0f2f6 commit 02f6f59

33 files changed

+352
-196
lines changed

logicaldoc-gui/src/main/java/com/logicaldoc/gui/common/client/data/LDAPServersDS.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.logicaldoc.gui.common.client.data;
22

33
import com.smartgwt.client.data.DataSource;
4-
import com.smartgwt.client.data.fields.DataSourceImageField;
4+
import com.smartgwt.client.data.fields.DataSourceBooleanField;
55
import com.smartgwt.client.data.fields.DataSourceTextField;
66

77
/**
@@ -18,7 +18,7 @@ public LDAPServersDS() {
1818
DataSourceTextField id = new DataSourceTextField("id");
1919
id.setPrimaryKey(true);
2020
DataSourceTextField src = new DataSourceTextField("url");
21-
DataSourceImageField enabled = new DataSourceImageField("eenabled");
21+
DataSourceBooleanField enabled = new DataSourceBooleanField("eenabled");
2222

2323
setFields(id, src, enabled);
2424
setDataURL("data/ldapservers.xml");

logicaldoc-gui/src/main/java/com/logicaldoc/gui/common/client/data/TenantsDS.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.smartgwt.client.data.DataSource;
44
import com.smartgwt.client.data.fields.DataSourceBooleanField;
55
import com.smartgwt.client.data.fields.DataSourceDateTimeField;
6-
import com.smartgwt.client.data.fields.DataSourceImageField;
76
import com.smartgwt.client.data.fields.DataSourceTextField;
87

98
/**
@@ -26,7 +25,6 @@ public TenantsDS(boolean appendSystemTenant) {
2625

2726
DataSourceTextField name = new DataSourceTextField("name");
2827
DataSourceTextField displayName = new DataSourceTextField("displayName");
29-
DataSourceImageField enabledIcon = new DataSourceImageField("enabledIcon");
3028
DataSourceBooleanField enabled = new DataSourceBooleanField("eenabled");
3129
DataSourceTextField email = new DataSourceTextField("email");
3230
DataSourceTextField city = new DataSourceTextField("city");
@@ -37,8 +35,7 @@ public TenantsDS(boolean appendSystemTenant) {
3735
DataSourceTextField address = new DataSourceTextField("address");
3836
DataSourceDateTimeField expire = new DataSourceDateTimeField("expire");
3937

40-
setFields(id, name, enabledIcon, enabled, expire, displayName, email, city, country, telephone, postalCode,
41-
state, address);
38+
setFields(id, name, enabled, expire, displayName, email, city, country, telephone, postalCode, state, address);
4239
setDataURL("data/tenants.xml" + (appendSystemTenant ? "?appendSystemTenant=true" : ""));
4340
setClientOnly(true);
4441
}

logicaldoc-gui/src/main/java/com/logicaldoc/gui/common/client/data/UsersDS.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public UsersDS(String groupIdOrName, boolean required, boolean skipDisabled) {
2626
DataSourceTextField label = new DataSourceTextField("label");
2727
DataSourceBooleanField guest = new DataSourceBooleanField("guest");
2828
guest.setHidden(true);
29-
DataSourceImageField eenabled = new DataSourceImageField("enabledIcon");
3029
DataSourceBooleanField enabled = new DataSourceBooleanField("eenabled");
3130
DataSourceTextField name = new DataSourceTextField("name");
3231
DataSourceTextField firstName = new DataSourceTextField("firstName");
@@ -47,9 +46,9 @@ public UsersDS(String groupIdOrName, boolean required, boolean skipDisabled) {
4746
DataSourceDateField creation = new DataSourceDateField("creation");
4847
DataSourceIntegerField source = new DataSourceIntegerField("source");
4948

50-
setFields(id, username, label, eenabled, enabled, name, firstName, email, phone, cell, city, company,
51-
department, organizationalUnit, building, groups, usergroup, guest, lastlogin, expire, creation, avatar,
52-
timeZone, source);
49+
setFields(id, username, label, enabled, name, firstName, email, phone, cell, city, company, department,
50+
organizationalUnit, building, groups, usergroup, guest, lastlogin, expire, creation, avatar, timeZone,
51+
source);
5352
setDataURL("data/users.xml?1=1" + (groupIdOrName != null ? "&groupId=" + groupIdOrName : "") + "&required="
5453
+ required + "&skipdisabled=" + skipDisabled);
5554
setClientOnly(true);

logicaldoc-gui/src/main/java/com/logicaldoc/gui/common/client/util/AwesomeFactory.java

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,16 @@ public static String getSpinnerIconHtml(String icon, String text) {
159159
}
160160

161161
public static String getIconButtonHTML(String icon, String text, String tooltip, String color, String url) {
162+
return getIconButtonHTML(icon, text, tooltip, color, null, url);
163+
}
164+
165+
public static String getIconButtonHTML(String icon, String text, String tooltip, String color, String animation,
166+
String url) {
162167
String button = DIV_CLASS_STATUS_ICON
163168
+ (tooltip != null && !tooltip.isEmpty() ? TITLE + I18N.message(tooltip) + "'" : "")
164169
+ (color != null && !color.isEmpty() ? STYLE_COLOR + color + "'" : "")
165170
+ (url != null && !url.isEmpty() ? " onclick=\"download('" + url + "')\"" : "") + " >";
166-
button += getColoredIconHtml(icon, text, color);
171+
button += getColoredIconHtml(icon, text, color, animation);
167172
button += CLOSE_DIV;
168173

169174
return button;
@@ -233,24 +238,40 @@ public static String getIconHtml(String icon, String text) {
233238
}
234239

235240
public static String getColoredIconHtml(String icon, String text, String color) {
236-
return getColoredIconHtmlWithoutI18N(icon, I18N.message(text), color);
241+
return getColoredIconHtml(icon, I18N.message(text), color, null);
242+
}
243+
244+
public static String getColoredIconHtml(String icon, String text, String color, String animation) {
245+
return getColoredIconHtmlWithoutI18N(icon, I18N.message(text), color, animation);
237246
}
238247

239248
public static String getIconHtml(String icon, String rotation, String text) {
249+
return getIconHtml(icon, rotation, text, null);
250+
}
251+
252+
public static String getIconHtml(String icon, String rotation, String text, String animation) {
240253
if (text == null || text.isEmpty())
241254
return I_CLASS + getCssClassPrefix() + " fa-" + icon + (rotation != null ? " " + rotation : "") + " fa-"
242-
+ STYLE + "' aria-hidden='true'></i>";
255+
+ STYLE + (animation != null && !animation.isEmpty() ? " fa-" + animation : "")
256+
+ "' aria-hidden='true'></i>";
243257
else
244258
return DIV_I_CLASS + getCssClassPrefix() + " fa-" + icon + (rotation != null ? " " + rotation : "") + " fa-"
245259
+ STYLE + " fa-fw' aria-hidden='true'></i> " + I18N.message(text) + CLOSE_DIV;
246260
}
247261

248262
public static String getColoredIconHtmlWithoutI18N(String icon, String text, String color) {
263+
return getColoredIconHtmlWithoutI18N(icon, text, color, null);
264+
}
265+
266+
public static String getColoredIconHtmlWithoutI18N(String icon, String text, String color, String animation) {
249267
if (text == null || text.isEmpty())
250-
return I_CLASS + getCssClassPrefix() + " fa-" + icon + " fa-" + STYLE + "' aria-hidden='true' "
268+
return I_CLASS + getCssClassPrefix() + " fa-" + icon + " fa-" + STYLE
269+
+ (animation != null && !animation.isEmpty() ? " fa-" + animation : "") + "' aria-hidden='true' "
251270
+ (color != null && !color.isEmpty() ? "style='color: " + color + "'" : "") + "></i>";
252271
else
253-
return DIV_I_CLASS + getCssClassPrefix() + " fa-" + icon + " fa-" + STYLE + " fa-fw' aria-hidden='true'"
272+
return DIV_I_CLASS + getCssClassPrefix() + " fa-" + icon + " fa-" + STYLE
273+
+ (animation != null && !animation.isEmpty() ? " fa-" + animation : "")
274+
+ " fa-fw' aria-hidden='true'"
254275
+ (color != null && !color.isEmpty() ? "style='color: " + color + "'" : "") + "></i> " + text
255276
+ CLOSE_DIV;
256277
}

logicaldoc-gui/src/main/java/com/logicaldoc/gui/common/client/widgets/UserPickListProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.logicaldoc.gui.common.client.widgets;
22

3-
import com.logicaldoc.gui.common.client.formatters.UserCellFormatter;
3+
import com.logicaldoc.gui.common.client.widgets.grid.formatters.UserCellFormatter;
44
import com.smartgwt.client.widgets.grid.ListGrid;
55

66
/**
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.logicaldoc.gui.common.client.widgets.grid;
2+
3+
import com.logicaldoc.gui.common.client.widgets.grid.formatters.EnabledCellFormatter;
4+
import com.smartgwt.client.widgets.grid.ListGridRecord;
5+
6+
/**
7+
* A field to display dates but also sensible to the enabled status of the
8+
* record
9+
*
10+
* @author Marco Meschieri - LogicalDOC
11+
* @since 9.1.1
12+
*/
13+
public class EnabledDateListGridField extends DateListGridField {
14+
15+
public EnabledDateListGridField(String name, String title, int format) {
16+
super(name, title, format);
17+
}
18+
19+
public EnabledDateListGridField(String name, String title) {
20+
this(name, title, DateCellFormatter.FORMAT_DEFAULT);
21+
22+
setCellFormatter(new DateCellFormatter() {
23+
24+
@Override
25+
public String format(Object value, ListGridRecord rec, int rowNum, int colNum) {
26+
String content = super.format(value, rec, rowNum, colNum);
27+
return new EnabledCellFormatter().format(content, rec, rowNum, colNum);
28+
}
29+
});
30+
}
31+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.logicaldoc.gui.common.client.widgets.grid;
2+
3+
import com.logicaldoc.gui.common.client.util.AwesomeFactory;
4+
import com.smartgwt.client.widgets.grid.ListGridField;
5+
import com.smartgwt.client.widgets.grid.ListGridRecord;
6+
7+
/**
8+
* A field to display the enabled/disabled status, it must be bound to a boolean
9+
* column named eenabled
10+
*
11+
* @author Marco Meschieri - LogicalDOC
12+
* @since 9.1.1
13+
*/
14+
public class EnabledListGridField extends ListGridField {
15+
16+
public EnabledListGridField() {
17+
super("eenabled", " ", 30);
18+
setCanFilter(true);
19+
setCanSort(true);
20+
setCellFormatter((value, rec, rowNum, colNum) -> formatStatusIconCell(rec));
21+
}
22+
23+
private String formatStatusIconCell(ListGridRecord rec) {
24+
Boolean enabled = rec.getAttributeAsBoolean("eenabled");
25+
if (enabled == null)
26+
return "";
27+
28+
String content = "<div style='display: flex; text-align: center; justify-content: center;'>";
29+
if (Boolean.TRUE.equals(enabled)) {
30+
content += AwesomeFactory.getIconButtonHTML("circle-check", null, "enabled", "green", null);
31+
} else {
32+
content += AwesomeFactory.getIconButtonHTML("ban", null, "disabled", "red", null);
33+
}
34+
content += "</div>";
35+
return content;
36+
}
37+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.logicaldoc.gui.common.client.widgets.grid;
2+
3+
import com.logicaldoc.gui.common.client.util.AwesomeFactory;
4+
import com.smartgwt.client.widgets.grid.ListGridRecord;
5+
6+
/**
7+
* A field to display the running status, it must be bound to a boolean column
8+
* named running
9+
*
10+
* @author Marco Meschieri - LogicalDOC
11+
* @since 9.1.1
12+
*/
13+
public class RunningListGridField extends ColoredListGridField {
14+
15+
public RunningListGridField() {
16+
super("running", " ", 30);
17+
setCanFilter(true);
18+
setCanSort(true);
19+
setCellFormatter((value, rec, rowNum, colNum) -> formatStatusIconCell(rec));
20+
}
21+
22+
private String formatStatusIconCell(ListGridRecord rec) {
23+
String color = rec.getAttributeAsString(colorFieldName);
24+
Boolean running = rec.getAttributeAsBoolean("running");
25+
if (running == null)
26+
return "";
27+
28+
String content = "<div style='display: flex; text-align: center; justify-content: center;'>";
29+
if (Boolean.TRUE.equals(running)) {
30+
content += AwesomeFactory.getIconButtonHTML("cog", null, "running", color, "spin", null);
31+
} else {
32+
content += AwesomeFactory.getIconButtonHTML("cog", null, "idle", color, null);
33+
}
34+
content += "</div>";
35+
return content;
36+
}
37+
}

logicaldoc-gui/src/main/java/com/logicaldoc/gui/common/client/widgets/grid/StatusIconsListGridField.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public StatusIconsListGridField() {
3434
setWidth(110);
3535
setCanFilter(false);
3636
setCanSort(false);
37-
setCellFormatter((Object value, ListGridRecord rec, int rowNum, int colNum) -> formatStatusIconCell(rec));
37+
setCellFormatter((value, rec, rowNum, colNum) -> formatStatusIconCell(rec));
3838
}
3939

4040
private String formatStatusIconCell(ListGridRecord rec) {
41-
String color = rec.getAttributeAsString("color");
41+
String color = rec.getAttributeAsString(colorFieldName);
4242

4343
String content = "<div style='display: flex; text-align: center; justify-content: center;'>";
4444

logicaldoc-gui/src/main/java/com/logicaldoc/gui/common/client/widgets/grid/IconGridField.java renamed to logicaldoc-gui/src/main/java/com/logicaldoc/gui/common/client/widgets/grid/TypeIconGridField.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
* @author Marco Meschieri - LogicalDOC
1616
* @since 8.8.6
1717
*/
18-
public class IconGridField extends ListGridField {
18+
public class TypeIconGridField extends ListGridField {
1919

20-
public IconGridField() {
20+
public TypeIconGridField() {
2121
super("icon", " ", 30);
2222
setType(ListGridFieldType.TEXT);
2323
setCanSort(false);

0 commit comments

Comments
 (0)