refs 3772: SAI - Create a github project importer

Task-Url: https://support.d4science.org/issues/3772

Fixed GitHub connector to support Liferay 6.2

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/github-connector@129711 82a268e6-3cf1-43bd-a215-b396298e98cf
master
Giancarlo Panichi 8 years ago
parent fbe45dec78
commit 3c3c237114

@ -32,7 +32,7 @@
<role>developer</role>
</roles>
</developer>
</developers>
</developers>
<properties>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
@ -288,18 +288,26 @@
<build>
<!-- Generate compiled stuff in the folder used for developing mode -->
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<skipTests>true</skipTests>
<exclude>**/GwtTest*.java</exclude>
</configuration>
<!-- TODO check if needed -->
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.16</version>
</dependency>
</dependencies>
</plugin>
<!-- GWT Maven Plugin -->
<plugin>
@ -312,8 +320,8 @@
<extraJvmArgs>-Xss512m -Xmx3072m -XX:MaxPermSize=2048m</extraJvmArgs>
</configuration>
<goals>
<goal>compile</goal>
<goal>test</goal>
<!-- <goal>test</goal> -->
<goal>resources</goal>
</goals>
</execution>
</executions>
@ -321,7 +329,7 @@
<runTarget>GitHubConnector.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<module>org.gcube.portlets.widgets.githubconnector.githubman</module>
<includes>**/GwtTest*.java</includes>
</configuration>
</plugin>

@ -65,14 +65,14 @@ public class GitHubConnectorController {
public void onFailure(Throwable caught) {
GWT.log("No valid user found: " + caught.getMessage());
if (caught instanceof ExpiredSessionServiceException) {
GWTMessages.alert("Error", "Expired Session");
GWTMessages.alert("Error", "Expired Session",-1);
sessionExpiredShowDelayed();
} else {
GWTMessages.alert(
"Error",
"No user found: "
+ caught.getLocalizedMessage());
+ caught.getLocalizedMessage(),-1);
}
}

