Extension SDK 10.1.2

oracle.ide.util
Class IdeUtil

java.lang.Object
  extended byoracle.ide.util.IdeUtil

public final class IdeUtil
extends java.lang.Object


Field Summary
static java.lang.String MAIN_WINDOW_KEY
           
static java.lang.String PROGRAM_NAME_KEY
           
 
Method Summary
static void addAll(java.util.Collection target, java.util.Iterator toAdd)
          Adds all objects in the Iterator to target.
static void addAll(java.util.Collection target, java.lang.Object[] toAdd)
          Adds all objects in toAdd to target.
static void addComboBoxDocumentListener(javax.swing.JComboBox jcomboBox, javax.swing.event.DocumentListener documentListener)
           
static void centerTreeSelection(javax.swing.JTree tree)
          Centers the current tree selection within its scroll pane.
static void centerWindow(java.awt.Container parent, java.awt.Component child)
          Center a component over another.
static void comboBoxSelectItem(javax.swing.JComboBox comboBox, java.lang.Object item)
           
static int compareToCurrentDocumentVersion(java.net.URL fileToOpen)
          Compares the version of the URL passed in (which MUST be a URL pointing to either a project or workspace file) to the version of JDeveloper that is attempting to open the file.
static java.lang.String[] convertStringToStringArray(java.lang.String s)
           
static java.lang.String[] convertStringToStringArray(java.lang.String s, boolean allowQuotedStrings, boolean keepQuotes)
           
static void copyToClipboard(java.lang.String s)
           
static java.util.Collection distinct(java.util.Collection source, java.util.Comparator comparator)
          Eliminates the doublons from source.
static void expandAllTreeRows(javax.swing.JTree tree)
          Expands all the rows in the specified JTree.
static void expandTreeToDepth(javax.swing.JTree tree, int depth)
          Expands the rows in the specified JTree up to the specified tree depth; all other rows are collapsed.
static java.awt.Window findActiveModalWindow()
          Finds the window in the container hierarchy which is visible, modal and active.
static java.awt.Dialog findDialog(java.awt.Component component)
          Finds the first parent of the specified Component that is an instance of Dialog.
static java.awt.Frame findFrame(java.awt.Component component)
           
static java.lang.String getDigitsFromString(java.lang.String inString)
          Takes a string and strips out any non-digit characters and returns an int
static java.lang.String getDocumentVersion(java.net.URL url)
          Reads the header information of the file pointed to by the given url and determines the version number.
static java.lang.String getIdeEncoding()
          Retrieves the IDE-wide encoding.
static java.lang.String getIdeIanaEncoding()
          Retrieves the IDE-wide IANA encoding.
static java.awt.Frame getMainWindow()
           
static java.lang.String getProgramName()
           
static java.lang.String getSubString(java.lang.String sIn, char c, boolean bBefore)
          Returns the string before the first occurence of c if bBefore is true or the string after the first occurence of c if bBefore is false
static javax.swing.Icon grayIcon(javax.swing.Icon icon)
           
static void invokeAfterRepaint(java.lang.Runnable runnable)
          This method is similar to SwingUtilities.invokeLater(Runnable) except that the runnable is started after all the pending repaints.
static boolean isDocumentVersionCurrent(java.net.URL url)
          Reads the header information of the file pointed to by the given url and determines if the version number in the file matches the current product version.
static boolean isJavaIdentifier(java.lang.String name)
          Returns true if the specified String is a valid Java identifier.
static boolean isJavaKeyword(java.lang.String name)
          Returns true if the specified String is a Java keyword.
static boolean isJavaReservedWord(java.lang.String name)
          Returns true if the specified String is a Java reserved word.
static boolean isPackageIdentifier(java.lang.String name)
          Returns true if the specified String is a valid package identifier.
static java.lang.String list2String(java.util.List list)
           
static java.awt.Component moveFocusAway()
          Since the JDK sends inconsistent focus messages when a focused component is removed from the screen, it is often necessary to move that focus away before to move a component to another container or to remove the component.
static java.lang.String prepad(java.lang.String s, char c, int len)
          Return a string where the beginning of the string has been padded to obtain a desired length.
static java.lang.String removeChars(java.lang.String sIn, java.lang.String sRemove)
          Return a sIn without any character found is sRemove
static java.lang.String replaceHTMLReservedCharacters(java.lang.String s)
          Replaces teh HTML reserved characters with the appropriate entity.
static void runNow(java.lang.Runnable r)
           
static void setIdeEncoding(java.lang.String encoding)
          Sets the IDE-wide encoding.
static void setMainWindow(javax.swing.JFrame frame)
           
static void setProgramName(java.lang.String name)
           
static void setStartupWindow(javax.swing.JFrame frame)
          The startup window is a JFrame upon which dialogs and other UI may be parented before the showing of the main window.
static void showErrorDialog(java.awt.Component parent, java.lang.String title, java.lang.String message)
          Deprecated. use oracle.ide.dialogs.MessageDialog.alert()
