refs:3772: SAI - Create a github project importer
https://support.d4science.org/issues/3772 Added Wait Dialog git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/github-connector@129140 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a5cd17254d
commit
4e2bb216a7
|
@ -22,7 +22,6 @@
|
|||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>github-connector</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>github-connector</description>
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ public class GitHubConnectorCredentialCard extends WizardCard {
|
|||
// private DecoratorPanel decPanel;
|
||||
|
||||
public GitHubConnectorCredentialCard() {
|
||||
super("Credential", "Select the credentials to use");
|
||||
super("Credential", "Select the credentials to use[OAuth2 for big repository]");
|
||||
tabPanel = new TabLayoutPanel(2.5, Unit.EM);
|
||||
tabPanel.setAnimationDuration(1000);
|
||||
tabPanel.setAnimationVertical(true);
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
package org.gcube.portlets.widgets.githubconnector.client;
|
||||
|
||||
import com.google.gwt.core.shared.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.i18n.client.Constants;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.DecoratorPanel;
|
||||
import com.google.gwt.user.client.ui.DialogBox;
|
||||
import com.google.gwt.user.client.ui.DockPanel;
|
||||
import com.google.gwt.user.client.ui.FlexTable;
|
||||
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
|
||||
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
import com.google.gwt.user.client.ui.PushButton;
|
||||
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 GitHubConnectorDialog extends DialogBox implements ClickHandler {
|
||||
|
||||
public static interface GitHubConnectorDialogConstants extends Constants {
|
||||
|
||||
@DefaultStringValue("Owner:")
|
||||
String gitCDecoratorPanelFormOwner();
|
||||
|
||||
@DefaultStringValue("Name:")
|
||||
String gitCDecoratorPanelFormRepository();
|
||||
|
||||
@DefaultStringValue("Repository")
|
||||
String gitCDecoratorPanelFormTitle();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An instance of the constants.
|
||||
*/
|
||||
private final GitHubConnectorDialogConstants gitHubConnectorDialogConstants = GWT
|
||||
.create(GitHubConnectorDialogConstants.class);
|
||||
|
||||
public GitHubConnectorDialog() {
|
||||
setText("GitHub Connector");
|
||||
setGlassEnabled(true);
|
||||
setAnimationEnabled(true);
|
||||
|
||||
ClickHandler searchRepositoryClickHandler=new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
//TODO
|
||||
|
||||
}
|
||||
};
|
||||
PushButton searchRepository = new PushButton(new Image(), searchRepositoryClickHandler);
|
||||
|
||||
|
||||
// Form
|
||||
FlexTable layout = new FlexTable();
|
||||
layout.setCellSpacing(10);
|
||||
FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
|
||||
|
||||
// Add a title to the form
|
||||
layout.setHTML(0, 0,
|
||||
"<b>"+gitHubConnectorDialogConstants.gitCDecoratorPanelFormTitle()+"</b>");
|
||||
cellFormatter.setColSpan(0, 0, 3);
|
||||
cellFormatter.setHorizontalAlignment(0, 0,
|
||||
HasHorizontalAlignment.ALIGN_CENTER);
|
||||
|
||||
// Add some standard form options
|
||||
layout.setHTML(1, 0,
|
||||
gitHubConnectorDialogConstants.gitCDecoratorPanelFormOwner());
|
||||
layout.setWidget(1, 1, new TextBox());
|
||||
layout.setWidget(1, 2, searchRepository);
|
||||
|
||||
layout.setHTML(2, 0, gitHubConnectorDialogConstants
|
||||
.gitCDecoratorPanelFormRepository());
|
||||
layout.setWidget(2, 1, new TextBox());
|
||||
|
||||
// Wrap the content in a DecoratorPanel
|
||||
DecoratorPanel decPanel = new DecoratorPanel();
|
||||
decPanel.setWidget(layout);
|
||||
|
||||
|
||||
|
||||
Button closeButton = new Button("Close", this);
|
||||
|
||||
/*HTML msg = new HTML(
|
||||
"<center>A standard dialog box component.</center>", true);*/
|
||||
|
||||
DockPanel dock = new DockPanel();
|
||||
dock.setSpacing(4);
|
||||
|
||||
dock.add(closeButton, DockPanel.SOUTH);
|
||||
dock.add(decPanel, DockPanel.CENTER);
|
||||
//dock.add(new HTML("images/yourImage.jpg"), DockPanel.CENTER);
|
||||
|
||||
dock.setCellHorizontalAlignment(closeButton, DockPanel.ALIGN_CENTER);
|
||||
dock.setWidth("100%");
|
||||
setWidget(dock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
hide();
|
||||
}
|
||||
}
|
|
@ -9,8 +9,7 @@ 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.rpc.AsyncCallback;
|
||||
//import com.google.gwt.event.logical.shared.ResizeEvent;
|
||||
//import com.google.gwt.event.logical.shared.ResizeHandler;
|
||||
|
||||
|
||||
/**
|
||||
* Entry point classes define <code>onModuleLoad()</code>.
|
||||
|
@ -67,9 +66,6 @@ public class GitHubConnectorManager implements EntryPoint {
|
|||
|
||||
private void loadMainPanel() {
|
||||
GWT.log("GitHubConnectorManager");
|
||||
//TestController = new GitHubConnectorController();
|
||||
//GitHubConnectorDialog dialog=new GitHubConnectorDialog();
|
||||
//dialog.show();
|
||||
|
||||
/*
|
||||
WizardWindow wizardWindow = new WizardWindow("TestWindow");
|
||||
|
@ -83,10 +79,16 @@ public class GitHubConnectorManager implements EntryPoint {
|
|||
wizardWindow.show();
|
||||
*/
|
||||
|
||||
|
||||
GitHubConnectorWizard wizard=new GitHubConnectorWizard("0cfde9e2-a6f0-451f-a048-adbd42d7d57f");
|
||||
wizard.show();
|
||||
|
||||
|
||||
/*
|
||||
WaitDialog progressDialog=new WaitDialog();
|
||||
progressDialog.show();
|
||||
*/
|
||||
|
||||
}
|
||||
/*
|
||||
private void bind() {
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||
import org.gcube.portlets.widgets.githubconnector.client.resource.GCResources;
|
||||
import org.gcube.portlets.widgets.githubconnector.client.rpc.GitHubConnectorServiceAsync;
|
||||
import org.gcube.portlets.widgets.githubconnector.client.util.GWTMessages;
|
||||
import org.gcube.portlets.widgets.githubconnector.client.util.WaitDialog;
|
||||
import org.gcube.portlets.widgets.githubconnector.client.wizard.WizardCard;
|
||||
import org.gcube.portlets.widgets.githubconnector.shared.exception.ExpiredSessionServiceException;
|
||||
import org.gcube.portlets.widgets.githubconnector.shared.git.data.GitHubRepository;
|
||||
|
@ -87,6 +88,9 @@ public class GitHubConnectorRepositorySelectionCard extends WizardCard {
|
|||
if (repOwner == null || repOwner.isEmpty()) {
|
||||
GWTMessages.alert("Attention", "Enter a owner!");
|
||||
} else {
|
||||
final WaitDialog waitDialog=new WaitDialog();
|
||||
waitDialog.show();
|
||||
|
||||
final GitHubConnectorWizard wiz = (GitHubConnectorWizard) getWizardWindow();
|
||||
GitHubConnectorServiceAsync.INSTANCE.getRepositories(repOwner, wiz
|
||||
.getGitHubCloneSession().getGitHubCredential(),
|
||||
|
@ -94,6 +98,7 @@ public class GitHubConnectorRepositorySelectionCard extends WizardCard {
|
|||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
waitDialog.hide();
|
||||
GWT.log("Error retrieving repositories: "
|
||||
+ caught.getMessage());
|
||||
if (caught instanceof ExpiredSessionServiceException) {
|
||||
|
@ -112,6 +117,7 @@ public class GitHubConnectorRepositorySelectionCard extends WizardCard {
|
|||
@Override
|
||||
public void onSuccess(
|
||||
ArrayList<GitHubRepository> repositories) {
|
||||
waitDialog.hide();
|
||||
repositoryName.clear();
|
||||
for (GitHubRepository repository : repositories) {
|
||||
repositoryName.addItem(repository.getName());
|
||||
|
@ -175,11 +181,15 @@ public class GitHubConnectorRepositorySelectionCard extends WizardCard {
|
|||
}
|
||||
|
||||
private void callCloneForRepository() {
|
||||
final WaitDialog waitDialog=new WaitDialog();
|
||||
waitDialog.show();
|
||||
|
||||
final GitHubConnectorWizard wiz = (GitHubConnectorWizard) getWizardWindow();
|
||||
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) {
|
||||
|
@ -197,6 +207,7 @@ public class GitHubConnectorRepositorySelectionCard extends WizardCard {
|
|||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
waitDialog.hide();
|
||||
goNext();
|
||||
|
||||
}
|
||||
|
|
|
@ -67,3 +67,28 @@
|
|||
.card-panel-content {
|
||||
margin: 6px;
|
||||
}
|
||||
|
||||
|
||||
/* Progress */
|
||||
.progress-bar-container {
|
||||
width: 100%;
|
||||
height: 25px;
|
||||
position: relative;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
color: #fff;
|
||||
background-color: #a5a5a5;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
.progress-bar-text {
|
||||
text-align: center;
|
||||
color: #2d2d2d;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
|
|
@ -43,4 +43,13 @@ public interface WizardCSS extends CssResource {
|
|||
@ClassName("card-panel-content")
|
||||
public String getCardPanelContent();
|
||||
|
||||
@ClassName("progress-bar-container")
|
||||
public String getProgressBarContainer();
|
||||
|
||||
@ClassName("progress-bar")
|
||||
public String getProgressBar();
|
||||
|
||||
@ClassName("progress-bar-text")
|
||||
public String getProgressBarText();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
package org.gcube.portlets.widgets.githubconnector.client.util;
|
||||
|
||||
import com.google.gwt.core.client.Callback;
|
||||
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.ui.Button;
|
||||
import com.google.gwt.user.client.ui.DialogBox;
|
||||
import com.google.gwt.user.client.ui.DockPanel;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ProgressDialog extends DialogBox implements ClickHandler {
|
||||
private Callback<Void, Void> callback;
|
||||
protected HTML msg;
|
||||
protected double msgMinWidth=200;
|
||||
protected double msgMinHeight=30;
|
||||
|
||||
|
||||
public ProgressDialog(String title, String text) {
|
||||
init(title, text);
|
||||
}
|
||||
|
||||
public ProgressDialog(String title, String text, Callback<Void, Void> callback) {
|
||||
init(title, text);
|
||||
}
|
||||
|
||||
private void init(String title, String text) {
|
||||
setText(title);
|
||||
|
||||
|
||||
|
||||
Button closeButton = new Button("Close", this);
|
||||
msg = new HTML(text, true);
|
||||
msg.getElement().getStyle().setProperty("minWidth", msgMinWidth, Unit.PX);
|
||||
msg.getElement().getStyle().setProperty("minHeight",msgMinHeight, Unit.PX);
|
||||
|
||||
DockPanel dock = new DockPanel();
|
||||
dock.setSpacing(4);
|
||||
|
||||
|
||||
dock.add(closeButton, DockPanel.SOUTH);
|
||||
dock.add(msg, DockPanel.CENTER);
|
||||
|
||||
dock.setCellHorizontalAlignment(closeButton, DockPanel.ALIGN_CENTER);
|
||||
dock.setWidth("100%");
|
||||
setWidget(dock);
|
||||
center();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if(callback!=null){
|
||||
callback.onSuccess(null);
|
||||
}
|
||||
hide();
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
package org.gcube.portlets.widgets.githubconnector.client.util;
|
||||
|
||||
import org.gcube.portlets.widgets.githubconnector.client.resource.GCResources;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.logical.shared.ResizeEvent;
|
||||
import com.google.gwt.event.logical.shared.ResizeHandler;
|
||||
import com.google.gwt.event.shared.HandlerRegistration;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.ui.DialogBox;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class WaitDialog extends DialogBox {
|
||||
private HandlerRegistration resizeHandlerRegistration;
|
||||
private HTML msg;
|
||||
private String msgWidth = "200px";
|
||||
private String msgHeight = "25px";
|
||||
private Timer t;
|
||||
|
||||
public WaitDialog(){
|
||||
init("Please Wait", "Working...");
|
||||
}
|
||||
|
||||
public WaitDialog(String title, String text) {
|
||||
init(title, text);
|
||||
}
|
||||
|
||||
private void init(String title, String text) {
|
||||
GWT.log("WaitDialog:[title=" + title + ", text=" + text + "]");
|
||||
GCResources.INSTANCE.wizardCSS().ensureInjected();
|
||||
setModal(true);
|
||||
setGlassEnabled(true);
|
||||
initHandler();
|
||||
setText(title);
|
||||
|
||||
msg = new HTML("<div class='"
|
||||
+ GCResources.INSTANCE.wizardCSS().getProgressBarContainer()
|
||||
+ "'>" + "<div class='"
|
||||
+ GCResources.INSTANCE.wizardCSS().getProgressBar()
|
||||
+ "' style='width:50%'></div>" + "<div class='"
|
||||
+ GCResources.INSTANCE.wizardCSS().getProgressBarText() + "'>"
|
||||
+ text + "</div>" + "</div><br>");
|
||||
|
||||
msg.setWidth(msgWidth);
|
||||
msg.setHeight(msgHeight);
|
||||
|
||||
setWidget(msg);
|
||||
center();
|
||||
startTimer();
|
||||
}
|
||||
|
||||
private void initHandler() {
|
||||
resizeHandlerRegistration = Window
|
||||
.addResizeHandler(new ResizeHandler() {
|
||||
|
||||
@Override
|
||||
public void onResize(ResizeEvent event) {
|
||||
center();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void startTimer() {
|
||||
t = new Timer() {
|
||||
private int width = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (width > 100) {
|
||||
width = 0;
|
||||
}
|
||||
msg.getElement().getFirstChildElement().getFirstChildElement()
|
||||
.getStyle().setWidth(width, Unit.PCT);
|
||||
width += 10;
|
||||
}
|
||||
};
|
||||
|
||||
// Schedule the timer to run once in 200 millseconds.
|
||||
t.scheduleRepeating(400);
|
||||
|
||||
}
|
||||
|
||||
private void stopTimer() {
|
||||
t.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
stopTimer();
|
||||
if (resizeHandlerRegistration != null) {
|
||||
resizeHandlerRegistration.removeHandler();
|
||||
resizeHandlerRegistration = null;
|
||||
}
|
||||
super.hide();
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue