Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
soimugeo committed Jan 9, 2025
1 parent a83cdf1 commit 9dcbda0
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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<CreateNewProjectFromProjectBackupResult>(
errorDisplay,
progressDisplay) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,12 @@ public interface CreateNewProjectView extends HasInitialFocusable, IsWidget {
String getFileSourceType();

void setFileSourceTypeOptions();

boolean isBackupFilesBranchSet();

void showBranchNameMissingMessage();

boolean isBackupFileSourceType();

String getProjectVersioningBranch();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -53,7 +51,14 @@ interface CreateNewProjectViewImplUiBinder extends UiBinder<HTMLPanel, CreateNew
@UiField
ListBox fileSourceType;

private HandlerRegistration submitCompleteHandlerRegistraion = () -> {};
private HandlerRegistration submitCompleteHandlerRegistraion = () -> {
};

@UiField
HTMLPanel backupFileBranchContainer;

@UiField
TextBox backupFileBranchField;


@Inject
Expand Down Expand Up @@ -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
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
<ui:safehtml from="{msg.projectSettings_owl_import_helpText}"/>
</label>
</g:HTMLPanel>
<g:HTMLPanel addStyleNames="{wp.style.formGroup}" ui:field="backupFileBranchContainer" visible="false">
<g:Label text="WHOFIC Ontology Files Branch Name" addStyleNames="{wp.style.formLabel}"/>
<g:TextBox ui:field="backupFileBranchField" addStyleNames="{style.formField}"/>
<label class="{wp.style.formHelpText} {style.helpText}">
Please enter the Git branch name for the backup files.
</label>
</g:HTMLPanel>


</g:HTMLPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class CreateNewProjectFromProjectBackupAction implements Action<CreateNew
private ProjectId newProjectId;

private NewProjectSettings newProjectSettings;
private String branchName;

/**
* For serialization purposes only
Expand All @@ -22,9 +23,11 @@ private CreateNewProjectFromProjectBackupAction() {

@JsonCreator
public CreateNewProjectFromProjectBackupAction(@JsonProperty("newProjectId") ProjectId newProjectId,
@JsonProperty("newProjectSettings") NewProjectSettings newProjectSettings) {
@JsonProperty("newProjectSettings") NewProjectSettings newProjectSettings,
@JsonProperty("branchName") String branchName) {
this.newProjectId = newProjectId;
this.newProjectSettings = checkNotNull(newProjectSettings);
this.branchName = branchName;
}

public ProjectId getNewProjectId() {
Expand Down Expand Up @@ -57,6 +60,7 @@ public String toString() {
return toStringHelper("CreateNewProjectFromProjectBackupAction")
.addValue(newProjectId)
.addValue(newProjectSettings)
.addValue(branchName)
.toString();
}
}

0 comments on commit 9dcbda0

Please sign in to comment.