66 lines
2.1 KiB
Java
66 lines
2.1 KiB
Java
package org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project;
|
|
|
|
import java.util.List;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.view.SubDocumentView;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.gallery.ImagesSectionGallery;
|
|
|
|
import com.github.gwtbootstrap.client.ui.PageHeader;
|
|
import com.google.gwt.core.client.GWT;
|
|
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.HTML;
|
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
public class SectionViewer extends Composite {
|
|
|
|
private static SectionViewerUiBinder uiBinder = GWT.create(SectionViewerUiBinder.class);
|
|
|
|
interface SectionViewerUiBinder extends UiBinder<Widget, SectionViewer> {
|
|
}
|
|
|
|
private SectionView sectionView;
|
|
|
|
@UiField
|
|
HTMLPanel sectionPanelContainer;
|
|
|
|
@UiField
|
|
PageHeader sectionTitle;
|
|
|
|
public SectionViewer(SectionView sectionView) {
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
this.sectionView = sectionView;
|
|
|
|
List<SubDocumentView> subDocuments = sectionView.getListSubDocuments();
|
|
|
|
sectionTitle.setTitle(sectionView.getSectionTitle());
|
|
sectionTitle.setText(sectionView.getSectionTitle());
|
|
|
|
boolean displayAsGallery = false;
|
|
for (SubDocumentView subDocumentView : subDocuments) {
|
|
if (subDocumentView.getListImages() != null && subDocumentView.getListImages().size() > 0) {
|
|
displayAsGallery = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//Displaying the whole section as a Gallery
|
|
if (displayAsGallery) {
|
|
ImagesSectionGallery sectionGallery = new ImagesSectionGallery(sectionView);
|
|
sectionPanelContainer.add(sectionGallery.getGalleryPanel());
|
|
sectionGallery.fillGallery();
|
|
} else {
|
|
for (SubDocumentView subDocumentView : subDocuments) {
|
|
String table = GeoportalDataViewerConstants.jsonToTableHTML(subDocumentView.getMetadataAsJSON());
|
|
sectionPanelContainer.add(new HTML(table));
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|