static void showInfoDialog(java.awt.Component parent, java.lang.String title, java.lang.String message)
          Deprecated. use oracle.ide.dialogs.MessageDialog.information()
static void showPopupMenu(javax.swing.JPopupMenu popup, java.awt.Component invoker, int x, int y)
          Deprecated. Replace with MenuUtils.showPopupMenu(JPopupMenu,Component,int,int).
static void string2List(java.lang.String string, java.util.List list)
           
static void tryToRestoreFocus(java.awt.Component cPreferred)
          This method tries to set the focus on cPreferred.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAIN_WINDOW_KEY

public static final java.lang.String MAIN_WINDOW_KEY
See Also:
Constant Field Values

PROGRAM_NAME_KEY

public static final java.lang.String PROGRAM_NAME_KEY
See Also:
Constant Field Values
Method Detail

centerWindow

public static void centerWindow(java.awt.Container parent,
                                java.awt.Component child)
Center a component over another. If parent is null, the component is centered over the screen.


centerTreeSelection

public static void centerTreeSelection(javax.swing.JTree tree)
Centers the current tree selection within its scroll pane. If the specified JTree is null or is not hosted in a JScrollPane, the this method does nothing.

Parameters:
tree - The JTree whose selection is to be centered.

expandAllTreeRows

public static void expandAllTreeRows(javax.swing.JTree tree)
Expands all the rows in the specified JTree. This method assumes that the JTree is in single-selection mode; if any row was selected prior to expanding all rows, then that row will remain selected after all rows have been expanded.


expandTreeToDepth

public static void expandTreeToDepth(javax.swing.JTree tree,
                                     int depth)
Expands the rows in the specified JTree up to the specified tree depth; all other rows are collapsed. The depth of a row is defined as the length of the TreePath's path for that row.

This method assumes that the JTree is in single-selection mode; if any row was selected prior to expanding all rows, then that row will remain selected after all rows have been expanded.

Parameters:
tree - the JTree to expand.
depth - the desired expansion depth; a depth of <=0 expands all rows in the tree.

findDialog

public static java.awt.Dialog findDialog(java.awt.Component component)
Finds the first parent of the specified Component that is an instance of Dialog. If the component itself is a Dialog, then it is returned. If the component is null then null is returned.


findFrame

public static java.awt.Frame findFrame(java.awt.Component component)

isJavaKeyword

public static boolean isJavaKeyword(java.lang.String name)
Returns true if the specified String is a Java keyword.

Parameters:
name - the String to test.

isJavaReservedWord

public static boolean isJavaReservedWord(java.lang.String name)
Returns true if the specified String is a Java reserved word. A Java reserved word is either a keyword, a boolean literal, or the null literal.

Parameters:
name - the String to test.

isJavaIdentifier

public static boolean isJavaIdentifier(java.lang.String name)
Returns true if the specified String is a valid Java identifier.

Parameters:
name - the String to test.

isPackageIdentifier

public static boolean isPackageIdentifier(java.lang.String name)
Returns true if the specified String is a valid package identifier.


list2String

public static java.lang.String list2String(java.util.List list)

string2List

public static void string2List(java.lang.String string,
                               java.util.List list)

convertStringToStringArray

public static java.lang.String[] convertStringToStringArray(java.lang.String s)

convertStringToStringArray

public static java.lang.String[] convertStringToStringArray(java.lang.String s,
                                                            boolean allowQuotedStrings,
                                                            boolean keepQuotes)

getSubString

public static java.lang.String getSubString(java.lang.String sIn,
                                            char c,
                                            boolean bBefore)
Returns the string before the first occurence of c if bBefore is true or the string after the first occurence of c if bBefore is false


removeChars

public static java.lang.String removeChars(java.lang.String sIn,
                                           java.lang.String sRemove)
Return a sIn without any character found is sRemove


prepad

public static java.lang.String prepad(java.lang.String s,
                                      char c,
                                      int len)
Return a string where the beginning of the string has been padded to obtain a desired length.

Parameters:
s - the String to pad.
c - the character to use when padding.
len - the desired length of the string.

addAll

public static void addAll(java.util.Collection target,
                          java.lang.Object[] toAdd)
Adds all objects in toAdd to target.

Parameters:
target - the Collection to which the elements are added.
toAdd - the objects to add to the target. Cannot be null.

addAll

public static void addAll(java.util.Collection target,
                          java.util.Iterator toAdd)
Adds all objects in the Iterator to target.

Parameters:
target - the Collection to which the elements are added.
toAdd - the objects to add to the target. Cannot be null.

distinct

public static java.util.Collection distinct(java.util.Collection source,
                                            java.util.Comparator comparator)
Eliminates the doublons from source.

Parameters:
source - The source collection
comparator - Used to decide if two elements are unique.
Returns:
returns a set of disctinct elements

showErrorDialog

public static void showErrorDialog(java.awt.Component parent,
                                   java.lang.String title,
                                   java.lang.String message)
Deprecated. use oracle.ide.dialogs.MessageDialog.alert()

Shows an error dialog containing the specified message and an OK button. The message is displayed using a wrapping label that attempts to proportion its X and Y sizes to have a 5:1 aspect ratio.


