Added Upldoad Image View

This commit is contained in:
francesco 2020-11-05 14:05:14 +01:00
parent a72d7de599
commit c5c6823587
16 changed files with 475 additions and 47 deletions

View File

@ -32,7 +32,6 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>

View File

@ -1,4 +1,4 @@
eclipse.preferences.version=1
lastWarOutDir=/home/francesco-mangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-1.0.0-SNAPSHOT
lastWarOutDir=/home/francesco/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-1.0.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

View File

@ -6,4 +6,4 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## [v1.0.0-SNAPSHOT] - 2020-10-07
First release
[#20004] First release

View File

@ -11,6 +11,8 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.ProductType;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
import com.github.gwtbootstrap.client.ui.Tab;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
@ -20,6 +22,7 @@ import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
// TODO: Auto-generated Javadoc
@ -144,22 +147,38 @@ public class GeoportalDataViewer implements EntryPoint {
List<String> productIds = fRow.getMapProperties().get("product_id");
if(productIds!=null && productIds.size()>0) {
long id = Long.parseLong(productIds.get(0));
String tabName = "Dettagli Prodotto";
List<String> listName = fRow.getMapProperties().get("nome");
if(listName!=null && listName.size()>0) {
tabName = listName.get(0);
}
boolean found = mainPanel.selectTabForProductId(id);
GWT.log("Product with id: "+id+" found? "+found);
if(!found) {
final Tab theTab = mainPanel.addAsTab(tabName, true, null);
GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(id, new AsyncCallback<ConcessioneDV>() {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
theTab.clear();
theTab.setIcon(IconType.WARNING_SIGN);
theTab.add(new HTML(caught.getMessage()));
}
@Override
public void onSuccess(ConcessioneDV result) {
mainPanel.addNewTab(result);
GWT.log("Showing: "+result);
mainPanel.renderProductIntoTab(theTab, result);
}
});
}else
Window.alert("No product id found");
}
}
}

View File

@ -0,0 +1,13 @@
package org.gcube.portlets.user.geoportaldataviewer.client.resources;
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
public interface Images extends ClientBundle {
public static final Images ICONS = GWT.create(Images.class);
@Source("loading.gif")
ImageResource loading();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -1,7 +1,13 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.concessione.ConcessioneView;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.products.ConcessioneView;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
import com.github.gwtbootstrap.client.ui.Button;
@ -10,6 +16,8 @@ import com.github.gwtbootstrap.client.ui.Tab;
import com.github.gwtbootstrap.client.ui.TabPanel;
import com.github.gwtbootstrap.client.ui.constants.IconType;
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.ClickHandler;
import com.google.gwt.event.shared.HandlerManager;
@ -40,8 +48,7 @@ public class GeonaDataViewMainPanel extends Composite {
@UiField
TabPanel mainTabPanel;
// @UiField
// ButtonGroup buttonGroup;
private List<Tab> listTabs = new ArrayList<Tab>();
private MapPanel mapPanel;
@ -49,6 +56,8 @@ public class GeonaDataViewMainPanel extends Composite {
private HandlerManager eventBus;
private Map<Long, Tab> mapProducts = new HashMap<Long, Tab>();
public GeonaDataViewMainPanel(HandlerManager eventBus) {
initWidget(uiBinder.createAndBindUi(this));
this.eventBus = eventBus;
@ -116,14 +125,90 @@ public class GeonaDataViewMainPanel extends Composite {
}
public void addNewTab(ConcessioneDV cdv) {
Tab tab = new Tab();
String nome = cdv.getNome();
tab.setHeading(nome);
public void renderProductIntoTab(Tab tab, ConcessioneDV cdv) {
tab.clear();
tab.setHeading(cdv.getNome());
tab.add(new ConcessioneView(cdv));
mapProducts.put(cdv.getId(), tab);
selectTabForProductId(cdv.getId());
}
public boolean selectTabForProductId(long productId) {
Tab product = mapProducts.get(productId);
if(product!=null) {
selectTab(product);
//found
return true;
}
//not found
return false;
}
/**
* Adds the as tab.
*
* @param tabTitle the tab title
* @param tabDescr the tab descr
* @param spinner the spinner
* @param w the w
* @return the tab
*/
public Tab addAsTab(String tabTitle, boolean spinner, Widget w){
// field_create_analytics_request.setActive(false);
Tab tab = new Tab();
mainTabPanel.add(tab);
tab.asWidget().getElement().focus();
if(spinner) {
LoaderIcon loader = new LoaderIcon("Loading...");
tab.add(loader);
}
tab.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
}
});
//tab.setActive(true);
tab.setHeading(tabTitle);
listTabs.add(tab);
if(w!=null)
tab.add(w);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
selectTab(tab);
}
});
return tab;
// tab.setActive(true);
}
private void selectTab(Tab theTab) {
int i = 1;
for (Tab tab : listTabs) {
GWT.log("Selecting "+tab);
tab.setActive(false);
if(tab.equals(theTab)) {
GWT.log("Tab selected "+tab);
mainTabPanel.selectTab(i);
}
i++;
}
}
}

