task_21363 #1
|
@ -1,5 +1,6 @@
|
|||
package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
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.TableRangeViewChangedEvent;
|
||||
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.HomeView;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.ui.MainTabPanel;
|
||||
|
@ -55,6 +56,8 @@ public class CkanContentModeratorWidgetController {
|
|||
|
||||
public final static HandlerManager eventBus = new HandlerManager(null);
|
||||
private HomeView howeView;
|
||||
|
||||
private HashMap<String, CkanShowItemFrame> mapOfItemsTabDisplayed = new HashMap<String, CkanShowItemFrame>();
|
||||
|
||||
/**
|
||||
* Instantiates a new ckan content moderator widget.
|
||||
|
@ -94,7 +97,8 @@ public class CkanContentModeratorWidgetController {
|
|||
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) {
|
||||
CatalogueDataset clickedDataset = (CatalogueDataset) t;
|
||||
CkanInternalFramePanel cfp = new CkanInternalFramePanel(eventBus);
|
||||
cfp.instanceFrame(clickedDataset.getUrl());
|
||||
mainTabPanel.addTab(clickedDataset.getTitle(), cfp);
|
||||
CkanShowItemFrame csif = new CkanShowItemFrame(eventBus);
|
||||
csif.instanceFrame(clickedDataset.getUrl());
|
||||
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
|
||||
public void onClick(CloseAllTabsEvent closeAllTabsEvent) {
|
||||
mainTabPanel.closeTabs();
|
||||
mapOfItemsTabDisplayed.clear();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -196,6 +206,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) {
|
||||
|
||||
|
|
|
@ -1,33 +1,40 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
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.OPERATION;
|
||||
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.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.LoadHandler;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
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.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.HTMLPanel;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
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
|
||||
*
|
||||
* 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 HandlerManager eventBus;
|
||||
|
@ -35,32 +42,54 @@ public class CkanInternalFramePanel extends FlowPanel {
|
|||
private String messageToSend;
|
||||
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) {
|
||||
this.eventBus = eventBus;
|
||||
addLoading();
|
||||
interface CkanShowItemFrameUiBinder extends UiBinder<Widget, CkanShowItemFrame> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)/*-{
|
||||
console.log(msg);
|
||||
}-*/;
|
||||
public CkanShowItemFrame(HandlerManager eventBus) {
|
||||
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
|
||||
* @return the namedFrame
|
||||
* @return the frame
|
||||
*/
|
||||
public Frame instanceFrame(String datasetURL) {
|
||||
this.datasetURL = datasetURL;
|
||||
GWT.log("Instancing new IFRAME with uri: " + datasetURL);
|
||||
addLoading();
|
||||
String urlEncoded = URL.encode(datasetURL);
|
||||
|
@ -78,14 +107,15 @@ public class CkanInternalFramePanel extends FlowPanel {
|
|||
@Override
|
||||
public void onLoad(LoadEvent arg0) {
|
||||
|
||||
CkanInternalFramePanel.this.remove(loading);
|
||||
removeLoading();
|
||||
eventBus.fireEvent(new IFrameInstanciedEvent(namedFrame, OPERATION.ONLOAD));
|
||||
}
|
||||
});
|
||||
add(namedFrame);
|
||||
panel_container.add(namedFrame);
|
||||
namedFrame.setVisible(true);
|
||||
eventBus.fireEvent(new IFrameInstanciedEvent(namedFrame, OPERATION.INIT));
|
||||
return namedFrame;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,8 +131,30 @@ public class CkanInternalFramePanel extends FlowPanel {
|
|||
* add loading image.
|
||||
*/
|
||||
private void addLoading() {
|
||||
this.add(loading);
|
||||
panel_container.add(loading);
|
||||
loading.getElement().getStyle().setProperty("margin", "auto");
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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>
|
|
@ -78,9 +78,9 @@ public class MainTabPanel extends Composite {
|
|||
public Tab addTab(String heading, Widget w) {
|
||||
final Tab tab = new Tab();
|
||||
|
||||
if (w instanceof CkanInternalFramePanel) {
|
||||
if (w instanceof CkanShowItemFrame) {
|
||||
tab.setCustomIconStyle("icon-rotate-right icon-spin");
|
||||
CkanInternalFramePanel ckanFramePanel = (CkanInternalFramePanel) w;
|
||||
CkanShowItemFrame ckanFramePanel = (CkanShowItemFrame) w;
|
||||
ckanFramePanel.getFrame().addLoadHandler(new LoadHandler() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -68,11 +68,12 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
|||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016
|
||||
*/
|
||||
public static enum DISPLAY_FIELD {
|
||||
NAME, TITLE, AUTHOR, CREATED, TYPE
|
||||
NAME, TITLE, AUTHOR, CREATED, TYPE, LAST_UPDATE
|
||||
};
|
||||
|
||||
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 boolean isAsyncronusTable;
|
||||
|
||||
|
@ -243,7 +244,7 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
|||
if (this.displayFields.contains(DISPLAY_FIELD.CREATED)) {
|
||||
|
||||
DateCell date = new DateCell(dtformat);
|
||||
dateColumn = new Column<T, Date>(date) {
|
||||
createdColumn = new Column<T, Date>(date) {
|
||||
|
||||
@Override
|
||||
public Date getValue(T object) {
|
||||
|
@ -253,7 +254,7 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
|||
return new Date(((CatalogueDataset) object).getCreated());
|
||||
}
|
||||
};
|
||||
sortedCellTable.addColumn(dateColumn, "Created", true);
|
||||
sortedCellTable.addColumn(createdColumn, "Created", true);
|
||||
|
||||
if (!isAsyncronusTable) {
|
||||
Comparator<T> c = new Comparator<T>() {
|
||||
|
@ -277,7 +278,49 @@ public class ItemsTable<T extends CatalogueDataset> extends AbstractItemsCellTab
|
|||
}
|
||||
};
|
||||
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;
|
||||
case CREATED:
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.CREATED)) {
|
||||
sortedCellTable.setDefaultSortOrder(dateColumn, false); // sorts ascending on first click
|
||||
sortedCellTable.setInitialSortColumn(dateColumn);
|
||||
sortedCellTable.setDefaultSortOrder(createdColumn, false); // sorts ascending on first click
|
||||
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);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -50,6 +50,7 @@ public class CatalogueBeansConverter {
|
|||
//here is always null
|
||||
myDataset.setUrl(t.getUrl());
|
||||
myDataset.setCreated(t.getMetadataCreated().getTime());
|
||||
myDataset.setLastUpdate(t.getMetadataModified().getTime());
|
||||
return myDataset;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -35,6 +35,7 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
|||
private String extra_ItemURL;
|
||||
private String extra_SystemType;
|
||||
private long created;
|
||||
private long lastUpdate;
|
||||
|
||||
/**
|
||||
* Instantiates a new ckan dataset base.
|
||||
|
@ -158,6 +159,15 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
|||
this.created = created;
|
||||
}
|
||||
|
||||
public void setLastUpdate(long time) {
|
||||
this.lastUpdate = time;
|
||||
|
||||
}
|
||||
|
||||
public long getLastUpdate() {
|
||||
return lastUpdate;
|
||||
}
|
||||
|
||||
public String getExtra_ItemURL() {
|
||||
return extra_ItemURL;
|
||||
}
|
||||
|
@ -209,6 +219,8 @@ public class CatalogueDataset implements Serializable, IsSerializable {
|
|||
builder.append(extra_SystemType);
|
||||
builder.append(", created=");
|
||||
builder.append(created);
|
||||
builder.append(", lastUpdate=");
|
||||
builder.append(lastUpdate);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue