Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.gjt.sp.jedit
Class GUIUtilities  view GUIUtilities download GUIUtilities.java

java.lang.Object
  extended byorg.gjt.sp.jedit.GUIUtilities

public class GUIUtilities
extends java.lang.Object

Various GUI functions.

The most frequently used members of this class are:

Version:
$Id: GUIUtilities.java,v 1.77 2003/11/02 21:16:37 spestov Exp $

Nested Class Summary
(package private) static class GUIUtilities.UnixWorkaround
           
 
Field Summary
private static java.lang.String defaultIconPath
           
static javax.swing.Icon DIRTY_BUFFER_ICON
           
private static java.lang.String iconPath
           
private static java.util.Hashtable icons
           
static javax.swing.Icon NEW_BUFFER_ICON
           
static javax.swing.Icon NORMAL_BUFFER_ICON
           
static javax.swing.Icon READ_ONLY_BUFFER_ICON
           
private static org.gjt.sp.jedit.gui.SplashScreen splash
           
static javax.swing.Icon WINDOW_ICON
           
 
Constructor Summary
private GUIUtilities()
           
 
Method Summary
static void adjustForScreenBounds(java.awt.Rectangle desired)
          Gives a rectangle the specified bounds, ensuring it is within the screen bounds.
(package private) static void advanceSplashProgress()
           
static void centerOnScreen(java.awt.Window win)
          Centers the given window on the screen.
static int confirm(java.awt.Component comp, java.lang.String name, java.lang.Object[] args, int buttons, int type)
          Displays a confirm dialog box and returns the button pushed by the user.
static javax.swing.JComponent createMultilineLabel(java.lang.String str)
          Creates a component that displays a multiple line message.
static void error(java.awt.Component comp, java.lang.String name, java.lang.Object[] args)
          Displays an error dialog box.
static java.lang.String getColorHexString(java.awt.Color c)
          Converts a color object to its hex value.
static java.awt.Component getComponentParent(java.awt.Component comp, java.lang.Class clazz)
          Finds a parent of the specified component.
static java.awt.Image getEditorIcon()
          Returns the default editor window image.
static int getExtendedState(java.awt.Frame frame)
          On Java 1.4, calls Frame.getExtendedState().
static javax.swing.JDialog getParentDialog(java.awt.Component c)
          Traverses the given component's parent tree looking for an instance of JDialog, and return it.
static java.awt.Image getPluginIcon()
          Returns the default plugin window image.
static java.lang.String getStyleString(org.gjt.sp.jedit.syntax.SyntaxStyle style)
          Converts a style into it's string representation.
static View getView(java.awt.Component comp)
          Finds the view parent of the specified component.
static void hideSplashScreen()
          Ensures that the splash screen is not visible.
(package private) static void init()
           
static java.lang.String input(java.awt.Component comp, java.lang.String name, java.lang.Object def)
          Displays an input dialog box and returns any text the user entered.
static java.lang.String input(java.awt.Component comp, java.lang.String name, java.lang.Object[] args, java.lang.Object def)
          Displays an input dialog box and returns any text the user entered.
static java.lang.String inputProperty(java.awt.Component comp, java.lang.String name, java.lang.Object[] args, java.lang.String def)
          Displays an input dialog box and returns any text the user entered.
static java.lang.String inputProperty(java.awt.Component comp, java.lang.String name, java.lang.String def)
          Displays an input dialog box and returns any text the user entered.
static boolean isAncestorOf(java.awt.Component comp1, java.awt.Component comp2)
          Returns if the first component is an ancestor of the second by traversing up the component hierarchy.
static boolean isMiddleButton(int modifiers)
           
static boolean isPopupTrigger(java.awt.event.MouseEvent evt)
          Returns if the specified event is the popup trigger event.
static boolean isRightButton(int modifiers)
           
static void loadGeometry(java.awt.Window win, java.lang.String name)
          Loads a windows's geometry from the properties.
static javax.swing.Icon loadIcon(java.lang.String iconName)
          Loads an icon.
