org.gudy.azureus2.ui.swt
Class Utils

java.lang.Object
  extended by org.gudy.azureus2.ui.swt.Utils

public class Utils
extends Object

Author:
Olivier

Field Summary
static int BUTTON_MARGIN
           
static int BUTTON_MINWIDTH
           
static org.eclipse.swt.graphics.Rectangle EMPTY_RECT
           
static String GOOD_STRING
           
static boolean isCarbon
           
static boolean isCocoa
           
static boolean isGTK
           
static boolean isGTK3
           
static boolean LAST_TABLECOLUMN_EXPANDS
          Some platforms expand the last column to fit the remaining width of the table.
static boolean TABLE_GRIDLINE_IS_ALTERNATING_COLOR
          GTK already handles alternating background for tables
 
Constructor Summary
Utils()
           
 
Method Summary
static void addListenerAndChildren(org.eclipse.swt.widgets.Composite area, int event, org.eclipse.swt.widgets.Listener listener)
           
static org.eclipse.swt.graphics.Image adjustPXForDPI(org.eclipse.swt.widgets.Display display, org.eclipse.swt.graphics.Image image)
           
static void adjustPXForDPI(org.eclipse.swt.layout.FormAttachment fa)
           
static void adjustPXForDPI(org.eclipse.swt.layout.FormData fd)
           
static int adjustPXForDPI(int unadjustedPX)
           
static void adjustPXForDPI(Object layoutData)
           
static org.eclipse.swt.graphics.Point adjustPXForDPI(org.eclipse.swt.graphics.Point size)
           
static org.eclipse.swt.graphics.Rectangle adjustPXForDPI(org.eclipse.swt.graphics.Rectangle bounds)
           
static boolean adjustPXForDPIRequired(org.eclipse.swt.graphics.Image image)
           
static void alternateRowBackground(org.eclipse.swt.widgets.TableItem item)
           
static void alternateTableBackground(org.eclipse.swt.widgets.Table table)
           
static boolean anyShellHaveStyle(int styles)
           
static void beep()
           
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)
           
static void centerRelativeTo(org.eclipse.swt.graphics.Rectangle target, org.eclipse.swt.graphics.Rectangle reference)
          Centers the target Rectangle relative to the reference Rectangle
static void centerWindowRelativeTo(org.eclipse.swt.widgets.Shell window, org.eclipse.swt.widgets.Control control)
          Centers a window relative to a control.
static void centreWindow(org.eclipse.swt.widgets.Shell shell)
           
static void centreWindow(org.eclipse.swt.widgets.Shell shell, boolean shrink_if_needed)
           
static int[] colorToIntArray(org.eclipse.swt.graphics.Color color)
           
static org.eclipse.swt.graphics.Image createAlphaImage(org.eclipse.swt.graphics.Device device, int width, int height)
           
static org.eclipse.swt.graphics.Image createAlphaImage(org.eclipse.swt.graphics.Device device, int width, int height, byte defaultAlpha)
           
static BrowserWrapper createSafeBrowser(org.eclipse.swt.widgets.Composite parent, int style)
           
static org.eclipse.swt.widgets.Sash createSash(org.eclipse.swt.widgets.Composite form, int SASH_WIDTH)
           
static void createTorrentDropTarget(org.eclipse.swt.widgets.Composite composite, boolean bAllowShareAdd)
           
static void createURLDropTarget(org.eclipse.swt.widgets.Composite composite, org.eclipse.swt.widgets.Text url)
           
static void disposeComposite(org.eclipse.swt.widgets.Composite composite)
           
static void disposeComposite(org.eclipse.swt.widgets.Composite composite, boolean disposeSelf)
           
static void disposeSWTObjects(List disposeList)
          Dispose of a list of SWT objects
static void disposeSWTObjects(Object[] disposeList)
           
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)
           
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
static void dump(org.eclipse.swt.widgets.Control comp)
           
static boolean execSWTThread(Runnable code)
          Execute code in the Runnable object using SWT's thread.
static boolean execSWTThread(Runnable code, boolean async)
          Execute code in the Runnable object using SWT's thread.
