Class MessageBoxShell

java.lang.Object
com.biglybt.ui.swt.shells.MessageBoxShell
All Implemented Interfaces:
UIFunctionsUserPrompter

public class MessageBoxShell extends Object implements UIFunctionsUserPrompter
A messagebox that allows you config the button
  • Field Details

    • STATUS_TEXT_CLOSE

      public static final String STATUS_TEXT_CLOSE
      See Also:
    • MIN_SIZE_X_DEFAULT

      private static final int MIN_SIZE_X_DEFAULT
      See Also:
    • MIN_SIZE_Y_DEFAULT

      private static final int MIN_SIZE_Y_DEFAULT
      See Also:
    • MAX_SIZE_X_DEFAULT

      private static final int MAX_SIZE_X_DEFAULT
      See Also:
    • MIN_BUTTON_SIZE

      private static final int MIN_BUTTON_SIZE
      See Also:
    • 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 String title
    • text

      private final String text
    • buttons

      private String[] buttons
    • buttonVals

      private Integer[] buttonVals
    • defaultButtonPos

      private int defaultButtonPos
    • rememberID

      private String rememberID
    • rememberText

      private String rememberText
    • rememberByDefault

      private boolean rememberByDefault
    • rememberOnlyIfButtonPos

      private int rememberOnlyIfButtonPos
    • autoCloseInMS

      private int autoCloseInMS
    • html

      private String html
    • url

      private String url
    • squish

      private boolean squish
    • autoClosed

      private boolean autoClosed
    • relatedObjects

      private 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
    • isRemembered

      protected boolean isRemembered
    • supportsApplyToAll

      private boolean supportsApplyToAll
    • applyToAll

      private boolean applyToAll
    • iconImageID

      private 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 String cbMessageID
    • cbMinUserMode

      private int cbMinUserMode
    • cbEnabled

      private boolean cbEnabled
    • instanceID

      private String instanceID
    • mapInstances

      private static Map<String,MessageBoxShell> mapInstances
  • Constructor Details

    • MessageBoxShell

      public MessageBoxShell(String title, String text, String[] buttons, int defaultOption)
      Parameters:
      shellForChildren -
      string -
      string2 -
      strings -
    • MessageBoxShell

      @Deprecated public MessageBoxShell(org.eclipse.swt.widgets.Shell parent, String title, String text, String[] buttons, int defaultOption)
      Deprecated.
      ONLY FOR OLD EMP. DO NOT USE
    • MessageBoxShell

      public MessageBoxShell(String title, String text)
    • MessageBoxShell

      public MessageBoxShell(int style, String keyPrefix, String[] textParams)
      Open a messagebox using resource keys for title/text
      Parameters:
      style - SWT styles for messagebox
      keyPrefix - 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
      parent - Parent shell for messagebox
    • MessageBoxShell

      public MessageBoxShell(int style, String title, String text)
      Open a messagebox with actual title and text
      Parameters:
      style -
      title -
      text -
      parent -
  • Method Details

    • open

      public static void open(org.eclipse.swt.widgets.Shell parent, String title, String text, String[] buttons, int defaultOption, String rememberID, 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.

      Use open(UserPrompterResultListener)

      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 interface UIFunctionsUserPrompter
    • 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, String text2)
      Parameters:
      textComposite -
      text2 -
      Returns:
    • createLinkLabel

      private org.eclipse.swt.widgets.Canvas createLinkLabel(org.eclipse.swt.widgets.Composite shell, String text)
    • getHtml

      public String getHtml()
      Description copied from interface: UIFunctionsUserPrompter
      Returns the HTML that will be displayed along with the prompt

      TODO: Create a boolean canHandleHTML()

      Specified by:
      getHtml in interface UIFunctionsUserPrompter
      Returns:
    • setHtml

      public void setHtml(String html)
      Specified by:
      setHtml in interface UIFunctionsUserPrompter
      Parameters:
      html -
    • setUrl

      public void setUrl(String url)
      Specified by:
      setUrl in interface UIFunctionsUserPrompter
      Parameters:
      url -
    • setSize

      public void setSize(int width, int height)
    • getRememberID

      public String getRememberID()
      Description copied from interface: UIFunctionsUserPrompter
      Retrieves the Remember ID associated with this prompt
      Specified by:
      getRememberID in interface UIFunctionsUserPrompter
      Returns:
      the rememberID
    • setRemember

      public void setRemember(String rememberID, boolean rememberByDefault, String rememberText)
      Specified by:
      setRemember in interface UIFunctionsUserPrompter
      Parameters:
      rememberID -
      rememberByDefault -
      rememberText - null if you want the default
    • getRememberText

      public String getRememberText()
      Description copied from interface: UIFunctionsUserPrompter
      Retrieves the text to be displayed by the "Remember this Action" checkbox
      Specified by:
      getRememberText in interface UIFunctionsUserPrompter
      Returns:
      the rememberText
    • setRememberText

      public void setRememberText(String rememberText)
      Specified by:
      setRememberText in interface UIFunctionsUserPrompter
      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
      invalid reference
      #open()
      is called), and typically does not decrease while the user is viewing the prompt (certain implementations may operate differently)
      Specified by:
      getAutoCloseInMS in interface UIFunctionsUserPrompter
      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
      invalid reference
      #open()
      is called), and typically does not decrease while the user is viewing the prompt (certain implementations may operate differently)
      Specified by:
      setAutoCloseInMS in interface UIFunctionsUserPrompter
      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
      invalid reference
      #open()
      was called, or if the user chose an option.
      Specified by:
      isAutoClosed in interface UIFunctionsUserPrompter
      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(Object relatedObject)
      Specified by:
      setRelatedObject in interface UIFunctionsUserPrompter
      Parameters:
      relatedObject -
    • setRelatedObjects

      public void setRelatedObjects(Object[] relatedObjects)
      Specified by:
      setRelatedObjects in interface UIFunctionsUserPrompter
    • getRelatedObjects

      public Object[] getRelatedObjects()
    • getLeftImage

      public 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(String resource)
      Specified by:
      setIconResource in interface UIFunctionsUserPrompter
      Parameters:
      resource - image repository resource name (e.g. "error", "warning", "info")
    • main

      public static void main(String[] args)
    • getRememberOnlyIfButton

      public int getRememberOnlyIfButton()
    • setRememberOnlyIfButton

      public void setRememberOnlyIfButton(int rememberOnlyIfButton)
      Specified by:
      setRememberOnlyIfButton in interface UIFunctionsUserPrompter
      Parameters:
      rememberOnlyIfButton -
    • 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 interface UIFunctionsUserPrompter
    • getResult

      public int getResult()
    • swtButtonStylesToText

      private static Object[] swtButtonStylesToText(int style)
    • getButtons

      public String[] getButtons()
    • setButtons

      public void setButtons(String[] buttons)
    • setButtons

      public void setButtons(int defaltButtonPos, String[] buttons, Integer[] buttonVals)
    • addCheckBox

      public void addCheckBox(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(String id)
    • setOneInstanceOf

      public void setOneInstanceOf(String instanceID)
      Description copied from interface: UIFunctionsUserPrompter
      Prevent more than one dialog of instanceID from showing up at once
      Specified by:
      setOneInstanceOf in interface UIFunctionsUserPrompter
      Parameters:
      instanceID -