Fixed OnEsc error

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-wizard-widget@101670 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-11-21 11:11:36 +00:00 committed by Giancarlo Panichi
parent 2e902b3a79
commit de664ce16d
1 changed files with 39 additions and 27 deletions

View File

@ -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<WizardCard> cardStack = new ArrayList<WizardCard>();
protected TextButton backButton;
@ -68,11 +70,11 @@ public class WizardWindow extends Window {
protected ArrayList<WizardListener> 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().<Element> 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<Component,Void>() {
UtilsGXT3.alert(title, message, new Callback<Component, Void>() {
@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();