org.formaria.editor.eclipse.project.pages
Class EditorUtility

java.lang.Object
  extended by org.formaria.editor.eclipse.project.pages.EditorUtility
All Implemented Interfaces:
IEditorUtility

public class EditorUtility
extends java.lang.Object
implements IEditorUtility

A utility class to help interact with the NetBeans editors


Field Summary
 
Fields inherited from interface org.formaria.editor.project.pages.IEditorUtility
FRAME_HEIGHT, FRAME_WIDTH
 
Constructor Summary
EditorUtility()
          Creates a new instance of EditorUtility
 
Method Summary
 boolean activateEditor(PageResource pageRes, boolean activate)
          Activate the source code editor for this page
 void addJar(EditorProject currentProject, java.net.URL jarUrl)
          Add a jar reference to the project class path.
 boolean canImportDbTable(java.awt.datatransfer.DataFlavor transferFlavor)
          Indicates whether a database table can be imported from a given data flavor.
 void copy(java.io.InputStream in, java.io.OutputStream out)
          Copies data from "in" to "out"
 void copyToClipboard(java.lang.String text)
          Copy text to the clipboard
 Page getCachedPage(EditorProject currentProject, PageResource pageRes)
          If the page xml has been cached we want to use that xml to generate the page otherwise we just return the page contained in the pageRes object
 java.sql.Connection getDbConnection(java.lang.Object obj)
          Get database connection
 java.lang.String getDbConnectionName(java.lang.Object tableObject)
          Get the database connection name
 java.lang.String getDbDriver(java.lang.Object obj)
          Get the database connection driver
 java.lang.String getDbDriverFile(java.lang.Object obj)
          Get the path to the file (zip, jar) containing the jdbc driver used to connect the the database.
 java.lang.String getDbPassword(java.lang.Object obj)
          Get database connection password It cannot be obtained from the Connection object
 java.lang.String getDbTableName(java.lang.Object obj)
          Get database table name
 java.lang.ClassLoader getEditorClassLoader(EditorProject project)
          Gets the class loader being used by the editor to load resources of the specified project.
 javax.swing.JEditorPane getEditorPane(java.awt.Container cont)
          Search the container for an instance of JEditorPane
 javax.swing.JEditorPane getEditorPane(java.lang.String fileName)
          Search the container for an instance of JEditorPane
 java.lang.Object[] getHandlerMethods(EditorProject currentProject, java.lang.String fileName)
          Get a list of the methods provided by the page class
 Modifiable getPageDataObject(EditorProject currentProject, java.lang.String name)
          Retrieve the PageDataObject for the page with the passed name
 java.lang.String getPlatform()
           
 java.net.URL[] getProjectURLs(EditorProject project)
          Gets the class path URLs of the given project
 boolean hasMethod(EditorProject currentProject, java.lang.String fileName, java.lang.String methodName)
          Check if a method is already contained within the direct superclass
 void insertTextAtCaret(java.lang.Object sce, java.lang.String newText)
           
 boolean isEclipse()
          Is this an eclipse plugin?
 boolean isValid(java.lang.Object sourceCodeEditor)
           
 java.awt.Image loadImage(java.lang.String name)
           
 boolean locateMethod(Project currentProject, PageResource pageRes, java.lang.Object sce, java.lang.String methodName, java.lang.String searchText, boolean addNew, boolean ctrlDown)
           
 void markDirty(EditorProject project)
          Mark the project as dirty
 boolean openSourceFile(EditorProject currentProject, PageResource pr, java.lang.String fileName)
           
 void requestActive(java.lang.Object window)
           
 boolean setSourceCodeEditor(PageResource pageRes, java.lang.String fileName)
          Set the source code editor for the pageResource
 void showErrorMessage(java.lang.String msg, java.lang.String title)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EditorUtility

public EditorUtility()
Creates a new instance of EditorUtility

Method Detail

setSourceCodeEditor

public boolean setSourceCodeEditor(PageResource pageRes,
                                   java.lang.String fileName)
Set the source code editor for the pageResource

Specified by:
setSourceCodeEditor in interface IEditorUtility

activateEditor

public boolean activateEditor(PageResource pageRes,
                              boolean activate)
Activate the source code editor for this page

Specified by:
activateEditor in interface IEditorUtility
Parameters:
pageRes - the page resource that owns the source
activate - force the source editor to display if true
Returns:
true if the editor is open and has been activated, otherwise false

getEditorPane

public javax.swing.JEditorPane getEditorPane(java.awt.Container cont)
Search the container for an instance of JEditorPane

Specified by:
getEditorPane in interface IEditorUtility
Parameters:
cont - the container to search
Returns:
the editor or null if none is found

getEditorPane

public javax.swing.JEditorPane getEditorPane(java.lang.String fileName)
Search the container for an instance of JEditorPane

Specified by:
getEditorPane in interface IEditorUtility
Parameters:
cont - the container to search
Returns:
the editor or null if none is found

getPageDataObject

public Modifiable getPageDataObject(EditorProject currentProject,
                                    java.lang.String name)
Retrieve the PageDataObject for the page with the passed name

Specified by:
getPageDataObject in interface IEditorUtility
Parameters:
name - the name of the page whose PageDataObject we wish to retrieve
Returns:
the PageDataObject

getCachedPage

public Page getCachedPage(EditorProject currentProject,
                          PageResource pageRes)
If the page xml has been cached we want to use that xml to generate the page otherwise we just return the page contained in the pageRes object

