|
|
|
@ -13,6 +13,7 @@ import org.gcube.portlets.widgets.githubconnector.shared.exception.ExpiredSessio
|
|
|
|
|
import org.gcube.portlets.widgets.githubconnector.shared.git.data.GitHubRepository;
|
|
|
|
|
|
|
|
|
|
import com.google.gwt.core.shared.GWT;
|
|
|
|
|
import com.google.gwt.dom.client.Style.Unit;
|
|
|
|
|
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
|
|
import com.google.gwt.user.client.Command;
|
|
|
|
@ -25,6 +26,12 @@ import com.google.gwt.user.client.ui.PushButton;
|
|
|
|
|
import com.google.gwt.user.client.ui.SimplePanel;
|
|
|
|
|
import com.google.gwt.user.client.ui.TextBox;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @author Giancarlo Panichi email: <a
|
|
|
|
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public class GitHubConnectorRepositorySelectionCard extends WizardCard {
|
|
|
|
|
|
|
|
|
|
private TextBox repositoryOwner;
|
|
|
|
@ -58,6 +65,7 @@ public class GitHubConnectorRepositorySelectionCard extends WizardCard {
|
|
|
|
|
PushButton searchRepository = new PushButton(new Image(
|
|
|
|
|
GCResources.INSTANCE.search16()),
|
|
|
|
|
searchRepositoryClickHandler);
|
|
|
|
|
searchRepository.getElement().getStyle().setMargin(3, Unit.PX);
|
|
|
|
|
|
|
|
|
|
// Form
|
|
|
|
|
FlexTable layout = new FlexTable();
|
|
|
|
@ -88,11 +96,11 @@ public class GitHubConnectorRepositorySelectionCard extends WizardCard {
|
|
|
|
|
private void retrieveRepositories() {
|
|
|
|
|
String repOwner = repositoryOwner.getValue();
|
|
|
|
|
if (repOwner == null || repOwner.isEmpty()) {
|
|
|
|
|
GWTMessages.alert("Attention", "Enter a owner!");
|
|
|
|
|
GWTMessages.alert("Attention", "Enter a owner!",getZIndex());
|
|
|
|
|
} else {
|
|
|
|
|
final WaitDialog waitDialog=new WaitDialog();
|
|
|
|
|
final WaitDialog waitDialog = new WaitDialog(getZIndex());
|
|
|
|
|
waitDialog.show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final GitHubConnectorWizard wiz = (GitHubConnectorWizard) getWizardWindow();
|
|
|
|
|
GitHubConnectorServiceAsync.INSTANCE.getRepositories(repOwner, wiz
|
|
|
|
|
.getGitHubCloneSession().getGitHubCredential(),
|
|
|
|
@ -156,70 +164,74 @@ public class GitHubConnectorRepositorySelectionCard extends WizardCard {
|
|
|
|
|
|
|
|
|
|
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
|
|
|
|
getWizardWindow().setNextButtonCommand(sayNextCard);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getWizardWindow().setNextButtonToFinish();
|
|
|
|
|
setEnableBackButton(true);
|
|
|
|
|
setBackButtonVisible(true);
|
|
|
|
|
setEnableNextButton(true);
|
|
|
|
|
setNextButtonVisible(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void checkData() {
|
|
|
|
|
String repoOwner=repositoryOwner.getValue();
|
|
|
|
|
String repoOwner = repositoryOwner.getValue();
|
|
|
|
|
if (repoOwner == null || repoOwner.isEmpty()) {
|
|
|
|
|
GWTMessages.alert("Attention", "Enter a repository owner!");
|
|
|
|
|
GWTMessages.alert("Attention", "Enter a repository owner!",getZIndex());
|
|
|
|
|
} else {
|
|
|
|
|
String repoName=repositoryName.getSelectedItemText();
|
|
|
|
|
if (repoName == null || repoName.isEmpty()) {
|
|
|
|
|
GWTMessages.alert("Attention", "Select a repository name!");
|
|
|
|
|
int selected = repositoryName.getSelectedIndex();
|
|
|
|
|
if (selected >= 0) {
|
|
|
|
|
String repoName = repositoryName.getValue(selected);
|
|
|
|
|
if (repoName == null || repoName.isEmpty()) {
|
|
|
|
|
GWTMessages.alert("Attention", "Select a repository name!",getZIndex());
|
|
|
|
|
} else {
|
|
|
|
|
GitHubConnectorWizard wiz = (GitHubConnectorWizard) getWizardWindow();
|
|
|
|
|
wiz.getGitHubCloneSession().setRepositoryName(repoName);
|
|
|
|
|
wiz.getGitHubCloneSession().setRepositoryOwner(repoOwner);
|
|
|
|
|
callCloneForRepository();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
GitHubConnectorWizard wiz = (GitHubConnectorWizard) getWizardWindow();
|
|
|
|
|
wiz.getGitHubCloneSession().setRepositoryName(repoName);
|
|
|
|
|
wiz.getGitHubCloneSession().setRepositoryOwner(repoOwner);
|
|
|
|
|
callCloneForRepository();
|
|
|
|
|
GWTMessages.alert("Attention", "Select a repository name!",getZIndex());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void callCloneForRepository() {
|
|
|
|
|
final WaitDialog waitDialog=new WaitDialog();
|
|
|
|
|
final WaitDialog waitDialog = new WaitDialog(getZIndex());
|
|
|
|
|
waitDialog.show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final GitHubConnectorWizard wiz = (GitHubConnectorWizard) getWizardWindow();
|
|
|
|
|
GitHubConnectorServiceAsync.INSTANCE.cloneRepository(wiz.getGitHubCloneSession(), new AsyncCallback<Void>() {
|
|
|
|
|
GitHubConnectorServiceAsync.INSTANCE.cloneRepository(
|
|
|
|
|
wiz.getGitHubCloneSession(), new AsyncCallback<Void>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
waitDialog.hide();
|
|
|
|
|
GWT.log("Error in clone repository: "
|
|
|
|
|
+ caught.getMessage());
|
|
|
|
|
if (caught instanceof ExpiredSessionServiceException) {
|
|
|
|
|
showErrorAndHide("Error", "Expired Session");
|
|
|
|
|
wiz.sessionExpiredShowDelayed();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
showErrorAndHide("Error", "In clone repository: "
|
|
|
|
|
+ caught.getLocalizedMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
waitDialog.hide();
|
|
|
|
|
GWT.log("Error in clone repository: "
|
|
|
|
|
+ caught.getMessage());
|
|
|
|
|
if (caught instanceof ExpiredSessionServiceException) {
|
|
|
|
|
showErrorAndHide("Error", "Expired Session");
|
|
|
|
|
wiz.sessionExpiredShowDelayed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
showErrorAndHide(
|
|
|
|
|
"Error",
|
|
|
|
|
"In clone repository: "
|
|
|
|
|
+ caught.getLocalizedMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Void result) {
|
|
|
|
|
waitDialog.hide();
|
|
|
|
|
goNext();
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Void result) {
|
|
|
|
|
waitDialog.hide();
|
|
|
|
|
goNext();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void goNext() {
|
|
|
|
|
try {
|
|
|
|
|
GWT.log("NextCard");
|
|
|
|
|
WizardEvent event=new WizardEvent(WizardEventType.Completed);
|
|
|
|
|
WizardEvent event = new WizardEvent(WizardEventType.Completed);
|
|
|
|
|
getWizardWindow().fireEvent(event);
|
|
|
|
|
getWizardWindow().close(false);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|