Updated Manage Resources
This commit is contained in:
parent
515c3ebb88
commit
ed87b4c8ca
|
@ -9,6 +9,7 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.AddResou
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.AddResourceEventHandler;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.AddResourceEventHandler;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteResourceEvent;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteResourceEvent;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteResourceEventHandler;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteResourceEventHandler;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.ReloadDatasetPageEvent;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.utils.LoaderIcon;
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.utils.LoaderIcon;
|
||||||
|
|
||||||
|
@ -16,7 +17,6 @@ import com.github.gwtbootstrap.client.ui.Accordion;
|
||||||
import com.github.gwtbootstrap.client.ui.AccordionGroup;
|
import com.github.gwtbootstrap.client.ui.AccordionGroup;
|
||||||
import com.github.gwtbootstrap.client.ui.Alert;
|
import com.github.gwtbootstrap.client.ui.Alert;
|
||||||
import com.github.gwtbootstrap.client.ui.Button;
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
import com.github.gwtbootstrap.client.ui.Paragraph;
|
|
||||||
import com.github.gwtbootstrap.client.ui.Tab;
|
import com.github.gwtbootstrap.client.ui.Tab;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.IconPosition;
|
import com.github.gwtbootstrap.client.ui.constants.IconPosition;
|
||||||
|
@ -29,6 +29,7 @@ import com.google.gwt.uibinder.client.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
import com.google.gwt.user.client.ui.FlexTable;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
@ -118,24 +119,32 @@ public class AddedResourcesSummary extends Composite {
|
||||||
tabAddedResources.setIconPosition(IconPosition.RIGHT);
|
tabAddedResources.setIconPosition(IconPosition.RIGHT);
|
||||||
|
|
||||||
// get the resource
|
// get the resource
|
||||||
final ResourceElementBean justAddedResource = addResourceEvent.getResource();
|
final ResourceElementBean addedResourceBean = addResourceEvent.getResource();
|
||||||
|
|
||||||
// Build an accordion to show resource info
|
// Build an accordion to show resource info
|
||||||
final Accordion accordion = new Accordion();
|
final Accordion accordion = new Accordion();
|
||||||
AccordionGroup accordionGroup = new AccordionGroup();
|
AccordionGroup accordionGroup = new AccordionGroup();
|
||||||
accordionGroup.setHeading("* " + justAddedResource.getName());
|
accordionGroup.setHeading("* " + addedResourceBean.getName());
|
||||||
accordionGroup.getHeading().addStyleName("accordion-resource-added");
|
accordionGroup.getHeading().addStyleName("accordion-resource-added");
|
||||||
accordion.add(accordionGroup);
|
accordion.add(accordionGroup);
|
||||||
|
|
||||||
|
FlexTable resourceTable = new FlexTable();
|
||||||
|
resourceTable.addStyleName("resource-table");
|
||||||
|
|
||||||
// add sub-info such as url and description
|
// add sub-info such as url and description
|
||||||
HTML htmlURL = new HTML();
|
//HTML htmlURL = new HTML();
|
||||||
if (justAddedResource.getUrl() != null) {
|
if (addedResourceBean.getUrl() != null) {
|
||||||
htmlURL.setHTML(
|
// htmlURL.setHTML(
|
||||||
"URL: <a href=" + justAddedResource.getUrl() + ">" + justAddedResource.getUrl() + "</a>");
|
// "URL: <a href=" + addedResourceBean.getUrl() + ">" + addedResourceBean.getUrl() + "</a>");
|
||||||
|
resourceTable.setWidget(0, 0, new HTML("URL"));
|
||||||
|
resourceTable.setWidget(0, 1, new HTML("<a href=" + addedResourceBean.getUrl() + ">" + addedResourceBean.getUrl() + "</a>"));
|
||||||
|
|
||||||
}
|
}
|
||||||
Paragraph pDescription = new Paragraph();
|
//Paragraph pDescription = new Paragraph();
|
||||||
pDescription.setText("Description : " + justAddedResource.getDescription());
|
//pDescription.setText("Description : " + addedResourceBean.getDescription());
|
||||||
|
|
||||||
|
resourceTable.setWidget(1, 0, new HTML("Description"));
|
||||||
|
resourceTable.setWidget(1, 1, new HTML(addedResourceBean.getDescription()));
|
||||||
|
|
||||||
// button to delete the resource
|
// button to delete the resource
|
||||||
final Button deleteButton = new Button();
|
final Button deleteButton = new Button();
|
||||||
|
@ -145,23 +154,23 @@ public class AddedResourcesSummary extends Composite {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
|
|
||||||
eventBus.fireEvent(new DeleteResourceEvent(deleteButton, justAddedResource));
|
eventBus.fireEvent(new DeleteResourceEvent(deleteButton, addedResourceBean));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// fill accordion
|
// fill accordion
|
||||||
accordionGroup.add(htmlURL);
|
//accordionGroup.add(htmlURL);
|
||||||
accordionGroup.add(pDescription);
|
accordionGroup.add(resourceTable);
|
||||||
accordionGroup.add(deleteButton);
|
accordionGroup.add(deleteButton);
|
||||||
|
|
||||||
// add to the list
|
// add to the list
|
||||||
addedResources.add(justAddedResource);
|
addedResources.add(addedResourceBean);
|
||||||
|
|
||||||
// add to the panel
|
// add to the panel
|
||||||
addResourcesPanel.add(accordion);
|
addResourcesPanel.add(accordion);
|
||||||
|
|
||||||
mapAddedResources.put(justAddedResource.getBeanID(), accordion);
|
mapAddedResources.put(addedResourceBean.getBeanID(), accordion);
|
||||||
checkNoResources();
|
checkNoResources();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -205,6 +214,11 @@ public class AddedResourcesSummary extends Composite {
|
||||||
// remove from the list
|
// remove from the list
|
||||||
addedResources.remove(toDelete);
|
addedResources.remove(toDelete);
|
||||||
addResourcesPanel.remove(toDeleteAccordion);
|
addResourcesPanel.remove(toDeleteAccordion);
|
||||||
|
|
||||||
|
//Firing event to reload the dataset page
|
||||||
|
eventBus.fireEvent(new ReloadDatasetPageEvent(
|
||||||
|
deleteResourceEvent.getResource().getCkanDatasetId()));
|
||||||
|
|
||||||
checkNoResources();
|
checkNoResources();
|
||||||
} else {
|
} else {
|
||||||
setAlertMessage(null, "Sorry, the resource described by '"
|
setAlertMessage(null, "Sorry, the resource described by '"
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||||
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||||
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
|
xmlns:g="urn:import:com.google.gwt.user.client.ui"
|
||||||
xmlns:g="urn:import:com.google.gwt.user.client.ui">
|
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
|
||||||
|
<ui:style>
|
||||||
|
|
||||||
|
</ui:style>
|
||||||
<g:HTMLPanel>
|
<g:HTMLPanel>
|
||||||
<h3>Added Resources</h3>
|
<div style="font-size: 21px; color: #333; line-height: 40px; padding: 10px;">Added Resources</div>
|
||||||
<g:VerticalPanel ui:field="addResourcesPanel"
|
<g:VerticalPanel ui:field="addResourcesPanel"
|
||||||
width="100%">
|
width="100%">
|
||||||
<b:Alert visible="false" ui:field="alertMessage"></b:Alert>
|
<b:Alert visible="false" ui:field="alertMessage"></b:Alert>
|
||||||
|
|
|
@ -7,6 +7,8 @@ import com.github.gwtbootstrap.client.ui.TabPanel;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
||||||
import com.github.gwtbootstrap.client.ui.resources.Bootstrap.Tabs;
|
import com.github.gwtbootstrap.client.ui.resources.Bootstrap.Tabs;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.core.client.Scheduler;
|
||||||
|
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.event.shared.HandlerManager;
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
|
@ -33,7 +35,7 @@ public class ManageResources extends Composite {
|
||||||
|
|
||||||
private AddedResourcesSummary addedResourcesSummary;
|
private AddedResourcesSummary addedResourcesSummary;
|
||||||
|
|
||||||
private AddResourceToDataset resourceForm;
|
private AddResourceToDataset addResourceForm;
|
||||||
|
|
||||||
private HandlerManager eventBus;
|
private HandlerManager eventBus;
|
||||||
|
|
||||||
|
@ -43,19 +45,27 @@ public class ManageResources extends Composite {
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
|
|
||||||
resourceForm = new AddResourceToDataset(eventBus, theDatasetBean.getId(), theDatasetBean.getTitle(),
|
addResourceForm = new AddResourceToDataset(eventBus, theDatasetBean.getId(), theDatasetBean.getTitle(),
|
||||||
theDatasetBean.getSelectedOrganization(), datasetUrl);
|
theDatasetBean.getSelectedOrganization(), datasetUrl);
|
||||||
|
|
||||||
addedResourcesSummary = new AddedResourcesSummary(eventBus, addedResources, addedResourcesIcon);
|
addedResourcesSummary = new AddedResourcesSummary(eventBus, addedResources, addedResourcesIcon);
|
||||||
|
|
||||||
// tab for the form
|
// tab for the form
|
||||||
addResources.add(resourceForm);
|
addResources.add(addResourceForm);
|
||||||
addedResources.add(addedResourcesSummary);
|
addedResources.add(addedResourcesSummary);
|
||||||
|
|
||||||
tabPanel.setTabPosition(Tabs.LEFT.name());
|
|
||||||
tabPanel.selectTab(0);
|
|
||||||
|
|
||||||
bind();
|
bind();
|
||||||
|
|
||||||
|
tabPanel.setTabPosition(Tabs.ABOVE.name());
|
||||||
|
tabPanel.selectTab(0);
|
||||||
|
|
||||||
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
tabPanel.selectTab(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bind() {
|
private void bind() {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
}
|
}
|
||||||
</ui:style>
|
</ui:style>
|
||||||
<g:HTMLPanel>
|
<g:HTMLPanel>
|
||||||
|
<h4>Manage Resources</h4>
|
||||||
<b:TabPanel ui:field="tabPanel">
|
<b:TabPanel ui:field="tabPanel">
|
||||||
<b:Tab ui:field="addResources" heading="Add Resource"></b:Tab>
|
<b:Tab ui:field="addResources" heading="Add Resource"></b:Tab>
|
||||||
<b:Tab ui:field="addedResources" heading="Added Resources"></b:Tab>
|
<b:Tab ui:field="addedResources" heading="Added Resources"></b:Tab>
|
||||||
|
|
|
@ -139,4 +139,21 @@
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
box-shadow: 3px 3px #888;
|
box-shadow: 3px 3px #888;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resource-table {
|
||||||
|
margin: 5px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
font-size: 14px;
|
||||||
|
max-width: 98%;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resource-table td {
|
||||||
|
padding: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resource-table td:first-child {
|
||||||
|
color: gray;
|
||||||
|
width: 75px;
|
||||||
}
|
}
|
|
@ -29,6 +29,7 @@ public class PublisherCatalogueConveter {
|
||||||
reb.setUrl(ckanResource.getUrl());
|
reb.setUrl(ckanResource.getUrl());
|
||||||
reb.setMimeType(ckanResource.getMimetype());
|
reb.setMimeType(ckanResource.getMimetype());
|
||||||
reb.setOrganizationNameDatasetParent(orgNameParent);
|
reb.setOrganizationNameDatasetParent(orgNameParent);
|
||||||
|
reb.setCkanDatasetId(ckanResource.getPackageId());
|
||||||
return reb;
|
return reb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,8 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
|
||||||
|
|
||||||
private String ckanResourceID;
|
private String ckanResourceID;
|
||||||
|
|
||||||
|
private String ckanDatasetId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The key provider that provides the unique ID of a bean.
|
* The key provider that provides the unique ID of a bean.
|
||||||
*/
|
*/
|
||||||
|
@ -467,11 +469,14 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
|
||||||
this.rootIdInWorkspace = rootIdInWorkspace;
|
this.rootIdInWorkspace = rootIdInWorkspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setCkanDatasetId(String packageId) {
|
||||||
* To string.
|
this.ckanDatasetId = packageId;
|
||||||
*
|
}
|
||||||
* @return the string
|
|
||||||
*/
|
public String getCkanDatasetId() {
|
||||||
|
return ckanDatasetId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
@ -497,10 +502,14 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
|
||||||
builder.append(description);
|
builder.append(description);
|
||||||
builder.append(", organizationNameDatasetParent=");
|
builder.append(", organizationNameDatasetParent=");
|
||||||
builder.append(organizationNameDatasetParent);
|
builder.append(organizationNameDatasetParent);
|
||||||
builder.append(", childrenSize=");
|
|
||||||
builder.append(childrenSize);
|
|
||||||
builder.append(", toPublish=");
|
builder.append(", toPublish=");
|
||||||
builder.append(toPublish);
|
builder.append(toPublish);
|
||||||
|
builder.append(", identifierGWT=");
|
||||||
|
builder.append(identifierGWT);
|
||||||
|
builder.append(", ckanResourceID=");
|
||||||
|
builder.append(ckanResourceID);
|
||||||
|
builder.append(", ckanDatasetId=");
|
||||||
|
builder.append(ckanDatasetId);
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue