task_21363 #1

Closed
francesco.mangiacrapa wants to merge 53 commits from task_21363 into master
7 changed files with 191 additions and 37 deletions
Showing only changes of commit 81f102c6f8 - Show all commits

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client; package org.gcube.portlets.widgets.ckancontentmoderator.client;
import java.util.HashMap;
import java.util.List; import java.util.List;
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus; import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
@ -20,7 +21,7 @@ import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowMessage
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowMessageEventHandler; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.ShowMessageEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEvent; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEventHandler; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.TableRangeViewChangedEventHandler;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.CkanInternalFramePanel; import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.CkanShowItemFrame;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.ContentModeratorToolbar; import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.ContentModeratorToolbar;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.HomeView; import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.HomeView;
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.MainTabPanel; import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.MainTabPanel;
@ -56,6 +57,8 @@ public class CkanContentModeratorWidgetController {
public final static HandlerManager eventBus = new HandlerManager(null); public final static HandlerManager eventBus = new HandlerManager(null);
private HomeView howeView; private HomeView howeView;
private HashMap<String, CkanShowItemFrame> mapOfItemsTabDisplayed = new HashMap<String, CkanShowItemFrame>();
/** /**
* Instantiates a new ckan content moderator widget. * Instantiates a new ckan content moderator widget.
* *
@ -94,7 +97,8 @@ public class CkanContentModeratorWidgetController {
howeView.setVisibleUpdateStatusAction(false); howeView.setVisibleUpdateStatusAction(false);
} }
//If an action updated the item status we reloading it
reloadItemsDisplayedInTab();
} }
} }
}); });
@ -109,9 +113,14 @@ public class CkanContentModeratorWidgetController {
for (T t : items) { for (T t : items) {
CatalogueDataset clickedDataset = (CatalogueDataset) t; CatalogueDataset clickedDataset = (CatalogueDataset) t;
CkanInternalFramePanel cfp = new CkanInternalFramePanel(eventBus); CkanShowItemFrame csif = new CkanShowItemFrame(eventBus);
cfp.instanceFrame(clickedDataset.getUrl()); csif.instanceFrame(clickedDataset.getUrl());
mainTabPanel.addTab(clickedDataset.getTitle(), cfp); mainTabPanel.addTab(clickedDataset.getTitle(), csif);
mapOfItemsTabDisplayed.put(clickedDataset.getUrl(), csif);
// CkanInternalFramePanel cfp = new CkanInternalFramePanel(eventBus);
// cfp.instanceFrame(clickedDataset.getUrl());
// mainTabPanel.addTab(clickedDataset.getTitle(), cfp);
} }
} }
@ -163,6 +172,7 @@ public class CkanContentModeratorWidgetController {
@Override @Override
public void onClick(CloseAllTabsEvent closeAllTabsEvent) { public void onClick(CloseAllTabsEvent closeAllTabsEvent) {
mainTabPanel.closeTabs(); mainTabPanel.closeTabs();
mapOfItemsTabDisplayed.clear();
} }
}); });
@ -197,6 +207,14 @@ public class CkanContentModeratorWidgetController {
}); });
} }
private void reloadItemsDisplayedInTab() {
for (String datasetURL : mapOfItemsTabDisplayed.keySet()) {
CkanShowItemFrame showItemFrame = mapOfItemsTabDisplayed.get(datasetURL);
showItemFrame.reloadPage();
}
}
private void showMessage(String msg, AlertType alertType) { private void showMessage(String msg, AlertType alertType) {
final Alert alert = new Alert(msg); final Alert alert = new Alert(msg);

View File

@ -1,33 +1,40 @@
/**
*
*/
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui; package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.IFrameInstanciedEvent; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.IFrameInstanciedEvent;
import org.gcube.portlets.widgets.ckancontentmoderator.client.events.IFrameInstanciedEvent.OPERATION; import org.gcube.portlets.widgets.ckancontentmoderator.client.events.IFrameInstanciedEvent.OPERATION;
import org.gcube.portlets.widgets.ckancontentmoderator.client.resources.ContentModeratorWidgetResources; import org.gcube.portlets.widgets.ckancontentmoderator.client.resources.ContentModeratorWidgetResources;
import com.google.gwt.core.shared.GWT; import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Display; import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.LoadEvent; import com.google.gwt.event.dom.client.LoadEvent;
import com.google.gwt.event.dom.client.LoadHandler; import com.google.gwt.event.dom.client.LoadHandler;
import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.http.client.URL; import com.google.gwt.http.client.URL;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Random; import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Frame; import com.google.gwt.user.client.ui.Frame;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.NamedFrame; import com.google.gwt.user.client.ui.NamedFrame;
import com.google.gwt.user.client.ui.Widget;
/** /**
* The Class CkanInternalFramePanel. * The Class CkanShowItemFrame.
* *
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* Feb 25, 2022 * Apr 4, 2022
*/ */
public class CkanInternalFramePanel extends FlowPanel { public class CkanShowItemFrame extends Composite {
private static CkanShowItemFrameUiBinder uiBinder = GWT.create(CkanShowItemFrameUiBinder.class);
private NamedFrame namedFrame; private NamedFrame namedFrame;
private HandlerManager eventBus; private HandlerManager eventBus;
@ -35,32 +42,54 @@ public class CkanInternalFramePanel extends FlowPanel {
private String messageToSend; private String messageToSend;
private String iFrameRandomName; private String iFrameRandomName;
@UiField
Button button_reload;
@UiField
HTMLPanel panel_container;
// @UiField
// AlertBlock alertBlockNav;
private String datasetURL;
/** /**
* Instantiates a new ckan namedFrame panel. * The Interface CkanShowItemFrameUiBinder.
* *
* @param eventBus the event bus * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Apr 4, 2022
*/ */
public CkanInternalFramePanel(HandlerManager eventBus) { interface CkanShowItemFrameUiBinder extends UiBinder<Widget, CkanShowItemFrame> {
this.eventBus = eventBus;
addLoading();
} }
/** /**
* Prints the. * Instantiates a new ckan show item frame.
* *
* @param msg the msg * @param eventBus the event bus
*/ */
private static native void print(String msg)/*-{ public CkanShowItemFrame(HandlerManager eventBus) {
console.log(msg); initWidget(uiBinder.createAndBindUi(this));
}-*/; this.eventBus = eventBus;
// alertBlockNav.setType(AlertType.INFO);
button_reload.setIcon(IconType.ROTATE_RIGHT);
button_reload.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
reloadPage();
}
});
}
/** /**
* Instance namedFrame. * Instance frame.
* *
* @param datasetURL the dataset URL * @param datasetURL the dataset URL
* @return the namedFrame * @return the frame
*/ */
public Frame instanceFrame(String datasetURL) { public Frame instanceFrame(String datasetURL) {
this.datasetURL = datasetURL;
GWT.log("Instancing new IFRAME with uri: " + datasetURL); GWT.log("Instancing new IFRAME with uri: " + datasetURL);
addLoading(); addLoading();
String urlEncoded = URL.encode(datasetURL); String urlEncoded = URL.encode(datasetURL);
@ -78,14 +107,15 @@ public class CkanInternalFramePanel extends FlowPanel {
@Override @Override
public void onLoad(LoadEvent arg0) { public void onLoad(LoadEvent arg0) {
CkanInternalFramePanel.this.remove(loading); removeLoading();
eventBus.fireEvent(new IFrameInstanciedEvent(namedFrame, OPERATION.ONLOAD)); eventBus.fireEvent(new IFrameInstanciedEvent(namedFrame, OPERATION.ONLOAD));
} }
}); });
add(namedFrame); panel_container.add(namedFrame);
namedFrame.setVisible(true); namedFrame.setVisible(true);
eventBus.fireEvent(new IFrameInstanciedEvent(namedFrame, OPERATION.INIT)); eventBus.fireEvent(new IFrameInstanciedEvent(namedFrame, OPERATION.INIT));
return namedFrame; return namedFrame;
} }
/** /**
@ -101,8 +131,30 @@ public class CkanInternalFramePanel extends FlowPanel {
* add loading image. * add loading image.
*/ */
private void addLoading() { private void addLoading() {
this.add(loading); panel_container.add(loading);
loading.getElement().getStyle().setProperty("margin", "auto"); loading.getElement().getStyle().setProperty("margin", "auto");
loading.getElement().getStyle().setDisplay(Display.BLOCK); loading.getElement().getStyle().setDisplay(Display.BLOCK);
button_reload.setEnabled(false);
} }
/**
* Removes the loading.
*/
private void removeLoading() {
try {
panel_container.remove(loading);
button_reload.setEnabled(true);
} catch (Exception e) {
}
}
/**
* Reload page.
*/
public void reloadPage() {
panel_container.clear();
instanceFrame(datasetURL);
}
} }

