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
master
Giancarlo Panichi 8 years ago
parent ccd291d299
commit 233c381937

@ -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.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.Scheduler;
@ -73,15 +71,20 @@ public class GitHubConnectorManager implements EntryPoint {
//GitHubConnectorDialog dialog=new GitHubConnectorDialog();
//dialog.show();
/*
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);
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);
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.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;
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>
* @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);
public static final GCResources INSTANCE = GWT.create(GCResources.class);
@Source("Wizard.css")
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")
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();
@Source("tool-button-close_20.png")
ImageResource toolButtonClose20();
}

@ -1,43 +1,57 @@
@CHARSET "UTF-8";
.wizard-title {
.wizard-card-title {
padding: 5px;
font-weight: bold;
font-size: small;
background-color: #C3D9FF;
background-color: #f1f1f1;
}
.wizard-footer {
.wizard-card-footer {
padding: 5px;
font-weight: bold;
font-size: x-small;
text-align: left;
background-color: #CDEB8B
background-color: #f1f1f1;
}
.source-selection-hover:hover {
cursor: pointer;
.wizard-previous-button-text {
line-height: 24px;
vertical-align: middle;
}
.wizard-previous-button-icon {
vertical-align: middle;
float: left;
}
.wizard-next-button-text {
line-height: 24px;
vertical-align: middle;
}
.column-excluded {
background-color: #e6e0da !important;
color: #bfa698;
.wizard-next-button-icon {
vertical-align: middle;
float: right;
}
.importSelection-sources {
padding: 30px;
display: block;
margin-top: 5px;
.wizard-tool-button-text {
margin-left: -20px;
margin-top: 2px;
}
.importSelection-source {
padding-bottom: 20px;
.wizard-tool-button-text:hover {
margin-left: -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"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @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();
@ClassName("wizard-card-title")
public String getWizardCardTitle();
@ClassName("wizard-card-footer")
public String getWizardCardFooter();
@ClassName("wizard-previous-button-text")
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();
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 781 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 778 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 502 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 957 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 656 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 474 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 559 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 431 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.event.dom.client.ClickHandler;
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.Widget;
@ -22,7 +24,7 @@ import com.google.gwt.user.client.ui.Widget;
public class WizardCard extends SimplePanel {
private WizardWindow wizardWindow;
private DockPanel dockPanel;
protected GCResources res=GCResources.INSTANCE;
@ -45,6 +47,18 @@ public class WizardCard extends SimplePanel {
public WizardCard(String title, String footer) {
GWT.log(title);
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)
{
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 org.gcube.portlets.widgets.githubconnector.client.resource.GCResources;
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.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.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
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.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
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.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.FlowPanel;
import com.google.gwt.user.client.ui.Widget;
/**
*
* @author "Giancarlo Panichi" <a
@ -31,9 +39,13 @@ import com.google.gwt.user.client.ui.Widget;
*
*/
public class WizardWindow extends DialogBox {
private HandlerRegistration resizeHandlerRegistration;
protected boolean WIZARD_RESIZABLE = false;
protected boolean WIZARD_COLLAPSIBLE = true;
protected ArrayList<WizardListener> listeners;
protected EventBus eventBus;
protected String title;
protected ArrayList<WizardCard> cardStack = new ArrayList<WizardCard>();
@ -54,11 +66,7 @@ public class WizardWindow extends DialogBox {
protected DockPanel dockPanel;
protected ArrayList<WizardListener> listeners;
protected EventBus eventBus;
protected MenuBar cardMoveToolBar;
protected FlowPanel moveToolBar;
// protected FillToolItem fillSpacingCardMoveToolBar;
protected WizardMessages msgs;
@ -81,71 +89,89 @@ public class WizardWindow extends DialogBox {
this.title = title;
this.eventBus = eventBus;
this.msgs = GWT.create(WizardMessages.class);
initWindow();
initHandler();
addToolIcon();
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());
deckPanel = new DeckPanel();
backButton = new Button("<div><img class='"
+ GCResources.INSTANCE.wizardCSS()
.getWizardPreviousButtonIcon()
+ "' src='"
+ GCResources.INSTANCE.wizardPrevious24().getSafeUri()
.asString()
+ "'/>"
+ "<span class='"
+ GCResources.INSTANCE.wizardCSS()
.getWizardPreviousButtonText() + "'>"
+ msgs.buttonBackLabel() + "</span>" + "</div>");
backButton = new Button(msgs.buttonBackLabel());
// backButton.setIcon(GCResources.INSTANCE.wizardPrevious());
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();
else
previousCard();
SafeHtml backItem=new SafeHtmlBuilder().appendEscaped(
msgs.buttonBackLabel()).toSafeHtml();
}
});
cardMoveToolBar.addItem(backItem,menuCommandBack);
nextButton = new Button("<div><span class='"
+ GCResources.INSTANCE.wizardCSS().getWizardNextButtonText()
+ "'>" + msgs.buttonNextLabel() + "</span>" + "<img class='"
+ GCResources.INSTANCE.wizardCSS().getWizardNextButtonIcon()
+ "'" + " src='"
+ GCResources.INSTANCE.wizardNext24().getSafeUri().asString()
+ "'/></div>");
nextButton = new Button(msgs.buttonNextLabel());
// backButton.setIcon(GCResources.INSTANCE.wizardPrevious());
nextButton.setEnabled(false);
nextButton.setTabIndex(1002);
nextButton.getElement().getStyle().setFloat(Float.RIGHT);
nextButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if (nextButtonAction != null)
nextButtonAction.execute();
else
nextCard();
SafeHtml nextItem=new SafeHtmlBuilder().appendEscaped(
msgs.buttonNextLabel()).toSafeHtml();
}
});
cardMoveToolBar.addItem(nextItem,menuCommandNext);
moveToolBar = new FlowPanel();
moveToolBar.setWidth("100%");
moveToolBar.add(backButton);
moveToolBar.add(nextButton);
dockPanel = new DockPanel();
dockPanel.setSpacing(4);
dockPanel.add(deckPanel , DockPanel.CENTER);
dockPanel.add(cardMoveToolBar, DockPanel.SOUTH);
dockPanel.add(deckPanel, DockPanel.CENTER);
dockPanel.add(moveToolBar, DockPanel.SOUTH);
dockPanel.setWidth("100%");
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;
}
public void addListener(WizardListener listener) {
listeners.add(listener);
}
@ -172,8 +197,8 @@ public class WizardWindow extends DialogBox {
*/
public void nextCard() {
int index=deckPanel.getVisibleWidget();
Widget activeItem =deckPanel.getWidget(index);
int index = deckPanel.getVisibleWidget();
Widget activeItem = deckPanel.getWidget(index);
if (activeItem instanceof WizardCard)
((WizardCard) activeItem).dispose();
@ -197,9 +222,9 @@ public class WizardWindow extends DialogBox {
GWT.log("cardStack size:" + cardStack.size());
WizardCard card = cardStack.get(newPos);
deckPanel.add(card);
int showIndex=deckPanel.getWidgetIndex(card);
int showIndex = deckPanel.getWidgetIndex(card);
deckPanel.showWidget(showIndex);
if (card instanceof WizardCard)
((WizardCard) card).setup();
}
@ -208,9 +233,9 @@ public class WizardWindow extends DialogBox {
* Shows the previous available card.
*/
public void previousCard() {
int index=deckPanel.getVisibleWidget();
Widget activeItem =deckPanel.getWidget(index);
int index = deckPanel.getVisibleWidget();
Widget activeItem = deckPanel.getWidget(index);
if (activeItem instanceof WizardCard)
((WizardCard) activeItem).dispose();
@ -232,9 +257,9 @@ public class WizardWindow extends DialogBox {
WizardCard card = cardStack.get(newPos);
deckPanel.add(card);
int showIndex=deckPanel.getWidgetIndex(card);
int showIndex = deckPanel.getWidgetIndex(card);
deckPanel.showWidget(showIndex);
if (card instanceof WizardCard)
((WizardCard) card).setup();
}
@ -254,8 +279,8 @@ public class WizardWindow extends DialogBox {
* @return
*/
public int getCurrentCard() {
int index=deckPanel.getVisibleWidget();
Widget activeItem =deckPanel.getWidget(index);
int index = deckPanel.getVisibleWidget();
Widget activeItem = deckPanel.getWidget(index);
return cardStack.indexOf(activeItem);
}
@ -273,16 +298,22 @@ public class WizardWindow extends DialogBox {
* to it.
*/
public void setNextButtonToFinish() {
nextButton.setText(msgs.buttonFinishLabel());
//nextButton.setIcon(GCResources.INSTANCE.wizardGo());
//nextButton.setIconAlign(IconAlign.RIGHT);
nextButton = new Button("<div><span class='"
+ GCResources.INSTANCE.wizardCSS().getWizardNextButtonText()
+ "'>" + 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() {
public void execute() {
close(false);
}
};
}
/**
@ -311,32 +342,40 @@ public class WizardWindow extends DialogBox {
@Override
public void show() {
super.show();
int index=deckPanel.getVisibleWidget();
GWT.log("Visible widget: "+index);
int index = deckPanel.getVisibleWidget();
GWT.log("Visible widget: " + index);
Widget activeItem;
if(index==-1){
if(deckPanel.getWidgetCount()>0){
if (index == -1) {
if (deckPanel.getWidgetCount() > 0) {
deckPanel.showWidget(0);
activeItem=deckPanel.getWidget(0);
activeItem = deckPanel.getWidget(0);
if (activeItem instanceof WizardCard)
((WizardCard) activeItem).setup();
backButton.setEnabled(false);
center();
} else {
backButton.setEnabled(false);
nextButton.setEnabled(false);
}
} else {
deckPanel.showWidget(index);
activeItem=deckPanel.getWidget(index);
activeItem = deckPanel.getWidget(index);
if (activeItem instanceof WizardCard)
((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) {
card.setWizardWindow(this);
if(deckPanel.getVisibleWidget()>-1){
int index=deckPanel.getVisibleWidget();
if (deckPanel.getVisibleWidget() > -1) {
int index = deckPanel.getVisibleWidget();
deckPanel.remove(index);
}
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
}
}

Loading…
Cancel
Save