static javax.swing.JMenu loadMenu(ActionContext context, java.lang.String name)
          Creates a menu.
static javax.swing.JMenu loadMenu(java.lang.String name)
          Creates a menu.
static javax.swing.JMenuBar loadMenuBar(ActionContext context, java.lang.String name)
          Creates a menubar.
static javax.swing.JMenuBar loadMenuBar(java.lang.String name)
          Creates a menubar.
static javax.swing.JMenuItem loadMenuItem(ActionContext context, java.lang.String name, boolean setMnemonic)
          Creates a menu item.
static javax.swing.JMenuItem loadMenuItem(java.lang.String name)
          Creates a menu item.
static javax.swing.JMenuItem loadMenuItem(java.lang.String name, boolean setMnemonic)
          Creates a menu item.
static javax.swing.JPopupMenu loadPopupMenu(ActionContext context, java.lang.String name)
          Creates a popup menu.
static javax.swing.JPopupMenu loadPopupMenu(java.lang.String name)
          Creates a popup menu.
static org.gjt.sp.jedit.syntax.SyntaxStyle[] loadStyles(java.lang.String family, int size)
          Loads the syntax styles from the properties, giving them the specified base font family and size.
static org.gjt.sp.jedit.syntax.SyntaxStyle[] loadStyles(java.lang.String family, int size, boolean color)
          Loads the syntax styles from the properties, giving them the specified base font family and size.
static javax.swing.Box loadToolBar(ActionContext context, java.lang.String name)
          Creates a toolbar.
static javax.swing.Box loadToolBar(java.lang.String name)
          Creates a toolbar.
static org.gjt.sp.jedit.gui.EnhancedButton loadToolButton(ActionContext context, java.lang.String name)
          Loads a tool bar button.
static org.gjt.sp.jedit.gui.EnhancedButton loadToolButton(java.lang.String name)
          Loads a tool bar button.
static void message(java.awt.Component comp, java.lang.String name, java.lang.Object[] args)
          Displays a dialog box.
static java.awt.Color parseColor(java.lang.String name)
          Converts a color name to a color object.
static java.awt.Color parseColor(java.lang.String name, java.awt.Color defaultColor)
           
static org.gjt.sp.jedit.syntax.SyntaxStyle parseStyle(java.lang.String str, java.lang.String family, int size)
          Converts a style string to a style object.
static org.gjt.sp.jedit.syntax.SyntaxStyle parseStyle(java.lang.String str, java.lang.String family, int size, boolean color)
          Converts a style string to a style object.
static java.lang.String prettifyMenuLabel(java.lang.String label)
          `Prettifies' a menu item label by removing the `$' sign.
static void requestFocus(java.awt.Window win, java.awt.Component comp)
          Focuses on the specified component as soon as the window becomes active.
static void saveGeometry(java.awt.Window win, java.lang.String name)
          Saves a window's geometry to the properties.
static void setExtendedState(java.awt.Frame frame, int extState)
          On Java 1.4, calls Frame.setExtendedState().
static void setIconPath(java.lang.String iconPath)
          Sets the path where jEdit looks for icons.
static void showPopupMenu(javax.swing.JPopupMenu popup, java.awt.Component comp, int x, int y)
          Shows the specified popup menu, ensuring it is displayed within the bounds of the screen.
static void showPopupMenu(javax.swing.JPopupMenu popup, java.awt.Component comp, int x, int y, boolean point)
          Shows the specified popup menu, ensuring it is displayed within the bounds of the screen.
(package private) static void showSplashScreen()
           
static java.lang.String[] showVFSFileDialog(View view, java.lang.String path, int type, boolean multipleSelection)
          Displays a VFS file selection dialog box.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEW_BUFFER_ICON

public static javax.swing.Icon NEW_BUFFER_ICON

DIRTY_BUFFER_ICON

public static javax.swing.Icon DIRTY_BUFFER_ICON

READ_ONLY_BUFFER_ICON

public static javax.swing.Icon READ_ONLY_BUFFER_ICON

NORMAL_BUFFER_ICON

