diff options
author | Stephan Merkli | 2015-06-15 10:20:54 +0000 |
---|---|---|
committer | Stephan Merkli | 2015-06-15 11:43:27 +0000 |
commit | 7397b16185bfa4d9c3d54cf8f79cd34c54aff4f2 (patch) | |
tree | 68ab31db38b7c4e6140e0058c1271e01952bc8d0 | |
parent | 0052bb87dfaf8cab4a2e80ef987d0cf77251a56e (diff) | |
download | org.eclipse.scout.rt-7397b16185bfa4d9c3d54cf8f79cd34c54aff4f2.tar.gz org.eclipse.scout.rt-7397b16185bfa4d9c3d54cf8f79cd34c54aff4f2.tar.xz org.eclipse.scout.rt-7397b16185bfa4d9c3d54cf8f79cd34c54aff4f2.zip |
MessageBox: title removal & method chaining
Title of message box was removed because not required/supported anymore
Multi args constructors / static convenience methods were removed,
method chaining is now supported instead.
Renamed intro text to header
Renamed info / actionText to body
9 files changed, 95 insertions, 86 deletions
diff --git a/org.eclipse.scout.rt.client.test/src/test/java/org/eclipse/scout/rt/client/ui/form/fields/button/ButtonTest.java b/org.eclipse.scout.rt.client.test/src/test/java/org/eclipse/scout/rt/client/ui/form/fields/button/ButtonTest.java index 2a73d60ed7..c10f5deb1e 100644 --- a/org.eclipse.scout.rt.client.test/src/test/java/org/eclipse/scout/rt/client/ui/form/fields/button/ButtonTest.java +++ b/org.eclipse.scout.rt.client.test/src/test/java/org/eclipse/scout/rt/client/ui/form/fields/button/ButtonTest.java @@ -20,7 +20,7 @@ import org.eclipse.scout.rt.client.ui.action.menu.IMenu; import org.eclipse.scout.rt.client.ui.form.AbstractForm; import org.eclipse.scout.rt.client.ui.form.fields.button.ButtonTest.TestForm.MainBox.PushButton1; import org.eclipse.scout.rt.client.ui.form.fields.groupbox.AbstractGroupBox; -import org.eclipse.scout.rt.client.ui.messagebox.MessageBox; +import org.eclipse.scout.rt.client.ui.messagebox.MessageBoxes; import org.eclipse.scout.rt.testing.client.runner.ClientTestRunner; import org.eclipse.scout.rt.testing.client.runner.RunWithClientSession; import org.eclipse.scout.rt.testing.platform.runner.RunWithSubject; @@ -87,7 +87,7 @@ public class ButtonTest { @Override protected void execAction() throws ProcessingException { - MessageBox.createOk().header("click").body("it").start(); + MessageBoxes.createOk().header("click").body("it").show(); } } @@ -105,7 +105,7 @@ public class ButtonTest { @Override protected void execAction() throws ProcessingException { - MessageBox.createOk().header("click").body("it").start(); + MessageBoxes.createOk().header("click").body("it").show(); } } } diff --git a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/services/common/exceptionhandler/ErrorPopup.java b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/services/common/exceptionhandler/ErrorPopup.java index 975db68e33..f4532d5dcb 100644 --- a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/services/common/exceptionhandler/ErrorPopup.java +++ b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/services/common/exceptionhandler/ErrorPopup.java @@ -26,7 +26,7 @@ import org.eclipse.scout.commons.StringUtility; import org.eclipse.scout.commons.annotations.Internal; import org.eclipse.scout.commons.exception.ProcessingException; import org.eclipse.scout.commons.exception.VetoException; -import org.eclipse.scout.rt.client.ui.messagebox.MessageBox; +import org.eclipse.scout.rt.client.ui.messagebox.MessageBoxes; import org.eclipse.scout.rt.platform.Bean; import org.eclipse.scout.rt.shared.ScoutTexts; import org.eclipse.scout.rt.shared.servicetunnel.HttpException; @@ -51,13 +51,13 @@ public class ErrorPopup { public void showMessageBox(Throwable error) { ensureErrorParsed(error); - MessageBox.create(). + MessageBoxes.create(). header(m_text). body(m_detail). yesButtonText(m_acceptText). hiddenText(m_copyPasteText). severity(m_cause.getStatus().getSeverity()). - start(); + show(); } @Internal diff --git a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/services/common/pwd/PasswordPolicyVerifier.java b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/services/common/pwd/PasswordPolicyVerifier.java index beabcd9ff4..89149a53be 100644 --- a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/services/common/pwd/PasswordPolicyVerifier.java +++ b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/services/common/pwd/PasswordPolicyVerifier.java @@ -19,6 +19,7 @@ import org.eclipse.scout.rt.client.session.ClientSessionProvider; import org.eclipse.scout.rt.client.ui.desktop.IDesktop; import org.eclipse.scout.rt.client.ui.form.useradmin.DefaultPasswordForm; import org.eclipse.scout.rt.client.ui.messagebox.MessageBox; +import org.eclipse.scout.rt.client.ui.messagebox.MessageBoxes; import org.eclipse.scout.rt.platform.BEANS; import org.eclipse.scout.rt.platform.exception.ExceptionHandler; import org.eclipse.scout.rt.shared.ScoutTexts; @@ -78,7 +79,7 @@ public class PasswordPolicyVerifier { header = ScoutTexts.get("PasswordWillExpireHeaderX", ScoutTexts.get("InDaysX", "" + remainDays)); } - int answer = MessageBox.createYesNoCancel().header(header).body(ScoutTexts.get("PasswordWillExpireInfo")).start(); + int answer = MessageBoxes.createYesNoCancel().header(header).body(ScoutTexts.get("PasswordWillExpireInfo")).show(); if (answer == MessageBox.YES_OPTION) { changeNow = true; } @@ -86,7 +87,7 @@ public class PasswordPolicyVerifier { } else { // has expired - MessageBox.createOk().header(ScoutTexts.get("PasswordHasExpiredTitle")).body(ScoutTexts.get("PasswordHasExpiredHeader")).start(); + MessageBoxes.createOk().header(ScoutTexts.get("PasswordHasExpiredTitle")).body(ScoutTexts.get("PasswordHasExpiredHeader")).show(); changeNow = true; } // diff --git a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/desktop/UnsavedFormChangesForm.java b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/desktop/UnsavedFormChangesForm.java index 396b1f8291..f9bb8e667d 100644 --- a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/desktop/UnsavedFormChangesForm.java +++ b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/desktop/UnsavedFormChangesForm.java @@ -31,7 +31,7 @@ import org.eclipse.scout.rt.client.ui.form.fields.button.AbstractCancelButton; import org.eclipse.scout.rt.client.ui.form.fields.button.AbstractOkButton; import org.eclipse.scout.rt.client.ui.form.fields.groupbox.AbstractGroupBox; import org.eclipse.scout.rt.client.ui.form.fields.listbox.AbstractListBox; -import org.eclipse.scout.rt.client.ui.messagebox.MessageBox; +import org.eclipse.scout.rt.client.ui.messagebox.MessageBoxes; import org.eclipse.scout.rt.shared.TEXTS; import org.eclipse.scout.rt.shared.services.lookup.ILookupCall; import org.eclipse.scout.rt.shared.services.lookup.ILookupRow; @@ -219,7 +219,7 @@ public class UnsavedFormChangesForm extends AbstractForm { for (IForm f : invalidForms) { msg.append("- ").append(getFormDisplayName(f)).append("\n"); } - MessageBox.createOk().header(TEXTS.get("NotAllCheckedFormsCanBeSaved")).body(msg.toString()).start(); + MessageBoxes.createOk().header(TEXTS.get("NotAllCheckedFormsCanBeSaved")).body(msg.toString()).show(); return false; } return true; diff --git a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/desktop/bookmark/AbstractBookmarkTreeField.java b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/desktop/bookmark/AbstractBookmarkTreeField.java index 6530d4099e..d64ce4db32 100644 --- a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/desktop/bookmark/AbstractBookmarkTreeField.java +++ b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/desktop/bookmark/AbstractBookmarkTreeField.java @@ -49,6 +49,7 @@ import org.eclipse.scout.rt.client.ui.desktop.bookmark.view.IPublishBookmarkComm import org.eclipse.scout.rt.client.ui.form.IForm; import org.eclipse.scout.rt.client.ui.form.fields.treefield.AbstractTreeField; import org.eclipse.scout.rt.client.ui.messagebox.MessageBox; +import org.eclipse.scout.rt.client.ui.messagebox.MessageBoxes; import org.eclipse.scout.rt.platform.BEANS; import org.eclipse.scout.rt.platform.exception.ExceptionHandler; import org.eclipse.scout.rt.shared.AbstractIcons; @@ -946,7 +947,7 @@ public abstract class AbstractBookmarkTreeField extends AbstractTreeField { } } if (success != null && !success) { - MessageBox.createOk().body(ScoutTexts.get("ApplyBookmarkToSearchFailedMessage")).start(); + MessageBoxes.createOk().body(ScoutTexts.get("ApplyBookmarkToSearchFailedMessage")).show(); } } } diff --git a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/AbstractForm.java b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/AbstractForm.java index 5dea2db091..6bfcc63889 100644 --- a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/AbstractForm.java +++ b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/AbstractForm.java @@ -105,7 +105,7 @@ import org.eclipse.scout.rt.client.ui.form.internal.FindFieldByFormDataIdVisitor import org.eclipse.scout.rt.client.ui.form.internal.FindFieldByXmlIdsVisitor; import org.eclipse.scout.rt.client.ui.form.internal.FormDataPropertyFilter; import org.eclipse.scout.rt.client.ui.messagebox.IMessageBox; -import org.eclipse.scout.rt.client.ui.messagebox.MessageBox; +import org.eclipse.scout.rt.client.ui.messagebox.MessageBoxes; import org.eclipse.scout.rt.client.ui.profiler.DesktopProfiler; import org.eclipse.scout.rt.client.ui.wizard.IWizard; import org.eclipse.scout.rt.client.ui.wizard.IWizardStep; @@ -1812,10 +1812,10 @@ public abstract class AbstractForm extends AbstractPropertyObserver implements I }; visitFields(collector); if (collector.getCollectionCount() > 0 && isAskIfNeedSave()) { - int result = MessageBox.createYesNoCancel(). + int result = MessageBoxes.createYesNoCancel(). header(getCancelVerificationText()). severity(IStatus.INFO). - start(); + show(); if (result == IMessageBox.YES_OPTION) { doOk(); @@ -2366,9 +2366,9 @@ public abstract class AbstractForm extends AbstractPropertyObserver implements I } catch (Exception e) { LOG.warn("loading: " + newPath + " Exception: " + e); - MessageBox.createOk(). + MessageBoxes.createOk(). header(TEXTS.get("LoadFormXmlFailedText")). - start(); + show(); } } } diff --git a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/messagebox/IMessageBox.java b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/messagebox/IMessageBox.java index 6f30fac3c1..3f1b1d7cef 100644 --- a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/messagebox/IMessageBox.java +++ b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/messagebox/IMessageBox.java @@ -75,7 +75,7 @@ public interface IMessageBox extends IPropertyObserver { /** * To close the message box automatically after the specified period of time. By default, the result - * {@link #CANCEL_OPTION} is returned after being closed. This can be changed by using {@link #start(int)} to + * {@link #CANCEL_OPTION} is returned after being closed. This can be changed by using {@link #show(int)} to * construct the message box. * * @param autoCloseMillis @@ -99,7 +99,7 @@ public interface IMessageBox extends IPropertyObserver { * * @return The close result ({@link #YES_OPTION}, {@link #NO_OPTION}, {@link #CANCEL_OPTION}). */ - int start(); + int show(); /** * Opens a message box. This call blocks until the message box is closed. @@ -108,5 +108,5 @@ public interface IMessageBox extends IPropertyObserver { * default result to return if not closed by the user (e.g. by auto-close timer). * @return The close result ({@link #YES_OPTION}, {@link #NO_OPTION}, {@link #CANCEL_OPTION}). */ - int start(int defaultResult); + int show(int defaultResult); } diff --git a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/messagebox/MessageBox.java b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/messagebox/MessageBox.java index be421d46d4..aebf8041cb 100644 --- a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/messagebox/MessageBox.java +++ b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/messagebox/MessageBox.java @@ -27,7 +27,6 @@ import org.eclipse.scout.rt.client.context.ClientRunContexts; import org.eclipse.scout.rt.client.job.ClientJobs; import org.eclipse.scout.rt.client.session.ClientSessionProvider; import org.eclipse.scout.rt.client.ui.desktop.IDesktop; -import org.eclipse.scout.rt.platform.BEANS; import org.eclipse.scout.rt.platform.Bean; import org.eclipse.scout.rt.platform.job.IBlockingCondition; import org.eclipse.scout.rt.platform.job.IFuture; @@ -41,72 +40,11 @@ public class MessageBox extends AbstractPropertyObserver implements IMessageBox private static final IScoutLogger LOG = ScoutLogManager.getLogger(MessageBox.class); /** - * Do not use, use {@link #create()} instead. + * Do not use, use {@link MessageBoxes#create()} instead. */ public MessageBox() { } - public static IMessageBox create() { - return BEANS.get(IMessageBox.class); - } - - /** - * Creates a message box with one button labeled OK. - * <p> - * Do not forget to call {@link #start()} at the end. - */ - public static IMessageBox createOk() { - return create(). - yesButtonText(ScoutTexts.get("OkButton")); - } - - /** - * Creates e message box with yes and not buttons. - */ - public static IMessageBox createYesNo() { - return create(). - yesButtonText(ScoutTexts.get("YesButton")). - noButtonText(ScoutTexts.get("NoButton")); - } - - /** - * Creates a message box with yes, no and cancel buttons. - */ - public static IMessageBox createYesNoCancel() { - return createYesNo(). - cancelButtonText(ScoutTexts.get("CancelButton")); - } - - /** - * Convenience function for simple info message box. - * - * @deprecated use createOk().header(header).body(body).start() instead. Will be removed in the "N" release. - */ - @Deprecated - public static int showOkMessage(String title, String header, String body) { - return createOk().header(header).body(body).start(); - } - - /** - * Convenience function for simple yes/no message box - * - * @deprecated use createYesNo().header(header).body(body).start() instead. Will be removed in the "N" release. - */ - @Deprecated - public static int showYesNoMessage(String title, String header, String body) { - return createYesNo().header(header).body(body).start(); - } - - /** - * Convenience function for simple yes/no/cancel message box - * - * @deprecated use createYesNoCancel().header(header).body(body).start() instead. Will be removed in the "N" release. - */ - @Deprecated - public static int showYesNoCancelMessage(String title, String header, String body) { - return createYesNoCancel().header(header).body(body).start(); - } - /** * Convenience function for simple delete confirmation message box * @@ -195,7 +133,7 @@ public class MessageBox extends AbstractPropertyObserver implements IMessageBox body = (n > 0 ? t.toString() : null); } - int result = createYesNo().header(header).body(body).start(); + int result = MessageBoxes.createYesNo().header(header).body(body).show(); return result == IMessageBox.YES_OPTION; } @@ -429,13 +367,24 @@ public class MessageBox extends AbstractPropertyObserver implements IMessageBox return m_blockingCondition.isBlocking(); } + /** + * Displays the message box and waits for a response. + * <p> + * If {@link #autoCloseMillis()} is set, the message box will return with {@link IMessageBox#CANCEL_OPTION} after the + * specific time. + */ @Override - public int start() { - return start(CANCEL_OPTION); + public int show() { + return show(CANCEL_OPTION); } + /** + * Displays the message box and waits for a response. + * <p> + * If {@link #autoCloseMillis()} is set, the message box will return with given response after the specific time. + */ @Override - public int start(int defaultResult) { + public int show(int defaultResult) { m_answerSet = false; m_answer = defaultResult; if (ClientSessionProvider.currentSession() != null) { diff --git a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/messagebox/MessageBoxes.java b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/messagebox/MessageBoxes.java new file mode 100644 index 0000000000..a3aaee30e9 --- /dev/null +++ b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/messagebox/MessageBoxes.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2015 BSI Business Systems Integration AG. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * BSI Business Systems Integration AG - initial API and implementation + ******************************************************************************/ +package org.eclipse.scout.rt.client.ui.messagebox; + +import org.eclipse.scout.rt.platform.BEANS; +import org.eclipse.scout.rt.shared.ScoutTexts; + +/** + * Factory for message boxes. + * + * @since 6.0.0 + */ +public class MessageBoxes { + + /** + * Creates a message box with no defined buttons. + * <p> + * Do not forget to call {@link #show()} at the end. + */ + public static IMessageBox create() { + return BEANS.get(IMessageBox.class); + } + + /** + * Creates a message box with one button labeled OK. + * <p> + * Do not forget to call {@link #show()} at the end. + */ + public static IMessageBox createOk() { + return MessageBoxes.create(). + yesButtonText(ScoutTexts.get("OkButton")); + } + + /** + * Creates e message box with yes and not buttons. + */ + public static IMessageBox createYesNo() { + return MessageBoxes.create(). + yesButtonText(ScoutTexts.get("YesButton")). + noButtonText(ScoutTexts.get("NoButton")); + } + + /** + * Creates a message box with yes, no and cancel buttons. + */ + public static IMessageBox createYesNoCancel() { + return MessageBoxes.createYesNo(). + cancelButtonText(ScoutTexts.get("CancelButton")); + } +} |