View File

@ -0,0 +1,54 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.images;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
import com.github.gwtbootstrap.client.ui.Heading;
import com.github.gwtbootstrap.client.ui.Image;
import com.github.gwtbootstrap.client.ui.Paragraph;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
public class ImageView extends Composite {
private static ImageViewUiBinder uiBinder = GWT.create(ImageViewUiBinder.class);
interface ImageViewUiBinder extends UiBinder<Widget, ImageView> {
}
public ImageView() {
initWidget(uiBinder.createAndBindUi(this));
}
@UiField
Image imageURL;
@UiField
Heading heading;
@UiField
Paragraph paragraph1;
public ImageView(UploadedImageDV imageDV) {
initWidget(uiBinder.createAndBindUi(this));
imageDV.getDidascalia();
heading.setText(imageDV.getTitolo());
paragraph1.setText(imageDV.getDidascalia());
if(imageDV.getListWsContent()!=null && imageDV.getListWsContent().size()>0) {
WorkspaceContentDV latest = imageDV.getListWsContent().get(imageDV.getListWsContent().size()-1);
imageURL.setUrl(latest.getLink());
}
}
}

View File

@ -0,0 +1,22 @@
<!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>
.max-width-300 {
max-width: 300px;
}
</ui:style>
<b:Thumbnail size="4">
<b:Image ui:field="imageURL"
addStyleNames="{style.max-width-300}" />
<b:Caption>
<b:Heading size="4" ui:field="heading"></b:Heading>
<b:Paragraph ui:field="paragraph1">
</b:Paragraph>
<b:Paragraph ui:field="paragraph2">
<b:Button ui:field="expandImage">Expand</b:Button>
</b:Paragraph>
</b:Caption>
</b:Thumbnail>
</ui:UiBinder>

View File