showInfoDialog

public static void showInfoDialog(java.awt.Component parent,
                                  java.lang.String title,
                                  java.lang.String message)
Deprecated. use oracle.ide.dialogs.MessageDialog.information()

Shows an info dialog containing the specified message and an OK button. The message is displayed using a wrapping label that attempts to proportion its X and Y sizes to have a 5:1 aspect ratio.


isDocumentVersionCurrent

public static boolean isDocumentVersionCurrent(java.net.URL url)
Reads the header information of the file pointed to by the given url and determines if the version number in the file matches the current product version. If the document is an XML file, the version number is taken from the XML namespace URI, assuming that the namespace URI follows the format used by JDeveloper. A namespace URI is expected to a have a format like * this: http://xmlns.oracle.com/jdeveloper/#####/... where ##### is the version string and ... is any text after the version string to identify the specific document type.

Returns:
true if the file version matches the current product version or the url points to a new file.

getDocumentVersion

public static java.lang.String getDocumentVersion(java.net.URL url)
Reads the header information of the file pointed to by the given url and determines the version number. If the document is an XML file, the version number is taken from the XML namespace URI, assuming that the namespace URI follows the format used by JDeveloper. A namespace URI is expected to a have a format like this: http://xmlns.oracle.com/jdeveloper/#####/... where ##### is the version string and ... is any text after the version string to identify the specific document type.

Returns:
the version string in the document or null if the version could not be determined. Note that if the file pointed to by the url does not exists, this method assumes this is a new file that will be written using the current product version.

showPopupMenu

public static void showPopupMenu(javax.swing.JPopupMenu popup,
                                 java.awt.Component invoker,
                                 int x,
                                 int y)
Deprecated. Replace with MenuUtils.showPopupMenu(JPopupMenu,Component,int,int).


addComboBoxDocumentListener

public static void addComboBoxDocumentListener(javax.swing.JComboBox jcomboBox,
                                               javax.swing.event.DocumentListener documentListener)

comboBoxSelectItem

public static void comboBoxSelectItem(javax.swing.JComboBox comboBox,
                                      java.lang.Object item)

grayIcon

public static javax.swing.Icon grayIcon(javax.swing.Icon icon)

runNow

public static void runNow(java.lang.Runnable r)

copyToClipboard

public static void copyToClipboard(java.lang.String s)

getMainWindow

public static java.awt.Frame getMainWindow()

setMainWindow

public static void setMainWindow(javax.swing.JFrame frame)

setStartupWindow

public static void setStartupWindow(javax.swing.JFrame frame)
The startup window is a JFrame upon which dialogs and other UI may be parented before the showing of the main window.


getProgramName

public static java.lang.String getProgramName()

setProgramName

public static void setProgramName(java.lang.String name)

getIdeEncoding

public static java.lang.String getIdeEncoding()
Retrieves the IDE-wide encoding.


setIdeEncoding

public static void setIdeEncoding(java.lang.String encoding)
Sets the IDE-wide encoding.


getIdeIanaEncoding

public static java.lang.String getIdeIanaEncoding()
Retrieves the IDE-wide IANA encoding.


replaceHTMLReservedCharacters

public static java.lang.String replaceHTMLReservedCharacters(java.lang.String s)
Replaces teh HTML reserved characters with the appropriate entity.


moveFocusAway

public static java.awt.Component moveFocusAway()
Since the JDK sends inconsistent focus messages when a focused component is removed from the screen, it is often necessary to move that focus away before to move a component to another container or to remove the component. This method moves the focus to the menu bar.

Returns:
the component that had the focus.
See Also:
tryToRestoreFocus(java.awt.Component)

tryToRestoreFocus

public static void tryToRestoreFocus(java.awt.Component cPreferred)
This method tries to set the focus on cPreferred. If cPreferred is null, not visible or disabled, it will focus the top editor. If there is no editor, it tries to activate the first dockable. If there is no dockable visible, I have no idea of what it does.

See Also:
moveFocusAway()

findActiveModalWindow

public static final java.awt.Window findActiveModalWindow()
Finds the window in the container hierarchy which is visible, modal and active.

Returns:
the window, or null if no active modal windows were found.

compareToCurrentDocumentVersion

public static int compareToCurrentDocumentVersion(java.net.URL fileToOpen)
Compares the version of the URL passed in (which MUST be a URL pointing to either a project or workspace file) to the version of JDeveloper that is attempting to open the file.

Returns:
-1 if the fileToOpen is older than the current JDeveloper version; 0 if they are the same version; 1 if the fileToOpen is from a newer version of JDeveloper

getDigitsFromString

public static java.lang.String getDigitsFromString(java.lang.String inString)
Takes a string and strips out any non-digit characters and returns an int

Parameters:
inString -
Returns:
string of the digits found in inString

invokeAfterRepaint

public static void invokeAfterRepaint(java.lang.Runnable runnable)
This method is similar to SwingUtilities.invokeLater(Runnable) except that the runnable is started after all the pending repaints.

Parameters:
runnable -

Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.