public static javax.swing.Icon NORMAL_BUFFER_ICON

WINDOW_ICON

public static javax.swing.Icon WINDOW_ICON

splash

private static org.gjt.sp.jedit.gui.SplashScreen splash

icons

private static java.util.Hashtable icons

iconPath

private static java.lang.String iconPath

defaultIconPath

private static java.lang.String defaultIconPath
Constructor Detail

GUIUtilities

private GUIUtilities()
Method Detail

setIconPath

public static void setIconPath(java.lang.String iconPath)
Sets the path where jEdit looks for icons.

Since:
jEdit 4.2pre5

loadIcon

public static javax.swing.Icon loadIcon(java.lang.String iconName)
Loads an icon.

Since:
jEdit 2.6pre7

getEditorIcon

public static java.awt.Image getEditorIcon()
Returns the default editor window image.


getPluginIcon

public static java.awt.Image getPluginIcon()
Returns the default plugin window image.


loadMenuBar

public static javax.swing.JMenuBar loadMenuBar(java.lang.String name)
Creates a menubar. Plugins should not need to call this method.

Since:
jEdit 3.2pre5

loadMenuBar

public static javax.swing.JMenuBar loadMenuBar(ActionContext context,
                                               java.lang.String name)
Creates a menubar. Plugins should not need to call this method.

Since:
jEdit 4.2pre1

loadMenu

public static javax.swing.JMenu loadMenu(java.lang.String name)
Creates a menu. The menu label is set from the name.label property. The menu contents is taken from the name property, which is a whitespace separated list of action names. An action name of - inserts a separator in the menu.

Since:
jEdit 2.6pre2

loadMenu

public static javax.swing.JMenu loadMenu(ActionContext context,
                                         java.lang.String name)
Creates a menu. The menu label is set from the name.label property. The menu contents is taken from the name property, which is a whitespace separated list of action names. An action name of - inserts a separator in the menu.

Since:
jEdit 4.2pre1

loadPopupMenu

public static javax.swing.JPopupMenu loadPopupMenu(java.lang.String name)
Creates a popup menu.

Since:
jEdit 2.6pre2

loadPopupMenu

public static javax.swing.JPopupMenu loadPopupMenu(ActionContext context,
                                                   java.lang.String name)
Creates a popup menu.

Since:
jEdit 4.2pre1

loadMenuItem

public static javax.swing.JMenuItem loadMenuItem(java.lang.String name)
Creates a menu item. The menu item is bound to the action named by name with label taken from the return value of the EditAction.getLabel() 55 method.

Since:
jEdit 2.6pre1

loadMenuItem

public static javax.swing.JMenuItem loadMenuItem(java.lang.String name,
                                                 boolean setMnemonic)
Creates a menu item.

Since:
jEdit 3.1pre1

loadMenuItem

public static javax.swing.JMenuItem loadMenuItem(ActionContext context,
                                                 java.lang.String name,
                                                 boolean setMnemonic)
Creates a menu item.

Since:
jEdit 4.2pre1

loadToolBar

public static javax.swing.Box loadToolBar(java.lang.String name)
Creates a toolbar.

Since:
jEdit 4.2pre2

loadToolBar

public static javax.swing.Box loadToolBar(ActionContext context,
                                          java.lang.String name)
Creates a toolbar.

Since:
jEdit 4.2pre2

loadToolButton

public static org.gjt.sp.jedit.gui.EnhancedButton loadToolButton(java.lang.String name)
Loads a tool bar button. The tooltip is constructed from the name.label and name.shortcut properties and the icon is loaded from the resource named '/org/gjt/sp/jedit/icons/' suffixed with the value of the name.icon property.


loadToolButton

public static org.gjt.sp.jedit.gui.EnhancedButton loadToolButton(ActionContext context,
                                                                 java.lang.String name)
Loads a tool bar button. The tooltip is constructed from the name.label and name.shortcut properties and the icon is loaded from the resource named '/org/gjt/sp/jedit/icons/' suffixed with the value of the name.icon property.

Since:
jEdit 4.2pre1

prettifyMenuLabel