static boolean execSWTThreadLater(int msLater, Runnable code)
          Schedule execution of the code in the Runnable object using SWT's thread.
static Boolean execSWTThreadWithBool(String ID, AERunnableBoolean code)
          Deprecated. Use #execSWTThread(AERunnableWithCallback) to avoid thread locking issues
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.
static Object execSWTThreadWithObject(String ID, AERunnableObject code)
          Deprecated. Use #execSWTThread(AERunnableWithCallback) to avoid thread locking issues
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.
static org.eclipse.swt.widgets.Shell findAnyShell()
           
static org.eclipse.swt.widgets.Control findBackgroundImageControl(org.eclipse.swt.widgets.Control control)
           
static org.eclipse.swt.widgets.Control findChild(org.eclipse.swt.widgets.Composite comp, int x, int y)
           
static org.eclipse.swt.widgets.Shell findFirstShellWithStyle(int styles)
           
static org.eclipse.swt.widgets.Control getCursorControl()
          Sometimes, Display.getCursorControl doesn't go deep enough..
static org.eclipse.swt.widgets.Control getCursorControl(org.eclipse.swt.widgets.Composite parent, org.eclipse.swt.graphics.Point cursorLocation)
           
static org.eclipse.swt.widgets.Display getDisplay()
           
static org.eclipse.swt.layout.FormData getFilledFormData()
           
static int getInitialBrowserStyle(int style)
          Consistently applies the browser style obtained during the first invocation
static String getLinkFromClipboard(org.eclipse.swt.widgets.Display display, boolean accept_magnets, boolean default_magnet)
          Gets an URL from the clipboard if a valid URL for downloading has been copied.
static org.eclipse.swt.graphics.Point getLocationRelativeToShell(org.eclipse.swt.widgets.Control control)
           
static org.eclipse.swt.widgets.Monitor getMonitor(org.eclipse.swt.graphics.Point location)
          Returns the Monitor that the given Point resides in
static void getOffOfSWTThread(AERunnable runnable)
           
static int getTableBottomIndex(org.eclipse.swt.widgets.Table table, int iTopIndex)
          Bottom Index may be negative.
static int getUserMode()
           
static String getWidgetBGColorURLParam()
           
static org.eclipse.swt.layout.GridData getWrappableLabelGridData(int hspan, int styles)
           
static void initialize(org.eclipse.swt.widgets.Display display)
           
static boolean isAZ2UI()
           
static boolean isInstallingTorBrowser()
           
static boolean isQuickViewActive(DiskManagerFileInfo file)
           
static boolean isQuickViewSupported(DiskManagerFileInfo file)
           
static boolean isSWTThread()
           
static boolean isThisThreadSWT()
           
static void launch(DiskManagerFileInfo fileInfo)
           
static void launch(String sFile)
           
static void launch(String sFileOriginal, boolean sync)
           
static void launch(String sFileOriginal, boolean sync, boolean force_url)
           
static void launch(String sFileOriginal, boolean sync, boolean force_url, boolean force_anon)
           
static void launch(URL url)
           
static boolean linkShellMetricsToConfig(org.eclipse.swt.widgets.Shell shell, String sConfigPrefix)
           
static void maintainSashPanelWidth(org.eclipse.swt.custom.SashForm sash, org.eclipse.swt.widgets.Composite comp, int[] default_weights, String config_key)
           
static void makeButtonsEqualWidth(List<org.eclipse.swt.widgets.Button> buttons)
           
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.
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.
static int pixelsToPoint(int pixels, int dpi)
           
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
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
static void relayoutUp(org.eclipse.swt.widgets.Composite c)
           
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)
           
static void reportError(Throwable e)
           
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.
static void setClipping(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle r)
           
static org.eclipse.swt.layout.GridData setGridData(org.eclipse.swt.widgets.Composite composite, int gridStyle, org.eclipse.swt.widgets.Control ctrlBestSize, int maxHeight)
           
static void setLayout(org.eclipse.swt.widgets.Composite composite, org.eclipse.swt.layout.GridLayout layout)
           
