org.formaria.editor
Class EditorUtilities

java.lang.Object
  extended by org.formaria.editor.EditorUtilities

public class EditorUtilities
extends java.lang.Object

A collection of useful methods

Copyright (c) Formaria Ltd., 2002-2003

$Revision: 1.13 $

License: see License.txt


Constructor Summary
EditorUtilities()
           
 
Method Summary
static void buildPath(java.io.File file)
           
static void buildPath(java.lang.String path)
           
static void centreDialog(javax.swing.JDialog dlg)
           
static void centreWindow(java.awt.Window window, java.awt.Dimension windowSize)
           
static boolean copy(java.io.InputStream is, java.io.OutputStream os)
          Copy a stream specified by the source path to the target path
static boolean copyFile(java.io.InputStream is, java.lang.String target)
          Copy a file specified by the source path to the target path
static boolean copyFile(Project currentProject, java.lang.Class clazz, java.lang.String source, java.lang.String target, boolean noResMgr)
          Copy a file specified by the source path to the target path
static boolean copyFile(Project currentProject, java.lang.String source, java.lang.String target)
          Copy a file specified by the source path to the target path
static void copyJar(EditorProject currentProject, java.lang.String jarName, java.lang.String defFolder)
          Copy the named jar.
static void copyJar(java.lang.String projectPath, java.lang.String jarName, java.lang.String defFolder)
          Copy the named jar.
static void createDir(java.lang.String filename)
          Create the directory specified by filename
static NanoXmlElement createNanoXmlElement(XmlElement source)
          Create an nanoxml version of the source node if it is not already a nanoxml node
static java.lang.String getComponentClassName(java.awt.Component c)
           
static int replaceFileTokens(java.io.File source, java.lang.String[] sourceTokens, java.lang.String[] replacementTokens)
          Update a file by replacing a set of tokens
static void setDefaultFont(java.awt.Container cont)
          Set the default font for all the components in this container.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EditorUtilities

public EditorUtilities()
Method Detail

copy

public static boolean copy(java.io.InputStream is,
                           java.io.OutputStream os)
Copy a stream specified by the source path to the target path

Parameters:
is - the input stream
os - the stream we want to write to
Returns:
true if the copy operation was successful, otherwise false is returned

copyFile

public static boolean copyFile(java.io.InputStream is,
                               java.lang.String target)
Copy a file specified by the source path to the target path

Parameters:
is - the file input stream
target - the file we want to create
Returns:
true if the copy operation was successful, otherwise false is returned

copyFile

public static boolean copyFile(Project currentProject,
                               java.lang.Class clazz,
                               java.lang.String source,
                               java.lang.String target,
                               boolean noResMgr)
Copy a file specified by the source path to the target path

Parameters:
currentProject - the context for this method
clazz - a class whos classloader will be used to load the resource
source - the file which we want to copy
target - the file we want to create
Returns:
true if the copy operation was successful, otherwise false is returned

buildPath

public static void buildPath(java.lang.String path)

buildPath

public static void buildPath(java.io.File file)

copyFile

public static boolean copyFile(Project currentProject,
                               java.lang.String source,
                               java.lang.String target)
Copy a file specified by the source path to the target path

Parameters:
source - the file which we want to copy
target - the file we want to create
Returns:
true if the copy operation was successful, otherwise false is returned

createDir

public static void createDir(java.lang.String filename)
Create the directory specified by filename

Parameters:
filename - the directory to create

setDefaultFont

public static void setDefaultFont(java.awt.Container cont)
Set the default font for all the components in this container.

Parameters:
cont - the container

centreWindow

public static void centreWindow(java.awt.Window window,
                                java.awt.Dimension windowSize)

centreDialog

public static void centreDialog(javax.swing.JDialog dlg)

getComponentClassName

public static java.lang.String getComponentClassName(java.awt.Component c)

copyJar

public static void copyJar(EditorProject currentProject,
                           java.lang.String jarName,
                           java.lang.String defFolder)
Copy the named jar.


copyJar

public static void copyJar(java.lang.String projectPath,
                           java.lang.String jarName,
                           java.lang.String defFolder)
Copy the named jar.


replaceFileTokens

public static int replaceFileTokens(java.io.File source,
                                    java.lang.String[] sourceTokens,
                                    java.lang.String[] replacementTokens)
Update a file by replacing a set of tokens

Parameters:
source - the file to read and modify
sourceTokens - the tokens to find and replace
replacementTokens - the new values to insert in the file
Returns:
the number of values changed, or -1 on error

createNanoXmlElement

public static NanoXmlElement createNanoXmlElement(XmlElement source)
Create an nanoxml version of the source node if it is not already a nanoxml node

Parameters:
source - the source xml node
Returns: