geoportal-data-viewer-app/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/relation/TimelineManagerStatus.java

61 lines
1.9 KiB
Java

package org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.relation;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.RootPanel;
public class TimelineManagerStatus {
private ProjectDV showingProject;
private HandlerManager applicationBus;
public TimelineManagerStatus(HandlerManager applicationBus) {
this.applicationBus = applicationBus;
}
protected TimelineRelationPanel getTimelineOf(ProjectDV theProject) {
if (showingProject == null) {
GWT.log("Displaying new Timeline of " + theProject);
this.showingProject = theProject;
return new TimelineRelationPanel(applicationBus, theProject);
} else {
boolean c1 = showingProject.getId().compareTo(theProject.getId()) == 0;
boolean c2 = showingProject.getProfileID().compareTo(theProject.getProfileID()) == 0;
if (!c1 || !c2) {
GWT.log("Displaying Timeline of " + theProject);
this.showingProject = theProject;
return new TimelineRelationPanel(applicationBus, theProject);
}
GWT.log("Skipping already displayed Timeline of " + theProject);
return null;
}
}
public void showTimelineProjectRelations(ProjectDV theProject) {
GWT.log("Showing project relations for: " + theProject);
TimelineRelationPanel timeline = getTimelineOf(theProject);
if (timeline != null) {
RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).clear();
RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).setVisible(true);
RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).add(timeline);
}
}
public void hideTimelineProjectRelations() {
GWT.log("hideTimelineProjectRelations");
RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).setVisible(false);
RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).clear();
}
}