@ -17,6 +17,12 @@ import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.TabLayoutPanel;
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 GitHubConnectorCredentialCard extends WizardCard {
private TabLayoutPanel tabPanel;
private TextBox userName;
@ -45,7 +51,7 @@ public class GitHubConnectorCredentialCard extends WizardCard {
password.setWidth("166px");
password.setEnabled(false);
anonymousCheck = new CheckBox("Anonymous");
anonymousCheck = new CheckBox();
anonymousCheck.setValue(true);
anonymousCheck.ensureDebugId("credentialCheckBoxAnonymous");
anonymousCheck.addClickHandler(new ClickHandler() {
@ -149,12 +155,12 @@ public class GitHubConnectorCredentialCard extends WizardCard {
} else {
String userN = userName.getValue();
if (userN == null || userN.isEmpty()) {
GWTMessages.alert("Attention", "Enter a user name!");
GWTMessages.alert("Attention", "Enter a user name!",getZIndex());
} else {
String pwd = password.getValue();
if (pwd == null || pwd.isEmpty()) {
GWTMessages.alert("Attention",
"Enter a user password!");
"Enter a user password!", getZIndex());
} else {
GitHubConnectorWizard wiz = (GitHubConnectorWizard) getWizardWindow();
wiz.getGitHubCloneSession().setGitHubCredential(
@ -169,7 +175,7 @@ public class GitHubConnectorCredentialCard extends WizardCard {
if (selectedIndex == 1) {
String tk = token.getValue();
if (tk == null || tk.isEmpty()) {
GWTMessages.alert("Attention", "Enter a token!");
GWTMessages.alert("Attention", "Enter a token!",getZIndex());
} else {
GitHubConnectorWizard wiz = (GitHubConnectorWizard) getWizardWindow();
wiz.getGitHubCloneSession().setGitHubCredential(
@ -177,7 +183,7 @@ public class GitHubConnectorCredentialCard extends WizardCard {
goNext();
}
} else {
GWTMessages.alert("Attention", "Select a valid tab!");
GWTMessages.alert("Attention", "Select a valid tab!",getZIndex());
}
}

@ -4,7 +4,6 @@ import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper;
import org.gcube.portlets.widgets.githubconnector.client.util.GWTMessages;
import org.gcube.portlets.widgets.githubconnector.client.wizard.event.WizardEvent;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
@ -13,7 +12,10 @@ import com.google.gwt.user.client.Window.Location;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class GitHubConnectorManager implements EntryPoint {
@ -52,14 +54,14 @@ public class GitHubConnectorManager implements EntryPoint {
} else {
GWTMessages
.alert("Attention",
"ClientScopeHelper has returned a false value!");
"ClientScopeHelper has returned a false value!",-1);
}
}
@Override
public void onFailure(Throwable caught) {
GWTMessages.alert("Error", "Error setting scope: "
+ caught.getLocalizedMessage());
+ caught.getLocalizedMessage(),-1);
caught.printStackTrace();
}
});

@ -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) {

@ -56,6 +56,7 @@ public class GitHubConnectorWizard extends WizardWindow {
timeoutTimer.schedule(TIMEOUT * 1000); // timeout is in milliseconds
}
}

@ -12,7 +12,10 @@ import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/**
* The client side stub for the RPC service.
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
@RemoteServiceRelativePath("githubconnectorservice")
public interface GitHubConnectorService extends RemoteService {

@ -12,8 +12,8 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface GitHubConnectorServiceAsync {

@ -22,16 +22,18 @@ public class AlertDialog extends DialogBox implements ClickHandler {
protected double msgMinHeight=30;
public AlertDialog(String title, String text) {
init(title, text);
public AlertDialog(String title, String text, int zIndex) {
init(title, text, zIndex);
}
public AlertDialog(String title, String text, Callback<Void, Void> callback) {
init(title, text);
public AlertDialog(String title, String text, int zIndex, Callback<Void, Void> callback) {
init(title, text, zIndex);
}
private void init(String title, String text) {
private void init(String title, String text, int zIndex) {
setText(title);
setModal(true);
setGlassEnabled(true);
Button closeButton = new Button("Close", this);
msg = new HTML(text, true);
@ -48,6 +50,11 @@ public class AlertDialog extends DialogBox implements ClickHandler {
dock.setCellHorizontalAlignment(closeButton, DockPanel.ALIGN_CENTER);
dock.setWidth("100%");
setWidget(dock);
if(zIndex>0){
getGlassElement().getStyle().setZIndex(zIndex+4);
getElement().getStyle().setZIndex(zIndex+5);
}
center();
}

@ -10,16 +10,17 @@ import com.google.gwt.core.client.Callback;
*/
public class GWTMessages {
public static void alert(String title, String text) {
AlertDialog alertDialgo = new AlertDialog(title, text);
alertDialgo.show();
public static void alert(String title, String text, int zIndex) {
AlertDialog alertDialog = new AlertDialog(title, text, zIndex);
alertDialog.show();
}
public static void alert(String title, String text,
public static void alert(String title, String text,int zIndex,
Callback<Void, Void> callback) {
AlertDialog alertDialgo = new AlertDialog(title, text, callback);
alertDialgo.show();
AlertDialog alertDialog = new AlertDialog(title, text, zIndex, callback);
alertDialog.show();
}

@ -25,15 +25,15 @@ public class WaitDialog extends DialogBox {
private String msgHeight = "25px";
private Timer t;
public WaitDialog(){
init("Please Wait", "Working...");
public WaitDialog(int zIndex){
init("Please Wait", "Working...", zIndex);
}
public WaitDialog(String title, String text) {
init(title, text);
public WaitDialog(String title, String text, int zIndex) {
init(title, text, zIndex);
}
private void init(String title, String text) {
private void init(String title, String text, int zIndex) {
GWT.log("WaitDialog:[title=" + title + ", text=" + text + "]");
GCResources.INSTANCE.wizardCSS().ensureInjected();
setModal(true);
@ -53,6 +53,11 @@ public class WaitDialog extends DialogBox {
msg.setHeight(msgHeight);
setWidget(msg);
if(zIndex>0){
getGlassElement().getStyle().setZIndex(zIndex+2);
getElement().getStyle().setZIndex(zIndex+3);
}
center();
startTimer();
}

@ -227,7 +227,9 @@ public class WizardCard extends SimplePanel {
wizardWindow.showErrorAndHide(title, message);
}
public int getZIndex(){
return wizardWindow.getZIndex();
}
public void hideWindow()
{

@ -73,6 +73,11 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
// protected FillToolItem fillSpacingCardMoveToolBar;
protected WizardMessages msgs;
protected DeckPanel deckPanel;
private Node closeEventTarget = null;
private int zIndex=-1;
/**
* Create a new Wizard Window with the specified title.
@ -525,7 +530,7 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
event.setException(new Exception(throwable));
GWTMessages.alert(title, message, new Callback<Void, Void>() {
GWTMessages.alert(title, message, getZIndex(), new Callback<Void, Void>() {
@Override
public void onFailure(Void reason) {
@ -547,7 +552,7 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
private Node closeEventTarget = null;
private void addToolIcon() {
@ -594,6 +599,17 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
public HandlerRegistration addWizardEventHandler(WizardEventHandler handler) {
return addHandler(handler, WizardEvent.getType());
}
public void setZIndex(int zIndex) {
this.zIndex=zIndex;
getGlassElement().getStyle().setZIndex(zIndex);
getElement().getStyle().setZIndex(zIndex+1);
}
public int getZIndex(){
return zIndex;
}
}

@ -2,26 +2,20 @@
<module rename-to='githubman'>
<inherits name='com.google.gwt.user.User' />
<inherits name="com.google.gwt.http.HTTP" />
<inherits name="com.google.gwt.resources.Resources" />
<inherits name='com.google.gwt.user.theme.clean.Clean' />
<!-- <inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" /> -->
<!-- <inherits name="com.google.gwt.logging.Logging" /> -->
<!-- Debug CSS style -->
<set-configuration-property name="CssResource.style"
value="pretty" />
<!-- <inherits name="org.gcube.portlets.user.tdw.TabularDataWidget" /> <inherits
name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' /> <inherits name='org.gcube.portlets.user.csvimportwizard.CSVImportWizard'
/> -->
<inherits name='org.gcube.portlets.widgets.sessionchecker.SessionChecker' />
<!-- <inherits name="org.gcube.portlets.user.csvimportwizard.ws.CSVImportWizardWorkspace"
/> -->
<!--
<entry-point
class='org.gcube.portlets.widgets.githubconnector.client.GitHubConnectorManager' />
-->
<!--
<set-property name="gwt.logging.enabled" value="TRUE" />

@ -20,7 +20,10 @@ import org.slf4j.LoggerFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/**
* The server side implementation of the RPC service.
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
@SuppressWarnings("serial")
public class GitHubConnectorServiceImpl extends RemoteServiceServlet implements

@ -9,6 +9,12 @@ import org.gcube.portlets.widgets.githubconnector.shared.exception.ServiceExcept
import org.gcube.portlets.widgets.githubconnector.shared.git.data.GitHubRepository;
import org.gcube.portlets.widgets.githubconnector.shared.git.data.GitHubUser;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class GitHubRepositoryBuilder {
private static Logger logger = Logger
.getLogger(GitHubRepositoryBuilder.class);

@ -3,7 +3,9 @@ package org.gcube.portlets.widgets.githubconnector.shared.exception;
/**
* ASL Session Expired Exception
*
* @author "Giancarlo Panichi"
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ExpiredSessionServiceException extends

@ -2,39 +2,34 @@
<module rename-to='githubman'>
<inherits name='com.google.gwt.user.User' />
<inherits name="com.google.gwt.http.HTTP" />
<inherits name='com.google.gwt.user.theme.clean.Clean' />
<inherits name="com.google.gwt.resources.Resources" />
<!-- <inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" /> -->
<!-- <inherits name="com.google.gwt.logging.Logging" /> -->
<inherits name='com.google.gwt.user.theme.clean.Clean' />
<!-- Debug CSS style -->
<set-configuration-property name="CssResource.style"
value="pretty" />
<!-- <inherits name="org.gcube.portlets.user.tdw.TabularDataWidget" /> <inherits
name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' /> <inherits name='org.gcube.portlets.user.csvimportwizard.CSVImportWizard'
/> -->
<inherits name='org.gcube.portlets.widgets.sessionchecker.SessionChecker' />
<!-- <inherits name="org.gcube.portlets.user.csvimportwizard.ws.CSVImportWizardWorkspace"
/> -->
<!--
<entry-point
class='org.gcube.portlets.widgets.githubconnector.client.GitHubConnectorManager' />
-->
<!--
<set-property name="gwt.logging.enabled" value="TRUE" />
<set-property name="gwt.logging.enabled" value="TRUE" />
<set-property name="gwt.logging.logLevel" value="SEVERE" />
<set-property name="gwt.logging.consoleHandler" value="ENABLED" />
<set-property name="gwt.logging.simpleRemoteHandler" value="ENABLED" /> -->
<set-property name="gwt.logging.simpleRemoteHandler" value="ENABLED" />
-->
<!--
<!--
<set-property name="log_ConsoleLogger" value="ENABLED" />
<set-property name="log_DivLogger" value="ENABLED" />
<set-property name="log_GWTLogger" value="ENABLED" />
<set-property name="log_SystemLogger" value="ENABLED" /> -->
<set-property name="log_SystemLogger" value="ENABLED" /> -->
<!--
<set-property name="log_ConsoleLogger" value="DISABLED" />

Loading…
Cancel
Save