refs:3772: SAI - Create a github project importer
https://support.d4science.org/issues/3772 Added Wizard support and Repository explorer git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/github-connector@129100 82a268e6-3cf1-43bd-a215-b396298e98cf
6
pom.xml
|
@ -45,6 +45,7 @@
|
||||||
|
|
||||||
<!-- GWT configuration -->
|
<!-- GWT configuration -->
|
||||||
<gwtVersion>2.7.0</gwtVersion>
|
<gwtVersion>2.7.0</gwtVersion>
|
||||||
|
<gwtLogVersion>3.3.2</gwtLogVersion>
|
||||||
|
|
||||||
<KEYS>${env.KEYS}</KEYS>
|
<KEYS>${env.KEYS}</KEYS>
|
||||||
|
|
||||||
|
@ -262,6 +263,11 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- LOGGING -->
|
<!-- LOGGING -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.allen-sauer.gwt.log</groupId>
|
||||||
|
<artifactId>gwt-log</artifactId>
|
||||||
|
<version>${gwtLogVersion}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
|
|
@ -2,10 +2,13 @@ package org.gcube.portlets.widgets.githubconnector.client;
|
||||||
|
|
||||||
import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper;
|
import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper;
|
||||||
import org.gcube.portlets.widgets.githubconnector.client.util.GWTMessages;
|
import org.gcube.portlets.widgets.githubconnector.client.util.GWTMessages;
|
||||||
|
import org.gcube.portlets.widgets.githubconnector.client.wizard.SimpleWizardCard;
|
||||||
|
import org.gcube.portlets.widgets.githubconnector.client.wizard.WizardWindow;
|
||||||
|
|
||||||
import com.google.gwt.core.client.EntryPoint;
|
import com.google.gwt.core.client.EntryPoint;
|
||||||
import com.google.gwt.core.client.Scheduler;
|
import com.google.gwt.core.client.Scheduler;
|
||||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||||
|
import com.google.gwt.core.shared.GWT;
|
||||||
import com.google.gwt.user.client.Window.Location;
|
import com.google.gwt.user.client.Window.Location;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
//import com.google.gwt.event.logical.shared.ResizeEvent;
|
//import com.google.gwt.event.logical.shared.ResizeEvent;
|
||||||
|
@ -65,10 +68,22 @@ public class GitHubConnectorManager implements EntryPoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadMainPanel() {
|
private void loadMainPanel() {
|
||||||
TestController = new GitHubConnectorController();
|
GWT.log("GitHubConnectorManager");
|
||||||
GitHubConnectorDialog dialog=new GitHubConnectorDialog();
|
//TestController = new GitHubConnectorController();
|
||||||
dialog.show();
|
//GitHubConnectorDialog dialog=new GitHubConnectorDialog();
|
||||||
|
//dialog.show();
|
||||||
|
|
||||||
|
WizardWindow wizardWindow = new WizardWindow("TestWindow");
|
||||||
|
SimpleWizardCard simple1=new SimpleWizardCard("Test Title","Test Footer", "This is 1 card");
|
||||||
|
wizardWindow.addCard(simple1);
|
||||||
|
SimpleWizardCard simple2=new SimpleWizardCard("Test Title","Test Footer", "This is 2 card");
|
||||||
|
wizardWindow.addCard(simple2);
|
||||||
|
SimpleWizardCard simple3=new SimpleWizardCard("Test Title","Test Footer", "This is 3 card");
|
||||||
|
wizardWindow.addCard(simple3);
|
||||||
|
|
||||||
|
wizardWindow.show();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
private void bind() {
|
private void bind() {
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
package org.gcube.portlets.widgets.githubconnector.client.resource;
|
||||||
|
|
||||||
|
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.resources.client.ClientBundle;
|
||||||
|
import com.google.gwt.resources.client.ImageResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface GCResources extends ClientBundle {
|
||||||
|
|
||||||
|
public static final GCResources INSTANCE=GWT.create(GCResources.class);
|
||||||
|
|
||||||
|
@Source("Wizard.css")
|
||||||
|
WizardCSS wizardCSS();
|
||||||
|
|
||||||
|
@Source("arrow-refresh.png")
|
||||||
|
ImageResource refresh();
|
||||||
|
|
||||||
|
@Source("arrow-refresh_16.png")
|
||||||
|
ImageResource refresh16();
|
||||||
|
|
||||||
|
|
||||||
|
@Source("arrow-refresh_32.png")
|
||||||
|
ImageResource refresh32();
|
||||||
|
|
||||||
|
@Source("wizard-next.png")
|
||||||
|
ImageResource wizardNext();
|
||||||
|
|
||||||
|
@Source("wizard-next_32.png")
|
||||||
|
ImageResource wizardNext32();
|
||||||
|
|
||||||
|
@Source("wizard-previous.png")
|
||||||
|
ImageResource wizardPrevious();
|
||||||
|
|
||||||
|
@Source("wizard-previous_32.png")
|
||||||
|
ImageResource wizardPrevious32();
|
||||||
|
|
||||||
|
@Source("wizard-go.png")
|
||||||
|
ImageResource wizardGo();
|
||||||
|
|
||||||
|
@Source("wizard-go_32.png")
|
||||||
|
ImageResource wizardGo32();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
@CHARSET "UTF-8";
|
||||||
|
|
||||||
|
|
||||||
|
.wizard-title {
|
||||||
|
padding: 5px;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: small;
|
||||||
|
background-color: #C3D9FF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wizard-footer {
|
||||||
|
padding: 5px;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: x-small;
|
||||||
|
text-align: left;
|
||||||
|
background-color: #CDEB8B
|
||||||
|
}
|
||||||
|
|
||||||
|
.source-selection-hover:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.column-excluded {
|
||||||
|
background-color: #e6e0da !important;
|
||||||
|
color: #bfa698;
|
||||||
|
}
|
||||||
|
|
||||||
|
.importSelection-sources {
|
||||||
|
padding: 30px;
|
||||||
|
display: block;
|
||||||
|
margin-top: 5px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.importSelection-source {
|
||||||
|
padding-bottom: 20px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.widgets.githubconnector.client.resource;
|
||||||
|
|
||||||
|
import com.google.gwt.resources.client.CssResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface WizardCSS extends CssResource {
|
||||||
|
|
||||||
|
@ClassName("wizard-title")
|
||||||
|
public String getWizardTitle();
|
||||||
|
|
||||||
|
@ClassName("wizard-footer")
|
||||||
|
public String getWizardFooter();
|
||||||
|
|
||||||
|
@ClassName("source-selection-hover")
|
||||||
|
public String getSourceSelectionHover();
|
||||||
|
|
||||||
|
@ClassName("column-excluded")
|
||||||
|
public String getColumnExcluded();
|
||||||
|
|
||||||
|
@ClassName("importSelection-sources")
|
||||||
|
public String getImportSelectionSources();
|
||||||
|
|
||||||
|
@ClassName("importSelection-source")
|
||||||
|
public String getImportSelectionSource();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
After Width: | Height: | Size: 781 B |
After Width: | Height: | Size: 984 B |
After Width: | Height: | Size: 572 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 701 B |
After Width: | Height: | Size: 778 B |
After Width: | Height: | Size: 771 B |
After Width: | Height: | Size: 502 B |
After Width: | Height: | Size: 656 B |
After Width: | Height: | Size: 474 B |
After Width: | Height: | Size: 559 B |
After Width: | Height: | Size: 431 B |
After Width: | Height: | Size: 573 B |
|
@ -1,9 +1,10 @@
|
||||||
package org.gcube.portlets.widgets.githubconnector.client.rpc;
|
package org.gcube.portlets.widgets.githubconnector.client.rpc;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.githubconnector.shared.exception.ServiceException;
|
import org.gcube.portlets.widgets.githubconnector.shared.exception.ServiceException;
|
||||||
import org.gcube.portlets.widgets.githubconnector.shared.git.GitHubRepository;
|
import org.gcube.portlets.widgets.githubconnector.shared.git.GitHubRepository;
|
||||||
|
import org.gcube.portlets.widgets.githubconnector.shared.git.credential.GitHubCredential;
|
||||||
import org.gcube.portlets.widgets.githubconnector.shared.session.UserInfo;
|
import org.gcube.portlets.widgets.githubconnector.shared.session.UserInfo;
|
||||||
|
|
||||||
import com.google.gwt.user.client.rpc.RemoteService;
|
import com.google.gwt.user.client.rpc.RemoteService;
|
||||||
|
@ -17,7 +18,7 @@ public interface GitHubConnectorService extends RemoteService {
|
||||||
|
|
||||||
public UserInfo hello() throws ServiceException;
|
public UserInfo hello() throws ServiceException;
|
||||||
|
|
||||||
public List<GitHubRepository> getRepositories(String owner) throws ServiceException;
|
public ArrayList<GitHubRepository> getRepositories(String repositoryOwner, GitHubCredential gitHubCredential) throws ServiceException;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package org.gcube.portlets.widgets.githubconnector.client.rpc;
|
package org.gcube.portlets.widgets.githubconnector.client.rpc;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.githubconnector.shared.git.GitHubRepository;
|
import org.gcube.portlets.widgets.githubconnector.shared.git.GitHubRepository;
|
||||||
|
import org.gcube.portlets.widgets.githubconnector.shared.git.credential.GitHubCredential;
|
||||||
import org.gcube.portlets.widgets.githubconnector.shared.session.UserInfo;
|
import org.gcube.portlets.widgets.githubconnector.shared.session.UserInfo;
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
@ -21,6 +22,8 @@ public interface GitHubConnectorServiceAsync {
|
||||||
|
|
||||||
void hello(AsyncCallback<UserInfo> callback);
|
void hello(AsyncCallback<UserInfo> callback);
|
||||||
|
|
||||||
void getRepositories(String owner, AsyncCallback<List<GitHubRepository>> callback);
|
void getRepositories(String repositoryOwner,
|
||||||
|
GitHubCredential gitHubCredential,
|
||||||
|
AsyncCallback<ArrayList<GitHubRepository>> callback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.gcube.portlets.widgets.githubconnector.client.util;
|
package org.gcube.portlets.widgets.githubconnector.client.util;
|
||||||
|
|
||||||
|
import com.google.gwt.core.client.Callback;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.user.client.ui.Button;
|
import com.google.gwt.user.client.ui.Button;
|
||||||
|
@ -9,24 +10,34 @@ import com.google.gwt.user.client.ui.HTML;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Giancarlo Panichi
|
* @author Giancarlo Panichi email: <a
|
||||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class AlertDialog extends DialogBox implements ClickHandler {
|
public class AlertDialog extends DialogBox implements ClickHandler {
|
||||||
|
private Callback<Void, Void> callback;
|
||||||
|
|
||||||
|
|
||||||
public AlertDialog(String title, String text) {
|
public AlertDialog(String title, String text) {
|
||||||
|
init(title, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AlertDialog(String title, String text, Callback<Void, Void> callback) {
|
||||||
|
init(title, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init(String title, String text) {
|
||||||
setText(title);
|
setText(title);
|
||||||
|
|
||||||
Button closeButton = new Button("Close", this);
|
Button closeButton = new Button("Close", this);
|
||||||
HTML msg = new HTML(
|
HTML msg = new HTML(text, true);
|
||||||
text, true);
|
|
||||||
|
|
||||||
DockPanel dock = new DockPanel();
|
DockPanel dock = new DockPanel();
|
||||||
dock.setSpacing(4);
|
dock.setSpacing(4);
|
||||||
|
|
||||||
dock.add(closeButton, DockPanel.SOUTH);
|
dock.add(closeButton, DockPanel.SOUTH);
|
||||||
dock.add(msg, DockPanel.CENTER);
|
dock.add(msg, DockPanel.CENTER);
|
||||||
|
|
||||||
dock.setCellHorizontalAlignment(closeButton, DockPanel.ALIGN_CENTER);
|
dock.setCellHorizontalAlignment(closeButton, DockPanel.ALIGN_CENTER);
|
||||||
dock.setWidth("100%");
|
dock.setWidth("100%");
|
||||||
setWidget(dock);
|
setWidget(dock);
|
||||||
|
@ -34,7 +45,11 @@ public class AlertDialog extends DialogBox implements ClickHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
|
if(callback!=null){
|
||||||
|
callback.onSuccess(null);
|
||||||
|
}
|
||||||
hide();
|
hide();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,17 +1,26 @@
|
||||||
package org.gcube.portlets.widgets.githubconnector.client.util;
|
package org.gcube.portlets.widgets.githubconnector.client.util;
|
||||||
|
|
||||||
|
import com.google.gwt.core.client.Callback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Giancarlo Panichi
|
* @author Giancarlo Panichi email: <a
|
||||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class GWTMessages {
|
public class GWTMessages {
|
||||||
|
|
||||||
public static void alert(String title, String text) {
|
public static void alert(String title, String text) {
|
||||||
AlertDialog alertDialgo = new AlertDialog(title, text);
|
AlertDialog alertDialgo = new AlertDialog(title, text);
|
||||||
alertDialgo.show();
|
alertDialgo.show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void alert(String title, String text,
|
||||||
|
Callback<Void, Void> callback) {
|
||||||
|
AlertDialog alertDialgo = new AlertDialog(title, text, callback);
|
||||||
|
alertDialgo.show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.widgets.githubconnector.client.wizard;
|
||||||
|
|
||||||
|
import com.google.gwt.core.shared.GWT;
|
||||||
|
import com.google.gwt.user.client.Command;
|
||||||
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
|
import com.google.gwt.user.client.ui.SimplePanel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SimpleWizardCard extends WizardCard {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new simple wizard card.
|
||||||
|
*
|
||||||
|
* @param title
|
||||||
|
* the card title.
|
||||||
|
* @param footer
|
||||||
|
* the card footer.
|
||||||
|
* @param content
|
||||||
|
* the card content.
|
||||||
|
*/
|
||||||
|
public SimpleWizardCard(String title, String footer, String content) {
|
||||||
|
super(title, footer);
|
||||||
|
|
||||||
|
SimplePanel contentPanel = new SimplePanel();
|
||||||
|
HTML htmlContent = new HTML(content);
|
||||||
|
htmlContent.setStyleName("wizard-simple-content");
|
||||||
|
contentPanel.add(htmlContent);
|
||||||
|
|
||||||
|
setContent(contentPanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
Command sayNextCard = new Command() {
|
||||||
|
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
GWT.log("NextCard");
|
||||||
|
getWizardWindow().nextCard();
|
||||||
|
} catch (Exception e) {
|
||||||
|
GWT.log("sayNextCard :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
Command sayPreviousCard = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
GWT.log("PreviousCard");
|
||||||
|
getWizardWindow().previousCard();
|
||||||
|
} catch (Exception e) {
|
||||||
|
GWT.log("sayPreviousCard :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||||
|
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||||
|
|
||||||
|
setEnableBackButton(true);
|
||||||
|
setBackButtonVisible(true);
|
||||||
|
setEnableNextButton(true);
|
||||||
|
setNextButtonVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,220 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.widgets.githubconnector.client.wizard;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.githubconnector.client.resource.GCResources;
|
||||||
|
|
||||||
|
import com.google.gwt.core.shared.GWT;
|
||||||
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
|
import com.google.gwt.event.shared.EventBus;
|
||||||
|
import com.google.gwt.user.client.ui.SimplePanel;
|
||||||
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class WizardCard extends SimplePanel {
|
||||||
|
|
||||||
|
private WizardWindow wizardWindow;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected GCResources res=GCResources.INSTANCE;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new wizard card.
|
||||||
|
* The footer is automatically calculated.
|
||||||
|
* @param title the card title.
|
||||||
|
*/
|
||||||
|
public WizardCard(String title) {
|
||||||
|
this(title,"");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new wizard card.
|
||||||
|
* @param title the card title.
|
||||||
|
* @param footer the card footer.
|
||||||
|
*/
|
||||||
|
public WizardCard(String title, String footer) {
|
||||||
|
GWT.log(title);
|
||||||
|
res.wizardCSS().ensureInjected();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the card content.
|
||||||
|
* @param content the card content.
|
||||||
|
*/
|
||||||
|
public void setContent(Widget content)
|
||||||
|
{
|
||||||
|
setWidget(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the next button.
|
||||||
|
* @param enable <code>true</code> to enable it, <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public void setEnableNextButton(boolean enable)
|
||||||
|
{
|
||||||
|
if (wizardWindow!=null){
|
||||||
|
wizardWindow.setEnableNextButton(enable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the back button.
|
||||||
|
* @param enable <code>true</code> to enable the button, <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public void setEnableBackButton(boolean enable)
|
||||||
|
{
|
||||||
|
if (wizardWindow!=null){
|
||||||
|
wizardWindow.setEnableBackButton(enable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**dispose
|
||||||
|
* Sets the next button label.
|
||||||
|
* @param text the button label.
|
||||||
|
*/
|
||||||
|
public void setNextButtonText(String text)
|
||||||
|
{
|
||||||
|
if (wizardWindow!=null){
|
||||||
|
wizardWindow.setNextButtonText(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the back button label.
|
||||||
|
* @param text the button label.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void setBackButtonText(String text)
|
||||||
|
{
|
||||||
|
if (wizardWindow!=null){
|
||||||
|
wizardWindow.setBackButtonText(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Visible the next button.
|
||||||
|
* @param visible <code>true</code> to show the button, <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public void setNextButtonVisible(boolean visible)
|
||||||
|
{
|
||||||
|
if (wizardWindow!=null){
|
||||||
|
wizardWindow.setNextButtonVisible(visible);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Visible the back button.
|
||||||
|
* @param visible <code>true</code> to show the button, <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public void setBackButtonVisible(boolean visible)
|
||||||
|
{
|
||||||
|
if (wizardWindow!=null){
|
||||||
|
wizardWindow.setBackButtonVisible(visible);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setNextButtonToFinish()
|
||||||
|
{
|
||||||
|
if (wizardWindow!=null){
|
||||||
|
wizardWindow.setNextButtonToFinish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the WizardWindow for this import card.
|
||||||
|
* @param wizardWindow the WizardWindow.
|
||||||
|
*/
|
||||||
|
protected void setWizardWindow(WizardWindow wizardWindow)
|
||||||
|
{
|
||||||
|
this.wizardWindow = wizardWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current wizard window.
|
||||||
|
* @return the wizard window.
|
||||||
|
*/
|
||||||
|
protected WizardWindow getWizardWindow()
|
||||||
|
{
|
||||||
|
if (wizardWindow==null) throw new IllegalStateException("No Wizard Window setup");
|
||||||
|
return wizardWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addToWindowTitle(String toAdd)
|
||||||
|
{
|
||||||
|
wizardWindow.setTitle(wizardWindow.getOriginalTitle()+toAdd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called before the card is showed.
|
||||||
|
*/
|
||||||
|
public void setup()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the card is disposed.
|
||||||
|
*/
|
||||||
|
public void dispose()
|
||||||
|
{}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a listener to the next button.
|
||||||
|
* @param listener the listener to add.
|
||||||
|
*/
|
||||||
|
public void addNextButtonListener(ClickHandler listener)
|
||||||
|
{
|
||||||
|
if (wizardWindow!=null){
|
||||||
|
wizardWindow.addNextButtonListener(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the number of cards in the wizard window.
|
||||||
|
* @return the number of cards.
|
||||||
|
*/
|
||||||
|
public int getNumberOfCards()
|
||||||
|
{
|
||||||
|
return getWizardWindow().getCardStackSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns this card position on card list.
|
||||||
|
* @return the card position on the card stack.
|
||||||
|
*/
|
||||||
|
public int getCardPosition()
|
||||||
|
{
|
||||||
|
int indexPosition = getWizardWindow().getCardStack().indexOf(this);
|
||||||
|
return (indexPosition>=0)?indexPosition+1:indexPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showErrorAndHide(String title, final String message, String details, final Throwable throwable)
|
||||||
|
{
|
||||||
|
wizardWindow.showErrorAndHide(title, message, details, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hideWindow()
|
||||||
|
{
|
||||||
|
wizardWindow.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventBus getEventBus(){
|
||||||
|
return wizardWindow.eventBus;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.widgets.githubconnector.client.wizard;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface WizardListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the wizard is completed without errors
|
||||||
|
*/
|
||||||
|
public void completed(String id);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the operation is put in background
|
||||||
|
*/
|
||||||
|
public void putInBackground();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the wizard has been aborted by the user.
|
||||||
|
*/
|
||||||
|
public void aborted();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the something in the wizard is failed.
|
||||||
|
* @param title
|
||||||
|
* @param message the failure reason.
|
||||||
|
* @param details the failure details.
|
||||||
|
* @param throwable the exception.
|
||||||
|
*/
|
||||||
|
public void failed(String title, String message, String details, Throwable throwable);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package org.gcube.portlets.widgets.githubconnector.client.wizard;
|
||||||
|
|
||||||
|
import com.google.gwt.i18n.client.Messages;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo
|
||||||
|
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface WizardMessages extends Messages {
|
||||||
|
|
||||||
|
//
|
||||||
|
@DefaultMessage("Back")
|
||||||
|
String buttonBackLabel();
|
||||||
|
|
||||||
|
@DefaultMessage("Next")
|
||||||
|
String buttonNextLabel();
|
||||||
|
|
||||||
|
@DefaultMessage("Finish")
|
||||||
|
String buttonFinishLabel();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,489 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.widgets.githubconnector.client.wizard;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.githubconnector.client.util.GWTMessages;
|
||||||
|
|
||||||
|
import com.google.gwt.core.client.Callback;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||||
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
|
import com.google.gwt.event.shared.EventBus;
|
||||||
|
import com.google.gwt.event.shared.SimpleEventBus;
|
||||||
|
import com.google.gwt.safehtml.shared.SafeHtml;
|
||||||
|
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||||
|
import com.google.gwt.user.client.Command;
|
||||||
|
import com.google.gwt.user.client.ui.Button;
|
||||||
|
import com.google.gwt.user.client.ui.DeckPanel;
|
||||||
|
import com.google.gwt.user.client.ui.DialogBox;
|
||||||
|
import com.google.gwt.user.client.ui.DockPanel;
|
||||||
|
import com.google.gwt.user.client.ui.MenuBar;
|
||||||
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class WizardWindow extends DialogBox {
|
||||||
|
|
||||||
|
protected boolean WIZARD_RESIZABLE = false;
|
||||||
|
protected boolean WIZARD_COLLAPSIBLE = true;
|
||||||
|
protected String title;
|
||||||
|
|
||||||
|
protected ArrayList<WizardCard> cardStack = new ArrayList<WizardCard>();
|
||||||
|
|
||||||
|
protected Button backButton;
|
||||||
|
|
||||||
|
protected Button nextButton;
|
||||||
|
|
||||||
|
protected String originalTitle;
|
||||||
|
|
||||||
|
protected boolean checkBeforeClose = true;
|
||||||
|
|
||||||
|
protected boolean nextCardFinish = false;
|
||||||
|
|
||||||
|
protected Command nextButtonAction = null;
|
||||||
|
|
||||||
|
protected Command previousButtonAction = null;
|
||||||
|
|
||||||
|
protected DockPanel dockPanel;
|
||||||
|
|
||||||
|
protected ArrayList<WizardListener> listeners;
|
||||||
|
|
||||||
|
protected EventBus eventBus;
|
||||||
|
|
||||||
|
protected MenuBar cardMoveToolBar;
|
||||||
|
|
||||||
|
// protected FillToolItem fillSpacingCardMoveToolBar;
|
||||||
|
protected WizardMessages msgs;
|
||||||
|
protected DeckPanel deckPanel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Wizard Window with the specified title.
|
||||||
|
*
|
||||||
|
* @param title
|
||||||
|
* the wizard window title.
|
||||||
|
*/
|
||||||
|
public WizardWindow(String title) {
|
||||||
|
this(title, new SimpleEventBus());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public WizardWindow(String title, EventBus eventBus) {
|
||||||
|
super();
|
||||||
|
GWT.log("WizardWindow");
|
||||||
|
this.title = title;
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
this.msgs = GWT.create(WizardMessages.class);
|
||||||
|
|
||||||
|
initWindow();
|
||||||
|
|
||||||
|
listeners = new ArrayList<WizardListener>();
|
||||||
|
deckPanel=new DeckPanel();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cardMoveToolBar = new MenuBar();
|
||||||
|
|
||||||
|
// Create a command that will execute on menu item selection
|
||||||
|
ScheduledCommand menuCommandBack = new ScheduledCommand() {
|
||||||
|
|
||||||
|
public void execute() {
|
||||||
|
if (previousButtonAction != null)
|
||||||
|
previousButtonAction.execute();
|
||||||
|
else
|
||||||
|
previousCard();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ScheduledCommand menuCommandNext = new ScheduledCommand() {
|
||||||
|
|
||||||
|
public void execute() {
|
||||||
|
if (nextButtonAction != null)
|
||||||
|
nextButtonAction.execute();
|
||||||
|
else
|
||||||
|
nextCard();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// cardMoveToolBar.setSpacing(2);
|
||||||
|
// cardMoveToolBar.addStyleName(ThemeStyles.get().style().borderTop());
|
||||||
|
|
||||||
|
backButton = new Button(msgs.buttonBackLabel());
|
||||||
|
// backButton.setIcon(GCResources.INSTANCE.wizardPrevious());
|
||||||
|
backButton.setEnabled(false);
|
||||||
|
backButton.setTabIndex(1001);
|
||||||
|
|
||||||
|
SafeHtml backItem=new SafeHtmlBuilder().appendEscaped(
|
||||||
|
msgs.buttonBackLabel()).toSafeHtml();
|
||||||
|
|
||||||
|
cardMoveToolBar.addItem(backItem,menuCommandBack);
|
||||||
|
|
||||||
|
nextButton = new Button(msgs.buttonNextLabel());
|
||||||
|
// backButton.setIcon(GCResources.INSTANCE.wizardPrevious());
|
||||||
|
nextButton.setEnabled(false);
|
||||||
|
nextButton.setTabIndex(1002);
|
||||||
|
|
||||||
|
SafeHtml nextItem=new SafeHtmlBuilder().appendEscaped(
|
||||||
|
msgs.buttonNextLabel()).toSafeHtml();
|
||||||
|
|
||||||
|
cardMoveToolBar.addItem(nextItem,menuCommandNext);
|
||||||
|
|
||||||
|
dockPanel = new DockPanel();
|
||||||
|
dockPanel.setSpacing(4);
|
||||||
|
|
||||||
|
dockPanel.add(deckPanel , DockPanel.CENTER);
|
||||||
|
dockPanel.add(cardMoveToolBar, DockPanel.SOUTH);
|
||||||
|
|
||||||
|
|
||||||
|
dockPanel.setWidth("100%");
|
||||||
|
setWidget(dockPanel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initWindow() {
|
||||||
|
GWT.log(title);
|
||||||
|
setModal(true);
|
||||||
|
setGlassEnabled(true);
|
||||||
|
setAnimationEnabled(true);
|
||||||
|
setText(title);
|
||||||
|
this.originalTitle = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void addListener(WizardListener listener) {
|
||||||
|
listeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeListener(WizardListener listener) {
|
||||||
|
listeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows the next available card.
|
||||||
|
*/
|
||||||
|
public void nextCard() {
|
||||||
|
|
||||||
|
int index=deckPanel.getVisibleWidget();
|
||||||
|
Widget activeItem =deckPanel.getWidget(index);
|
||||||
|
|
||||||
|
if (activeItem instanceof WizardCard)
|
||||||
|
((WizardCard) activeItem).dispose();
|
||||||
|
|
||||||
|
int cardPos = cardStack.indexOf(activeItem);
|
||||||
|
|
||||||
|
// NEXT ->
|
||||||
|
|
||||||
|
nextButton.setEnabled(true);
|
||||||
|
backButton.setEnabled(true);
|
||||||
|
|
||||||
|
int newPos = cardPos + 1;
|
||||||
|
|
||||||
|
if (newPos == 0) {
|
||||||
|
// we are moving forward from the first card
|
||||||
|
backButton.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
nextButtonAction = null;
|
||||||
|
previousButtonAction = null;
|
||||||
|
GWT.log("cardStack size:" + cardStack.size());
|
||||||
|
WizardCard card = cardStack.get(newPos);
|
||||||
|
deckPanel.add(card);
|
||||||
|
int showIndex=deckPanel.getWidgetIndex(card);
|
||||||
|
deckPanel.showWidget(showIndex);
|
||||||
|
|
||||||
|
if (card instanceof WizardCard)
|
||||||
|
((WizardCard) card).setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows the previous available card.
|
||||||
|
*/
|
||||||
|
public void previousCard() {
|
||||||
|
int index=deckPanel.getVisibleWidget();
|
||||||
|
Widget activeItem =deckPanel.getWidget(index);
|
||||||
|
|
||||||
|
if (activeItem instanceof WizardCard)
|
||||||
|
((WizardCard) activeItem).dispose();
|
||||||
|
|
||||||
|
int cardPos = cardStack.indexOf(activeItem);
|
||||||
|
|
||||||
|
// BACK <-
|
||||||
|
|
||||||
|
nextButton.setEnabled(true);
|
||||||
|
backButton.setEnabled(true);
|
||||||
|
|
||||||
|
int newPos = cardPos - 1;
|
||||||
|
|
||||||
|
if (newPos == 0) {
|
||||||
|
backButton.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
nextButtonAction = null;
|
||||||
|
previousButtonAction = null;
|
||||||
|
|
||||||
|
WizardCard card = cardStack.get(newPos);
|
||||||
|
deckPanel.add(card);
|
||||||
|
int showIndex=deckPanel.getWidgetIndex(card);
|
||||||
|
deckPanel.showWidget(showIndex);
|
||||||
|
|
||||||
|
if (card instanceof WizardCard)
|
||||||
|
((WizardCard) card).setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of available cards.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getCardStackSize() {
|
||||||
|
return cardStack.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current active card.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getCurrentCard() {
|
||||||
|
int index=deckPanel.getVisibleWidget();
|
||||||
|
Widget activeItem =deckPanel.getWidget(index);
|
||||||
|
return cardStack.indexOf(activeItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkBeforeClose() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close(boolean check) {
|
||||||
|
checkBeforeClose = check;
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the label of next button to "Finish" value and add a close command
|
||||||
|
* to it.
|
||||||
|
*/
|
||||||
|
public void setNextButtonToFinish() {
|
||||||
|
nextButton.setText(msgs.buttonFinishLabel());
|
||||||
|
//nextButton.setIcon(GCResources.INSTANCE.wizardGo());
|
||||||
|
//nextButton.setIconAlign(IconAlign.RIGHT);
|
||||||
|
nextButtonAction = new Command() {
|
||||||
|
|
||||||
|
public void execute() {
|
||||||
|
close(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the command for the next button.
|
||||||
|
*
|
||||||
|
* @param command
|
||||||
|
* the command to execute.
|
||||||
|
*/
|
||||||
|
public void setNextButtonCommand(Command command) {
|
||||||
|
nextButtonAction = command;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the command for the previous button.
|
||||||
|
*
|
||||||
|
* @param command
|
||||||
|
* the command to execute.
|
||||||
|
*/
|
||||||
|
public void setPreviousButtonCommand(Command command) {
|
||||||
|
previousButtonAction = command;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
super.show();
|
||||||
|
|
||||||
|
int index=deckPanel.getVisibleWidget();
|
||||||
|
GWT.log("Visible widget: "+index);
|
||||||
|
Widget activeItem;
|
||||||
|
if(index==-1){
|
||||||
|
if(deckPanel.getWidgetCount()>0){
|
||||||
|
deckPanel.showWidget(0);
|
||||||
|
activeItem=deckPanel.getWidget(0);
|
||||||
|
if (activeItem instanceof WizardCard)
|
||||||
|
((WizardCard) activeItem).setup();
|
||||||
|
backButton.setEnabled(false);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
backButton.setEnabled(false);
|
||||||
|
nextButton.setEnabled(false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
deckPanel.showWidget(index);
|
||||||
|
activeItem=deckPanel.getWidget(index);
|
||||||
|
if (activeItem instanceof WizardCard)
|
||||||
|
((WizardCard) activeItem).setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the card list.
|
||||||
|
*
|
||||||
|
* @param cards
|
||||||
|
*/
|
||||||
|
public void setCards(ArrayList<WizardCard> cards) {
|
||||||
|
for (WizardCard card : cards) {
|
||||||
|
addCard(card);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a card to this wizard.
|
||||||
|
*
|
||||||
|
* @param card
|
||||||
|
* the card to add.
|
||||||
|
*/
|
||||||
|
public void addCard(WizardCard card) {
|
||||||
|
card.setWizardWindow(this);
|
||||||
|
|
||||||
|
if(deckPanel.getVisibleWidget()>-1){
|
||||||
|
int index=deckPanel.getVisibleWidget();
|
||||||
|
deckPanel.remove(index);
|
||||||
|
}
|
||||||
|
deckPanel.add(card);
|
||||||
|
cardStack.add(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a card to this wizard.
|
||||||
|
*
|
||||||
|
* @param card
|
||||||
|
* the card to add.
|
||||||
|
*/
|
||||||
|
public void removeCard(WizardCard card) {
|
||||||
|
deckPanel.remove(card);
|
||||||
|
cardStack.remove(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the next button on the wizard.
|
||||||
|
*
|
||||||
|
* @param enable
|
||||||
|
* <code>true</code> to enable the next button,
|
||||||
|
* <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public void setEnableNextButton(boolean enable) {
|
||||||
|
nextButton.setEnabled(enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the back button on the wizard.
|
||||||
|
*
|
||||||
|
* @param enable
|
||||||
|
* <code>true</code> to enable the back button,
|
||||||
|
* <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public void setEnableBackButton(boolean enable) {
|
||||||
|
backButton.setEnabled(enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the next button label.
|
||||||
|
*
|
||||||
|
* @param text
|
||||||
|
* the button label.
|
||||||
|
*/
|
||||||
|
protected void setNextButtonText(String text) {
|
||||||
|
nextButton.setText(text);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the back button label.
|
||||||
|
*
|
||||||
|
* @param text
|
||||||
|
* the button label.
|
||||||
|
*/
|
||||||
|
protected void setBackButtonText(String text) {
|
||||||
|
backButton.setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets visible next button.
|
||||||
|
*
|
||||||
|
* @param visible
|
||||||
|
*/
|
||||||
|
protected void setNextButtonVisible(boolean visible) {
|
||||||
|
nextButton.setVisible(visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets visible back button.
|
||||||
|
*
|
||||||
|
* @param visible
|
||||||
|
*/
|
||||||
|
protected void setBackButtonVisible(boolean visible) {
|
||||||
|
backButton.setVisible(visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a listener to the next button.
|
||||||
|
*
|
||||||
|
* @param listener
|
||||||
|
* the listener to add.
|
||||||
|
*/
|
||||||
|
protected void addNextButtonListener(ClickHandler listener) {
|
||||||
|
nextButton.addClickHandler(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the originalTitle
|
||||||
|
*/
|
||||||
|
public String getOriginalTitle() {
|
||||||
|
return originalTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the card list.
|
||||||
|
*
|
||||||
|
* @return teh card list.
|
||||||
|
*/
|
||||||
|
public ArrayList<WizardCard> getCardStack() {
|
||||||
|
return cardStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showErrorAndHide(final String title, final String message,
|
||||||
|
final String details, final Throwable throwable) {
|
||||||
|
GWTMessages.alert(title, message + " " + details,
|
||||||
|
new Callback<Void, Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Void reason) {
|
||||||
|
hide();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Void result) {
|
||||||
|
hide();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -4,10 +4,9 @@
|
||||||
<inherits name="com.google.gwt.http.HTTP" />
|
<inherits name="com.google.gwt.http.HTTP" />
|
||||||
|
|
||||||
<inherits name='com.google.gwt.user.theme.clean.Clean' />
|
<inherits name='com.google.gwt.user.theme.clean.Clean' />
|
||||||
|
|
||||||
<!-- <inherits name="com.google.gwt.logging.Logging" /> -->
|
|
||||||
<!-- <inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" /> -->
|
<!-- <inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" /> -->
|
||||||
<inherits name="com.google.gwt.logging.Logging" />
|
<!-- <inherits name="com.google.gwt.logging.Logging" /> -->
|
||||||
|
|
||||||
|
|
||||||
<!-- Debug CSS style -->
|
<!-- Debug CSS style -->
|
||||||
|
@ -20,16 +19,28 @@
|
||||||
<inherits name='org.gcube.portlets.widgets.sessionchecker.SessionChecker' />
|
<inherits name='org.gcube.portlets.widgets.sessionchecker.SessionChecker' />
|
||||||
<!-- <inherits name="org.gcube.portlets.user.csvimportwizard.ws.CSVImportWizardWorkspace"
|
<!-- <inherits name="org.gcube.portlets.user.csvimportwizard.ws.CSVImportWizardWorkspace"
|
||||||
/> -->
|
/> -->
|
||||||
|
|
||||||
<entry-point
|
<entry-point
|
||||||
class='org.gcube.portlets.widgets.githubconnector.client.GitHubConnectorManager' />
|
class='org.gcube.portlets.widgets.githubconnector.client.GitHubConnectorManager' />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<set-property name="gwt.logging.enabled" value="TRUE" />
|
||||||
<set-property name="gwt.logging.logLevel" value="SEVERE" />
|
<set-property name="gwt.logging.logLevel" value="SEVERE" />
|
||||||
<set-property name="gwt.logging.enabled" value="TRUE" />
|
|
||||||
<set-property name="gwt.logging.consoleHandler" value="ENABLED" />
|
<set-property name="gwt.logging.consoleHandler" 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_ConsoleLogger" value="DISABLED" />
|
||||||
|
<set-property name="log_DivLogger" value="DISABLED" />
|
||||||
|
<set-property name="log_GWTLogger" value="DISABLED" />
|
||||||
|
<set-property name="log_SystemLogger" value="DISABLED" /> -->
|
||||||
|
|
||||||
<source path='client' />
|
<source path='client' />
|
||||||
<source path='shared' />
|
<source path='shared' />
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.gcube.portlets.widgets.githubconnector.server;
|
package org.gcube.portlets.widgets.githubconnector.server;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
@ -8,8 +8,10 @@ import javax.servlet.http.HttpSession;
|
||||||
import org.gcube.application.framework.accesslogger.library.impl.AccessLogger;
|
import org.gcube.application.framework.accesslogger.library.impl.AccessLogger;
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
import org.gcube.application.framework.core.session.ASLSession;
|
||||||
import org.gcube.portlets.widgets.githubconnector.client.rpc.GitHubConnectorService;
|
import org.gcube.portlets.widgets.githubconnector.client.rpc.GitHubConnectorService;
|
||||||
|
import org.gcube.portlets.widgets.githubconnector.server.git.GitConnectorService;
|
||||||
import org.gcube.portlets.widgets.githubconnector.shared.exception.ServiceException;
|
import org.gcube.portlets.widgets.githubconnector.shared.exception.ServiceException;
|
||||||
import org.gcube.portlets.widgets.githubconnector.shared.git.GitHubRepository;
|
import org.gcube.portlets.widgets.githubconnector.shared.git.GitHubRepository;
|
||||||
|
import org.gcube.portlets.widgets.githubconnector.shared.git.credential.GitHubCredential;
|
||||||
import org.gcube.portlets.widgets.githubconnector.shared.session.UserInfo;
|
import org.gcube.portlets.widgets.githubconnector.shared.session.UserInfo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -43,6 +45,7 @@ public class GitHubConnectorServiceImpl extends RemoteServiceServlet implements
|
||||||
try {
|
try {
|
||||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||||
|
logger.debug("hello()");
|
||||||
UserInfo userInfo = new UserInfo(aslSession.getUsername(),
|
UserInfo userInfo = new UserInfo(aslSession.getUsername(),
|
||||||
aslSession.getGroupId(), aslSession.getGroupName(),
|
aslSession.getGroupId(), aslSession.getGroupName(),
|
||||||
aslSession.getScope(), aslSession.getScopeName(),
|
aslSession.getScope(), aslSession.getScopeName(),
|
||||||
|
@ -62,10 +65,22 @@ public class GitHubConnectorServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GitHubRepository> getRepositories(String owner)
|
public ArrayList<GitHubRepository> getRepositories(String repositoryOwner, GitHubCredential gitHubCredential)
|
||||||
throws ServiceException {
|
throws ServiceException {
|
||||||
|
try {
|
||||||
return null;
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
|
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||||
|
logger.debug("getRepository(): "+gitHubCredential);
|
||||||
|
GitConnectorService gitConnectorService=new GitConnectorService(aslSession.getUsername(), gitHubCredential);
|
||||||
|
return gitConnectorService.getRepositories(repositoryOwner);
|
||||||
|
} catch (ServiceException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw e;
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error("Hello(): " + e.getLocalizedMessage(), e);
|
||||||
|
throw new ServiceException(e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,9 @@ import org.eclipse.egit.github.core.service.RepositoryService;
|
||||||
import org.gcube.portlets.widgets.githubconnector.server.storage.StorageUtil;
|
import org.gcube.portlets.widgets.githubconnector.server.storage.StorageUtil;
|
||||||
import org.gcube.portlets.widgets.githubconnector.shared.exception.ServiceException;
|
import org.gcube.portlets.widgets.githubconnector.shared.exception.ServiceException;
|
||||||
import org.gcube.portlets.widgets.githubconnector.shared.git.GitHubRepository;
|
import org.gcube.portlets.widgets.githubconnector.shared.git.GitHubRepository;
|
||||||
|
import org.gcube.portlets.widgets.githubconnector.shared.git.credential.GitHubCredential;
|
||||||
|
import org.gcube.portlets.widgets.githubconnector.shared.git.credential.GitHubCredentialLogin;
|
||||||
|
import org.gcube.portlets.widgets.githubconnector.shared.git.credential.GitHubCredentialOAuth2;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -31,31 +34,30 @@ public class GitConnectorService {
|
||||||
|
|
||||||
private GitHubClient gitHubClient;
|
private GitHubClient gitHubClient;
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
public GitConnectorService(String userName) {
|
|
||||||
this.userName = userName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param userGitHub
|
* @param userName
|
||||||
* @param passwordGitHub
|
* @param gitHubCredential
|
||||||
*/
|
*/
|
||||||
public GitConnectorService(String userName, String userGitHub,
|
public GitConnectorService(String userName, GitHubCredential gitHubCredential) {
|
||||||
String passwordGitHub) {
|
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
gitHubClient = new GitHubClient();
|
if(gitHubCredential!=null&& gitHubCredential.getType()!=null){
|
||||||
gitHubClient.setCredentials(userGitHub, passwordGitHub);
|
if(gitHubCredential instanceof GitHubCredentialLogin){
|
||||||
}
|
GitHubCredentialLogin gitHubCredentialLogin=(GitHubCredentialLogin) gitHubCredential;
|
||||||
|
gitHubClient = new GitHubClient();
|
||||||
/**
|
gitHubClient.setCredentials(gitHubCredentialLogin.getUser()
|
||||||
*
|
,gitHubCredentialLogin.getPassword());
|
||||||
* @param oauth2Token
|
} else {
|
||||||
*/
|
if(gitHubCredential instanceof GitHubCredentialOAuth2){
|
||||||
public GitConnectorService(String userName, String oauth2Token) {
|
GitHubCredentialOAuth2 gitHubCredentialOAuth2=(GitHubCredentialOAuth2) gitHubCredential;
|
||||||
this.userName = userName;
|
gitHubClient = new GitHubClient();
|
||||||
gitHubClient = new GitHubClient();
|
gitHubClient.setOAuth2Token(gitHubCredentialOAuth2.getToken());
|
||||||
gitHubClient.setOAuth2Token(oauth2Token);
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<GitHubRepository> getRepositories(String repositoryOwner)
|
public ArrayList<GitHubRepository> getRepositories(String repositoryOwner)
|
||||||
|
|
|
@ -13,6 +13,12 @@ public class GitHubRepositoryBuilder {
|
||||||
private static Logger logger = Logger
|
private static Logger logger = Logger
|
||||||
.getLogger(GitHubRepositoryBuilder.class);
|
.getLogger(GitHubRepositoryBuilder.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param repository
|
||||||
|
* @return
|
||||||
|
* @throws ServiceException
|
||||||
|
*/
|
||||||
public static GitHubRepository build(Repository repository)
|
public static GitHubRepository build(Repository repository)
|
||||||
throws ServiceException {
|
throws ServiceException {
|
||||||
try {
|
try {
|
||||||
|
@ -52,6 +58,12 @@ public class GitHubRepositoryBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param repositories
|
||||||
|
* @return
|
||||||
|
* @throws ServiceException
|
||||||
|
*/
|
||||||
public static ArrayList<GitHubRepository> build(
|
public static ArrayList<GitHubRepository> build(
|
||||||
List<Repository> repositories) throws ServiceException {
|
List<Repository> repositories) throws ServiceException {
|
||||||
if (repositories != null) {
|
if (repositories != null) {
|
||||||
|
|
|
@ -3,6 +3,12 @@ package org.gcube.portlets.widgets.githubconnector.shared.git;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Giancarlo Panichi
|
||||||
|
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class GitHubRepository implements Serializable {
|
public class GitHubRepository implements Serializable {
|
||||||
private static final long serialVersionUID = 3024419362503115243L;
|
private static final long serialVersionUID = 3024419362503115243L;
|
||||||
private long id;
|
private long id;
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package org.gcube.portlets.widgets.githubconnector.shared.git.credential;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Giancarlo Panichi email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GitHubCredential implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 6198756446799134610L;
|
||||||
|
private GitHubCredentialType type;
|
||||||
|
|
||||||
|
public GitHubCredential() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GitHubCredential(GitHubCredentialType type) {
|
||||||
|
super();
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GitHubCredentialType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GitHubCredential [type=" + type + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.gcube.portlets.widgets.githubconnector.shared.git.credential;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Giancarlo Panichi
|
||||||
|
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GitHubCredentialAnonymous extends GitHubCredential {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 6967297424938062981L;
|
||||||
|
|
||||||
|
public GitHubCredentialAnonymous() {
|
||||||
|
super(GitHubCredentialType.Anonymous);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GitHubCredentialAnonymous []";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package org.gcube.portlets.widgets.githubconnector.shared.git.credential;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Giancarlo Panichi email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GitHubCredentialLogin extends GitHubCredential {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 6967297424938062981L;
|
||||||
|
private String user;
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
public GitHubCredentialLogin() {
|
||||||
|
super(GitHubCredentialType.Login);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GitHubCredentialLogin(String user, String password) {
|
||||||
|
super(GitHubCredentialType.Login);
|
||||||
|
this.user = user;
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(String user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GitHubCredentialLogin [user=" + user + ", password=" + password
|
||||||
|
+ "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package org.gcube.portlets.widgets.githubconnector.shared.git.credential;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Giancarlo Panichi email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GitHubCredentialOAuth2 extends GitHubCredential {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 6967297424938062981L;
|
||||||
|
private String token;
|
||||||
|
|
||||||
|
public GitHubCredentialOAuth2() {
|
||||||
|
super(GitHubCredentialType.OAuth2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GitHubCredentialOAuth2(String token) {
|
||||||
|
super(GitHubCredentialType.OAuth2);
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToken() {
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToken(String token) {
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GitHubCredentialOAuth2 [token=" + token + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package org.gcube.portlets.widgets.githubconnector.shared.git.credential;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Giancarlo Panichi
|
||||||
|
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum GitHubCredentialType {
|
||||||
|
Anonymous("Anonymous"),
|
||||||
|
OAuth2("OAuth2"),
|
||||||
|
Login("Login");
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param text
|
||||||
|
*/
|
||||||
|
private GitHubCredentialType(final String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String id;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static GitHubCredentialType getFromId(String id) {
|
||||||
|
for (GitHubCredentialType type : values()) {
|
||||||
|
if (type.id.compareToIgnoreCase(id) == 0) {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,9 +5,9 @@
|
||||||
|
|
||||||
<inherits name='com.google.gwt.user.theme.clean.Clean' />
|
<inherits name='com.google.gwt.user.theme.clean.Clean' />
|
||||||
|
|
||||||
<!-- <inherits name="com.google.gwt.logging.Logging" /> -->
|
|
||||||
<!-- <inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" /> -->
|
<!-- <inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" /> -->
|
||||||
<inherits name="com.google.gwt.logging.Logging" />
|
<!-- <inherits name="com.google.gwt.logging.Logging" /> -->
|
||||||
|
|
||||||
|
|
||||||
<!-- Debug CSS style -->
|
<!-- Debug CSS style -->
|
||||||
|
@ -24,12 +24,23 @@
|
||||||
<entry-point
|
<entry-point
|
||||||
class='org.gcube.portlets.widgets.githubconnector.client.GitHubConnectorManager' />
|
class='org.gcube.portlets.widgets.githubconnector.client.GitHubConnectorManager' />
|
||||||
|
|
||||||
|
<!--
|
||||||
<set-property name="gwt.logging.logLevel" value="SEVERE" />
|
|
||||||
<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.consoleHandler" 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_ConsoleLogger" value="DISABLED" />
|
||||||
|
<set-property name="log_DivLogger" value="DISABLED" />
|
||||||
|
<set-property name="log_GWTLogger" value="DISABLED" />
|
||||||
|
<set-property name="log_SystemLogger" value="DISABLED" /> -->
|
||||||
|
|
||||||
<source path='client' />
|
<source path='client' />
|
||||||
<source path='shared' />
|
<source path='shared' />
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
|
|
||||||
<link type="text/css" rel="stylesheet" href="githubman/reset.css">
|
<!-- <link type="text/css" rel="stylesheet" href="githubman/reset.css"> -->
|
||||||
<link type="text/css" rel="stylesheet" href="GitHubConnector.css">
|
<link type="text/css" rel="stylesheet" href="GitHubConnector.css">
|
||||||
<link type="text/css" rel="stylesheet" href="gxt/css/gxt-all.css">
|
|
||||||
|
|
||||||
<title>Data Miner Manager</title>
|
<title>Data Miner Manager</title>
|
||||||
<script type="text/javascript" src="githubman/js/jquery-1.10.1.min.js"></script>
|
<script type="text/javascript" src="githubman/js/jquery-1.11.0.min.js"></script>
|
||||||
<script type="text/javascript" src="githubman/githubman.nocache.js"></script>
|
<script type="text/javascript" src="githubman/githubman.nocache.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
<%@page contentType="text/html"%>
|
<%@page contentType="text/html"%>
|
||||||
<%@page pageEncoding="UTF-8"%>
|
<%@page pageEncoding="UTF-8"%>
|
||||||
|
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- The module reference below is the link -->
|
<!-- The module reference below is the link -->
|
||||||
<!-- between html and your Web Toolkit module -->
|
<!-- between html and your Web Toolkit module -->
|
||||||
<link rel="stylesheet" href="<%= request.getContextPath()%>/githubman/reset.css" type="text/css"/>
|
<!-- <link rel="stylesheet" href="<%=request.getContextPath()%>/githubman/reset.css" type="text/css"/> -->
|
||||||
<link rel="stylesheet" href="<%= request.getContextPath()%>/GitHubConnector.css" type="text/css">
|
<link rel="stylesheet"
|
||||||
<link rel="stylesheet" href="<%= request.getContextPath()%>/gxt/css/gxt-all.css" type="text/css">
|
href="<%=request.getContextPath()%>/GitHubConnector.css"
|
||||||
<script src='<%=request.getContextPath()%>/githubman/js/jquery-1.10.1.min.js'></script>
|
type="text/css">
|
||||||
<script src='<%=request.getContextPath()%>/githubman/githubman.nocache.js'></script>
|
|
||||||
|
<script
|
||||||
|
src='<%=request.getContextPath()%>/githubman/js/jquery-1.11.0.min.js'></script>
|
||||||
|
<script
|
||||||
|
src='<%=request.getContextPath()%>/githubman/githubman.nocache.js'></script>
|
||||||
|
|
||||||
|
|
||||||
<div class="contentDiv" id="contentDiv"></div>
|
<div class="contentDiv" id="contentDiv"></div>
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.eclipse.egit.github.core.service.RepositoryService;
|
||||||
import org.gcube.portlets.widgets.githubconnector.server.git.GitConnectorService;
|
import org.gcube.portlets.widgets.githubconnector.server.git.GitConnectorService;
|
||||||
import org.gcube.portlets.widgets.githubconnector.shared.Constants;
|
import org.gcube.portlets.widgets.githubconnector.shared.Constants;
|
||||||
import org.gcube.portlets.widgets.githubconnector.shared.exception.ServiceException;
|
import org.gcube.portlets.widgets.githubconnector.shared.exception.ServiceException;
|
||||||
|
import org.gcube.portlets.widgets.githubconnector.shared.git.credential.GitHubCredentialAnonymous;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -28,9 +29,9 @@ import org.slf4j.LoggerFactory;
|
||||||
*/
|
*/
|
||||||
public class GitHubConnectorTest extends TestCase {
|
public class GitHubConnectorTest extends TestCase {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(GitHubConnectorTest.class);
|
private static Logger logger = LoggerFactory
|
||||||
|
.getLogger(GitHubConnectorTest.class);
|
||||||
|
|
||||||
|
|
||||||
public void testExecuteProcess() {
|
public void testExecuteProcess() {
|
||||||
if (Constants.TEST_ENABLE) {
|
if (Constants.TEST_ENABLE) {
|
||||||
executeProcess();
|
executeProcess();
|
||||||
|
@ -42,22 +43,24 @@ public class GitHubConnectorTest extends TestCase {
|
||||||
|
|
||||||
public void testGitHubConnectorService() {
|
public void testGitHubConnectorService() {
|
||||||
if (Constants.TEST_ENABLE) {
|
if (Constants.TEST_ENABLE) {
|
||||||
GitConnectorService gitConnectorService=new GitConnectorService(Constants.DEFAULT_USER);
|
GitConnectorService gitConnectorService = new GitConnectorService(
|
||||||
|
Constants.DEFAULT_USER, new GitHubCredentialAnonymous());
|
||||||
try {
|
try {
|
||||||
gitConnectorService.cloneRepository(Constants.DEFAULT_FOLDER_ID,"jonan", "jonan.github.io");
|
gitConnectorService
|
||||||
|
.cloneRepository(Constants.DEFAULT_FOLDER_ID, "jonan",
|
||||||
|
"jonan.github.io");
|
||||||
} catch (ServiceException e) {
|
} catch (ServiceException e) {
|
||||||
assertFalse(true);
|
assertFalse(true);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void executeProcess() {
|
private void executeProcess() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -79,9 +82,8 @@ public class GitHubConnectorTest extends TestCase {
|
||||||
RepositoryService service = new RepositoryService();
|
RepositoryService service = new RepositoryService();
|
||||||
Repository repo = service.getRepository("jonan", "jonan.github.io");
|
Repository repo = service.getRepository("jonan", "jonan.github.io");
|
||||||
|
|
||||||
logger.debug("Repository: [Name=" + repo.getName()
|
logger.debug("Repository: [Name=" + repo.getName() + ", Watcher="
|
||||||
+ ", Watcher=" + repo.getWatchers() + ", GitUrl="
|
+ repo.getWatchers() + ", GitUrl=" + repo.getGitUrl() + "]");
|
||||||
+ repo.getGitUrl() + "]");
|
|
||||||
MilestoneService milestoneService = new MilestoneService(client);
|
MilestoneService milestoneService = new MilestoneService(client);
|
||||||
List<Milestone> listMilestone = milestoneService.getMilestones(
|
List<Milestone> listMilestone = milestoneService.getMilestones(
|
||||||
repo, null);
|
repo, null);
|
||||||
|
@ -111,14 +113,14 @@ public class GitHubConnectorTest extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//DeployKeyService deployKeyService=new DeployKeyService(client);
|
// DeployKeyService deployKeyService=new DeployKeyService(client);
|
||||||
/*
|
/*
|
||||||
PullRequestService pullRequetService=new PullRequestService(client);
|
* PullRequestService pullRequetService=new
|
||||||
CommitService commitService=new CommitService(client);
|
* PullRequestService(client); CommitService commitService=new
|
||||||
RepositoryCommit repoCommit=new RepositoryCommit();
|
* CommitService(client); RepositoryCommit repoCommit=new
|
||||||
CommitFile commitFile=new CommitFile();
|
* RepositoryCommit(); CommitFile commitFile=new CommitFile();
|
||||||
*/
|
*/
|
||||||
logger.debug("---------------------------------------------");
|
logger.debug("---------------------------------------------");
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|