static void setLayout(org.eclipse.swt.widgets.Composite composite, org.eclipse.swt.layout.RowLayout layout)
           
static void setLayoutData(BufferedLabel label, org.eclipse.swt.layout.GridData gridData)
           
static void setLayoutData(org.eclipse.swt.widgets.Control widget, org.eclipse.swt.layout.FormData layoutData)
           
static void setLayoutData(org.eclipse.swt.widgets.Control widget, org.eclipse.swt.layout.GridData layoutData)
           
static void setLayoutData(org.eclipse.swt.widgets.Control item, org.eclipse.swt.layout.RowData rowData)
           
static void setMenuItemImage(org.eclipse.swt.custom.CLabel item, String repoKey)
           
static void setMenuItemImage(org.eclipse.swt.widgets.MenuItem item, org.eclipse.swt.graphics.Image image)
           
static void setMenuItemImage(org.eclipse.swt.widgets.MenuItem item, String repoKey)
           Set a MenuItem's image with the given ImageRepository key.
static void setMenuItemImage(MenuItem item, String repoKey)
           
static void setQuickViewActive(DiskManagerFileInfo file, boolean active)
           
static void setShellIcon(org.eclipse.swt.widgets.Shell shell)
          Sets the shell's Icon(s) to the default Azureus icon.
static void setTextLinkFromClipboard(org.eclipse.swt.widgets.Shell shell, org.eclipse.swt.widgets.Text url, boolean accept_magnets, boolean default_magnet)
          Initializes the URL dialog with http:// If a valid link is found in the clipboard, it will be inserted and the size (and location) of the dialog is adjusted.
static org.eclipse.swt.graphics.RGB showColorDialog(org.eclipse.swt.widgets.Composite parent, org.eclipse.swt.graphics.RGB existing)
           
static org.eclipse.swt.graphics.RGB showColorDialog(org.eclipse.swt.widgets.Shell parent_shell, org.eclipse.swt.graphics.RGB existing)
           
static String toColorHexString(org.eclipse.swt.graphics.Color bg)
           
static String truncateText(org.eclipse.swt.graphics.GC gc, String text, int maxWidth, boolean cache)
           
static void updateScrolledComposite(org.eclipse.swt.custom.ScrolledComposite sc)
           
static boolean verifyShellRect(org.eclipse.swt.widgets.Shell shell, boolean bAdjustIfInvalid)
           
static void waitForModals()
          Waits until modal dialogs are disposed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GOOD_STRING

public static final String GOOD_STRING
See Also:
Constant Field Values

isGTK

public static final boolean isGTK

isGTK3

public static final boolean isGTK3

isCarbon

public static final boolean isCarbon

isCocoa

public static final boolean isCocoa

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

EMPTY_RECT

public static final org.eclipse.swt.graphics.Rectangle EMPTY_RECT
Constructor Detail

Utils

public Utils()
Method Detail

initialize

public static void initialize(org.eclipse.swt.widgets.Display display)

isAZ2UI

public static boolean isAZ2UI()

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)

setTextLinkFromClipboard

public static void setTextLinkFromClipboard(org.eclipse.swt.widgets.Shell shell,
                                            org.eclipse.swt.widgets.Text url,
                                            boolean accept_magnets,
                                            boolean default_magnet)
Initializes the URL dialog with http:// If a valid link is found in the clipboard, it will be inserted and the size (and location) of the dialog is adjusted.

Parameters:
shell - to set the dialog location if needed
url - the URL text control
accept_magnets -

getLinkFromClipboard

public static String getLinkFromClipboard(org.eclipse.swt.widgets.Display display,
                                          boolean accept_magnets,
                                          boolean default_magnet)

Gets an URL from the clipboard if a valid URL for downloading has been copied.

The supported protocols currently are http, https, and magnet.

Parameters:
display -
accept_magnets -
Returns:
first valid link from clipboard, else "http://" or "magnet:"

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 -

showColorDialog

public static org.eclipse.swt.graphics.RGB showColorDialog(org.eclipse.swt.widgets.Composite 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)

createTorrentDropTarget

