151 lines
4.3 KiB
Java
151 lines
4.3 KiB
Java
package org.gcube.portlets.user.geoportaldataentry.client.ui.relation;
|
|
|
|
import java.util.List;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
|
|
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp;
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.CloseCreateRelationGUIEvent;
|
|
import org.gcube.portlets.user.geoportaldataentry.client.resource.Images;
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.report.ReportTemplateToHTML;
|
|
|
|
import com.github.gwtbootstrap.client.ui.Alert;
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
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.google.gwt.core.client.GWT;
|
|
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.FlowPanel;
|
|
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 CreateRelationProjectsPanel extends Composite {
|
|
|
|
private static CreateRelationProjectsPanelUiBinder uiBinder = GWT.create(CreateRelationProjectsPanelUiBinder.class);
|
|
|
|
interface CreateRelationProjectsPanelUiBinder extends UiBinder<Widget, CreateRelationProjectsPanel> {
|
|
}
|
|
|
|
private String profileID;
|
|
|
|
@UiField
|
|
HTMLPanel firstPanelContainer;
|
|
|
|
@UiField
|
|
HTMLPanel panelTitle;
|
|
|
|
@UiField
|
|
HTMLPanel secondPanelContainer;
|
|
|
|
@UiField
|
|
Alert firstItemAlert;
|
|
|
|
@UiField
|
|
Alert secondItemAlert;
|
|
|
|
@UiField
|
|
Button buttFirtProjectReset;
|
|
|
|
@UiField
|
|
Button buttSecondProjectReset;
|
|
|
|
@UiField
|
|
FlowPanel firstProjectPanelContainer;
|
|
|
|
@UiField
|
|
FlowPanel secondProjectPanelContainer;
|
|
|
|
@UiField
|
|
ListBox listBoxRelationNames;
|
|
|
|
@UiField
|
|
Button closeButton;
|
|
|
|
private ResultDocumentDV[] selectedProject = new ResultDocumentDV[2];
|
|
|
|
private HandlerManager appManagerBus;
|
|
|
|
public CreateRelationProjectsPanel(String profileID, HandlerManager appManagerBus) {
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
this.profileID = profileID;
|
|
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());
|
|
}
|
|
});
|
|
|
|
listBoxRelationNames.setWidth("90%");
|
|
|
|
GeoPortalDataEntryApp.geoportalDataEntryService.getRelationshipNames(profileID,
|
|
new AsyncCallback<List<String>>() {
|
|
|
|
@Override
|
|
public void onSuccess(List<String> relationshipNames) {
|
|
for (String relName : relationshipNames) {
|
|
// NavLink navLink = new NavLink(relName);
|
|
listBoxRelationNames.addItem(relName, relName);
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
});
|
|
|
|
firstItemAlert.add(new Image(Images.ICONS.oneFingerIcon()));
|
|
firstItemAlert.setClose(false);
|
|
secondItemAlert.add(new Image(Images.ICONS.oneFingerIcon()));
|
|
secondItemAlert.setClose(false);
|
|
|
|
buttFirtProjectReset.setType(ButtonType.LINK);
|
|
buttFirtProjectReset.setIcon(IconType.REMOVE_SIGN);
|
|
buttFirtProjectReset.addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
public void onClick(ClickEvent event) {
|
|
selectedProject[0] = null;
|
|
firstProjectPanelContainer.clear();
|
|
|
|
}
|
|
});
|
|
|
|
buttSecondProjectReset.setType(ButtonType.LINK);
|
|
buttSecondProjectReset.setIcon(IconType.REMOVE_SIGN);
|
|
|
|
}
|
|
|
|
public void selectedProject(ResultDocumentDV project) {
|
|
|
|
if (selectedProject.length == 0) {
|
|
selectedProject[0] = project;
|
|
firstProjectPanelContainer
|
|
.add(new ReportTemplateToHTML("First Project", project.getDocumentAsJSON(), true, false));
|
|
} else if (selectedProject.length == 1) {
|
|
selectedProject[1] = project;
|
|
secondProjectPanelContainer
|
|
.add(new ReportTemplateToHTML("Second Project", project.getDocumentAsJSON(), true, false));
|
|
}
|
|
|
|
}
|
|
|
|
}
|