149 lines
5.2 KiB
Java
149 lines
5.2 KiB
Java
package org.gcube.portlets.user.geoportaldataentry.client.ui.relation;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV;
|
|
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp;
|
|
import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryServiceAsync;
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.CloseCreateRelationGUIEvent;
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateRelationHandlerEvent;
|
|
import org.gcube.portlets.user.geoportaldataentry.client.resource.Images;
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.report.ReportTemplateToHTML;
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
|
|
|
|
import com.github.gwtbootstrap.client.ui.Alert;
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
import com.github.gwtbootstrap.client.ui.Label;
|
|
import com.github.gwtbootstrap.client.ui.ListBox;
|
|
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
|
import com.github.gwtbootstrap.client.ui.constants.IconSize;
|
|
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
|
import com.github.gwtbootstrap.client.ui.constants.LabelType;
|
|
import com.google.gwt.core.client.GWT;
|
|
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.shared.HandlerManager;
|
|
import com.google.gwt.uibinder.client.UiBinder;
|
|
import com.google.gwt.uibinder.client.UiField;
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
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.HTML;
|
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
|
import com.google.gwt.user.client.ui.Image;
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
public class ViewRelationshipPanel extends Composite {
|
|
|
|
private static ViewRelationshipPanelUiBinder uiBinder = GWT.create(ViewRelationshipPanelUiBinder.class);
|
|
|
|
interface ViewRelationshipPanelUiBinder extends UiBinder<Widget, ViewRelationshipPanel> {
|
|
}
|
|
|
|
private String profileID;
|
|
|
|
@UiField
|
|
HTMLPanel firstPanelContainer;
|
|
|
|
@UiField
|
|
HTMLPanel panelTitle;
|
|
|
|
@UiField
|
|
HTMLPanel secondPanelContainer;
|
|
|
|
@UiField
|
|
FlowPanel firstProjectPanelContainer;
|
|
|
|
@UiField
|
|
FlowPanel secondProjectPanelContainer;
|
|
|
|
@UiField
|
|
Button closeButton;
|
|
|
|
private HashMap<Integer, ResultDocumentDV> selectedProjects = new HashMap<Integer, ResultDocumentDV>(2);
|
|
|
|
private HandlerManager appManagerBus;
|
|
|
|
public ViewRelationshipPanel(HandlerManager appManagerBus, ResultDocumentDV fromProject) {
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
this.appManagerBus = appManagerBus;
|
|
|
|
closeButton.setType(ButtonType.LINK);
|
|
closeButton.setIcon(IconType.REMOVE);
|
|
closeButton.setIconSize(IconSize.LARGE);
|
|
|
|
closeButton.addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
public void onClick(ClickEvent event) {
|
|
appManagerBus.fireEvent(new CloseCreateRelationGUIEvent());
|
|
}
|
|
});
|
|
|
|
showRelationsOf(fromProject);
|
|
}
|
|
|
|
public void showRelationsOf(ResultDocumentDV project) {
|
|
firstProjectPanelContainer.clear();
|
|
secondProjectPanelContainer.clear();
|
|
|
|
String htmlMsg = "<b>" + project.getFirstEntryOfMap().getKey() + ": " + project.getFirstEntryOfMap().getValue()
|
|
+ "</b> (id: " + project.getId() + ")";
|
|
|
|
firstProjectPanelContainer.add(new HTML(htmlMsg));
|
|
ReportTemplateToHTML rtth = new ReportTemplateToHTML("", project.getDocumentAsJSON(), false, false);
|
|
rtth.showAsJSON(false);
|
|
firstProjectPanelContainer.add(rtth);
|
|
|
|
HTML labelNoRelations = new HTML("No relationship/s found");
|
|
secondProjectPanelContainer.add(labelNoRelations);
|
|
|
|
if (project.getListRelationshipDV() != null && project.getListRelationshipDV().size() > 0) {
|
|
|
|
secondProjectPanelContainer.clear();
|
|
|
|
for (RelationshipDV relationDV : project.getListRelationshipDV()) {
|
|
final FlexTable flexTable = new FlexTable();
|
|
flexTable.getElement().getStyle().setMarginTop(10, Unit.PX);
|
|
Label label = new Label();
|
|
label.setType(LabelType.INFO);
|
|
label.setText(relationDV.getRelationshipName());
|
|
flexTable.setWidget(0, 0, label);
|
|
flexTable.setWidget(1, 0, new LoaderIcon("loading project.."));
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().getResultDocumentFoProjectByID(project.getProfileID(),
|
|
project.getId(), new AsyncCallback<ResultDocumentDV>() {
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
flexTable.setWidget(1, 0, new HTML(caught.getMessage()));
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onSuccess(ResultDocumentDV result) {
|
|
String htmlMsg = "<b>" + project.getFirstEntryOfMap().getValue() + "</b> (id: "
|
|
+ project.getId() + ")";
|
|
|
|
flexTable.setWidget(1, 0, new HTML(htmlMsg));
|
|
|
|
}
|
|
});
|
|
|
|
ReportTemplateToHTML rtth2 = new ReportTemplateToHTML("", project.getDocumentAsJSON(), false, false);
|
|
rtth.showAsJSON(false);
|
|
|
|
flexTable.setWidget(2, 0, rtth2);
|
|
secondProjectPanelContainer.add(flexTable);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|