net.refractions.udig.ui.export
Class FileExportOperation

java.lang.Object
  extended by net.refractions.udig.ui.export.FileExportOperation
All Implemented Interfaces:
IOp

public class FileExportOperation
extends java.lang.Object
implements IOp

Abstract class can be used to implement your ow "export to" opperations.

Based on ExportSLD by Jesse, contains ideas inspired by CIP.

I hope this can involve into a general export tool, where the prompt

Since:
1.0.0
Author:
Jesse

Nested Class Summary
protected  class FileExportOperation.PromptAndExport
          Responsible for asking the user for a filename and calleding exporTo.
 
Field Summary
 
Fields inherited from interface net.refractions.udig.ui.operations.IOp
EXTENSION_POINT
 
Constructor Summary
FileExportOperation()
           
 
Method Summary
 boolean canExport(java.lang.Object target)
          Let the extention point perform any additional checks before bothering the users with a prompt.
 java.lang.String defaultName(java.lang.Object target)
          Defalt name for provided target.
 void exportTo(java.lang.Object target, java.io.File file, IProgressMonitor monitor)
          Subclass should override to actually do something.
 java.lang.String[] getExtentions()
          Called by getFilterExtentions (example "sld").
 java.lang.String[] getFilterExtentions()
          Override as required (example "*.sld").
 java.lang.String[] getFilterNames()
          Override as required (example "Style Layer Descriptor document").
 void op(Display display, java.lang.Object target, IProgressMonitor monitor)
          This method is called in a non ui thread...
 java.lang.String prompt(java.lang.Object target)
          Prompt to use for title (example: "Export to")
 java.io.File promptFile(Display display, java.lang.Object target)
          Asks the users for a filename to export to ...
 void status(java.lang.String msg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileExportOperation

public FileExportOperation()
Method Detail

canExport

public boolean canExport(java.lang.Object target)
Let the extention point perform any additional checks before bothering the users with a prompt.

The extention point lets you specify the exact interface (or class) required. This method returns true, but could be used to perform a more indepth check of say a Layer's Schema to pervent the export of a SimpleFeatureType with multiple Geometry attributes being exported as a Shapefile.

Parameters:
target - Target to be considered for export
Returns:
true if non null, subclass can overrride with additional tests

exportTo

public void exportTo(java.lang.Object target,
                     java.io.File file,
                     IProgressMonitor monitor)
              throws java.lang.Exception
Subclass should override to actually do something.

Parameters:
target -
file -
monitor -
Throws:
java.lang.Exception

prompt

public java.lang.String prompt(java.lang.Object target)
Prompt to use for title (example: "Export to")

Parameters:
target -
Returns:
Prompt (may be based on target), should be internationalized

defaultName

public java.lang.String defaultName(java.lang.Object target)
Defalt name for provided target.

Should make use of provided target's title if available. This will be combined with the first filter extention to form a valid filename.

Parameters:
target -
Returns:
Default filename based on target, default is "new"

getFilterExtentions

public java.lang.String[] getFilterExtentions()
Override as required (example "*.sld").

Returns:
filter, default "*.*"

getExtentions

public java.lang.String[] getExtentions()
Called by getFilterExtentions (example "sld").

Returns:
filter, default "*"

getFilterNames

public java.lang.String[] getFilterNames()
Override as required (example "Style Layer Descriptor document").

Care should be taken to internationalization these.

Returns:
Filter names, default "All Files"

promptFile

public java.io.File promptFile(Display display,
                               java.lang.Object target)
Asks the users for a filename to export to ...

If the user asks for an existing filename they will be prompted to confirm that they do indeed wish to replace. If they press Yes the existing file will be removed so the opperation can repalce it, if they select false the they will be reprompted.

Parameters:
display - Display used to prompt with
target - Target (may be used to figure out prompt)
Returns:
File or null to be used to export

op

public void op(Display display,
               java.lang.Object target,
               IProgressMonitor monitor)
        throws java.lang.Exception
This method is called in a non ui thread...

Specified by:
op in interface IOp
target - the object that the operation operates on. This parameter will be the same as the type declared in targetClass of the operation extension. If the enablesFor attribute of the operation extension is not 1 or undefined then target will be an array of objects of the type declared in targetClass.
Throws:
java.lang.Exception

status

public void status(java.lang.String msg)
Parameters:
msg - Display msg on status bar (if possible)