Fixing timeline status

This commit is contained in:
Francesco Mangiacrapa 2022-11-08 14:50:48 +01:00
parent 7c646b3ead
commit fec3f26c0a
3 changed files with 61 additions and 21 deletions

View File

@ -148,8 +148,9 @@ public class ProjectViewer extends Composite {
List<RelationshipDV> relationships = projectView.getTheProjectDV().getRelationships();
if (relationships != null && relationships.size() > 0) {
relationshipsButton.setVisible(true);
} else
} else {
relationshipsButton.setVisible(false);
}
relationshipsButton.addClickHandler(new ClickHandler() {

View File

@ -9,32 +9,35 @@ import com.google.gwt.user.client.ui.RootPanel;
public class TimelineManagerStatus {
private ProjectDV showingProject;
private HandlerManager applicationBus;
private TimelineStatus status;
public TimelineManagerStatus(HandlerManager applicationBus) {
this.applicationBus = applicationBus;
}
protected TimelineRelationPanel getTimelineOf(ProjectDV theProject) {
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;
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;
boolean c1 = status.getTheProjectDV().getId().compareTo(theProject.getId()) == 0;
boolean c2 = status.getTheProjectDV().getProfileID().compareTo(theProject.getProfileID()) == 0;
if (!c1 || !c2) {
GWT.log("Displaying Timeline of " + theProject);
this.showingProject = theProject;
return new TimelineRelationPanel(applicationBus, theProject);
GWT.log("Displaying Timeline of " + status);
status = new TimelineStatus(true, new TimelineRelationPanel(applicationBus, theProject), theProject);
return status;
}
GWT.log("Skipping already displayed Timeline of " + theProject);
return null;
status.statusChanged(false);
GWT.log("Skipping already displayed Timeline of " + status);
return status;
}
@ -43,18 +46,50 @@ public class TimelineManagerStatus {
public void showTimelineProjectRelations(ProjectDV theProject) {
GWT.log("Showing project relations for: " + theProject);
TimelineRelationPanel timeline = getTimelineOf(theProject);
if (timeline != null) {
TimelineStatus timelineStatus = getTimelineOf(theProject);
if (timelineStatus.isStatusChanged()) {
RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).clear();
RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).setVisible(true);
RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).add(timeline);
RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).add(timelineStatus.getTimelineRP());
}
RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).setVisible(true);
timelineStatus.getTimelineRP().setTimelineContainerVisible(true);
}
public void hideTimelineProjectRelations() {
GWT.log("hideTimelineProjectRelations");
RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).setVisible(false);
RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).clear();
//RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).clear();
}
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;
}
}
}

View File

@ -83,9 +83,9 @@ public class TimelineRelationPanel extends Composite {
public void onClick(ClickEvent event) {
if(timelineContainer.isVisible())
timelineContainer.setVisible(false);
setTimelineContainerVisible(false);
else
timelineContainer.setVisible(true);
setTimelineContainerVisible(true);
}
});
@ -124,6 +124,10 @@ public class TimelineRelationPanel extends Composite {
});
}
public void setTimelineContainerVisible(boolean bool) {
timelineContainer.setVisible(bool);
}
private void setSelectedProject(String projectID) {
this.selectedProjectID = projectID;