refs:3772: SAI - Create a github project importer
https://support.d4science.org/issues/3772 Added GitHubConnectorWizard git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/github-connector@129124 82a268e6-3cf1-43bd-a215-b396298e98cf
|
@ -0,0 +1,187 @@
|
||||||
|
package org.gcube.portlets.widgets.githubconnector.client;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.githubconnector.client.wizard.WizardCard;
|
||||||
|
import org.gcube.portlets.widgets.githubconnector.shared.git.credential.GitHubCredential;
|
||||||
|
import org.gcube.portlets.widgets.githubconnector.shared.git.credential.GitHubCredentialType;
|
||||||
|
|
||||||
|
import com.google.gwt.core.shared.GWT;
|
||||||
|
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||||
|
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||||
|
import com.google.gwt.user.client.Command;
|
||||||
|
import com.google.gwt.user.client.ui.DecoratorPanel;
|
||||||
|
import com.google.gwt.user.client.ui.FlexTable;
|
||||||
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||||
|
import com.google.gwt.user.client.ui.RadioButton;
|
||||||
|
import com.google.gwt.user.client.ui.SimplePanel;
|
||||||
|
import com.google.gwt.user.client.ui.TextBox;
|
||||||
|
|
||||||
|
public class GitHubConnectorCredentialCard extends WizardCard {
|
||||||
|
|
||||||
|
private GitHubCredential gitHubCredential;
|
||||||
|
private GitHubCredentialType selected;
|
||||||
|
private SimplePanel simplePanel;
|
||||||
|
private FlexTable layout;
|
||||||
|
private TextBox userName;
|
||||||
|
private TextBox password;
|
||||||
|
private TextBox token;
|
||||||
|
//private DecoratorPanel decPanel;
|
||||||
|
|
||||||
|
public GitHubConnectorCredentialCard() {
|
||||||
|
super("Credential", "Select the credentials to use");
|
||||||
|
selected = GitHubCredentialType.Anonymous;
|
||||||
|
|
||||||
|
simplePanel = new SimplePanel();
|
||||||
|
// Form
|
||||||
|
layout = new FlexTable();
|
||||||
|
layout.setCellSpacing(16);
|
||||||
|
|
||||||
|
userName = new TextBox();
|
||||||
|
password = new TextBox();
|
||||||
|
token = new TextBox();
|
||||||
|
|
||||||
|
// Add some standard form options
|
||||||
|
HorizontalPanel hPanel = new HorizontalPanel();
|
||||||
|
hPanel.setSpacing(10);
|
||||||
|
|
||||||
|
for (GitHubCredentialType type : GitHubCredentialType.values()) {
|
||||||
|
|
||||||
|
RadioButton radioButton = new RadioButton("credentialType",
|
||||||
|
type.getLabel());
|
||||||
|
radioButton.getElement().setAttribute("itemId", type.name());
|
||||||
|
radioButton.ensureDebugId("radioButton-credentialType-"
|
||||||
|
+ type.name());
|
||||||
|
radioButton
|
||||||
|
.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onValueChange(
|
||||||
|
ValueChangeEvent<Boolean> event) {
|
||||||
|
if (event.getValue()) {
|
||||||
|
RadioButton radioButton = (RadioButton) event
|
||||||
|
.getSource();
|
||||||
|
String selectedCredential = radioButton
|
||||||
|
.getElement().getAttribute("itemId");
|
||||||
|
GWT.log("Selected Credential: "
|
||||||
|
+ selectedCredential);
|
||||||
|
if (selectedCredential != null) {
|
||||||
|
selected = GitHubCredentialType
|
||||||
|
.valueOf(selectedCredential);
|
||||||
|
|
||||||
|
if (selected != null) {
|
||||||
|
switch (selected) {
|
||||||
|
case Anonymous:
|
||||||
|
GWT.log("Anonymous");
|
||||||
|
setAnonymous();
|
||||||
|
break;
|
||||||
|
case Login:
|
||||||
|
GWT.log("Login");
|
||||||
|
setLogin();
|
||||||
|
break;
|
||||||
|
case OAuth2:
|
||||||
|
GWT.log("OAuth2");
|
||||||
|
setOAuth2();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
GWT.log("OAuth2");
|
||||||
|
setAnonymous();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
selected = GitHubCredentialType.Anonymous;
|
||||||
|
setAnonymous();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (type.compareTo(GitHubCredentialType.Anonymous) == 0) {
|
||||||
|
radioButton.setValue(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
hPanel.add(radioButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
layout.setHTML(1, 0, "Type:");
|
||||||
|
layout.setWidget(1, 1, hPanel);
|
||||||
|
|
||||||
|
// Wrap the content in a DecoratorPanel
|
||||||
|
//decPanel = new DecoratorPanel();
|
||||||
|
//decPanel.setWidget(layout);
|
||||||
|
|
||||||
|
simplePanel.add(layout);
|
||||||
|
setContent(simplePanel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAnonymous() {
|
||||||
|
if (selected.compareTo(GitHubCredentialType.Anonymous) != 0) {
|
||||||
|
for (int i = 1; i <= layout.getRowCount(); i++) {
|
||||||
|
layout.removeRow(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setOAuth2() {
|
||||||
|
if (selected.compareTo(GitHubCredentialType.OAuth2) != 0) {
|
||||||
|
for (int i = 1; i <= layout.getRowCount(); i++) {
|
||||||
|
layout.removeRow(i);
|
||||||
|
}
|
||||||
|
layout.setHTML(2, 0, "Token:");
|
||||||
|
layout.add(token);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setLogin() {
|
||||||
|
if (selected.compareTo(GitHubCredentialType.Login) != 0) {
|
||||||
|
for (int i = 1; i <= layout.getRowCount(); i++) {
|
||||||
|
layout.removeRow(i);
|
||||||
|
}
|
||||||
|
layout.setHTML(2, 0, "User:");
|
||||||
|
layout.add(userName);
|
||||||
|
|
||||||
|
layout.setHTML(3, 0, "Password:");
|
||||||
|
layout.add(password);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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(false);
|
||||||
|
setBackButtonVisible(false);
|
||||||
|
setEnableNextButton(true);
|
||||||
|
setNextButtonVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,8 +2,6 @@ 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;
|
||||||
|
@ -73,15 +71,20 @@ public class GitHubConnectorManager implements EntryPoint {
|
||||||
//GitHubConnectorDialog dialog=new GitHubConnectorDialog();
|
//GitHubConnectorDialog dialog=new GitHubConnectorDialog();
|
||||||
//dialog.show();
|
//dialog.show();
|
||||||
|
|
||||||
|
/*
|
||||||
WizardWindow wizardWindow = new WizardWindow("TestWindow");
|
WizardWindow wizardWindow = new WizardWindow("TestWindow");
|
||||||
SimpleWizardCard simple1=new SimpleWizardCard("Test Title","Test Footer", "This is 1 card");
|
SimpleWizardCard simple1=new SimpleWizardCard("Test Title 1","Test Footer 1", "This is 1 card");
|
||||||
wizardWindow.addCard(simple1);
|
wizardWindow.addCard(simple1);
|
||||||
SimpleWizardCard simple2=new SimpleWizardCard("Test Title","Test Footer", "This is 2 card");
|
SimpleWizardCard simple2=new SimpleWizardCard("Test Title 2","Test Footer 2", "This is 2 card");
|
||||||
wizardWindow.addCard(simple2);
|
wizardWindow.addCard(simple2);
|
||||||
SimpleWizardCard simple3=new SimpleWizardCard("Test Title","Test Footer", "This is 3 card");
|
SimpleWizardCard simple3=new SimpleWizardCard("Test Title 3","Test Footer 3", "This is 3 card");
|
||||||
wizardWindow.addCard(simple3);
|
wizardWindow.addCard(simple3);
|
||||||
|
|
||||||
wizardWindow.show();
|
wizardWindow.show();
|
||||||
|
*/
|
||||||
|
|
||||||
|
GitHubConnectorWizard wizard=new GitHubConnectorWizard();
|
||||||
|
wizard.show();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package org.gcube.portlets.widgets.githubconnector.client;
|
||||||
|
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.githubconnector.client.wizard.WizardWindow;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Giancarlo Panichi email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GitHubConnectorWizard extends WizardWindow {
|
||||||
|
|
||||||
|
public GitHubConnectorWizard() {
|
||||||
|
super("GitHub Connector");
|
||||||
|
GWT.log("GitHubConnectorWizard");
|
||||||
|
create();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void create() {
|
||||||
|
/*ApplyTableRuleSession applyTableRuleSession = new ApplyTableRuleSession();
|
||||||
|
applyTableRuleSession.setTrId(trId);*/
|
||||||
|
|
||||||
|
GitHubConnectorCredentialCard CredentialCard = new GitHubConnectorCredentialCard();
|
||||||
|
addCard(CredentialCard);
|
||||||
|
CredentialCard.setup();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,51 +1,32 @@
|
||||||
package org.gcube.portlets.widgets.githubconnector.client.resource;
|
package org.gcube.portlets.widgets.githubconnector.client.resource;
|
||||||
|
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.resources.client.ClientBundle;
|
import com.google.gwt.resources.client.ClientBundle;
|
||||||
import com.google.gwt.resources.client.ImageResource;
|
import com.google.gwt.resources.client.ImageResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author "Giancarlo Panichi"
|
* @author "Giancarlo Panichi" <a
|
||||||
* <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 interface GCResources extends ClientBundle {
|
public interface GCResources extends ClientBundle {
|
||||||
|
|
||||||
public static final GCResources INSTANCE=GWT.create(GCResources.class);
|
public static final GCResources INSTANCE = GWT.create(GCResources.class);
|
||||||
|
|
||||||
@Source("Wizard.css")
|
@Source("Wizard.css")
|
||||||
WizardCSS wizardCSS();
|
WizardCSS wizardCSS();
|
||||||
|
|
||||||
|
@Source("wizard-next_24.png")
|
||||||
|
ImageResource wizardNext24();
|
||||||
|
|
||||||
|
@Source("wizard-previous_24.png")
|
||||||
|
ImageResource wizardPrevious24();
|
||||||
|
|
||||||
|
@Source("wizard-go_24.png")
|
||||||
|
ImageResource wizardGo24();
|
||||||
|
|
||||||
@Source("arrow-refresh.png")
|
@Source("tool-button-close_20.png")
|
||||||
ImageResource refresh();
|
ImageResource toolButtonClose20();
|
||||||
|
|
||||||
@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();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,43 +1,57 @@
|
||||||
@CHARSET "UTF-8";
|
@CHARSET "UTF-8";
|
||||||
|
|
||||||
|
.wizard-card-title {
|
||||||
.wizard-title {
|
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: small;
|
font-size: small;
|
||||||
background-color: #C3D9FF;
|
background-color: #f1f1f1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wizard-footer {
|
.wizard-card-footer {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: x-small;
|
font-size: x-small;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
background-color: #CDEB8B
|
background-color: #f1f1f1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.source-selection-hover:hover {
|
.wizard-previous-button-text {
|
||||||
cursor: pointer;
|
line-height: 24px;
|
||||||
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wizard-previous-button-icon {
|
||||||
|
vertical-align: middle;
|
||||||
.column-excluded {
|
float: left;
|
||||||
background-color: #e6e0da !important;
|
|
||||||
color: #bfa698;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.importSelection-sources {
|
.wizard-next-button-text {
|
||||||
padding: 30px;
|
line-height: 24px;
|
||||||
display: block;
|
vertical-align: middle;
|
||||||
margin-top: 5px;
|
}
|
||||||
|
|
||||||
|
.wizard-next-button-icon {
|
||||||
|
vertical-align: middle;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wizard-tool-button-text {
|
||||||
|
margin-left: -20px;
|
||||||
|
margin-top: 2px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
.wizard-tool-button-text:hover {
|
||||||
.importSelection-source {
|
margin-left: -20px;
|
||||||
padding-bottom: 20px;
|
margin-top: 0px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.wizard-tool-button-icon {
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wizard-tool-button-icon:hover {
|
||||||
|
height: 20px;
|
||||||
|
border: 1px solid #222;
|
||||||
|
}
|
|
@ -7,30 +7,34 @@ import com.google.gwt.resources.client.CssResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author "Giancarlo Panichi"
|
* @author "Giancarlo Panichi" <a
|
||||||
* <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 interface WizardCSS extends CssResource {
|
public interface WizardCSS extends CssResource {
|
||||||
|
|
||||||
@ClassName("wizard-title")
|
|
||||||
public String getWizardTitle();
|
|
||||||
|
|
||||||
@ClassName("wizard-footer")
|
@ClassName("wizard-card-title")
|
||||||
public String getWizardFooter();
|
public String getWizardCardTitle();
|
||||||
|
|
||||||
@ClassName("source-selection-hover")
|
|
||||||
public String getSourceSelectionHover();
|
|
||||||
|
|
||||||
@ClassName("column-excluded")
|
|
||||||
public String getColumnExcluded();
|
|
||||||
|
|
||||||
@ClassName("importSelection-sources")
|
@ClassName("wizard-card-footer")
|
||||||
public String getImportSelectionSources();
|
public String getWizardCardFooter();
|
||||||
|
|
||||||
@ClassName("importSelection-source")
|
@ClassName("wizard-previous-button-text")
|
||||||
public String getImportSelectionSource();
|
public String getWizardPreviousButtonText();
|
||||||
|
|
||||||
|
@ClassName("wizard-previous-button-icon")
|
||||||
|
public String getWizardPreviousButtonIcon();
|
||||||
|
|
||||||
|
@ClassName("wizard-next-button-text")
|
||||||
|
public String getWizardNextButtonText();
|
||||||
|
|
||||||
|
@ClassName("wizard-next-button-icon")
|
||||||
|
public String getWizardNextButtonIcon();
|
||||||
|
|
||||||
|
@ClassName("wizard-tool-button-text")
|
||||||
|
public String getWizardToolButtonText();
|
||||||
|
|
||||||
|
@ClassName("wizard-tool-button-icon")
|
||||||
|
public String getWizardToolButtonIcon();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Before Width: | Height: | Size: 781 B |
Before Width: | Height: | Size: 984 B |
Before Width: | Height: | Size: 572 B |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 701 B |
Before Width: | Height: | Size: 778 B |
Before Width: | Height: | Size: 771 B |
After Width: | Height: | Size: 809 B |
Before Width: | Height: | Size: 502 B |
After Width: | Height: | Size: 957 B |
Before Width: | Height: | Size: 656 B |
Before Width: | Height: | Size: 474 B |
After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 559 B |
Before Width: | Height: | Size: 431 B |
After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 573 B |
|
@ -10,6 +10,8 @@ import org.gcube.portlets.widgets.githubconnector.client.resource.GCResources;
|
||||||
import com.google.gwt.core.shared.GWT;
|
import com.google.gwt.core.shared.GWT;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.event.shared.EventBus;
|
import com.google.gwt.event.shared.EventBus;
|
||||||
|
import com.google.gwt.user.client.ui.DockPanel;
|
||||||
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
import com.google.gwt.user.client.ui.SimplePanel;
|
import com.google.gwt.user.client.ui.SimplePanel;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
@ -22,7 +24,7 @@ import com.google.gwt.user.client.ui.Widget;
|
||||||
public class WizardCard extends SimplePanel {
|
public class WizardCard extends SimplePanel {
|
||||||
|
|
||||||
private WizardWindow wizardWindow;
|
private WizardWindow wizardWindow;
|
||||||
|
private DockPanel dockPanel;
|
||||||
|
|
||||||
|
|
||||||
protected GCResources res=GCResources.INSTANCE;
|
protected GCResources res=GCResources.INSTANCE;
|
||||||
|
@ -45,6 +47,18 @@ public class WizardCard extends SimplePanel {
|
||||||
public WizardCard(String title, String footer) {
|
public WizardCard(String title, String footer) {
|
||||||
GWT.log(title);
|
GWT.log(title);
|
||||||
res.wizardCSS().ensureInjected();
|
res.wizardCSS().ensureInjected();
|
||||||
|
|
||||||
|
HTML t=new HTML(title);
|
||||||
|
t.setStyleName(res.wizardCSS().getWizardCardTitle());
|
||||||
|
|
||||||
|
HTML f=new HTML(footer);
|
||||||
|
f.setStyleName(res.wizardCSS().getWizardCardFooter());
|
||||||
|
|
||||||
|
dockPanel=new DockPanel();
|
||||||
|
dockPanel.setWidth("100%");
|
||||||
|
dockPanel.add(t, DockPanel.NORTH);
|
||||||
|
dockPanel.add(f, DockPanel.SOUTH);
|
||||||
|
setWidget(dockPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,7 +69,8 @@ public class WizardCard extends SimplePanel {
|
||||||
*/
|
*/
|
||||||
public void setContent(Widget content)
|
public void setContent(Widget content)
|
||||||
{
|
{
|
||||||
setWidget(content);
|
GWT.log("Card SetContent()");
|
||||||
|
dockPanel.add(content, DockPanel.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,25 +5,33 @@ package org.gcube.portlets.widgets.githubconnector.client.wizard;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.githubconnector.client.resource.GCResources;
|
||||||
import org.gcube.portlets.widgets.githubconnector.client.util.GWTMessages;
|
import org.gcube.portlets.widgets.githubconnector.client.util.GWTMessages;
|
||||||
|
|
||||||
import com.google.gwt.core.client.Callback;
|
import com.google.gwt.core.client.Callback;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
import com.google.gwt.dom.client.Element;
|
||||||
|
import com.google.gwt.dom.client.NativeEvent;
|
||||||
|
import com.google.gwt.dom.client.Node;
|
||||||
|
import com.google.gwt.dom.client.Style.Float;
|
||||||
|
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.event.logical.shared.ResizeEvent;
|
||||||
|
import com.google.gwt.event.logical.shared.ResizeHandler;
|
||||||
import com.google.gwt.event.shared.EventBus;
|
import com.google.gwt.event.shared.EventBus;
|
||||||
|
import com.google.gwt.event.shared.HandlerRegistration;
|
||||||
import com.google.gwt.event.shared.SimpleEventBus;
|
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.Command;
|
||||||
|
import com.google.gwt.user.client.Event;
|
||||||
|
import com.google.gwt.user.client.Event.NativePreviewEvent;
|
||||||
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.ui.Button;
|
import com.google.gwt.user.client.ui.Button;
|
||||||
import com.google.gwt.user.client.ui.DeckPanel;
|
import com.google.gwt.user.client.ui.DeckPanel;
|
||||||
import com.google.gwt.user.client.ui.DialogBox;
|
import com.google.gwt.user.client.ui.DialogBox;
|
||||||
import com.google.gwt.user.client.ui.DockPanel;
|
import com.google.gwt.user.client.ui.DockPanel;
|
||||||
import com.google.gwt.user.client.ui.MenuBar;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author "Giancarlo Panichi" <a
|
* @author "Giancarlo Panichi" <a
|
||||||
|
@ -31,9 +39,13 @@ import com.google.gwt.user.client.ui.Widget;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class WizardWindow extends DialogBox {
|
public class WizardWindow extends DialogBox {
|
||||||
|
|
||||||
|
private HandlerRegistration resizeHandlerRegistration;
|
||||||
|
|
||||||
protected boolean WIZARD_RESIZABLE = false;
|
protected boolean WIZARD_RESIZABLE = false;
|
||||||
protected boolean WIZARD_COLLAPSIBLE = true;
|
protected boolean WIZARD_COLLAPSIBLE = true;
|
||||||
|
protected ArrayList<WizardListener> listeners;
|
||||||
|
protected EventBus eventBus;
|
||||||
protected String title;
|
protected String title;
|
||||||
|
|
||||||
protected ArrayList<WizardCard> cardStack = new ArrayList<WizardCard>();
|
protected ArrayList<WizardCard> cardStack = new ArrayList<WizardCard>();
|
||||||
|
@ -54,11 +66,7 @@ public class WizardWindow extends DialogBox {
|
||||||
|
|
||||||
protected DockPanel dockPanel;
|
protected DockPanel dockPanel;
|
||||||
|
|
||||||
protected ArrayList<WizardListener> listeners;
|
protected FlowPanel moveToolBar;
|
||||||
|
|
||||||
protected EventBus eventBus;
|
|
||||||
|
|
||||||
protected MenuBar cardMoveToolBar;
|
|
||||||
|
|
||||||
// protected FillToolItem fillSpacingCardMoveToolBar;
|
// protected FillToolItem fillSpacingCardMoveToolBar;
|
||||||
protected WizardMessages msgs;
|
protected WizardMessages msgs;
|
||||||
|
@ -81,71 +89,89 @@ public class WizardWindow extends DialogBox {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
this.msgs = GWT.create(WizardMessages.class);
|
this.msgs = GWT.create(WizardMessages.class);
|
||||||
|
|
||||||
initWindow();
|
initWindow();
|
||||||
|
initHandler();
|
||||||
|
addToolIcon();
|
||||||
|
|
||||||
listeners = new ArrayList<WizardListener>();
|
listeners = new ArrayList<WizardListener>();
|
||||||
deckPanel=new DeckPanel();
|
deckPanel = new DeckPanel();
|
||||||
|
|
||||||
|
backButton = new Button("<div><img class='"
|
||||||
|
+ GCResources.INSTANCE.wizardCSS()
|
||||||
cardMoveToolBar = new MenuBar();
|
.getWizardPreviousButtonIcon()
|
||||||
|
+ "' src='"
|
||||||
// Create a command that will execute on menu item selection
|
+ GCResources.INSTANCE.wizardPrevious24().getSafeUri()
|
||||||
ScheduledCommand menuCommandBack = new ScheduledCommand() {
|
.asString()
|
||||||
|
+ "'/>"
|
||||||
public void execute() {
|
+ "<span class='"
|
||||||
if (previousButtonAction != null)
|
+ GCResources.INSTANCE.wizardCSS()
|
||||||
|
.getWizardPreviousButtonText() + "'>"
|
||||||
|
+ msgs.buttonBackLabel() + "</span>" + "</div>");
|
||||||
|
|
||||||
|
backButton.setEnabled(false);
|
||||||
|
backButton.setTabIndex(1001);
|
||||||
|
backButton.getElement().getStyle().setFloat(Float.LEFT);
|
||||||
|
backButton.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
if (previousButtonAction != null)
|
||||||
previousButtonAction.execute();
|
previousButtonAction.execute();
|
||||||
else
|
else
|
||||||
previousCard();
|
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(
|
nextButton = new Button("<div><span class='"
|
||||||
msgs.buttonBackLabel()).toSafeHtml();
|
+ GCResources.INSTANCE.wizardCSS().getWizardNextButtonText()
|
||||||
|
+ "'>" + msgs.buttonNextLabel() + "</span>" + "<img class='"
|
||||||
|
+ GCResources.INSTANCE.wizardCSS().getWizardNextButtonIcon()
|
||||||
|
+ "'" + " src='"
|
||||||
|
+ GCResources.INSTANCE.wizardNext24().getSafeUri().asString()
|
||||||
|
+ "'/></div>");
|
||||||
|
|
||||||
cardMoveToolBar.addItem(backItem,menuCommandBack);
|
|
||||||
|
|
||||||
nextButton = new Button(msgs.buttonNextLabel());
|
|
||||||
// backButton.setIcon(GCResources.INSTANCE.wizardPrevious());
|
|
||||||
nextButton.setEnabled(false);
|
nextButton.setEnabled(false);
|
||||||
nextButton.setTabIndex(1002);
|
nextButton.setTabIndex(1002);
|
||||||
|
nextButton.getElement().getStyle().setFloat(Float.RIGHT);
|
||||||
|
nextButton.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
SafeHtml nextItem=new SafeHtmlBuilder().appendEscaped(
|
@Override
|
||||||
msgs.buttonNextLabel()).toSafeHtml();
|
public void onClick(ClickEvent event) {
|
||||||
|
if (nextButtonAction != null)
|
||||||
|
nextButtonAction.execute();
|
||||||
|
else
|
||||||
|
nextCard();
|
||||||
|
|
||||||
cardMoveToolBar.addItem(nextItem,menuCommandNext);
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
moveToolBar = new FlowPanel();
|
||||||
|
moveToolBar.setWidth("100%");
|
||||||
|
moveToolBar.add(backButton);
|
||||||
|
moveToolBar.add(nextButton);
|
||||||
|
|
||||||
dockPanel = new DockPanel();
|
dockPanel = new DockPanel();
|
||||||
dockPanel.setSpacing(4);
|
dockPanel.setSpacing(4);
|
||||||
|
|
||||||
dockPanel.add(deckPanel , DockPanel.CENTER);
|
dockPanel.add(deckPanel, DockPanel.CENTER);
|
||||||
dockPanel.add(cardMoveToolBar, DockPanel.SOUTH);
|
dockPanel.add(moveToolBar, DockPanel.SOUTH);
|
||||||
|
|
||||||
|
|
||||||
dockPanel.setWidth("100%");
|
dockPanel.setWidth("100%");
|
||||||
setWidget(dockPanel);
|
setWidget(dockPanel);
|
||||||
|
center();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initHandler() {
|
||||||
|
resizeHandlerRegistration = Window
|
||||||
|
.addResizeHandler(new ResizeHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResize(ResizeEvent event) {
|
||||||
|
center();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +184,6 @@ public class WizardWindow extends DialogBox {
|
||||||
this.originalTitle = title;
|
this.originalTitle = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addListener(WizardListener listener) {
|
public void addListener(WizardListener listener) {
|
||||||
listeners.add(listener);
|
listeners.add(listener);
|
||||||
}
|
}
|
||||||
|
@ -172,8 +197,8 @@ public class WizardWindow extends DialogBox {
|
||||||
*/
|
*/
|
||||||
public void nextCard() {
|
public void nextCard() {
|
||||||
|
|
||||||
int index=deckPanel.getVisibleWidget();
|
int index = deckPanel.getVisibleWidget();
|
||||||
Widget activeItem =deckPanel.getWidget(index);
|
Widget activeItem = deckPanel.getWidget(index);
|
||||||
|
|
||||||
if (activeItem instanceof WizardCard)
|
if (activeItem instanceof WizardCard)
|
||||||
((WizardCard) activeItem).dispose();
|
((WizardCard) activeItem).dispose();
|
||||||
|
@ -197,9 +222,9 @@ public class WizardWindow extends DialogBox {
|
||||||
GWT.log("cardStack size:" + cardStack.size());
|
GWT.log("cardStack size:" + cardStack.size());
|
||||||
WizardCard card = cardStack.get(newPos);
|
WizardCard card = cardStack.get(newPos);
|
||||||
deckPanel.add(card);
|
deckPanel.add(card);
|
||||||
int showIndex=deckPanel.getWidgetIndex(card);
|
int showIndex = deckPanel.getWidgetIndex(card);
|
||||||
deckPanel.showWidget(showIndex);
|
deckPanel.showWidget(showIndex);
|
||||||
|
|
||||||
if (card instanceof WizardCard)
|
if (card instanceof WizardCard)
|
||||||
((WizardCard) card).setup();
|
((WizardCard) card).setup();
|
||||||
}
|
}
|
||||||
|
@ -208,9 +233,9 @@ public class WizardWindow extends DialogBox {
|
||||||
* Shows the previous available card.
|
* Shows the previous available card.
|
||||||
*/
|
*/
|
||||||
public void previousCard() {
|
public void previousCard() {
|
||||||
int index=deckPanel.getVisibleWidget();
|
int index = deckPanel.getVisibleWidget();
|
||||||
Widget activeItem =deckPanel.getWidget(index);
|
Widget activeItem = deckPanel.getWidget(index);
|
||||||
|
|
||||||
if (activeItem instanceof WizardCard)
|
if (activeItem instanceof WizardCard)
|
||||||
((WizardCard) activeItem).dispose();
|
((WizardCard) activeItem).dispose();
|
||||||
|
|
||||||
|
@ -232,9 +257,9 @@ public class WizardWindow extends DialogBox {
|
||||||
|
|
||||||
WizardCard card = cardStack.get(newPos);
|
WizardCard card = cardStack.get(newPos);
|
||||||
deckPanel.add(card);
|
deckPanel.add(card);
|
||||||
int showIndex=deckPanel.getWidgetIndex(card);
|
int showIndex = deckPanel.getWidgetIndex(card);
|
||||||
deckPanel.showWidget(showIndex);
|
deckPanel.showWidget(showIndex);
|
||||||
|
|
||||||
if (card instanceof WizardCard)
|
if (card instanceof WizardCard)
|
||||||
((WizardCard) card).setup();
|
((WizardCard) card).setup();
|
||||||
}
|
}
|
||||||
|
@ -254,8 +279,8 @@ public class WizardWindow extends DialogBox {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getCurrentCard() {
|
public int getCurrentCard() {
|
||||||
int index=deckPanel.getVisibleWidget();
|
int index = deckPanel.getVisibleWidget();
|
||||||
Widget activeItem =deckPanel.getWidget(index);
|
Widget activeItem = deckPanel.getWidget(index);
|
||||||
return cardStack.indexOf(activeItem);
|
return cardStack.indexOf(activeItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,16 +298,22 @@ public class WizardWindow extends DialogBox {
|
||||||
* to it.
|
* to it.
|
||||||
*/
|
*/
|
||||||
public void setNextButtonToFinish() {
|
public void setNextButtonToFinish() {
|
||||||
nextButton.setText(msgs.buttonFinishLabel());
|
nextButton = new Button("<div><span class='"
|
||||||
//nextButton.setIcon(GCResources.INSTANCE.wizardGo());
|
+ GCResources.INSTANCE.wizardCSS().getWizardNextButtonText()
|
||||||
//nextButton.setIconAlign(IconAlign.RIGHT);
|
+ "'>" + msgs.buttonFinishLabel() + "</span>" + "<img class='"
|
||||||
|
+ GCResources.INSTANCE.wizardCSS().getWizardNextButtonIcon()
|
||||||
|
+ "'" + " src='"
|
||||||
|
+ GCResources.INSTANCE.wizardGo24().getSafeUri().asString()
|
||||||
|
+ "'/></div>");
|
||||||
|
// nextButton.setIcon(GCResources.INSTANCE.wizardGo());
|
||||||
|
// nextButton.setIconAlign(IconAlign.RIGHT);
|
||||||
nextButtonAction = new Command() {
|
nextButtonAction = new Command() {
|
||||||
|
|
||||||
public void execute() {
|
public void execute() {
|
||||||
close(false);
|
close(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -311,32 +342,40 @@ public class WizardWindow extends DialogBox {
|
||||||
@Override
|
@Override
|
||||||
public void show() {
|
public void show() {
|
||||||
super.show();
|
super.show();
|
||||||
|
|
||||||
int index=deckPanel.getVisibleWidget();
|
int index = deckPanel.getVisibleWidget();
|
||||||
GWT.log("Visible widget: "+index);
|
GWT.log("Visible widget: " + index);
|
||||||
Widget activeItem;
|
Widget activeItem;
|
||||||
if(index==-1){
|
if (index == -1) {
|
||||||
if(deckPanel.getWidgetCount()>0){
|
if (deckPanel.getWidgetCount() > 0) {
|
||||||
deckPanel.showWidget(0);
|
deckPanel.showWidget(0);
|
||||||
activeItem=deckPanel.getWidget(0);
|
activeItem = deckPanel.getWidget(0);
|
||||||
if (activeItem instanceof WizardCard)
|
if (activeItem instanceof WizardCard)
|
||||||
((WizardCard) activeItem).setup();
|
((WizardCard) activeItem).setup();
|
||||||
backButton.setEnabled(false);
|
backButton.setEnabled(false);
|
||||||
|
center();
|
||||||
} else {
|
} else {
|
||||||
backButton.setEnabled(false);
|
backButton.setEnabled(false);
|
||||||
nextButton.setEnabled(false);
|
nextButton.setEnabled(false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
deckPanel.showWidget(index);
|
deckPanel.showWidget(index);
|
||||||
activeItem=deckPanel.getWidget(index);
|
activeItem = deckPanel.getWidget(index);
|
||||||
if (activeItem instanceof WizardCard)
|
if (activeItem instanceof WizardCard)
|
||||||
((WizardCard) activeItem).setup();
|
((WizardCard) activeItem).setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
if (resizeHandlerRegistration != null) {
|
||||||
|
resizeHandlerRegistration.removeHandler();
|
||||||
|
resizeHandlerRegistration = null;
|
||||||
|
}
|
||||||
|
super.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -359,8 +398,8 @@ public class WizardWindow extends DialogBox {
|
||||||
public void addCard(WizardCard card) {
|
public void addCard(WizardCard card) {
|
||||||
card.setWizardWindow(this);
|
card.setWizardWindow(this);
|
||||||
|
|
||||||
if(deckPanel.getVisibleWidget()>-1){
|
if (deckPanel.getVisibleWidget() > -1) {
|
||||||
int index=deckPanel.getVisibleWidget();
|
int index = deckPanel.getVisibleWidget();
|
||||||
deckPanel.remove(index);
|
deckPanel.remove(index);
|
||||||
}
|
}
|
||||||
deckPanel.add(card);
|
deckPanel.add(card);
|
||||||
|
@ -486,4 +525,45 @@ public class WizardWindow extends DialogBox {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Node closeEventTarget = null;
|
||||||
|
|
||||||
|
private void addToolIcon() {
|
||||||
|
|
||||||
|
// get the "dialogTopRight" class td
|
||||||
|
Element dialogTopRight = getCellElement(0, 2);
|
||||||
|
|
||||||
|
// close button image html
|
||||||
|
dialogTopRight.setInnerHTML("<div class='"
|
||||||
|
+ GCResources.INSTANCE.wizardCSS().getWizardToolButtonText()
|
||||||
|
+ "'>"
|
||||||
|
+ "<img src='"
|
||||||
|
+ GCResources.INSTANCE.toolButtonClose20().getSafeUri()
|
||||||
|
.asString() + "' class='"
|
||||||
|
+ GCResources.INSTANCE.wizardCSS().getWizardToolButtonIcon()
|
||||||
|
+ "' /></div>");
|
||||||
|
|
||||||
|
// set the event target
|
||||||
|
closeEventTarget = dialogTopRight.getChild(0).getChild(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPreviewNativeEvent(NativePreviewEvent event) {
|
||||||
|
NativeEvent nativeEvent = event.getNativeEvent();
|
||||||
|
|
||||||
|
if (!event.isCanceled() && (event.getTypeInt() == Event.ONCLICK)
|
||||||
|
&& isCloseEvent(nativeEvent)) {
|
||||||
|
this.hide();
|
||||||
|
}
|
||||||
|
super.onPreviewNativeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
// see if the click target is the close button
|
||||||
|
private boolean isCloseEvent(NativeEvent event) {
|
||||||
|
return event.getEventTarget().equals(closeEventTarget); // compares
|
||||||
|
// equality of
|
||||||
|
// the
|
||||||
|
// underlying
|
||||||
|
// DOM elements
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|