ref #9056:TabMan - Improve resource management in TabMan

https://support.d4science.org/issues/9056

Improve resources management

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-resources-widget@152495 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-08-04 13:26:59 +00:00
parent a9b730fe13
commit a0e3458727
1 changed files with 51 additions and 56 deletions

View File

@ -147,8 +147,6 @@ public class ResourcesPanel extends FramedPanel {
} }
public void open(TRId trId) { public void open(TRId trId) {
this.trId = trId; this.trId = trId;
create(); create();
@ -204,27 +202,19 @@ public class ResourcesPanel extends FramedPanel {
+ "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'><b>" + "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'><b>"
+ msgs.descriptionLabelFixed() + "</b></td>" + msgs.descriptionLabelFixed() + "</b></td>"
+ "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'>" + "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'>"
+ SafeHtmlUtils.htmlEscape(value.getDescription()) + + SafeHtmlUtils.htmlEscape(value.getDescription());
/*
"</td>" + "</tr>" + "<tr>" "</td>" + "</tr>" + "<tr>"
+ "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'><b>" + "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'><b>"
+ msgs.creationDateLabelFixed() + "</b></td>" + msgs.creationDateLabelFixed() + "</b></td>"
+ "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'>" + "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'>"
+ SafeHtmlUtils.htmlEscape(value.getCreationDate()) + + SafeHtmlUtils.htmlEscape(value.getCreationDate()) +
/* "</td>" + "</tr>" + "<tr>"
* "</td>" + "</tr>" + "<tr>" + + "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'><b>" + msgs.typeLabelFixed()
* "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'><b>" + "</b></td>" + "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'>"
* + msgs.creatorIdLabelFixed() + "</b></td>" + + SafeHtmlUtils.htmlEscape(value.getResourceType().toString()) + "</td>" + "</tr>";*/
* "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'>"
* + new SafeHtmlBuilder().append(value.getCreatorId()).
* toSafeHtml().asString() +
*/
"</td>" + "</tr>" + "<tr>" + "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'><b>"
+ msgs.typeLabelFixed() + "</b></td>"
+ "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'>"
+ SafeHtmlUtils.htmlEscape(value.getResourceType().toString()) + "</td>" + "</tr>";
ResourceTD resource = value.getResourceTD(); ResourceTD resource = value.getResourceTD();
String resourceData = ""; String resourceData = "";
@ -273,15 +263,23 @@ public class ResourcesPanel extends FramedPanel {
} else { } else {
if (resource instanceof SDMXResourceTD) { if (resource instanceof SDMXResourceTD) {
SDMXResourceTD sdmxResourceTD = (SDMXResourceTD) resource; SDMXResourceTD sdmxResourceTD = (SDMXResourceTD) resource;
if (sdmxResourceTD.getName() != null && !sdmxResourceTD.getName().isEmpty()) { /*
resourceData = resourceData + "<tr>" * if (sdmxResourceTD.getName() != null
+ "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'><b>" * &&
+ msgs.sdmxNameIdLabelFixed() + "</b></td>" * !sdmxResourceTD.getName().isEmpty())
+ "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'>" * { resourceData = resourceData +
+ "<span>" + SafeHtmlUtils.htmlEscape(sdmxResourceTD.getName()) * "<tr>" +
+ "</span>" + "</td>" + "</tr>"; * "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'><b>"
* + msgs.sdmxNameIdLabelFixed() +
} * "</b></td>" +
* "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'>"
* + "<span>" +
* SafeHtmlUtils.htmlEscape(
* sdmxResourceTD.getName()) + "</span>"
* + "</td>" + "</tr>";
*
* }
*/
if (sdmxResourceTD.getResourceUrl() != null if (sdmxResourceTD.getResourceUrl() != null
&& !sdmxResourceTD.getResourceUrl().isEmpty()) { && !sdmxResourceTD.getResourceUrl().isEmpty()) {
@ -346,11 +344,11 @@ public class ResourcesPanel extends FramedPanel {
}); });
expanderColumn.setHideable(false); expanderColumn.setHideable(false);
//SafeStylesBuilder styleB=new SafeStylesBuilder(); // SafeStylesBuilder styleB=new SafeStylesBuilder();
//expanderColumn.setColumnStyle(styleB.margin(5.0, Unit.PX).toSafeStyles()); // expanderColumn.setColumnStyle(styleB.margin(5.0,
// Unit.PX).toSafeStyles());
expanderColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); expanderColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
ColumnConfig<ResourceTDDescriptor, String> nameCol = new ColumnConfig<ResourceTDDescriptor, String>( ColumnConfig<ResourceTDDescriptor, String> nameCol = new ColumnConfig<ResourceTDDescriptor, String>(
props.name(), 140, msgs.nameCol()); props.name(), 140, msgs.nameCol());
@ -452,33 +450,33 @@ public class ResourcesPanel extends FramedPanel {
listOfActionCells) { listOfActionCells) {
// override the default layout // override the default layout
@Override @Override
protected <X> void render(Cell.Context context, ResourceTDDescriptor value, protected <X> void render(Cell.Context context, ResourceTDDescriptor value, SafeHtmlBuilder sb,
SafeHtmlBuilder sb, HasCell<ResourceTDDescriptor, X> hasCell) { HasCell<ResourceTDDescriptor, X> hasCell) {
// Override individual cell layout // Override individual cell layout
Cell<X> cell = hasCell.getCell(); Cell<X> cell = hasCell.getCell();
// set the width of the text input cell // set the width of the text input cell
if (value!=null&&value.getResourceType()!=null) { if (value != null && value.getResourceType() != null) {
switch(value.getResourceType()){ switch (value.getResourceType()) {
case CHART: case CHART:
sb.appendHtmlConstant("<div style='display:block;float:left;'>"); sb.appendHtmlConstant("<div style='display:block;float:left;'>");
cell.render(context, hasCell.getValue(value), sb); cell.render(context, hasCell.getValue(value), sb);
sb.appendHtmlConstant("</div>"); sb.appendHtmlConstant("</div>");
break; break;
case CODELIST: case CODELIST:
if(((String)hasCell.getValue(value)).compareTo("delete")==0){ if (((String) hasCell.getValue(value)).compareTo("delete") == 0) {
sb.appendHtmlConstant("<div style='display:block;float:left;'>"); sb.appendHtmlConstant("<div style='display:block;float:left;'>");
cell.render(context, hasCell.getValue(value), sb); cell.render(context, hasCell.getValue(value), sb);
sb.appendHtmlConstant("</div>"); sb.appendHtmlConstant("</div>");
} }
break; break;
case CSV: case CSV:
if(((String)hasCell.getValue(value)).compareTo("delete")==0){ if (((String) hasCell.getValue(value)).compareTo("delete") == 0) {
sb.appendHtmlConstant("<div style='display:block;float:left;'>"); sb.appendHtmlConstant("<div style='display:block;float:left;'>");
cell.render(context, hasCell.getValue(value), sb); cell.render(context, hasCell.getValue(value), sb);
sb.appendHtmlConstant("</div>"); sb.appendHtmlConstant("</div>");
} else { } else {
if(((String)hasCell.getValue(value)).compareTo("save")==0){ if (((String) hasCell.getValue(value)).compareTo("save") == 0) {
sb.appendHtmlConstant("<div style='display:block;float:left;'>"); sb.appendHtmlConstant("<div style='display:block;float:left;'>");
cell.render(context, hasCell.getValue(value), sb); cell.render(context, hasCell.getValue(value), sb);
sb.appendHtmlConstant("</div>"); sb.appendHtmlConstant("</div>");
@ -491,26 +489,26 @@ public class ResourcesPanel extends FramedPanel {
sb.appendHtmlConstant("</div>"); sb.appendHtmlConstant("</div>");
break; break;
case GENERIC_TABLE: case GENERIC_TABLE:
if(((String)hasCell.getValue(value)).compareTo("delete")==0){ if (((String) hasCell.getValue(value)).compareTo("delete") == 0) {
sb.appendHtmlConstant("<div style='display:block;float:left;'>"); sb.appendHtmlConstant("<div style='display:block;float:left;'>");
cell.render(context, hasCell.getValue(value), sb); cell.render(context, hasCell.getValue(value), sb);
sb.appendHtmlConstant("</div>"); sb.appendHtmlConstant("</div>");
} }
break; break;
case GUESSER: case GUESSER:
if(((String)hasCell.getValue(value)).compareTo("delete")==0){ if (((String) hasCell.getValue(value)).compareTo("delete") == 0) {
sb.appendHtmlConstant("<div style='display:block;float:left;'>"); sb.appendHtmlConstant("<div style='display:block;float:left;'>");
cell.render(context, hasCell.getValue(value), sb); cell.render(context, hasCell.getValue(value), sb);
sb.appendHtmlConstant("</div>"); sb.appendHtmlConstant("</div>");
} }
break; break;
case JSON: case JSON:
if(((String)hasCell.getValue(value)).compareTo("delete")==0){ if (((String) hasCell.getValue(value)).compareTo("delete") == 0) {
sb.appendHtmlConstant("<div style='display:block;float:left;'>"); sb.appendHtmlConstant("<div style='display:block;float:left;'>");
cell.render(context, hasCell.getValue(value), sb); cell.render(context, hasCell.getValue(value), sb);
sb.appendHtmlConstant("</div>"); sb.appendHtmlConstant("</div>");
} else { } else {
if(((String)hasCell.getValue(value)).compareTo("save")==0){ if (((String) hasCell.getValue(value)).compareTo("save") == 0) {
sb.appendHtmlConstant("<div style='display:block;float:left;'>"); sb.appendHtmlConstant("<div style='display:block;float:left;'>");
cell.render(context, hasCell.getValue(value), sb); cell.render(context, hasCell.getValue(value), sb);
sb.appendHtmlConstant("</div>"); sb.appendHtmlConstant("</div>");
@ -518,12 +516,12 @@ public class ResourcesPanel extends FramedPanel {
} }
break; break;
case MAP: case MAP:
if(((String)hasCell.getValue(value)).compareTo("delete")==0){ if (((String) hasCell.getValue(value)).compareTo("delete") == 0) {
sb.appendHtmlConstant("<div style='display:block;float:left;'>"); sb.appendHtmlConstant("<div style='display:block;float:left;'>");
cell.render(context, hasCell.getValue(value), sb); cell.render(context, hasCell.getValue(value), sb);
sb.appendHtmlConstant("</div>"); sb.appendHtmlConstant("</div>");
} else { } else {
if(((String)hasCell.getValue(value)).compareTo("open")==0){ if (((String) hasCell.getValue(value)).compareTo("open") == 0) {
sb.appendHtmlConstant("<div style='display:block;float:left;'>"); sb.appendHtmlConstant("<div style='display:block;float:left;'>");
cell.render(context, hasCell.getValue(value), sb); cell.render(context, hasCell.getValue(value), sb);
sb.appendHtmlConstant("</div>"); sb.appendHtmlConstant("</div>");
@ -531,12 +529,12 @@ public class ResourcesPanel extends FramedPanel {
} }
break; break;
case SDMX: case SDMX:
if(((String)hasCell.getValue(value)).compareTo("delete")==0){ if (((String) hasCell.getValue(value)).compareTo("delete") == 0) {
sb.appendHtmlConstant("<div style='display:block;float:left;'>"); sb.appendHtmlConstant("<div style='display:block;float:left;'>");
cell.render(context, hasCell.getValue(value), sb); cell.render(context, hasCell.getValue(value), sb);
sb.appendHtmlConstant("</div>"); sb.appendHtmlConstant("</div>");
} else { } else {
if(((String)hasCell.getValue(value)).compareTo("open")==0){ if (((String) hasCell.getValue(value)).compareTo("open") == 0) {
sb.appendHtmlConstant("<div style='display:block;float:left;'>"); sb.appendHtmlConstant("<div style='display:block;float:left;'>");
cell.render(context, hasCell.getValue(value), sb); cell.render(context, hasCell.getValue(value), sb);
sb.appendHtmlConstant("</div>"); sb.appendHtmlConstant("</div>");
@ -544,7 +542,7 @@ public class ResourcesPanel extends FramedPanel {
} }
break; break;
default: default:
if(((String)hasCell.getValue(value)).compareTo("delete")==0){ if (((String) hasCell.getValue(value)).compareTo("delete") == 0) {
sb.appendHtmlConstant("<div style='display:block;float:left;'>"); sb.appendHtmlConstant("<div style='display:block;float:left;'>");
cell.render(context, hasCell.getValue(value), sb); cell.render(context, hasCell.getValue(value), sb);
sb.appendHtmlConstant("</div>"); sb.appendHtmlConstant("</div>");
@ -553,16 +551,12 @@ public class ResourcesPanel extends FramedPanel {
} }
}
}
} }
}; };
ColumnConfig<ResourceTDDescriptor, ResourceTDDescriptor> actionColumn = new ColumnConfig<ResourceTDDescriptor, ResourceTDDescriptor>( ColumnConfig<ResourceTDDescriptor, ResourceTDDescriptor> actionColumn = new ColumnConfig<ResourceTDDescriptor, ResourceTDDescriptor>(
new IdentityValueProvider<ResourceTDDescriptor>("Action")); new IdentityValueProvider<ResourceTDDescriptor>("Action"));
@ -652,7 +646,6 @@ public class ResourcesPanel extends FramedPanel {
expanderColumn.initPlugin(grid); expanderColumn.initPlugin(grid);
createContextMenu(); createContextMenu();
SelectHandler sh = new SelectHandler() { SelectHandler sh = new SelectHandler() {
@ -674,6 +667,8 @@ public class ResourcesPanel extends FramedPanel {
private boolean select(ResourceTDDescriptor item, String searchTerm) { private boolean select(ResourceTDDescriptor item, String searchTerm) {
if (item.getName() != null && item.getName().toLowerCase().contains(searchTerm.toLowerCase())) if (item.getName() != null && item.getName().toLowerCase().contains(searchTerm.toLowerCase()))
return true; return true;
if (item.getCreationDate() != null && item.getCreationDate().toLowerCase().contains(searchTerm.toLowerCase()))
return true;
return false; return false;
} }