From 9dcbda0877b1fde4520081bc3cc5a1c221f59b6e Mon Sep 17 00:00:00 2001 From: soimugeo Date: Thu, 9 Jan 2025 18:50:57 +0200 Subject: [PATCH] interim commit for https://github.com/who-icatx/icatx-versioning-service/issues/3 --- .../project/CreateNewProjectPresenter.java | 5 ++- .../client/project/CreateNewProjectView.java | 8 ++++ .../project/CreateNewProjectViewImpl.java | 41 ++++++++++++++++--- .../project/CreateNewProjectViewImpl.ui.xml | 7 ++++ ...eateNewProjectFromProjectBackupAction.java | 6 ++- 5 files changed, 60 insertions(+), 7 deletions(-) diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/CreateNewProjectPresenter.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/CreateNewProjectPresenter.java index 1060c13c3..8d3d4f6ca 100644 --- a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/CreateNewProjectPresenter.java +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/CreateNewProjectPresenter.java @@ -84,6 +84,9 @@ private boolean validate() { if (view.getProjectName().isEmpty()) { view.showProjectNameMissingMessage(); return false; + }else if ( view.isBackupFileSourceType() && !view.isBackupFilesBranchSet()){ + view.showBranchNameMissingMessage(); + return false; } return true; } @@ -149,7 +152,7 @@ private void handleCreateNewProjectFromProjectBackup(ProjectCreatedHandler proje private void submitCreateNewProjectFromProjectBackupRequest(NewProjectSettings newProjectSettings, ProjectCreatedHandler projectCreatedHandler) { String uuid = UuidV4.uuidv4(); ProjectId newProjectId = ProjectId.get(uuid); - dispatchServiceManager.execute(new CreateNewProjectFromProjectBackupAction(newProjectId, newProjectSettings), + dispatchServiceManager.execute(new CreateNewProjectFromProjectBackupAction(newProjectId, newProjectSettings, view.getProjectVersioningBranch()), new DispatchServiceCallbackWithProgressDisplay( errorDisplay, progressDisplay) { diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/CreateNewProjectView.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/CreateNewProjectView.java index 86f1aa827..6919dc757 100644 --- a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/CreateNewProjectView.java +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/CreateNewProjectView.java @@ -79,4 +79,12 @@ public interface CreateNewProjectView extends HasInitialFocusable, IsWidget { String getFileSourceType(); void setFileSourceTypeOptions(); + + boolean isBackupFilesBranchSet(); + + void showBranchNameMissingMessage(); + + boolean isBackupFileSourceType(); + + String getProjectVersioningBranch(); } diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/CreateNewProjectViewImpl.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/CreateNewProjectViewImpl.java index 0be201b8b..708e74fb1 100644 --- a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/CreateNewProjectViewImpl.java +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/CreateNewProjectViewImpl.java @@ -2,8 +2,7 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.event.shared.HandlerRegistration; -import com.google.gwt.uibinder.client.UiBinder; -import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.uibinder.client.*; import com.google.gwt.user.client.ui.*; import edu.stanford.bmir.protege.web.client.library.dlg.HasRequestFocus; import edu.stanford.bmir.protege.web.client.library.msgbox.MessageBox; @@ -14,8 +13,7 @@ import java.util.Optional; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.gwt.user.client.ui.FormPanel.ENCODING_MULTIPART; -import static com.google.gwt.user.client.ui.FormPanel.METHOD_POST; +import static com.google.gwt.user.client.ui.FormPanel.*; /** * Matthew Horridge Stanford Center for Biomedical Informatics Research 16 Nov 2017 @@ -53,7 +51,14 @@ interface CreateNewProjectViewImplUiBinder extends UiBinder {}; + private HandlerRegistration submitCompleteHandlerRegistraion = () -> { + }; + + @UiField + HTMLPanel backupFileBranchContainer; + + @UiField + TextBox backupFileBranchField; @Inject @@ -140,6 +145,12 @@ protected void onAttach() { super.onAttach(); projectNameField.setFocus(true); fileUpload.getElement().setId(FILE_UPLOAD_ID); + + fileSourceType.addChangeHandler(event -> { + String selectedType = getFileSourceType(); + boolean isBackupFiles = "backup".equals(selectedType); + backupFileBranchContainer.setVisible(isBackupFiles); + }); } @Override @@ -155,4 +166,24 @@ public void setFileSourceTypeOptions() { fileSourceType.addItem("Backup files", "backup"); fileSourceType.setSelectedIndex(0); // Default to the first option } + + @Override + public boolean isBackupFilesBranchSet() { + return !backupFileBranchField.getText().trim().isEmpty(); + } + + @Override + public void showBranchNameMissingMessage() { + messageBox.showAlert("Missing Branch Name", "Please enter the Git branch name for the backup files."); + } + + @Override + public boolean isBackupFileSourceType() { + return "backup".equals(getFileSourceType()); + } + + @Override + public String getProjectVersioningBranch() { + return backupFileBranchField.getText().trim(); + } } \ No newline at end of file diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/CreateNewProjectViewImpl.ui.xml b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/CreateNewProjectViewImpl.ui.xml index 2d937e4b3..98d25321e 100644 --- a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/CreateNewProjectViewImpl.ui.xml +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/project/CreateNewProjectViewImpl.ui.xml @@ -53,6 +53,13 @@ + + + + + diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/icd/CreateNewProjectFromProjectBackupAction.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/icd/CreateNewProjectFromProjectBackupAction.java index c36a38217..057ebcf39 100644 --- a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/icd/CreateNewProjectFromProjectBackupAction.java +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/icd/CreateNewProjectFromProjectBackupAction.java @@ -13,6 +13,7 @@ public class CreateNewProjectFromProjectBackupAction implements Action