Package com.biglybt.ui.swt.shells
Class MessageBoxShell
- java.lang.Object
-
- com.biglybt.ui.swt.shells.MessageBoxShell
-
- All Implemented Interfaces:
UIFunctionsUserPrompter
public class MessageBoxShell extends java.lang.Object implements UIFunctionsUserPrompter
A messagebox that allows you config the button
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
applyToAll
private boolean
autoClosed
private int
autoCloseInMS
private boolean
browser_follow_links
private java.lang.String[]
buttons
private java.lang.Integer[]
buttonVals
private boolean
cbEnabled
private java.lang.String
cbMessageID
private int
cbMinUserMode
private int
defaultButtonPos
private org.eclipse.swt.widgets.Listener
filterListener
private boolean
handleHTML
private java.lang.String
html
private org.eclipse.swt.graphics.Image
iconImage
private java.lang.String
iconImageID
private org.eclipse.swt.graphics.Image
imgLeft
private java.lang.String
instanceID
protected boolean
isRemembered
private static java.util.Map<java.lang.String,MessageBoxShell>
mapInstances
private int
max_size_x
private static int
MAX_SIZE_X_DEFAULT
private static int
MIN_BUTTON_SIZE
private int
min_size_x
private static int
MIN_SIZE_X_DEFAULT
private int
min_size_y
private static int
MIN_SIZE_Y_DEFAULT
private boolean
modal
private static int
numOpen
private boolean
opened
private org.eclipse.swt.widgets.Shell
parent
private java.lang.Object[]
relatedObjects
private boolean
rememberByDefault
private java.lang.String
rememberID
private int
rememberOnlyIfButtonPos
private java.lang.String
rememberText
private int
result
private UserPrompterResultListener
resultListener
private org.eclipse.swt.widgets.Shell
shell
private boolean
squish
static java.lang.String
STATUS_TEXT_CLOSE
private boolean
supportsApplyToAll
private java.lang.String
text
private java.lang.String
title
private java.lang.String
url
protected org.eclipse.swt.graphics.Color
urlColor
private boolean
useTextBox
-
Fields inherited from interface com.biglybt.ui.UIFunctionsUserPrompter
ICON_ERROR, ICON_INFO, ICON_WARNING
-
-
Constructor Summary
Constructors Constructor Description MessageBoxShell(int style, java.lang.String title, java.lang.String text)
Open a messagebox with actual title and textMessageBoxShell(int style, java.lang.String keyPrefix, java.lang.String[] textParams)
Open a messagebox using resource keys for title/textMessageBoxShell(java.lang.String title, java.lang.String text)
MessageBoxShell(java.lang.String title, java.lang.String text, java.lang.String[] buttons, int defaultOption)
MessageBoxShell(org.eclipse.swt.widgets.Shell parent, java.lang.String title, java.lang.String text, java.lang.String[] buttons, int defaultOption)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private void
_open()
void
addCheckBox(java.lang.String cbMessageID, int cbMinUserMode, boolean defaultOn)
Adds a checkbox to the message box.void
close()
private org.eclipse.swt.widgets.Canvas
createLinkLabel(org.eclipse.swt.widgets.Composite shell, java.lang.String text)
private org.eclipse.swt.widgets.Control
createTextBox(org.eclipse.swt.widgets.Composite textComposite, java.lang.String text2)
boolean
getApplyToAll()
int
getAutoCloseInMS()
Returns the number milliseconds the prompt will wait around until it auto closes.private int
getButtonPos(int buttonVal)
java.lang.String[]
getButtons()
private int
getButtonVal(int buttonPos)
boolean
getCheckBoxEnabled()
java.lang.String
getHtml()
Returns the HTML that will be displayed along with the promptjava.lang.Object
getLeftImage()
org.eclipse.swt.widgets.Shell
getParent()
java.lang.Object[]
getRelatedObjects()
java.lang.String
getRememberID()
Retrieves the Remember ID associated with this promptint
getRememberOnlyIfButton()
java.lang.String
getRememberText()
Retrieves the text to be displayed by the "Remember this Action" checkboxint
getResult()
org.eclipse.swt.graphics.Color
getUrlColor()
boolean
isAutoClosed()
Determines if the prompt was auto closed after#open()
was called, or if the user chose an option.static boolean
isOpen()
boolean
isRemembered()
static void
main(java.lang.String[] args)
int
open()
Deprecated.private void
open(boolean useCustomShell)
void
open(UserPrompterResultListener l)
Opens the prompt.static void
open(org.eclipse.swt.widgets.Shell parent, java.lang.String title, java.lang.String text, java.lang.String[] buttons, int defaultOption, java.lang.String rememberID, java.lang.String rememberText, boolean bRememberByDefault, int autoCloseInMS, UserPrompterResultListener l)
void
setApplyToAllEnabled()
void
setAutoCloseInMS(int autoCloseInMS)
Sets the # of milliseconds before auto closing.void
setBrowserFollowLinks(boolean follow)
void
setButtons(int defaltButtonPos, java.lang.String[] buttons, java.lang.Integer[] buttonVals)
void
setButtons(java.lang.String[] buttons)
void
setDefaultButtonUsingStyle(int defaultStyle)
void
setHandleHTML(boolean handleHTML)
void
setHtml(java.lang.String html)
void
setIconResource(java.lang.String resource)
void
setLeftImage(int icon)
Replaces Image on left with iconvoid
setLeftImage(java.lang.String id)
void
setLeftImage(org.eclipse.swt.graphics.Image imgLeft)
void
setModal(boolean m)
Only use this if you REALLY know what you're doing as in general it is a bad thing - check comments in this classvoid
setOneInstanceOf(java.lang.String instanceID)
Prevent more than one dialog of instanceID from showing up at oncevoid
setParent(org.eclipse.swt.widgets.Shell parent)
void
setRelatedObject(java.lang.Object relatedObject)
void
setRelatedObjects(java.lang.Object[] relatedObjects)
void
setRemember(java.lang.String rememberID, boolean rememberByDefault, java.lang.String rememberText)
void
setRememberOnlyIfButton(int rememberOnlyIfButton)
void
setRememberText(java.lang.String rememberText)
void
setSize(int width, int height)
void
setSquish(boolean b)
void
setUrl(java.lang.String url)
void
setUrlColor(org.eclipse.swt.graphics.Color colorURL)
void
setUseTextBox(boolean useTextBox)
private static java.lang.Object[]
swtButtonStylesToText(int style)
private void
triggerResultListener(int returnVal)
boolean
useTextBox()
int
waitUntilClosed()
NOT RECOMMENDED!
-
-
-
Field Detail
-
STATUS_TEXT_CLOSE
public static final java.lang.String STATUS_TEXT_CLOSE
- See Also:
- Constant Field Values
-
MIN_SIZE_X_DEFAULT
private static final int MIN_SIZE_X_DEFAULT
- See Also:
- Constant Field Values
-
MIN_SIZE_Y_DEFAULT
private static final int MIN_SIZE_Y_DEFAULT
- See Also:
- Constant Field Values
-
MAX_SIZE_X_DEFAULT
private static final int MAX_SIZE_X_DEFAULT
- See Also:
- Constant Field Values
-
MIN_BUTTON_SIZE
private static final int MIN_BUTTON_SIZE
- See Also:
- Constant Field Values
-
numOpen
private static int numOpen
-
parent
private org.eclipse.swt.widgets.Shell parent
-
min_size_x
private int min_size_x
-
min_size_y
private int min_size_y
-
max_size_x
private int max_size_x
-
title
private final java.lang.String title
-
text
private final java.lang.String text
-
buttons
private java.lang.String[] buttons
-
buttonVals
private java.lang.Integer[] buttonVals
-
defaultButtonPos
private int defaultButtonPos
-
rememberID
private java.lang.String rememberID
-
rememberText
private java.lang.String rememberText
-
rememberByDefault
private boolean rememberByDefault
-
rememberOnlyIfButtonPos
private int rememberOnlyIfButtonPos
-
autoCloseInMS
private int autoCloseInMS
-
html
private java.lang.String html
-
url
private java.lang.String url
-
squish
private boolean squish
-
autoClosed
private boolean autoClosed
-
relatedObjects
private java.lang.Object[] relatedObjects
-
imgLeft
private org.eclipse.swt.graphics.Image imgLeft
-
urlColor
protected org.eclipse.swt.graphics.Color urlColor
-
handleHTML
private boolean handleHTML
-
iconImage
private org.eclipse.swt.graphics.Image iconImage
-
browser_follow_links
private boolean browser_follow_links
-
isRemembered
protected boolean isRemembered
-
supportsApplyToAll
private boolean supportsApplyToAll
-
applyToAll
private boolean applyToAll
-
iconImageID
private java.lang.String iconImageID
-
resultListener
private UserPrompterResultListener resultListener
-
result
private int result
-
filterListener
private org.eclipse.swt.widgets.Listener filterListener
-
shell
private org.eclipse.swt.widgets.Shell shell
-
opened
private boolean opened
-
useTextBox
private boolean useTextBox
-
cbMessageID
private java.lang.String cbMessageID
-
cbMinUserMode
private int cbMinUserMode
-
cbEnabled
private boolean cbEnabled
-
instanceID
private java.lang.String instanceID
-
modal
private boolean modal
-
mapInstances
private static java.util.Map<java.lang.String,MessageBoxShell> mapInstances
-
-
Constructor Detail
-
MessageBoxShell
public MessageBoxShell(java.lang.String title, java.lang.String text, java.lang.String[] buttons, int defaultOption)
- Parameters:
shellForChildren
-string
-string2
-strings
-
-
MessageBoxShell
@Deprecated public MessageBoxShell(org.eclipse.swt.widgets.Shell parent, java.lang.String title, java.lang.String text, java.lang.String[] buttons, int defaultOption)
Deprecated.ONLY FOR OLD EMP. DO NOT USE
-
MessageBoxShell
public MessageBoxShell(java.lang.String title, java.lang.String text)
-
MessageBoxShell
public MessageBoxShell(int style, java.lang.String keyPrefix, java.lang.String[] textParams)
Open a messagebox using resource keys for title/text- Parameters:
parent
- Parent shell for messageboxstyle
- SWT styles for messageboxkeyPrefix
- message bundle key prefix used to get title and text. Title will be keyPrefix + ".title", and text will be set to keyPrefix + ".text"textParams
- any parameters for text
-
MessageBoxShell
public MessageBoxShell(int style, java.lang.String title, java.lang.String text)
Open a messagebox with actual title and text- Parameters:
parent
-style
-title
-text
-
-
-
Method Detail
-
open
public static void open(org.eclipse.swt.widgets.Shell parent, java.lang.String title, java.lang.String text, java.lang.String[] buttons, int defaultOption, java.lang.String rememberID, java.lang.String rememberText, boolean bRememberByDefault, int autoCloseInMS, UserPrompterResultListener l)
-
isOpen
public static boolean isOpen()
-
setDefaultButtonUsingStyle
public void setDefaultButtonUsingStyle(int defaultStyle)
-
open
@Deprecated public int open()
Deprecated.ONLY FOR OLD EMP. DO NOT USE.- Returns:
-
open
public void open(UserPrompterResultListener l)
Description copied from interface:UIFunctionsUserPrompter
Opens the prompt. returns when user has chosen an action, or auto-close- Specified by:
open
in interfaceUIFunctionsUserPrompter
-
triggerResultListener
private void triggerResultListener(int returnVal)
-
getButtonVal
private int getButtonVal(int buttonPos)
-
getButtonPos
private int getButtonPos(int buttonVal)
-
open
private void open(boolean useCustomShell)
-
_open
private void _open()
-
createTextBox
private org.eclipse.swt.widgets.Control createTextBox(org.eclipse.swt.widgets.Composite textComposite, java.lang.String text2)
- Parameters:
textComposite
-text2
-- Returns:
-
createLinkLabel
private org.eclipse.swt.widgets.Canvas createLinkLabel(org.eclipse.swt.widgets.Composite shell, java.lang.String text)
-
getHtml
public java.lang.String getHtml()
Description copied from interface:UIFunctionsUserPrompter
Returns the HTML that will be displayed along with the promptTODO: Create a boolean canHandleHTML()
- Specified by:
getHtml
in interfaceUIFunctionsUserPrompter
- Returns:
-
setHtml
public void setHtml(java.lang.String html)
- Specified by:
setHtml
in interfaceUIFunctionsUserPrompter
-
setUrl
public void setUrl(java.lang.String url)
- Specified by:
setUrl
in interfaceUIFunctionsUserPrompter
-
setSize
public void setSize(int width, int height)
-
getRememberID
public java.lang.String getRememberID()
Description copied from interface:UIFunctionsUserPrompter
Retrieves the Remember ID associated with this prompt- Specified by:
getRememberID
in interfaceUIFunctionsUserPrompter
- Returns:
- the rememberID
-
setRemember
public void setRemember(java.lang.String rememberID, boolean rememberByDefault, java.lang.String rememberText)
- Specified by:
setRemember
in interfaceUIFunctionsUserPrompter
- Parameters:
rememberID
-rememberByDefault
-rememberText
- null if you want the default
-
getRememberText
public java.lang.String getRememberText()
Description copied from interface:UIFunctionsUserPrompter
Retrieves the text to be displayed by the "Remember this Action" checkbox- Specified by:
getRememberText
in interfaceUIFunctionsUserPrompter
- Returns:
- the rememberText
-
setRememberText
public void setRememberText(java.lang.String rememberText)
- Specified by:
setRememberText
in interfaceUIFunctionsUserPrompter
- Parameters:
rememberText
- the rememberText to set
-
getAutoCloseInMS
public int getAutoCloseInMS()
Description copied from interface:UIFunctionsUserPrompter
Returns the number milliseconds the prompt will wait around until it auto closes. Timer starts after the user is prompted (when#open()
is called), and typically does not decrease while the user is viewing the prompt (certain implementations may operate differently)- Specified by:
getAutoCloseInMS
in interfaceUIFunctionsUserPrompter
- Returns:
- the autoCloseInMS
-
setAutoCloseInMS
public void setAutoCloseInMS(int autoCloseInMS)
Description copied from interface:UIFunctionsUserPrompter
Sets the # of milliseconds before auto closing. Timer starts after the user is prompted (when#open()
is called), and typically does not decrease while the user is viewing the prompt (certain implementations may operate differently)- Specified by:
setAutoCloseInMS
in interfaceUIFunctionsUserPrompter
- Parameters:
autoCloseInMS
- the autoCloseInMS to set
-
setSquish
public void setSquish(boolean b)
-
isAutoClosed
public boolean isAutoClosed()
Description copied from interface:UIFunctionsUserPrompter
Determines if the prompt was auto closed after#open()
was called, or if the user chose an option.- Specified by:
isAutoClosed
in interfaceUIFunctionsUserPrompter
- Returns:
- the autoClosed
-
setModal
public void setModal(boolean m)
Only use this if you REALLY know what you're doing as in general it is a bad thing - check comments in this class- Parameters:
m
-
-
setRelatedObject
public void setRelatedObject(java.lang.Object relatedObject)
- Specified by:
setRelatedObject
in interfaceUIFunctionsUserPrompter
-
setRelatedObjects
public void setRelatedObjects(java.lang.Object[] relatedObjects)
- Specified by:
setRelatedObjects
in interfaceUIFunctionsUserPrompter
-
getRelatedObjects
public java.lang.Object[] getRelatedObjects()
-
getLeftImage
public java.lang.Object getLeftImage()
- Returns:
- Since:
- 4.0.0.1
-
setLeftImage
public void setLeftImage(org.eclipse.swt.graphics.Image imgLeft)
-
setLeftImage
public void setLeftImage(int icon)
Replaces Image on left with icon- Parameters:
icon
- SWT.ICON_ERROR, ICON_INFORMATION, ICON_QUESTION, ICON_WARNING, ICON_WORKING- Since:
- 3.0.1.7
-
setIconResource
public void setIconResource(java.lang.String resource)
- Specified by:
setIconResource
in interfaceUIFunctionsUserPrompter
- Parameters:
resource
- image repository resource name (e.g. "error", "warning", "info")
-
main
public static void main(java.lang.String[] args)
-
getRememberOnlyIfButton
public int getRememberOnlyIfButton()
-
setRememberOnlyIfButton
public void setRememberOnlyIfButton(int rememberOnlyIfButton)
- Specified by:
setRememberOnlyIfButton
in interfaceUIFunctionsUserPrompter
-
getUrlColor
public org.eclipse.swt.graphics.Color getUrlColor()
-
setBrowserFollowLinks
public void setBrowserFollowLinks(boolean follow)
-
setUrlColor
public void setUrlColor(org.eclipse.swt.graphics.Color colorURL)
-
setHandleHTML
public void setHandleHTML(boolean handleHTML)
- Parameters:
b
-- Since:
- 3.0.5.3
-
isRemembered
public boolean isRemembered()
-
waitUntilClosed
public int waitUntilClosed()
NOT RECOMMENDED!TODO: Occasionaly inspect list of callers and make them use
UserPrompterResultListener
if possible- Specified by:
waitUntilClosed
in interfaceUIFunctionsUserPrompter
-
getResult
public int getResult()
-
swtButtonStylesToText
private static java.lang.Object[] swtButtonStylesToText(int style)
-
getButtons
public java.lang.String[] getButtons()
-
setButtons
public void setButtons(java.lang.String[] buttons)
-
setButtons
public void setButtons(int defaltButtonPos, java.lang.String[] buttons, java.lang.Integer[] buttonVals)
-
addCheckBox
public void addCheckBox(java.lang.String cbMessageID, int cbMinUserMode, boolean defaultOn)
Adds a checkbox to the message box. Currently only one checkbox can be made via this method.
-
getCheckBoxEnabled
public boolean getCheckBoxEnabled()
-
setApplyToAllEnabled
public void setApplyToAllEnabled()
-
getApplyToAll
public boolean getApplyToAll()
-
getParent
public org.eclipse.swt.widgets.Shell getParent()
-
setParent
public void setParent(org.eclipse.swt.widgets.Shell parent)
-
close
public void close()
-
setUseTextBox
public void setUseTextBox(boolean useTextBox)
- Parameters:
useTextBox
- The useTextBox to set.
-
useTextBox
public boolean useTextBox()
- Returns:
- Returns the useTextBox.
-
setLeftImage
public void setLeftImage(java.lang.String id)
-
setOneInstanceOf
public void setOneInstanceOf(java.lang.String instanceID)
Description copied from interface:UIFunctionsUserPrompter
Prevent more than one dialog of instanceID from showing up at once- Specified by:
setOneInstanceOf
in interfaceUIFunctionsUserPrompter
-
-