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-b396298e98cfmaster
parent
a5cd17254d
commit
4e2bb216a7
@ -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();
|
||||
}
|
||||
}
|
@ -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