Specified by:
getCachedPage in interface IEditorUtility
Parameters:
pageRes - the pageResource we're checking
Returns:
the newly parsed page or the page in the pageRes

requestActive

public void requestActive(java.lang.Object window)
Specified by:
requestActive in interface IEditorUtility

locateMethod

public boolean locateMethod(Project currentProject,
                            PageResource pageRes,
                            java.lang.Object sce,
                            java.lang.String methodName,
                            java.lang.String searchText,
                            boolean addNew,
                            boolean ctrlDown)
Specified by:
locateMethod in interface IEditorUtility

insertTextAtCaret

public void insertTextAtCaret(java.lang.Object sce,
                              java.lang.String newText)
Specified by:
insertTextAtCaret in interface IEditorUtility

isValid

public boolean isValid(java.lang.Object sourceCodeEditor)
Specified by:
isValid in interface IEditorUtility

openSourceFile

public boolean openSourceFile(EditorProject currentProject,
                              PageResource pr,
                              java.lang.String fileName)
Specified by:
openSourceFile in interface IEditorUtility

copy

public void copy(java.io.InputStream in,
                 java.io.OutputStream out)
Copies data from "in" to "out"

Specified by:
copy in interface IEditorUtility

hasMethod

public boolean hasMethod(EditorProject currentProject,
                         java.lang.String fileName,
                         java.lang.String methodName)
Check if a method is already contained within the direct superclass

Specified by:
hasMethod in interface IEditorUtility
Parameters:
currentProject - the current project
fileName - the full file name for the enclosing class
methodName - the bare method name e.g. 'showPrevious'

getHandlerMethods

public java.lang.Object[] getHandlerMethods(EditorProject currentProject,
                                            java.lang.String fileName)
Description copied from interface: IEditorUtility
Get a list of the methods provided by the page class

Specified by:
getHandlerMethods in interface IEditorUtility
Parameters:
currentProject - the current project
fileName - the full file name for the enclosing class

loadImage

public java.awt.Image loadImage(java.lang.String name)
Specified by:
loadImage in interface IEditorUtility

copyToClipboard

public void copyToClipboard(java.lang.String text)
Copy text to the clipboard

Specified by:
copyToClipboard in interface IEditorUtility
Parameters:
text - the text to be copied

getDbDriverFile

public java.lang.String getDbDriverFile(java.lang.Object obj)
Get the path to the file (zip, jar) containing the jdbc driver used to connect the the database. This method is fragile, it works with nb5.5 but can break in the next version.

Specified by:
getDbDriverFile in interface IEditorUtility
Parameters:
tableNode - the table node object from which the db driver path will be otained.

getDbPassword

public java.lang.String getDbPassword(java.lang.Object obj)
Get database connection password It cannot be obtained from the Connection object

Specified by:
getDbPassword in interface IEditorUtility
Parameters:
obj - from which password is to be obtained
Returns:
database connection password

getDbTableName

public java.lang.String getDbTableName(java.lang.Object obj)
Get database table name

Specified by:
getDbTableName in interface IEditorUtility
Parameters:
obj - from which database driver name is to be obtained
Returns:
database table name

getDbConnection

public java.sql.Connection getDbConnection(java.lang.Object obj)
Description copied from interface: IEditorUtility
Get database connection

Specified by:
getDbConnection in interface IEditorUtility
Parameters:
obj - the object that the connection is to be obtained from
Returns:
the database connection

getDbConnectionName

public java.lang.String getDbConnectionName(java.lang.Object tableObject)
Get the database connection name

Specified by:
getDbConnectionName in interface IEditorUtility
Parameters:
tableObject - object containing connection name
Returns:
connection name

getDbDriver

public java.lang.String getDbDriver(java.lang.Object obj)
Get the database connection driver

Specified by:
getDbDriver in interface IEditorUtility
Parameters:
obj - the object from which the database connection is to be obtained
Returns:
the database driver

getPlatform

public java.lang.String getPlatform()
Specified by:
getPlatform in interface IEditorUtility

showErrorMessage

public void showErrorMessage(java.lang.String msg,
                             java.lang.String title)
Specified by:
showErrorMessage in interface IEditorUtility

addJar

public void addJar(EditorProject currentProject,
                   java.net.URL jarUrl)
Add a jar reference to the project class path. Only add the jar if it is not already present

Specified by:
addJar in interface IEditorUtility
Parameters:
currentProject - the current project
jarUrl - the jar to add

canImportDbTable

public boolean canImportDbTable(java.awt.datatransfer.DataFlavor transferFlavor)
Indicates whether a database table can be imported from a given data flavor.

Specified by:
canImportDbTable in interface IEditorUtility
Returns:
true if database table can be imported, false otherwise

isEclipse

public boolean isEclipse()
Is this an eclipse plugin?

Specified by:
isEclipse in interface IEditorUtility
Returns:
true if the plugin is designed to run on eclipse

getEditorClassLoader

public java.lang.ClassLoader getEditorClassLoader(EditorProject project)
Gets the class loader being used by the editor to load resources of the specified project.

Specified by:
getEditorClassLoader in interface IEditorUtility
Parameters:
project - project the classloader of which is to be obtained
Returns:
the ClassLoader object

getProjectURLs

public java.net.URL[] getProjectURLs(EditorProject project)
Gets the class path URLs of the given project

Specified by:
getProjectURLs in interface IEditorUtility
Parameters:
project - project whose class path entries will be returned
Returns:
table containing class path URLs

markDirty

public void markDirty(EditorProject project)
Mark the project as dirty

Specified by:
markDirty in interface IEditorUtility
Parameters:
project - the current project