public static void createTorrentDropTarget(org.eclipse.swt.widgets.Composite composite,
                                           boolean bAllowShareAdd)

createURLDropTarget

public static void createURLDropTarget(org.eclipse.swt.widgets.Composite composite,
                                       org.eclipse.swt.widgets.Text url)
Parameters:
control - the control (usually a Shell) to add the DropTarget
url - the Text control where to set the link text

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:
Apple HIG

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 Azureus icon. OSX doesn't require an icon, so they are skipped

Parameters:
shell -

getDisplay

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

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:
sucess
Since:
3.0.4.3

isSWTThread

public static boolean isSWTThread()
Parameters:
code -
msLater - -2: sync
-1: sync if on SWT thread, async otherwise
0: async
>0: timerExec
Returns:
Since:
3.0.4.3

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(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)

isInstallingTorBrowser

public static boolean isInstallingTorBrowser()

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)

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()

pixelsToPoint

public static int pixelsToPoint(int pixels,
                                int dpi)

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)

addListenerAndChildren

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

findAnyShell

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

verifyShellRect

public static boolean verifyShellRect(org.eclipse.swt.widgets.Shell shell,
                                      boolean bAdjustIfInvalid)
Parameters:
listener -

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)
Deprecated. Use #execSWTThread(AERunnableWithCallback) to avoid thread locking issues


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)
Deprecated. Use #execSWTThread(AERunnableWithCallback) to avoid thread locking issues


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)

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

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(List<org.eclipse.swt.widgets.Button> buttons)

getInitialBrowserStyle

public static int getInitialBrowserStyle(int style)
Consistently applies the browser style obtained during the first invocation

Parameters:
style - the style you wish to apply
Returns:
the style, possibly ORed with SWT.MOZILLA

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 bg)
Parameters:
bg -
Returns:
Since:
3.1.1.1

getWidgetBGColorURLParam

public static String getWidgetBGColorURLParam()

reportError

public static void reportError(Throwable e)

getOffOfSWTThread

public static void getOffOfSWTThread(AERunnable runnable)

createSafeBrowser

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

getUserMode

public static int getUserMode()

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)

createSash

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

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)

updateScrolledComposite

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

maintainSashPanelWidth

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

adjustPXForDPI

public static int adjustPXForDPI(int unadjustedPX)

adjustPXForDPI

public static org.eclipse.swt.graphics.Rectangle adjustPXForDPI(org.eclipse.swt.graphics.Rectangle bounds)

adjustPXForDPI

public static org.eclipse.swt.graphics.Point adjustPXForDPI(org.eclipse.swt.graphics.Point size)

adjustPXForDPI

public static void adjustPXForDPI(org.eclipse.swt.layout.FormData fd)

adjustPXForDPI

public static void adjustPXForDPI(org.eclipse.swt.layout.FormAttachment fa)

setLayoutData

public static void setLayoutData(org.eclipse.swt.widgets.Control widget,
                                 org.eclipse.swt.layout.GridData layoutData)

setLayoutData

public static void setLayoutData(org.eclipse.swt.widgets.Control widget,
                                 org.eclipse.swt.layout.FormData layoutData)

setLayoutData

public static void setLayoutData(org.eclipse.swt.widgets.Control item,
                                 org.eclipse.swt.layout.RowData rowData)

setLayoutData

public static void setLayoutData(BufferedLabel label,
                                 org.eclipse.swt.layout.GridData gridData)

adjustPXForDPI

public static void adjustPXForDPI(Object layoutData)

adjustPXForDPIRequired

public static boolean adjustPXForDPIRequired(org.eclipse.swt.graphics.Image image)

adjustPXForDPI

public static org.eclipse.swt.graphics.Image adjustPXForDPI(org.eclipse.swt.widgets.Display display,
                                                            org.eclipse.swt.graphics.Image image)

setLayout

public static void setLayout(org.eclipse.swt.widgets.Composite composite,
                             org.eclipse.swt.layout.GridLayout layout)

setLayout

public static void setLayout(org.eclipse.swt.widgets.Composite composite,
                             org.eclipse.swt.layout.RowLayout layout)

setClipping

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