@ -1,11 +1,16 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.concessione;
package org.gcube.portlets.user.geoportaldataviewer.client.ui.products;
import java.util.List;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.images.ImageView;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
import com.github.gwtbootstrap.client.ui.Column;
import com.github.gwtbootstrap.client.ui.Heading;
import com.github.gwtbootstrap.client.ui.Label;
import com.github.gwtbootstrap.client.ui.Paragraph;
import com.github.gwtbootstrap.client.ui.Thumbnails;
import com.github.gwtbootstrap.client.ui.constants.LabelType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
@ -13,6 +18,7 @@ import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
@ -36,24 +42,50 @@ public class ConcessioneView extends Composite {
@UiField
Column contributore;
@UiField
HTMLPanel imagesPanel;
private ConcessioneDV concessioneDV;
private Thumbnails thumbNails = new Thumbnails();
public ConcessioneView() {
initWidget(uiBinder.createAndBindUi(this));
}
public ConcessioneView(ConcessioneDV concessione) {
public ConcessioneView(ConcessioneDV concessioneDV) {
this();
titolo.setText(concessione.getNome());
introduzione.setText(concessione.getIntroduzione());
this.concessioneDV = concessioneDV;
titolo.setText(concessioneDV.getNome());
introduzione.setText(concessioneDV.getIntroduzione());
for (String author : concessione.getAuthors()) {
for (String author : concessioneDV.getAuthors()) {
addLabel(autori, author);
//autori.add(new Label(author));
}
addLabel(contributore, concessione.getContributore());
addLabel(contributore, concessioneDV.getContributore());
addImages();
}
private void addImages() {
List<UploadedImageDV> immagini = concessioneDV.getImmaginiRappresentative();
if(immagini!=null && immagini.size()>0) {
imagesPanel.setVisible(true);
int i = 0;
for (UploadedImageDV uploadedImageDV : immagini) {
if(i==0)
imagesPanel.add(thumbNails);
thumbNails.add(new ImageView(uploadedImageDV));
}
}
}
public void addLabel(FlowPanel w, String labelValue, LabelType type){
Label label = new Label(labelValue);
label.setType(type);
@ -67,4 +99,8 @@ public class ConcessioneView extends Composite {
w.add(label);
}
public ConcessioneDV getConcessioneDV() {
return concessioneDV;
}
}

View File

@ -6,16 +6,21 @@
.important {
font-weight: bold;
}
.margin-left-10 {
margin-left: 10px;
}
.font-size-h1-22 h1{
font-size: 22px;
}
</ui:style>
<g:HTMLPanel>
<b:Hero>
<b:Heading size="2" ui:field="titolo">Hero Unit</b:Heading>
<b:Paragraph ui:field="introduzione">Some Text for the Hero Unit.</b:Paragraph>
</b:Hero>
<g:HTMLPanel ui:field="container" addStyleNames="{style.margin-left-10}">
<g:HTMLPanel ui:field="concessioniPanel"
addStyleNames="{style.margin-left-10}">
<b:Row>
<b:Column size="2">
<g:Label>Autori</g:Label>
@ -29,5 +34,9 @@
<b:Column size="8" ui:field="contributore"></b:Column>
</b:Row>
</g:HTMLPanel>
<g:HTMLPanel ui:field="imagesPanel"
addStyleNames="{style.margin-left-10}" visible="false">
<b:PageHeader addStyleNames="{style.font-size-h1-22}">Immagini Rappresentative</b:PageHeader>
</g:HTMLPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -0,0 +1,61 @@
/**
*
*/
package org.gcube.portlets.user.geoportaldataviewer.client.util;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
/**
* The Class LoaderIcon.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 19, 2015
*/
public class LoaderIcon extends HorizontalPanel{
private Image imgLoading = new Image(Images.ICONS.loading());
private HTML txtLoading = new HTML("");
/**
* Instantiates a new loader icon.
*
* @param txtHTML the txt html
*/
public LoaderIcon(String txtHTML) {
this();
setText(txtHTML);
}
/**
* Instantiates a new loader icon.
*/
public LoaderIcon() {
setStyleName("marginTop20");
add(imgLoading);
add(txtLoading);
}
/**
* Sets the text.
*
* @param txtHTML the new text
*/
public void setText(String txtHTML){
txtLoading.setHTML("<span style=\"margin-left:5px; vertical-align:middle;\">"+txtHTML+"</span>");
}
/**
* Show.
*
* @param bool the bool
*/
public void show(boolean bool){
this.setVisible(bool);
}
}

View File

@ -10,13 +10,16 @@ import org.gcube.application.geoportal.model.concessioni.Concessione;
import org.gcube.application.geoportal.model.concessioni.LayerConcessione;
import org.gcube.application.geoportal.model.concessioni.RelazioneScavo;
import org.gcube.application.geoportal.model.content.OtherContent;
import org.gcube.application.geoportal.model.content.PersistedContent;
import org.gcube.application.geoportal.model.content.UploadedImage;
import org.gcube.application.geoportal.model.content.WorkspaceContent;
import org.gcube.application.geoportal.model.gis.BBOX;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.LayerConcessioneDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.RelazioneScavoDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.OtherContentDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -211,10 +214,42 @@ public class ConvertToDataViewModel {
theUploadedImageDV.setSoggetto(uploadedImage.getSoggetto());
theUploadedImageDV.setTitolo(uploadedImage.getTitolo());
List<PersistedContent> actContent = uploadedImage.getActualContent();
if(actContent!=null && actContent.size()>0) {
List<WorkspaceContentDV> listWsContent = new ArrayList<WorkspaceContentDV>();
for (PersistedContent content : actContent) {
if(content!=null && content instanceof WorkspaceContent) {
listWsContent.add(toWorkspaceContent((WorkspaceContent)content));
}
}
theUploadedImageDV.setListWsContent(listWsContent);
}
LOG.debug("Returning: " + theUploadedImageDV);
return theUploadedImageDV;
}
/**
* To workspace content.
*
* @param wContent the w content
* @return the workspace content DV
*/
public static WorkspaceContentDV toWorkspaceContent(WorkspaceContent wContent){
if (wContent == null)
return null;
WorkspaceContentDV theWSDV = new WorkspaceContentDV();
theWSDV.setLink(wContent.getLink());
theWSDV.setMimetype(wContent.getMimetype());
theWSDV.setStorageID(wContent.getStorageID());
theWSDV.setId(wContent.getId());
return theWSDV;
}
/**
* To layer concessione.
*

View File

@ -0,0 +1,85 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.products.content;
import java.io.Serializable;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* The Class WorkspaceContentDV.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 5, 2020
*/
public class WorkspaceContentDV implements IsSerializable, Serializable {
/**
*
*/
private static final long serialVersionUID = -3919923007831416696L;
/** The mimetype. */
private String mimetype;
/** The storage ID. */
private String storageID;
/** The link. */
private String link;
private Long id;
public WorkspaceContentDV() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getMimetype() {
return mimetype;
}
public void setMimetype(String mimetype) {
this.mimetype = mimetype;
}
public String getStorageID() {
return storageID;
}
public void setStorageID(String storageID) {
this.storageID = storageID;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("WorkspaceContentDV [mimetype=");
builder.append(mimetype);
builder.append(", storageID=");
builder.append(storageID);
builder.append(", link=");
builder.append(link);
builder.append(", id=");
builder.append(id);
builder.append("]");
return builder.toString();
}
}

View File

@ -4,6 +4,7 @@ import java.io.Serializable;
import java.util.List;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.AssociatedContentDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV;
/**
* The Class UploadedImage.
@ -29,6 +30,8 @@ public class UploadedImageDV extends AssociatedContentDV implements Serializable
/** The soggetto. */
private List<String> soggetto;
private List<WorkspaceContentDV> listWsContent;
/**
* Instantiates a new uploaded image.
*/
@ -108,6 +111,14 @@ public class UploadedImageDV extends AssociatedContentDV implements Serializable
this.soggetto = soggetto;
}
public List<WorkspaceContentDV> getListWsContent() {
return listWsContent;
}
public void setListWsContent(List<WorkspaceContentDV> listWsContent) {
this.listWsContent = listWsContent;
}
/**
* To string.
*

View File

@ -14,14 +14,14 @@ public class GetConcessione {
private static final Logger LOG = LoggerFactory.getLogger(GetConcessione.class);
public static String SCOPE = "/gcube/devNext/NextNext";
public static long concessioneId = 14;
public static long concessioneId = 48;
public static void main(String[] args) {
ScopeProvider.instance.set(SCOPE);
Concessione loaded=(Concessione) ManagerFactory.getByRecordID(concessioneId).getRecord();
LOG.info("Loaded bean : "+loaded);
// Concessione loaded=(Concessione) ManagerFactory.getByRecordID(concessioneId).getRecord();
// LOG.info("Loaded bean : "+loaded);
try {
LOG.info("Trying to get record for id "+concessioneId);
@ -32,10 +32,9 @@ public class GetConcessione {
if(record !=null && record instanceof Concessione) {
concessione = (Concessione) record;
LOG.info("To concessione view model:" +ConvertToDataViewModel.toConcessione(concessione).toString());
}else
throw new Exception("No Concessione with id '"+concessioneId+"' is available");
}else {
LOG.warn("No Record with id '"+concessioneId+"' is available");
}
}catch (Exception e) {
String erroMsg = Concessione.class.getSimpleName() +" with id "+concessioneId+" not available";
LOG.error(erroMsg,e);