public static java.lang.String prettifyMenuLabel(java.lang.String label)
`Prettifies' a menu item label by removing the `$' sign. This can be used to process the contents of an action.label property.


message

public static void message(java.awt.Component comp,
                           java.lang.String name,
                           java.lang.Object[] args)
Displays a dialog box. The title of the dialog is fetched from the name.title property. The message is fetched from the name.message property. The message is formatted by the property manager with args as positional parameters.


error

public static void error(java.awt.Component comp,
                         java.lang.String name,
                         java.lang.Object[] args)
Displays an error dialog box. The title of the dialog is fetched from the name.title property. The message is fetched from the name.message property. The message is formatted by the property manager with args as positional parameters.


input

public static java.lang.String input(java.awt.Component comp,
                                     java.lang.String name,
                                     java.lang.Object def)
Displays an input dialog box and returns any text the user entered. The title of the dialog is fetched from the name.title property. The message is fetched from the name.message property.


inputProperty

public static java.lang.String inputProperty(java.awt.Component comp,
                                             java.lang.String name,
                                             java.lang.String def)
Displays an input dialog box and returns any text the user entered. The title of the dialog is fetched from the name.title property. The message is fetched from the name.message property.


input

public static java.lang.String input(java.awt.Component comp,
                                     java.lang.String name,
                                     java.lang.Object[] args,
                                     java.lang.Object def)
Displays an input dialog box and returns any text the user entered. The title of the dialog is fetched from the name.title property. The message is fetched from the name.message property.

Since:
jEdit 3.1pre3

inputProperty

public static java.lang.String inputProperty(java.awt.Component comp,
                                             java.lang.String name,
                                             java.lang.Object[] args,
                                             java.lang.String def)
Displays an input dialog box and returns any text the user entered. The title of the dialog is fetched from the name.title property. The message is fetched from the name.message property.

Since:
jEdit 3.1pre3

confirm

public static int confirm(java.awt.Component comp,
                          java.lang.String name,
                          java.lang.Object[] args,
                          int buttons,
                          int type)
Displays a confirm dialog box and returns the button pushed by the user. The title of the dialog is fetched from the name.title property. The message is fetched from the name.message property.

Since:
jEdit 3.1pre3

showVFSFileDialog

public static java.lang.String[] showVFSFileDialog(View view,
                                                   java.lang.String path,
                                                   int type,
                                                   boolean multipleSelection)
Displays a VFS file selection dialog box.

Since:
jEdit 2.6pre2

parseColor

public static java.awt.Color parseColor(java.lang.String name)
Converts a color name to a color object. The name must either be a known string, such as `red', `green', etc (complete list is in the java.awt.Color class) or a hex color value prefixed with `#', for example `#ff0088'.


parseColor

public static java.awt.Color parseColor(java.lang.String name,
                                        java.awt.Color defaultColor)

getColorHexString

public static java.lang.String getColorHexString(java.awt.Color c)
Converts a color object to its hex value. The hex value prefixed is with `#', for example `#ff0088'.


parseStyle

public static org.gjt.sp.jedit.syntax.SyntaxStyle parseStyle(java.lang.String str,
                                                             java.lang.String family,
                                                             int size)
                                                      throws java.lang.IllegalArgumentException
Converts a style string to a style object.

Since:
jEdit 3.2pre6

parseStyle

public static org.gjt.sp.jedit.syntax.SyntaxStyle parseStyle(java.lang.String str,
                                                             java.lang.String family,
                                                             int size,
                                                             boolean color)
                                                      throws java.lang.IllegalArgumentException
Converts a style string to a style object.

Since:
jEdit 4.0pre4

getStyleString

public static java.lang.String getStyleString(org.gjt.sp.jedit.syntax.SyntaxStyle style)
Converts a style into it's string representation.


loadStyles

public static org.gjt.sp.jedit.syntax.SyntaxStyle[] loadStyles(java.lang.String family,
                                                               int size)
Loads the syntax styles from the properties, giving them the specified base font family and size.

Since:
jEdit 3.2pre6

