Class Utils

java.lang.Object
com.biglybt.ui.swt.Utils

public class Utils extends Object
  • Field Details

    • hasDPIUtils

      static final boolean hasDPIUtils
    • GOOD_STRING

      public static final String GOOD_STRING
      See Also:
    • isGTK

      public static final boolean isGTK
    • isGTK3

      public static boolean isGTK3
    • LAST_TABLECOLUMN_EXPANDS

      public static final boolean LAST_TABLECOLUMN_EXPANDS
      Some platforms expand the last column to fit the remaining width of the table.
    • TABLE_GRIDLINE_IS_ALTERNATING_COLOR

      public static final boolean TABLE_GRIDLINE_IS_ALTERNATING_COLOR
      GTK already handles alternating background for tables
    • BUTTON_MARGIN

      public static int BUTTON_MARGIN
    • BUTTON_MINWIDTH

      public static int BUTTON_MINWIDTH
    • SCT_SKINNING_DISABLED

      public static final int SCT_SKINNING_DISABLED
      See Also:
    • SCT_NONE

      public static final int SCT_NONE
      See Also:
    • SCT_BUBBLE_TEXT_BOX

      public static final int SCT_BUBBLE_TEXT_BOX
      See Also:
    • SCT_MENU_ITEM

      public static final int SCT_MENU_ITEM
      See Also:
    • DEBUG_SWTEXEC

      private static final boolean DEBUG_SWTEXEC
      Debug/Diagnose SWT exec calls. Provides useful information like how many we are queuing up, and how long each call takes. Good to turn on occasionally to see if we coded something stupid.
    • queue

      private static ArrayList<Runnable> queue
    • diag_logger

      private static AEDiagnosticsLogger diag_logger
    • shellIcons

      private static org.eclipse.swt.graphics.Image[] shellIcons
    • icon128

      private static org.eclipse.swt.graphics.Image icon128
    • EMPTY_RECT

      public static final org.eclipse.swt.graphics.Rectangle EMPTY_RECT
    • userMode

      private static int userMode
    • isAZ2

      private static boolean isAZ2
    • isAZ3

      private static boolean isAZ3
    • evidenceGenerator

      private static AEDiagnosticsEvidenceGenerator evidenceGenerator
    • configUserModeListener

      private static ParameterListener configUserModeListener
    • configUIListener

      private static ParameterListener configUIListener
    • configOtherListener

      private static ParameterListener configOtherListener
    • terminated

      private static boolean terminated
    • SWT_VERSION

      private static final int SWT_VERSION
    • SWT_REVISION

      private static final int SWT_REVISION
    • SWT_PLATFORM

      private static final String SWT_PLATFORM
    • is_dark_appearance

      private static Boolean is_dark_appearance
    • force_dark_appearance

      private static boolean force_dark_appearance
    • skinner

      private static Utils.Skinner skinner
    • skinning_enabled

      private static int skinning_enabled
    • dark_misc_things

      private static volatile boolean dark_misc_things
    • gradient_fill

      private static volatile boolean gradient_fill
    • gui_refresh_disable_when_min

      private static volatile boolean gui_refresh_disable_when_min
    • gui_is_minimized

      private static volatile boolean gui_is_minimized
    • gui_refresh_enable

      private static volatile boolean gui_refresh_enable
    • SHELL_METRICS_DISABLED_KEY

      private static String SHELL_METRICS_DISABLED_KEY
    • display

      private static org.eclipse.swt.widgets.Display display
    • quick_view_active

      private static Set<DiskManagerFileInfo> quick_view_active
    • quick_view_event

      private static TimerEventPeriodic quick_view_event
    • dragDetectMask

      private static volatile int dragDetectMask
    • listeners

      private static CopyOnWriteList<Utils.TerminateListener> listeners
    • USE_ASYNC_EXEC_QUEUE

      static final boolean USE_ASYNC_EXEC_QUEUE
      Since:
      3.0.4.3
      See Also:
    • async_seq

      static AtomicInteger async_seq
    • async_exec_q

      static ConcurrentLinkedQueue<Object[]> async_exec_q
    • async_runner

      static Runnable async_runner
    • pending_ext_urls

      private static Set<String> pending_ext_urls
    • ext_url_dispatcher

      private static AsyncDispatcher ext_url_dispatcher
    • i2p_install_active_for_url

      private static boolean i2p_install_active_for_url
    • browser_install_active_for_url

      private static boolean browser_install_active_for_url
    • tb_installing

      private static boolean tb_installing
    • PL_SHOW_FILE

      public static final String PL_SHOW_FILE
      See Also:
    • truncatedTextCache

      private static Map truncatedTextCache
    • THREAD_NAME_OFFSWT

      public static final String THREAD_NAME_OFFSWT
      See Also:
    • tp

      private static ThreadPool tp
    • qv_exts

      private static Set<String> qv_exts
    • qv_max_bytes

      private static int qv_max_bytes
    • pconfigQuickViewListeners

      private static ParameterListener pconfigQuickViewListeners
    • RELAYOUT_UP_STOP_HERE

      public static final String RELAYOUT_UP_STOP_HERE
      See Also:
    • tt_enabled

      private static boolean tt_enabled
    • a_pattern

      private static Pattern a_pattern
    • href_pattern

      private static Pattern href_pattern
    • dl_depth

      private static AtomicInteger dl_depth
  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • initStatic

      static void initStatic(Core core)
    • initialize

      public static void initialize(org.eclipse.swt.widgets.Display _display)
    • setSkinningEnabled

      public static void setSkinningEnabled(boolean enabled)
    • setSkinnedControlType

      public static void setSkinnedControlType(org.eclipse.swt.widgets.Control control, int type)
    • setSkinnedForegroundDefault

      private static void setSkinnedForegroundDefault(org.eclipse.swt.widgets.Control control, org.eclipse.swt.graphics.Color color)
    • setSkinnedBackgroundDefault

      private static void setSkinnedBackgroundDefault(org.eclipse.swt.widgets.Control control, org.eclipse.swt.graphics.Color color)
    • setSkinnedForegroundDefault

      private static void setSkinnedForegroundDefault(org.eclipse.swt.custom.CTabItem control, org.eclipse.swt.graphics.Color color)
    • hasSkinnedForeground

      public static boolean hasSkinnedForeground(org.eclipse.swt.widgets.Control control)
    • setSkinnedForeground

      public static void setSkinnedForeground(org.eclipse.swt.widgets.Control control, org.eclipse.swt.graphics.Color color)
    • setSkinnedForeground

      public static void setSkinnedForeground(org.eclipse.swt.widgets.Control control, org.eclipse.swt.graphics.Color color, boolean force)
    • getSkinnedForeground

      public static org.eclipse.swt.graphics.Color getSkinnedForeground(org.eclipse.swt.widgets.Control c)
    • hasSkinnedBackground

      public static boolean hasSkinnedBackground(org.eclipse.swt.widgets.Control control)
    • getSkinnedBackground

      public static org.eclipse.swt.graphics.Color getSkinnedBackground(org.eclipse.swt.widgets.Control c)
    • setSkinnedBackground

      public static void setSkinnedBackground(org.eclipse.swt.widgets.Control control, org.eclipse.swt.graphics.Color color)
    • setSkinnedBackground

      public static void setSkinnedBackground(org.eclipse.swt.widgets.Control control, org.eclipse.swt.graphics.Color color, boolean force)
    • setSkinnedBackground

      public static void setSkinnedBackground(org.eclipse.swt.widgets.Control control, org.eclipse.swt.widgets.Control from)
    • createSkinnedLabelSeparator

      public static org.eclipse.swt.widgets.Control createSkinnedLabelSeparator(org.eclipse.swt.widgets.Composite parent, int style)
    • createSkinnedLabelSeparator

      public static org.eclipse.swt.widgets.Control createSkinnedLabelSeparator(org.eclipse.swt.widgets.Composite parent, int style, org.eclipse.swt.graphics.Color color)
    • createSkinnedComposite

      public static org.eclipse.swt.widgets.Composite createSkinnedComposite(org.eclipse.swt.widgets.Composite parent, int style, Object parentLayoutData)
    • createSkinnedCompositeEx

      public static org.eclipse.swt.widgets.Composite[] createSkinnedCompositeEx(org.eclipse.swt.widgets.Composite parent, int style, Object parentLayoutData)
    • createSkinnedGroup

      public static org.eclipse.swt.widgets.Group createSkinnedGroup(org.eclipse.swt.widgets.Composite parent, int style)
    • setLinkForeground

      public static void setLinkForeground(org.eclipse.swt.widgets.Control label)
    • getDragDetectModifiers

      public static int getDragDetectModifiers()
    • getSWTVersion

      public static int getSWTVersion()
    • getSWTRevision

      public static int getSWTRevision()
    • getSWTPlatform

      public static String getSWTPlatform()
    • getSWTVersionAndRevision

      public static String getSWTVersionAndRevision()
    • getDeviceZoom

      public static int getDeviceZoom()
    • setUIVisible

      public static void setUIVisible(boolean visible)
    • isUIUpdateEnabled

      public static boolean isUIUpdateEnabled()
    • addTerminateListener

      public static void addTerminateListener(Utils.TerminateListener l)
    • setTerminated

      public static void setTerminated()
    • isTerminated

      public static boolean isTerminated()
    • isAZ2UI

      public static boolean isAZ2UI()
    • isAZ3UI

      public static boolean isAZ3UI()
    • getUserMode

      public static int getUserMode()
    • setEnabled

      public static void setEnabled(org.eclipse.swt.widgets.Composite composite, boolean enabled)
    • disposeComposite

      public static void disposeComposite(org.eclipse.swt.widgets.Composite composite, boolean disposeSelf)
    • disposeComposite

      public static void disposeComposite(org.eclipse.swt.widgets.Composite composite)
    • disposeSWTObjects

      public static void disposeSWTObjects(List disposeList)
      Dispose of a list of SWT objects
      Parameters:
      disposeList -
    • disposeSWTObjects

      public static void disposeSWTObjects(Object... disposeList)
    • getLinkFromClipboard

      public static String getLinkFromClipboard(org.eclipse.swt.widgets.Display display)

      Gets a URL from the clipboard

      The supported protocols currently are http, https and udp.

      Parameters:
      display -
      Returns:
      first valid link from clipboard, else "http://"
    • centreWindow

      public static void centreWindow(org.eclipse.swt.widgets.Shell shell)
    • centreWindow

      public static void centreWindow(org.eclipse.swt.widgets.Shell shell, boolean shrink_if_needed)
    • centerWindowRelativeTo

      public static void centerWindowRelativeTo(org.eclipse.swt.widgets.Shell window, org.eclipse.swt.widgets.Control control)
      Centers a window relative to a control. That is to say, the window will be located at the center of the control.
      Parameters:
      window -
      control -
    • getCustomColors

      public static List<org.eclipse.swt.graphics.RGB> getCustomColors()
    • updateCustomColors

      public static void updateCustomColors(org.eclipse.swt.graphics.RGB[] new_cc)
    • getConfigColor

      public static org.eclipse.swt.graphics.Color getConfigColor(String name, org.eclipse.swt.graphics.Color def)
    • setConfigColor

      public static void setConfigColor(String name, org.eclipse.swt.graphics.Color c)
    • createColorButton

      public static Utils.ColorButton createColorButton(org.eclipse.swt.widgets.Composite composite, org.eclipse.swt.graphics.Point size, boolean isForeground, int[] existingColor, int[] defaultColor, Consumer<int[]> listener)
    • showColorDialog

      public static org.eclipse.swt.graphics.RGB showColorDialog(org.eclipse.swt.widgets.Control parent, org.eclipse.swt.graphics.RGB existing)
    • showColorDialog

      public static org.eclipse.swt.graphics.RGB showColorDialog(org.eclipse.swt.widgets.Shell parent_shell, org.eclipse.swt.graphics.RGB existing)
    • isDisplayDisposed

      public static boolean isDisplayDisposed()
    • getDisplayIfNotDisposing

      public static org.eclipse.swt.widgets.Display getDisplayIfNotDisposing()
    • getSimpleRowLayout

      public static org.eclipse.swt.layout.RowLayout getSimpleRowLayout(boolean fill)
    • getSimpleGridLayout

      public static org.eclipse.swt.layout.GridLayout getSimpleGridLayout(int cols)
    • alternateRowBackground

      public static void alternateRowBackground(org.eclipse.swt.widgets.TableItem item)
    • alternateTableBackground

      public static void alternateTableBackground(org.eclipse.swt.widgets.Table table)
    • setMenuItemImage

      public static void setMenuItemImage(org.eclipse.swt.widgets.MenuItem item, String repoKey)

      Set a MenuItem's image with the given ImageRepository key. In compliance with platform human interface guidelines, the images are not set under Mac OS X.

      Parameters:
      item - SWT MenuItem
      repoKey - ImageRepository image key
      See Also:
    • setMenuItemImage

      public static void setMenuItemImage(MenuItem item, String repoKey)
    • setMenuItemImage

      public static void setMenuItemImage(org.eclipse.swt.custom.CLabel item, String repoKey)
    • setMenuItemImage

      public static void setMenuItemImage(org.eclipse.swt.widgets.MenuItem item, org.eclipse.swt.graphics.Image image)
    • setShellIcon

      public static void setShellIcon(org.eclipse.swt.widgets.Shell shell)
      Sets the shell's Icon(s) to the default App icon. OSX doesn't require an icon, so they are skipped
      Parameters:
      shell -
    • getDisplay

      public static org.eclipse.swt.widgets.Display getDisplay()
    • getDisplay

      private static org.eclipse.swt.widgets.Display getDisplay(boolean warn)
    • execSWTThread

      public static boolean execSWTThread(Runnable code, boolean async)
      Execute code in the Runnable object using SWT's thread. If current thread it already SWT's thread, the code will run immediately. If the current thread is not SWT's, code will be run either synchronously or asynchronously on SWT's thread at the next reasonable opportunity. This method does not catch any exceptions.
      Parameters:
      code - code to run
      async - true if SWT asyncExec, false if SWT syncExec
      Returns:
      success
    • execSWTThreadLater

      public static boolean execSWTThreadLater(int msLater, Runnable code)
      Schedule execution of the code in the Runnable object using SWT's thread. Even if the current thread is the SWT Thread, the code will be scheduled.

      Much like Display.asyncExec, except getting the display is handled for you, and provides the ability to diagnose and monitor scheduled code run.

      Parameters:
      msLater - time to wait before running code on SWT thread. 0 does not mean immediate, but as soon as possible.
      code - Code to run
      Returns:
      success
      Since:
      3.0.4.3
    • isSWTThread

      public static boolean isSWTThread()
    • execSWTThread

      private static boolean execSWTThread(Runnable code, int msLater)
    • makeRunnableSafe

      private static Runnable makeRunnableSafe(Runnable code)
    • execSWTThread

      public static boolean execSWTThread(Runnable code)
      Execute code in the Runnable object using SWT's thread. If current thread it already SWT's thread, the code will run immediately. If the current thread is not SWT's, code will be run asynchronously on SWT's thread at the next reasonable opportunity. This method does not catch any exceptions.
      Parameters:
      code - code to run
      Returns:
      success
    • isThisThreadSWT

      public static boolean isThisThreadSWT()
    • getTableBottomIndex

      public static int getTableBottomIndex(org.eclipse.swt.widgets.Table table, int iTopIndex)
      Bottom Index may be negative. Returns bottom index even if invisible.

      Used by rssfeed

    • launch

      public static void launch(DiskManagerFileInfo fileInfo)
    • launch

      public static void launch(URL url)
    • launch

      public static void launch(Object urlOrFile)
    • launch

      public static void launch(String sFile)
    • launch

      public static void launch(String sFileOriginal, boolean sync)
    • launch

      public static void launch(String sFileOriginal, boolean sync, boolean force_url)
    • launch

      public static void launch(String sFileOriginal, boolean sync, boolean force_url, boolean force_anon)
    • launchFileExplicit

      public static void launchFileExplicit(DiskManagerFileInfo file, String exe)
    • launchFileExplicit

      public static void launchFileExplicit(String sfile, String... cmd_args)
    • fallbackLaunch

      private static boolean fallbackLaunch(String command, String... args)
    • handlePluginLaunch

      private static void handlePluginLaunch(String eb_choice, String net_type, boolean use_plugins, String sFileOriginal, String sFileModified, boolean sync, boolean force_url, boolean force_anon)
    • isInstallingTorBrowser

      public static boolean isInstallingTorBrowser()
    • installTorBrowser

      private static boolean installTorBrowser(String remember_id, boolean[] install_outcome, Runnable callback)
    • getExplicitLauncher

      private static String getExplicitLauncher(String file)
    • getPredefinedExplicitLauncher

      public static String getPredefinedExplicitLauncher(String type)
    • setCheckedInSetData

      public static void setCheckedInSetData(org.eclipse.swt.widgets.TableItem item, boolean checked)
      Sets the checkbox in a Virtual Table while inside a SWT.SetData listener trigger. SWT 3.1 has an OSX bug that needs working around.
      Parameters:
      item -
      checked -
    • linkShellMetricsToConfig

      public static boolean linkShellMetricsToConfig(org.eclipse.swt.widgets.Shell shell, String sConfigPrefix)
    • setShellMetricsConfigEnabled

      public static void setShellMetricsConfigEnabled(org.eclipse.swt.widgets.Shell shell, boolean enabled)
    • hasShellMetricsConfig

      public static boolean hasShellMetricsConfig(String sConfigPrefix)
    • setGridData

      public static org.eclipse.swt.layout.GridData setGridData(org.eclipse.swt.widgets.Composite composite, int gridStyle, org.eclipse.swt.widgets.Control ctrlBestSize, int maxHeight)
    • getFilledFormData

      public static org.eclipse.swt.layout.FormData getFilledFormData()
    • drawImageCenterScaleDown

      public static void drawImageCenterScaleDown(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Image imgSrc, org.eclipse.swt.graphics.Rectangle area)
    • hasAlpha

      public static boolean hasAlpha(org.eclipse.swt.graphics.Image image)
    • drawResizedImage

      public static void drawResizedImage(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight)
    • getResizedImage

      public static org.eclipse.swt.graphics.Image getResizedImage(org.eclipse.swt.graphics.Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destWidth, int destHeight)
    • drawImage

      public static boolean drawImage(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Image image, org.eclipse.swt.graphics.Point srcStart, org.eclipse.swt.graphics.Rectangle dstRect, org.eclipse.swt.graphics.Rectangle clipping, int hOffset, int vOffset, boolean clearArea)
    • findChild

      public static org.eclipse.swt.widgets.Control findChild(org.eclipse.swt.widgets.Composite comp, int x, int y)
    • dump

      public static void dump(org.eclipse.swt.widgets.Control comp)
    • dump

      private static void dump(IndentWriter iw, org.eclipse.swt.widgets.Control comp, Set<Object> done)
    • addListenerAndChildren

      public static void addListenerAndChildren(org.eclipse.swt.widgets.Composite area, int event, org.eclipse.swt.widgets.Listener listener)
      Parameters:
      area -
      event - id
      listener -
    • getActiveShell

      public static org.eclipse.swt.widgets.Shell getActiveShell()
    • findAnyShell

      public static org.eclipse.swt.widgets.Shell findAnyShell()
    • findAnyShell

      public static org.eclipse.swt.widgets.Shell findAnyShell(boolean preferMainShell)
    • verifyShellRect

      public static boolean verifyShellRect(org.eclipse.swt.widgets.Shell shell, boolean bAdjustIfInvalid)
    • verifyShellRect

      private static boolean verifyShellRect(org.eclipse.swt.widgets.Shell shell, boolean bAdjustIfInvalid, boolean reverifyOnChange)
    • relayout

      public static void relayout(org.eclipse.swt.widgets.Control control)
      Relayout all composites up from control until there's enough room for the control to fit
      Parameters:
      control - Control that had it's sized changed and needs more room
    • relayout

      public static void relayout(org.eclipse.swt.widgets.Control control, boolean expandOnly)
      Relayout all composites up from control until there's enough room for the control to fit
      Parameters:
      control - Control that had it's sized changed and needs more room
    • beep

      public static void beep()
    • execSWTThreadWithBool

      public static Boolean execSWTThreadWithBool(String ID, AERunnableBoolean code, long millis)
      Runs code within the SWT thread, waits for code to complete executing, (using a semaphore), and then returns a value.
      Parameters:
      ID - id for debug
      code - code to run
      millis - ms to timeout in
      Returns:
      returns NULL if code never run
    • execSWTThreadWithObject

      public static Object execSWTThreadWithObject(String ID, AERunnableObject code, long millis)
      Runs code within the SWT thread, waits for code to complete executing, (using a semaphore), and then returns a value.
      Parameters:
      ID - id for debug
      code - code to run
      millis - ms to timeout in
      Returns:
    • waitForModals

      public static void waitForModals()
      Waits until modal dialogs are disposed. Assumes we are on SWT thread
      Since:
      3.0.1.3
    • getWrappableLabelGridData

      public static org.eclipse.swt.layout.GridData getWrappableLabelGridData(int hspan, int styles)
    • getHSpanGridData

      public static org.eclipse.swt.layout.GridData getHSpanGridData(int hspan, int styles)
    • createAlphaImage

      public static org.eclipse.swt.graphics.Image createAlphaImage(org.eclipse.swt.graphics.Device device, int width, int height)
    • createAlphaImage

      public static org.eclipse.swt.graphics.Image createAlphaImage(org.eclipse.swt.graphics.Device device, int width, int height, byte defaultAlpha)
    • blitImage

      public static org.eclipse.swt.graphics.Image blitImage(org.eclipse.swt.graphics.Device device, org.eclipse.swt.graphics.Image srcImage, org.eclipse.swt.graphics.Rectangle srcArea, org.eclipse.swt.graphics.Image dstImage, org.eclipse.swt.graphics.Point dstPos)
    • drawStriped

      public static void drawStriped(org.eclipse.swt.graphics.GC gcImg, int x, int y, int width, int height, int lineDist, int leftshift, boolean fallingLines)
      Draws diagonal stripes onto the specified area of a GC
      Parameters:
      lineDist - spacing between the individual lines
      leftshift - moves the stripes to the left, useful to shift with the background
      fallingLines - true for top left to bottom-right lines, false otherwise
    • renderTransparency

      public static org.eclipse.swt.graphics.Image renderTransparency(org.eclipse.swt.widgets.Display display, org.eclipse.swt.graphics.Image background, org.eclipse.swt.graphics.Image foreground, org.eclipse.swt.graphics.Point foregroundOffsetOnBg, int modifyForegroundAlpha)
      Parameters:
      display -
      background -
      foreground -
      foregroundOffsetOnBg -
      modifyForegroundAlpha - 0 (fully transparent) to 255 (retain current alpha)
      Returns:
    • findBackgroundImageControl

      public static org.eclipse.swt.widgets.Control findBackgroundImageControl(org.eclipse.swt.widgets.Control control)
    • anyShellHaveStyle

      public static boolean anyShellHaveStyle(int styles)
      Returns:
      Since:
      3.0.3.5
    • findFirstShellWithStyle

      public static org.eclipse.swt.widgets.Shell findFirstShellWithStyle(int styles)
    • colorToIntArray

      public static int[] colorToIntArray(org.eclipse.swt.graphics.Color color)
    • centerRelativeTo

      public static void centerRelativeTo(org.eclipse.swt.graphics.Rectangle target, org.eclipse.swt.graphics.Rectangle reference)
      Centers the target Rectangle relative to the reference Rectangle
      Parameters:
      target -
      reference -
    • makeVisibleOnCursor

      public static void makeVisibleOnCursor(org.eclipse.swt.graphics.Rectangle rect)
      Ensure that the given Rectangle is fully visible on the monitor that the cursor is currently in. This method does not resize the given Rectangle; it merely reposition it if appropriate. If the given Rectangle is taller or wider than the current monitor then it may not fit 'fully' in the monitor.

      We use a best-effort approach with an emphasis to have at least the top-left of the Rectangle be visible. If the given Rectangle does not fit entirely in the monitor then portion of the right and/or left may be off-screen.

      This method does honor global screen elements when possible. Screen elements include the TaskBar on Windows and the Application menu on OSX, and possibly others. The re-positioned Rectangle returned will fit on the screen without overlapping (or sliding under) these screen elements.

      Parameters:
      rect -
    • makeVisibleOnMonitor

      public static void makeVisibleOnMonitor(org.eclipse.swt.graphics.Rectangle rect, org.eclipse.swt.widgets.Monitor monitor)
      Ensure that the given Rectangle is fully visible on the given Monitor. This method does not resize the given Rectangle; it merely reposition it if appropriate. If the given Rectangle is taller or wider than the current monitor then it may not fit 'fully' in the monitor.

      We use a best-effort approach with an emphasis to have at least the top-left of the Rectangle be visible. If the given Rectangle does not fit entirely in the monitor then portion of the right and/or left may be off-screen.

      This method does honor global screen elements when possible. Screen elements include the TaskBar on Windows and the Application menu on OSX, and possibly others. The re-positioned Rectangle returned will fit on the screen without overlapping (or sliding under) these screen elements.

      Parameters:
      rect -
      monitor -
    • getMonitor

      private static org.eclipse.swt.widgets.Monitor getMonitor(int x, int y)
      Returns the Monitor that the given x,y coordinates resides in
      Parameters:
      x -
      y -
      Returns:
      the monitor if found; otherwise returns null
    • getMonitor

      public static org.eclipse.swt.widgets.Monitor getMonitor(org.eclipse.swt.graphics.Point location)
      Returns the Monitor that the given Point resides in
      Parameters:
      location -
      Returns:
      the monitor if found; otherwise returns null
    • makeButtonsEqualWidth

      public static void makeButtonsEqualWidth(org.eclipse.swt.widgets.Button... buttons)
    • makeButtonsEqualWidth

      public static void makeButtonsEqualWidth(List<org.eclipse.swt.widgets.Button> buttons)
    • createOKCancelButtons

      public static org.eclipse.swt.widgets.Button[] createOKCancelButtons(org.eclipse.swt.widgets.Composite panel)
    • createAlertButton

      public static org.eclipse.swt.widgets.Button createAlertButton(org.eclipse.swt.widgets.Composite panel, String localizationKey)
    • truncateText

      public static String truncateText(org.eclipse.swt.graphics.GC gc, String text, int maxWidth, boolean cache)
    • toColorHexString

      public static String toColorHexString(org.eclipse.swt.graphics.Color color)
      Parameters:
      color -
      Returns:
      Since:
      3.1.1.1
    • twoHex

      private static void twoHex(StringBuffer sb, int h)
    • getWidgetBGColorURLParam

      public static String getWidgetBGColorURLParam()
    • reportError

      public static void reportError(Throwable e)
    • getOffOfSWTThread

      public static void getOffOfSWTThread(Runnable runnable)
    • getOffOfSWTThread

      public static void getOffOfSWTThread(AERunnable runnable)
    • runIfNotSWTThread

      public static boolean runIfNotSWTThread(Runnable code)
      Run code on SWT Thread if we are calling from non-SWT Thread. Otherwise, do nothing and return false

      Use Case:

       void foo() {
         if (Utils.runIfNotSWTThread(this::foo)) {
           return;
         }
         // Do SWT Stuff
       }
       
      Use Case:
       void foo(Object param) {
         if (Utils.runIfNotSWTThread(() -> foo(param)) {
           return;
         }
         // Do SWT Stuff
       }
       
    • createSafeBrowser

      public static BrowserWrapper createSafeBrowser(org.eclipse.swt.widgets.Composite parent, int style)
    • getLocationRelativeToShell

      public static org.eclipse.swt.graphics.Point getLocationRelativeToShell(org.eclipse.swt.widgets.Control control)
    • isQuickViewSupported

      public static boolean isQuickViewSupported(DiskManagerFileInfo file)
    • isQuickViewActive

      public static boolean isQuickViewActive(DiskManagerFileInfo file)
    • setQuickViewActive

      public static void setQuickViewActive(DiskManagerFileInfo file, boolean active)
    • quickView

      private static void quickView(DiskManagerFileInfo file)
    • quickViewRAR

      private static void quickViewRAR(DiskManagerFileInfo file)
    • createSash

      public static org.eclipse.swt.widgets.Sash createSash(org.eclipse.swt.widgets.Composite form, int SASH_WIDTH)
    • createSash

      public static org.eclipse.swt.widgets.Sash createSash(org.eclipse.swt.widgets.Composite form, int SASH_WIDTH, int style)
    • createSashWrapper

      public static Utils.SashWrapper createSashWrapper(org.eclipse.swt.widgets.Composite parent, String config_key, int def_pct)
    • createSashWrapper2

      public static Utils.SashWrapper2 createSashWrapper2(org.eclipse.swt.widgets.Composite parent, String config_key)
    • getCursorControl

      public static org.eclipse.swt.widgets.Control getCursorControl()
      Sometimes, Display.getCursorControl doesn't go deep enough..
    • getCursorControl

      public static org.eclipse.swt.widgets.Control getCursorControl(org.eclipse.swt.widgets.Composite parent, org.eclipse.swt.graphics.Point cursorLocation)
    • relayoutUp

      public static void relayoutUp(org.eclipse.swt.widgets.Composite c)
    • createScrolledComposite

      public static org.eclipse.swt.widgets.Composite createScrolledComposite(org.eclipse.swt.widgets.Composite parent)
      Creates a ScrollComposite that scrolls vertically and handles recalculating size.
      If parent's layout isn't GridLayout, sets parent to GridLayout with 1 column.
      Returns:
      a new Composite that is the main view of the ScrolledComposite. No layout for this composite has been set
    • createScrolledComposite

      public static org.eclipse.swt.widgets.Composite createScrolledComposite(org.eclipse.swt.widgets.Composite parent, int style)
    • createScrolledComposite

      public static org.eclipse.swt.widgets.Composite createScrolledComposite(org.eclipse.swt.widgets.Composite parent, org.eclipse.swt.widgets.Control mega_parent)
    • createScrolledComposite

      private static org.eclipse.swt.widgets.Composite createScrolledComposite(org.eclipse.swt.widgets.Composite parent, int style, org.eclipse.swt.widgets.Control mega_parent)
    • updateScrolledComposite

      public static void updateScrolledComposite(org.eclipse.swt.custom.ScrolledComposite sc)
    • updateScrolledComposite

      protected static void updateScrolledComposite(org.eclipse.swt.custom.ScrolledComposite sc, int style)
    • maintainSashPanelWidth

      public static void maintainSashPanelWidth(org.eclipse.swt.custom.SashForm sash, org.eclipse.swt.widgets.Composite comp, int[] default_weights, String config_key)
    • setClipping

      public static void setClipping(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle r)
    • addAndFireParameterListener

      public static void addAndFireParameterListener(Map<String,ParameterListener> mapConfigListeners, boolean requiresSWTThread, String parameter, ParameterListener listener)
    • removeParameterListeners

      public static void removeParameterListeners(Map<String,ParameterListener> mapListeners)
    • setPeronalShare

      public static boolean setPeronalShare(Map<String,String> properties)
    • getTTEnabled

      public static boolean getTTEnabled()
    • setTT

      public static void setTT(org.eclipse.swt.widgets.Control c, String text)
    • setTT

      public static void setTT(BufferedTruncatedLabel c, String text)
    • setTT

      public static void setTT(org.eclipse.swt.custom.CTabItem c, String text)
    • setTT

      public static void setTT(UISWTStatusEntry c, String text)
    • setTT

      public static void setTT(org.eclipse.swt.widgets.TableColumn c, String text)
    • setTT

      public static void setTT(org.eclipse.swt.widgets.ToolItem c, String text)
    • setTT

      public static void setTT(org.eclipse.swt.widgets.TrayItem c, String text)
    • setTT

      public static void setTT(TrayItemDelegate c, String text)
    • dispose

      public static void dispose()
    • createSubViewID

      public static String createSubViewID(String base, String sub)
    • getBaseViewID

      public static String getBaseViewID(String id)
    • isDarkAppearanceNativeWindows

      public static boolean isDarkAppearanceNativeWindows()
    • isDarkAppearanceNative

      public static boolean isDarkAppearanceNative()
    • isDarkAppearancePartial

      public static boolean isDarkAppearancePartial()
      Hack to switch some things to dark on Windows until proper support available
      Returns:
    • editSpeedLimitHandlerConfig

      public static void editSpeedLimitHandlerConfig(SpeedLimitHandler slh)
    • showText

      public static void showText(String title, String message, List<String> lines)
    • showText

      public static void showText(String title, String message, List<String> lines, Runnable callback)
    • setTextWithURLs

      public static void setTextWithURLs(org.eclipse.swt.custom.StyledText text, String value, boolean allow_focus)
    • escapeAccelerators

      public static String escapeAccelerators(String str)
    • addSafeMouseUpListener

      public static void addSafeMouseUpListener(org.eclipse.swt.widgets.Control control, org.eclipse.swt.widgets.Listener mouseUpListener)
    • addSafeMouseUpListener

      public static void addSafeMouseUpListener(org.eclipse.swt.widgets.Control control, org.eclipse.swt.widgets.Listener mouseDownListener, org.eclipse.swt.widgets.Listener mouseUpListener)
    • createStyledText

      public static org.eclipse.swt.custom.StyledText createStyledText(org.eclipse.swt.widgets.Composite parent, int style)
    • clearMenu

      public static void clearMenu(org.eclipse.swt.widgets.Menu menu)
    • getAllChildren

      public static List<org.eclipse.swt.widgets.Control> getAllChildren(org.eclipse.swt.widgets.Composite c)
    • getAllChildren

      private static void getAllChildren(org.eclipse.swt.widgets.Control c, List<org.eclipse.swt.widgets.Control> kids)
    • getCCString

      public static String getCCString(String cc)
    • resizeImage

      public static org.eclipse.swt.graphics.Image resizeImage(org.eclipse.swt.graphics.Image image, int newWidth, int newHeight)
      Resizes an image, using the given scaling factor. Constructs a new image resource, please take care of resource disposal if you no longer need the original one. This method is optimized for quality, not for speed.
      Parameters:
      image - source image
      Returns:
      scaled image
    • convertToAWT

      private static BufferedImage convertToAWT(org.eclipse.swt.graphics.ImageData data)
    • convertToSWT

      private static org.eclipse.swt.graphics.ImageData convertToSWT(BufferedImage bufferedImage)
    • gradientFillSelection

      public static boolean gradientFillSelection()
    • ensureDisplayUpdated

      public static void ensureDisplayUpdated()
    • readAndDispatchUntilIdle

      public static void readAndDispatchUntilIdle()
    • readAndDispatchLoop

      public static void readAndDispatchLoop(org.eclipse.swt.widgets.Control owner)
    • readAndDispatchLoop

      public static void readAndDispatchLoop(org.eclipse.swt.widgets.Control owner, boolean check_visible)
    • readAndDispatchUntilIdleFor

      public static void readAndDispatchUntilIdleFor(long millis)
    • readAndDispatchUntilIdleOr

      public static void readAndDispatchUntilIdleOr(Supplier<Boolean> done)
    • getDispatchLoopDepth

      public static int getDispatchLoopDepth()
    • readAndDispatchLoop

      public static boolean readAndDispatchLoop(Supplier<Boolean> done)
    • fileExistsWithTimeout

      public static boolean fileExistsWithTimeout(String path)
    • fileExistsWithTimeout

      public static boolean fileExistsWithTimeout(File file)
    • isDirectoryWithTimeout

      public static boolean isDirectoryWithTimeout(File dir)
    • canReadFileWithTimeout

      public static boolean canReadFileWithTimeout(File dir)
    • fileLengthWithTimeout

      public static long fileLengthWithTimeout(File file)
    • getCanonicalPathWithTimeout

      public static String getCanonicalPathWithTimeout(File file) throws IOException
      Throws:
      IOException
    • listFileRootsWithTimeout

      public static File[] listFileRootsWithTimeout()
    • numberPrompt

      public static void numberPrompt(String title_resource, String text_resource, Integer def, Consumer<Integer> cons)