[kune-commits] r1331 - in trunk/src/main/java/cc/kune: common/client/ui/dialogs core/client/notify/confirm
Vicente J. Ruiz Jurado
vjrj_ at ourproject.org
Fri Apr 29 15:16:38 CEST 2011
Author: vjrj_
Date: 2011-04-29 15:16:37 +0200 (Fri, 29 Apr 2011)
New Revision: 1331
Modified:
trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicDialog.java
trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicDialogView.java
trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicTopDialog.java
trunk/src/main/java/cc/kune/core/client/notify/confirm/UserConfirmPanel.java
Log:
Fix with dialog buttons refactorization
Modified: trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicDialog.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicDialog.java 2011-04-29 12:57:28 UTC (rev 1330)
+++ trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicDialog.java 2011-04-29 13:16:37 UTC (rev 1331)
@@ -31,7 +31,6 @@
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HasDirectionalText;
-import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.InsertPanel.ForIsWidget;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
@@ -81,11 +80,6 @@
}
@Override
- public HasText getFirstBtnText() {
- return firstBtn;
- }
-
- @Override
public ForIsWidget getInnerPanel() {
return vp;
}
@@ -96,11 +90,6 @@
}
@Override
- public HasText getSecondBtnText() {
- return secondBtn;
- }
-
- @Override
public HasDirectionalText getTitleText() {
return title;
}
@@ -114,6 +103,12 @@
}
@Override
+ public void setFirstBtnText(final String text) {
+ firstBtn.setText(text);
+ firstBtn.setVisible(TextUtils.notEmpty(text));
+ }
+
+ @Override
public void setFirstBtnTitle(final String title) {
firstBtn.setTitle(title);
}
@@ -132,6 +127,12 @@
}
@Override
+ public void setSecondBtnText(final String text) {
+ secondBtn.setText(text);
+ secondBtn.setVisible(TextUtils.notEmpty(text));
+ }
+
+ @Override
public void setSecondBtnTitle(final String title) {
secondBtn.setTitle(title);
}
Modified: trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicDialogView.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicDialogView.java 2011-04-29 12:57:28 UTC (rev 1330)
+++ trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicDialogView.java 2011-04-29 13:16:37 UTC (rev 1331)
@@ -21,31 +21,30 @@
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.HasDirectionalText;
-import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.InsertPanel.ForIsWidget;
public interface BasicDialogView {
- ForIsWidget getBottomPanel();
+ ForIsWidget getBottomPanel();
- HasClickHandlers getFirstBtn();
+ HasClickHandlers getFirstBtn();
- HasText getFirstBtnText();
+ ForIsWidget getInnerPanel();
- ForIsWidget getInnerPanel();
+ HasClickHandlers getSecondBtn();
- HasClickHandlers getSecondBtn();
+ HasDirectionalText getTitleText();
- HasText getSecondBtnText();
+ void setFirstBtnText(String text);
- HasDirectionalText getTitleText();
+ void setFirstBtnTitle(String title);
- void setFirstBtnTitle(String title);
+ void setFirstBtnVisible(boolean visible);
- void setFirstBtnVisible(boolean visible);
+ void setSecondBtnText(String text);
- void setSecondBtnTitle(String title);
+ void setSecondBtnTitle(String title);
- void setSecondBtnVisible(boolean visible);
+ void setSecondBtnVisible(boolean visible);
}
\ No newline at end of file
Modified: trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicTopDialog.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicTopDialog.java 2011-04-29 12:57:28 UTC (rev 1330)
+++ trunk/src/main/java/cc/kune/common/client/ui/dialogs/BasicTopDialog.java 2011-04-29 13:16:37 UTC (rev 1331)
@@ -28,139 +28,133 @@
public class BasicTopDialog extends BasicDialog {
- public static class Builder {
- private final boolean autohide;
- private boolean autoscroll = false;
- private final String dialogId;
- private String firstButtonId;
- private String firstButtonTitle;
- private String height = "70%";
- private String icon;
- private final boolean modal;
- private String sndButtonId;
- private String sndButtonTitle;
- private int tabIndexStart = 0;
- private String title;
- private String width = "400px";
+ public static class Builder {
+ private final boolean autohide;
+ private boolean autoscroll = false;
+ private final String dialogId;
+ private String firstButtonId;
+ private String firstButtonTitle;
+ private String height = "70%";
+ private String icon;
+ private final boolean modal;
+ private String sndButtonId;
+ private String sndButtonTitle;
+ private int tabIndexStart = 0;
+ private String title;
+ private String width = "400px";
- public Builder(final String dialogId, final boolean autohide, final boolean modal) {
- // Required params
- this.autohide = autohide;
- this.modal = modal;
- this.dialogId = dialogId;
- }
+ public Builder(final String dialogId, final boolean autohide, final boolean modal) {
+ // Required params
+ this.autohide = autohide;
+ this.modal = modal;
+ this.dialogId = dialogId;
+ }
- public Builder autoscroll(final boolean autoscroll) {
- // Not used for now
- this.autoscroll = autoscroll;
- return this;
- }
+ public Builder autoscroll(final boolean autoscroll) {
+ // Not used for now
+ this.autoscroll = autoscroll;
+ return this;
+ }
- public BasicTopDialog build() {
- return new BasicTopDialog(this);
- }
+ public BasicTopDialog build() {
+ return new BasicTopDialog(this);
+ }
- public Builder firstButtonId(final String firstButtonId) {
- this.firstButtonId = firstButtonId;
- return this;
- }
+ public Builder firstButtonId(final String firstButtonId) {
+ this.firstButtonId = firstButtonId;
+ return this;
+ }
- public Builder firstButtonTitle(final String firstButtonTitle) {
- this.firstButtonTitle = firstButtonTitle;
- return this;
- }
+ public Builder firstButtonTitle(final String firstButtonTitle) {
+ this.firstButtonTitle = firstButtonTitle;
+ return this;
+ }
- public Builder height(final int height) {
- this.height = String.valueOf(height);
- return this;
- }
+ public Builder height(final int height) {
+ this.height = String.valueOf(height);
+ return this;
+ }
- public Builder height(final String height) {
- this.height = height;
- return this;
- }
+ public Builder height(final String height) {
+ this.height = height;
+ return this;
+ }
- public Builder icon(final String icon) {
- this.icon = icon;
- return this;
- }
+ public Builder icon(final String icon) {
+ this.icon = icon;
+ return this;
+ }
- public Builder sndButtonId(final String sndButtonId) {
- this.sndButtonId = sndButtonId;
- return this;
- }
+ public Builder sndButtonId(final String sndButtonId) {
+ this.sndButtonId = sndButtonId;
+ return this;
+ }
- public Builder sndButtonTitle(final String sndButtonTitle) {
- this.sndButtonTitle = sndButtonTitle;
- return this;
- }
+ public Builder sndButtonTitle(final String sndButtonTitle) {
+ this.sndButtonTitle = sndButtonTitle;
+ return this;
+ }
- public Builder tabIndexStart(final int tabIndexStart) {
- this.tabIndexStart = tabIndexStart;
- return this;
- }
+ public Builder tabIndexStart(final int tabIndexStart) {
+ this.tabIndexStart = tabIndexStart;
+ return this;
+ }
- public Builder title(final String title) {
- this.title = title;
- return this;
- }
+ public Builder title(final String title) {
+ this.title = title;
+ return this;
+ }
- public Builder width(final int width) {
- this.width = String.valueOf(width);
- return this;
- }
+ public Builder width(final int width) {
+ this.width = String.valueOf(width);
+ return this;
+ }
- public Builder width(final String width) {
- this.width = width;
- return this;
- }
+ public Builder width(final String width) {
+ this.width = width;
+ return this;
}
+ }
- private final PopupTopPanel popup;
+ private final PopupTopPanel popup;
- private BasicTopDialog(final Builder builder) {
- popup = new PopupTopPanel(builder.autohide, builder.modal);
- popup.add(this);
- popup.ensureDebugId(builder.dialogId);
- super.getTitleText().setText(builder.title);
- if (TextUtils.notEmpty(builder.icon)) {
- super.setTitleIcon(builder.icon);
- }
- if (TextUtils.empty(builder.firstButtonTitle)) {
- super.setFirstBtnVisible(false);
- } else {
- super.getFirstBtnText().setText(builder.firstButtonTitle);
- if (TextUtils.notEmpty(builder.firstButtonId)) {
- super.setFirstBtnId(builder.firstButtonId);
- }
- super.setFirstBtnTabIndex(builder.tabIndexStart);
- }
- if (TextUtils.empty(builder.sndButtonTitle)) {
- super.setSecondBtnVisible(false);
- } else {
- super.getSecondBtnText().setText(builder.sndButtonTitle);
- if (TextUtils.notEmpty(builder.sndButtonId)) {
- super.setSecondBtnId(builder.sndButtonId);
- }
- super.setSecondBtnTabIndex(builder.tabIndexStart + 1);
- }
- super.setSize(builder.width, builder.height);
+ private BasicTopDialog(final Builder builder) {
+ popup = new PopupTopPanel(builder.autohide, builder.modal);
+ popup.add(this);
+ popup.ensureDebugId(builder.dialogId);
+ super.getTitleText().setText(builder.title);
+ if (TextUtils.notEmpty(builder.icon)) {
+ super.setTitleIcon(builder.icon);
}
+ super.setFirstBtnText(builder.firstButtonTitle);
+ super.setFirstBtnId(builder.firstButtonId);
+ super.setFirstBtnTabIndex(builder.tabIndexStart);
+ super.setSecondBtnText(builder.sndButtonTitle);
+ super.setSecondBtnId(builder.sndButtonId);
+ super.setSecondBtnTabIndex(builder.tabIndexStart + 1);
+ super.setSize(builder.width, builder.height);
+ }
- public HasCloseHandlers<PopupPanel> getClose() {
- return popup;
- }
+ public HasCloseHandlers<PopupPanel> getClose() {
+ return popup;
+ }
- public void hide() {
- popup.hide();
+ public void hide() {
+ popup.hide();
- }
+ }
- public void showCentered() {
- popup.showCentered();
- }
+ @Override
+ public void setFirstBtnTitle(final String title) {
+ super.setFirstBtnTitle(title);
- public void showRelativeTo(final UIObject object) {
- popup.showRelativeTo(object);
- }
+ }
+
+ public void showCentered() {
+ popup.showCentered();
+ }
+
+ public void showRelativeTo(final UIObject object) {
+ popup.showRelativeTo(object);
+ }
}
Modified: trunk/src/main/java/cc/kune/core/client/notify/confirm/UserConfirmPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/notify/confirm/UserConfirmPanel.java 2011-04-29 12:57:28 UTC (rev 1330)
+++ trunk/src/main/java/cc/kune/core/client/notify/confirm/UserConfirmPanel.java 2011-04-29 13:16:37 UTC (rev 1331)
@@ -21,7 +21,6 @@
import cc.kune.common.client.notify.ConfirmAskEvent;
import cc.kune.common.client.ui.dialogs.BasicTopDialog;
-import cc.kune.common.client.utils.TextUtils;
import cc.kune.core.client.notify.confirm.UserConfirmPresenter.UserConfirmView;
import cc.kune.core.shared.i18n.I18nTranslationService;
@@ -34,68 +33,63 @@
import com.gwtplatform.mvp.client.ViewImpl;
public class UserConfirmPanel extends ViewImpl implements UserConfirmView {
- private static final String CANCEL_ID = "k-conf-dial";
- private static final String DIALOG_ID = "k-conf-dial-nok";
- private static final String OK_ID = "k-conf-dial-ok";
- private HandlerRegistration acceptHandler;
- private final Label askLabel;
- private HandlerRegistration cancelHandler;
- private final BasicTopDialog dialog;
+ private static final String CANCEL_ID = "k-conf-dial";
+ private static final String DIALOG_ID = "k-conf-dial-nok";
+ private static final String OK_ID = "k-conf-dial-ok";
+ private HandlerRegistration acceptHandler;
+ private final Label askLabel;
+ private HandlerRegistration cancelHandler;
+ private final BasicTopDialog dialog;
- @Inject
- public UserConfirmPanel(final I18nTranslationService i18n) {
- dialog = new BasicTopDialog.Builder(DIALOG_ID, false, true).autoscroll(false).width(100).height(100).firstButtonId(
- OK_ID).sndButtonId(CANCEL_ID).tabIndexStart(1).build();
- askLabel = new Label();
- askLabel.addStyleName("k-userconfirm-label");
- dialog.getInnerPanel().add(askLabel);
- }
+ @Inject
+ public UserConfirmPanel(final I18nTranslationService i18n) {
+ dialog = new BasicTopDialog.Builder(DIALOG_ID, false, true).autoscroll(false).width(100).height(100).firstButtonId(
+ OK_ID).sndButtonId(CANCEL_ID).tabIndexStart(1).build();
+ askLabel = new Label();
+ askLabel.addStyleName("k-userconfirm-label");
+ dialog.getInnerPanel().add(askLabel);
+ }
- @Override
- public Widget asWidget() {
- return null;
- }
+ @Override
+ public Widget asWidget() {
+ return null;
+ }
- @Override
- public void confirmAsk(final ConfirmAskEvent ask) {
- dialog.getFirstBtnText().setText(ask.getAcceptBtnMsg());
- final String cancelBtnMsg = ask.getCancelBtnMsg();
- dialog.setFirstBtnTitle(ask.getAcceptBtnTooltip());
- if (TextUtils.notEmpty(cancelBtnMsg)) {
- dialog.getSecondBtnText().setText(cancelBtnMsg);
- dialog.setSecondBtnTitle(ask.getCancelBtnTooltip());
- dialog.setSecondBtnVisible(true);
- } else {
- dialog.setSecondBtnVisible(false);
- }
- dialog.getTitleText().setText(ask.getTitle());
- askLabel.setText(ask.getMessage());
- dialog.showCentered();
- resetHandlers();
- acceptHandler = dialog.getFirstBtn().addClickHandler(new ClickHandler() {
- @Override
- public void onClick(final ClickEvent event) {
- ask.getCallback().onSuccess();
- dialog.hide();
- }
- });
- cancelHandler = dialog.getSecondBtn().addClickHandler(new ClickHandler() {
- @Override
- public void onClick(final ClickEvent event) {
- ask.getCallback().onCancel();
- dialog.hide();
- }
- });
- dialog.showCentered();
- }
+ @Override
+ public void confirmAsk(final ConfirmAskEvent ask) {
+ dialog.setFirstBtnText(ask.getAcceptBtnMsg());
+ final String cancelBtnMsg = ask.getCancelBtnMsg();
+ dialog.setFirstBtnTitle(ask.getAcceptBtnTooltip());
+ dialog.setSecondBtnText(cancelBtnMsg);
+ dialog.setSecondBtnTitle(ask.getCancelBtnTooltip());
+ dialog.getTitleText().setText(ask.getTitle());
+ askLabel.setText(ask.getMessage());
+ dialog.showCentered();
+ resetHandlers();
+ acceptHandler = dialog.getFirstBtn().addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(final ClickEvent event) {
+ ask.getCallback().onSuccess();
+ dialog.hide();
+ }
+ });
+ cancelHandler = dialog.getSecondBtn().addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(final ClickEvent event) {
+ ask.getCallback().onCancel();
+ dialog.hide();
+ }
+ });
+ dialog.showCentered();
+ }
- private void resetHandlers() {
- if (acceptHandler != null) {
- acceptHandler.removeHandler();
- }
- if (cancelHandler != null) {
- cancelHandler.removeHandler();
- }
+ private void resetHandlers() {
+ if (acceptHandler != null) {
+ acceptHandler.removeHandler();
}
+ if (cancelHandler != null) {
+ cancelHandler.removeHandler();
+ }
+ }
}
More information about the kune-commits
mailing list