loadStyles

public static org.gjt.sp.jedit.syntax.SyntaxStyle[] loadStyles(java.lang.String family,
                                                               int size,
                                                               boolean color)
Loads the syntax styles from the properties, giving them the specified base font family and size.

Since:
jEdit 4.0pre4

loadGeometry

public static void loadGeometry(java.awt.Window win,
                                java.lang.String name)
Loads a windows's geometry from the properties. The geometry is loaded from the name.x, name.y, name.width and name.height properties.


adjustForScreenBounds

public static void adjustForScreenBounds(java.awt.Rectangle desired)
Gives a rectangle the specified bounds, ensuring it is within the screen bounds.

Since:
jEdit 4.2pre3

saveGeometry

public static void saveGeometry(java.awt.Window win,
                                java.lang.String name)
Saves a window's geometry to the properties. The geometry is saved to the name.x, name.y, name.width and name.height properties.


getExtendedState

public static int getExtendedState(java.awt.Frame frame)
On Java 1.4, calls Frame.getExtendedState(). On Java 1.3, returns 0.

Since:
jEdit 4.2pre1

setExtendedState

public static void setExtendedState(java.awt.Frame frame,
                                    int extState)
On Java 1.4, calls Frame.setExtendedState(). On Java 1.3, does nothing.

Since:
jEdit 4.2pre1

centerOnScreen

public static void centerOnScreen(java.awt.Window win)
Centers the given window on the screen. This method is needed because JDK 1.3 does not have a JWindow.setLocationRelativeTo() method.

Since:
jEdit 4.2pre3

hideSplashScreen

public static void hideSplashScreen()
Ensures that the splash screen is not visible. This should be called before displaying any dialog boxes or windows at startup.


createMultilineLabel

public static javax.swing.JComponent createMultilineLabel(java.lang.String str)
Creates a component that displays a multiple line message. This is implemented by assembling a number of JLabels in a JPanel.

Since:
jEdit 4.1pre3

requestFocus

public static void requestFocus(java.awt.Window win,
                                java.awt.Component comp)
Focuses on the specified component as soon as the window becomes active.


isPopupTrigger

public static boolean isPopupTrigger(java.awt.event.MouseEvent evt)
Returns if the specified event is the popup trigger event. This implements precisely defined behavior, as opposed to MouseEvent.isPopupTrigger().

Since:
jEdit 3.2pre8

isMiddleButton

public static boolean isMiddleButton(int modifiers)
Since:
jEdit 4.1pre9

isRightButton

public static boolean isRightButton(int modifiers)
Since:
jEdit 4.1pre9

showPopupMenu

public static void showPopupMenu(javax.swing.JPopupMenu popup,
                                 java.awt.Component comp,
                                 int x,
                                 int y)
Shows the specified popup menu, ensuring it is displayed within the bounds of the screen.

Since:
jEdit 4.0pre1

showPopupMenu

public static void showPopupMenu(javax.swing.JPopupMenu popup,
                                 java.awt.Component comp,
                                 int x,
                                 int y,
                                 boolean point)
Shows the specified popup menu, ensuring it is displayed within the bounds of the screen.

Since:
jEdit 4.1pre1

isAncestorOf

public static boolean isAncestorOf(java.awt.Component comp1,
                                   java.awt.Component comp2)
Returns if the first component is an ancestor of the second by traversing up the component hierarchy.

Since:
jEdit 4.1pre5

getParentDialog

public static javax.swing.JDialog getParentDialog(java.awt.Component c)
Traverses the given component's parent tree looking for an instance of JDialog, and return it. If not found, return null.


getComponentParent

public static java.awt.Component getComponentParent(java.awt.Component comp,
                                                    java.lang.Class clazz)
Finds a parent of the specified component.

Since:
jEdit 4.2pre1

getView

public static View getView(java.awt.Component comp)
Finds the view parent of the specified component.

Since:
jEdit 4.0pre2

init

static void init()

showSplashScreen

static void showSplashScreen()

advanceSplashProgress

static void advanceSplashProgress()