diff --git a/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/WizardWindow.java b/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/WizardWindow.java index 93b1fcc..b1b9753 100644 --- a/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/WizardWindow.java +++ b/src/main/java/org/gcube/portlets/user/td/wizardwidget/client/WizardWindow.java @@ -11,7 +11,10 @@ import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.Callback; +import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.user.client.Command; +import com.google.gwt.user.client.Element; +import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.EventBus; import com.google.web.bindery.event.shared.SimpleEventBus; @@ -42,11 +45,10 @@ public class WizardWindow extends Window { protected String WIZARDHEIGHT = "520px"; protected boolean WIZARRESIZABLE = false; protected boolean WIZARDCOLLAPSIBLE = true; - protected String BUTTONBACKLABEL="Back"; - protected String BUTTONNEXTLABEL="Next"; - protected String BUTTONFINISHLABEL="Finish"; - - + protected String BUTTONBACKLABEL = "Back"; + protected String BUTTONNEXTLABEL = "Next"; + protected String BUTTONFINISHLABEL = "Finish"; + protected ArrayList cardStack = new ArrayList(); protected TextButton backButton; @@ -68,11 +70,11 @@ public class WizardWindow extends Window { protected ArrayList listeners; protected EventBus eventBus; - - protected ToolBar cardMoveToolBar; - - protected FillToolItem fillSpacingCardMoveToolBar; + protected ToolBar cardMoveToolBar; + + protected FillToolItem fillSpacingCardMoveToolBar; + /** * Create a new Wizard Window with the specified title. * @@ -81,9 +83,9 @@ public class WizardWindow extends Window { */ public WizardWindow(String title) { this(title, new SimpleEventBus()); - + } - + public WizardWindow(String title, EventBus eventBus) { super(); this.eventBus = eventBus; @@ -111,13 +113,13 @@ public class WizardWindow extends Window { backButton = new TextButton(BUTTONBACKLABEL); backButton.setIcon(ResourceBundle.INSTANCE.wizardPrevious()); backButton.setIconAlign(IconAlign.LEFT); - + backButton.setEnabled(false); backButton.setTabIndex(1001); - cardMoveToolBar.add(backButton,new BoxLayoutData(new Margins(1))); - - fillSpacingCardMoveToolBar=new FillToolItem(); - + cardMoveToolBar.add(backButton, new BoxLayoutData(new Margins(1))); + + fillSpacingCardMoveToolBar = new FillToolItem(); + cardMoveToolBar.add(fillSpacingCardMoveToolBar); nextButton = new TextButton(BUTTONNEXTLABEL); @@ -131,7 +133,6 @@ public class WizardWindow extends Window { SelectHandler selectionHandler = new SelectHandler() { - public void onSelect(SelectEvent event) { TextButton button = (TextButton) event.getSource(); String btnID = button.getId(); @@ -159,7 +160,6 @@ public class WizardWindow extends Window { setWidget(container); } - /** * {@inheritDoc} */ @@ -169,7 +169,6 @@ public class WizardWindow extends Window { closeBtn.addSelectHandler(new SelectHandler() { - public void onSelect(SelectEvent event) { fireAborted(); hide(); @@ -178,6 +177,20 @@ public class WizardWindow extends Window { } + @Override + protected void onKeyPress(Event we) { + int keyCode = we.getKeyCode(); + + boolean t = getElement().isOrHasChild( + we.getEventTarget(). cast()); + boolean key = true; + if (key && super.isClosable() && super.isOnEsc() && keyCode == KeyCodes.KEY_ESCAPE && t) { + fireAborted(); + hide(); + } + + } + public void addListener(WizardListener listener) { listeners.add(listener); } @@ -452,37 +465,36 @@ public class WizardWindow extends Window { public void showErrorAndHide(final String title, final String message, final Throwable throwable) { - UtilsGXT3.alert(title, message, new Callback() { + UtilsGXT3.alert(title, message, new Callback() { @Override public void onFailure(Void reason) { hide(); fireFailed(title, message, throwable); - + } @Override public void onSuccess(Component result) { hide(); fireAborted(); - + } - + }); - + } public void fireCompleted(TRId id) { for (WizardListener listener : listeners) listener.completed(id); } - + public void firePutInBackground() { for (WizardListener listener : listeners) listener.putInBackground(); } - - + public void fireAborted() { for (WizardListener listener : listeners) listener.aborted();