View File

@ -0,0 +1,21 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.important {
font-weight: bold;
}
.asBar {
background-color: none !important;
}
</ui:style>
<g:HTMLPanel>
<b:AlertBlock close="false" addStyleNames="{style.asBar}" ui:field="alertBlockNav">
<b:Button ui:field="button_reload" title="Reload the page" type="LINK">Reload</b:Button>
</b:AlertBlock>
<g:HTMLPanel ui:field="panel_container">
</g:HTMLPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -78,9 +78,9 @@ public class MainTabPanel extends Composite {
public Tab addTab(String heading, Widget w) { public Tab addTab(String heading, Widget w) {
final Tab tab = new Tab(); final Tab tab = new Tab();
if (w instanceof CkanInternalFramePanel) { if (w instanceof CkanShowItemFrame) {
tab.setCustomIconStyle("icon-rotate-right icon-spin"); tab.setCustomIconStyle("icon-rotate-right icon-spin");
CkanInternalFramePanel ckanFramePanel = (CkanInternalFramePanel) w; CkanShowItemFrame ckanFramePanel = (CkanShowItemFrame) w;
ckanFramePanel.getFrame().addLoadHandler(new LoadHandler() { ckanFramePanel.getFrame().addLoadHandler(new LoadHandler() {
@Override @Override

View File

@ -68,11 +68,12 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016 * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016
*/ */
public static enum DISPLAY_FIELD { public static enum DISPLAY_FIELD {
NAME, TITLE, AUTHOR, CREATED, TYPE NAME, TITLE, AUTHOR, CREATED, TYPE, LAST_UPDATE
}; };
private List<DISPLAY_FIELD> displayFields; private List<DISPLAY_FIELD> displayFields;
private Column<T, Date> dateColumn; private Column<T, Date> createdColumn;
private Column<T, Date> lastUpdateColumn;
private DISPLAY_FIELD startSortByColumn; private DISPLAY_FIELD startSortByColumn;
private boolean isAsyncronusTable; private boolean isAsyncronusTable;
@ -243,7 +244,7 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
if (this.displayFields.contains(DISPLAY_FIELD.CREATED)) { if (this.displayFields.contains(DISPLAY_FIELD.CREATED)) {
DateCell date = new DateCell(dtformat); DateCell date = new DateCell(dtformat);
dateColumn = new Column<T, Date>(date) { createdColumn = new Column<T, Date>(date) {
@Override @Override
public Date getValue(T object) { public Date getValue(T object) {
@ -253,7 +254,7 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
return new Date(((CatalogueDataset) object).getCreated()); return new Date(((CatalogueDataset) object).getCreated());
} }
}; };
sortedCellTable.addColumn(dateColumn, "Created", true); sortedCellTable.addColumn(createdColumn, "Created", true);
if (!isAsyncronusTable) { if (!isAsyncronusTable) {
Comparator<T> c = new Comparator<T>() { Comparator<T> c = new Comparator<T>() {
@ -277,7 +278,49 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
} }
}; };
GWT.log("date colum sortable"); GWT.log("date colum sortable");
sortedCellTable.setComparator(dateColumn, c); sortedCellTable.setComparator(createdColumn, c);
}
}
if (this.displayFields.contains(DISPLAY_FIELD.LAST_UPDATE)) {
DateCell date = new DateCell(dtformat);
lastUpdateColumn = new Column<T, Date>(date) {
@Override
public Date getValue(T object) {
if (object == null)
return null;
return new Date(((CatalogueDataset) object).getLastUpdate());
}
};
sortedCellTable.addColumn(lastUpdateColumn, "Last Update", true);
if (!isAsyncronusTable) {
Comparator<T> c = new Comparator<T>() {
@Override
public int compare(T o1, T o2) {
if (o1 == null || o1.getCreated() == 0)
return -1;
if (o2 == null || o2.getCreated() == 0)
return 1;
Date d1 = new Date(((CatalogueDataset) o1).getLastUpdate());
Date d2 = new Date(((CatalogueDataset) o2).getLastUpdate());
// GWT.log(d1.toString() + "is after "+d2.toString() +" ? "+d2.after(d1));
if (d1.after(d2))
return 1;
else
return -1;
}
};
GWT.log("date colum sortable");
sortedCellTable.setComparator(lastUpdateColumn, c);
} }
} }
@ -359,8 +402,15 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
break; break;
case CREATED: case CREATED:
if (this.displayFields.contains(DISPLAY_FIELD.CREATED)) { if (this.displayFields.contains(DISPLAY_FIELD.CREATED)) {
sortedCellTable.setDefaultSortOrder(dateColumn, false); // sorts ascending on first click sortedCellTable.setDefaultSortOrder(createdColumn, false); // sorts ascending on first click
sortedCellTable.setInitialSortColumn(dateColumn); sortedCellTable.setInitialSortColumn(createdColumn);
GWT.log("sortedCellTable: " + sortedCellTable);
}
break;
case LAST_UPDATE:
if (this.displayFields.contains(DISPLAY_FIELD.LAST_UPDATE)) {
sortedCellTable.setDefaultSortOrder(lastUpdateColumn, false); // sorts ascending on first click
sortedCellTable.setInitialSortColumn(lastUpdateColumn);
GWT.log("sortedCellTable: " + sortedCellTable); GWT.log("sortedCellTable: " + sortedCellTable);
} }
break; break;

View File

@ -50,6 +50,7 @@ public class CatalogueBeansConverter {
//here is always null //here is always null
myDataset.setUrl(t.getUrl()); myDataset.setUrl(t.getUrl());
myDataset.setCreated(t.getMetadataCreated().getTime()); myDataset.setCreated(t.getMetadataCreated().getTime());
myDataset.setLastUpdate(t.getMetadataModified().getTime());
return myDataset; return myDataset;
} }
}; };

View File

@ -35,6 +35,7 @@ public class CatalogueDataset implements Serializable, IsSerializable {
private String extra_ItemURL; private String extra_ItemURL;
private String extra_SystemType; private String extra_SystemType;
private long created; private long created;
private long lastUpdate;
/** /**
* Instantiates a new ckan dataset base. * Instantiates a new ckan dataset base.
@ -158,6 +159,15 @@ public class CatalogueDataset implements Serializable, IsSerializable {
this.created = created; this.created = created;
} }
public void setLastUpdate(long time) {
this.lastUpdate = time;
}
public long getLastUpdate() {
return lastUpdate;
}
public String getExtra_ItemURL() { public String getExtra_ItemURL() {
return extra_ItemURL; return extra_ItemURL;
} }
@ -209,6 +219,8 @@ public class CatalogueDataset implements Serializable, IsSerializable {
builder.append(extra_SystemType); builder.append(extra_SystemType);
builder.append(", created="); builder.append(", created=");
builder.append(created); builder.append(created);
builder.append(", lastUpdate=");
builder.append(lastUpdate);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }