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

101 lines
3.0 KiB
Java
Raw Normal View History

2022-11-08 10:45:39 +01:00
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 HandlerManager applicationBus;
2022-11-08 14:50:48 +01:00
private TimelineStatus status;
2022-11-08 10:45:39 +01:00
public TimelineManagerStatus(HandlerManager applicationBus) {
this.applicationBus = applicationBus;
}
2022-11-08 14:50:48 +01:00
protected TimelineStatus getTimelineOf(ProjectDV theProject) {
if (status == null) {
status = new TimelineStatus(true, new TimelineRelationPanel(applicationBus, theProject), theProject);
GWT.log("Displaying new Timeline of " + status);
return status;
2022-11-08 10:45:39 +01:00
} else {
2022-11-08 14:50:48 +01:00
boolean c1 = status.getTheProjectDV().getId().compareTo(theProject.getId()) == 0;
boolean c2 = status.getTheProjectDV().getProfileID().compareTo(theProject.getProfileID()) == 0;
2022-11-08 10:45:39 +01:00
if (!c1 || !c2) {
2022-11-08 14:50:48 +01:00
GWT.log("Displaying Timeline of " + status);
status = new TimelineStatus(true, new TimelineRelationPanel(applicationBus, theProject), theProject);
return status;
2022-11-08 10:45:39 +01:00
}
2022-11-08 14:50:48 +01:00
status.statusChanged(false);
GWT.log("Skipping already displayed Timeline of " + status);
return status;
2022-11-08 10:45:39 +01:00
}
}
public void showTimelineProjectRelations(ProjectDV theProject, boolean showNotify) {
2022-11-08 10:45:39 +01:00
GWT.log("Showing project relations for: " + theProject);
2022-11-08 14:50:48 +01:00
TimelineStatus timelineStatus = getTimelineOf(theProject);
if (timelineStatus.isStatusChanged()) {
2022-11-08 10:45:39 +01:00
RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).clear();
2022-11-08 14:50:48 +01:00
RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).add(timelineStatus.getTimelineRP());
} else if (showNotify) {
2022-11-15 10:08:02 +01:00
GeoportalDataViewer.showPopover(RootPanel.get(GeoportalDataViewer.APP_NOTIFIER),
"Timeline from the selected project is already displayed", "Timeline displayed");
2022-11-08 10:45:39 +01:00
}
2022-11-08 14:50:48 +01:00
RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).setVisible(true);
timelineStatus.getTimelineRP().setTimelineContainerVisible(true);
2022-11-08 10:45:39 +01:00
}
2022-12-21 11:00:12 +01:00
2022-11-08 10:45:39 +01:00
public void hideTimelineProjectRelations() {
GWT.log("hideTimelineProjectRelations");
RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).setVisible(false);
// RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).clear();
2022-11-08 14:50:48 +01:00
}
public class TimelineStatus {
public boolean statusChanged = false;
private TimelineRelationPanel timelineRP;
private ProjectDV theProjectDV;
public TimelineStatus(boolean statusChanged, TimelineRelationPanel timelineRP, ProjectDV theProjectDV) {
this.statusChanged = statusChanged;
this.timelineRP = timelineRP;
this.theProjectDV = theProjectDV;
}
public void statusChanged(boolean bool) {
this.statusChanged = bool;
}
public boolean isStatusChanged() {
return statusChanged;
}
public TimelineRelationPanel getTimelineRP() {
return timelineRP;
}
public ProjectDV getTheProjectDV() {
return theProjectDV;
}
2022-11-08 10:45:39 +01:00
}
}