com.bbn.swede.ui.wizards
Class NewOWLDocumentWizardPage

java.lang.Object
  extended byWizardPage
      extended bycom.bbn.swede.ui.wizards.NewOWLDocumentWizardPage

public class NewOWLDocumentWizardPage
extends WizardPage

Standard main page for a wizard that creates a file resource.

This page may be used by clients as-is; it may be also be subclassed to suit.

Subclasses may override

Subclasses may extend

Author:
tself
See Also:
Serialized Form

Constructor Summary
NewOWLDocumentWizardPage(String pageName, IStructuredSelection selection)
          Creates a new file creation wizard page.
 
Method Summary
protected  void addToOWLModel(IFile file)
          Adds a file resource to the OWL model.
 void createControl(Composite parent)
           
protected  void createFile(IFile fileHandle, InputStream contents, IProgressMonitor monitor)
          Creates a file resource given the file handle and contents.
protected  IFile createFileHandle(IPath filePath)
          Creates a file resource handle for the file with the given workspace path.
 IFile createNewFile()
          Deprecated. As of SWeDE 1.0.2, replaced by createNewFile(InputStream). Creating the input stream externally allows the wizard to recover gracefully and notify the user if the URL is unreachable. See also openStream().
 IFile createNewFile(InputStream input)
          Creates a new file resource in the selected container and with the selected name.
 IPath getContainerFullPath()
          Returns the current full path of the containing resource as entered or selected by the user, or its anticipated initial value.
 String getFileName()
          Returns the current file name as entered by the user, or its anticipated initial value.
protected  InputStream getInitialContents()
          Returns a stream containing the initial contents to be given to new file resource instances.
protected  String getNewFileLabel()
          Returns the label to display in the file name specification visual component group.
protected  String getXMLBase()
          Retrieves the user-provided XML base for the new OWL document.
 void handleEvent(Event event)
          The WizardNewFileCreationPage implementation of this Listener method handles all events and enablements for controls on this page.
protected  void initialPopulateContainerNameField()
          Sets the initial contents of the container name entry field, based upon either a previously-specified initial value or the ability to determine such a value.
 InputStream openStream()
          Returns an input stream for importing an external document.
 void setContainerFullPath(IPath path)
          Sets the value of this page's container name field, or stores it for future use if this page's controls do not exist yet.
 void setFileName(String value)
          Sets the value of this page's file name field, or stores it for future use if this page's controls do not exist yet.
 void setVisible(boolean visible)
           
protected  boolean validatePage()
          Returns whether this page's controls currently all contain valid values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NewOWLDocumentWizardPage

public NewOWLDocumentWizardPage(String pageName,
                                IStructuredSelection selection)
Creates a new file creation wizard page. If the initial resource selection contains exactly one container resource then it will be used as the default container resource.

Parameters:
pageName - the name of the page
selection - the current resource selection
Method Detail

createControl

public void createControl(Composite parent)

addToOWLModel

protected void addToOWLModel(IFile file)
Adds a file resource to the OWL model. Whether it is added as an ordinary or external document depends on the state of the Import checkbox.

Parameters:
file - The file resource

createFile

protected void createFile(IFile fileHandle,
                          InputStream contents,
                          IProgressMonitor monitor)
                   throws CoreException
Creates a file resource given the file handle and contents.

Parameters:
fileHandle - the file handle to create a file resource with
contents - the initial contents of the new file resource, or null if none (equivalent to an empty stream)
monitor - the progress monitor to show visual progress with
Throws:
CoreException - if the operation fails

createFileHandle

protected IFile createFileHandle(IPath filePath)
Creates a file resource handle for the file with the given workspace path. This method does not create the file resource; this is the responsibility of createFile.

Parameters:
filePath - the path of the file resource to create a handle for
Returns:
the new file resource handle
See Also:
createFile(IFile, java.io.InputStream, IProgressMonitor)

createNewFile

public IFile createNewFile()
Deprecated. As of SWeDE 1.0.2, replaced by createNewFile(InputStream). Creating the input stream externally allows the wizard to recover gracefully and notify the user if the URL is unreachable. See also openStream().

Creates a new file resource in the selected container and with the selected name. Creates any missing resource containers along the path; does nothing if the container resources already exist.

In normal usage, this method is invoked after the user has pressed Finish on the wizard; the enablement of the Finish button implies that all controls on on this page currently contain valid values.

Note that this page caches the new file once it has been successfully created; subsequent invocations of this method will answer the same file resource without attempting to create it again.

This method should be called within a workspace modify operation since it creates resources.

Returns:
the created file resource, or null if the file was not created

createNewFile

public IFile createNewFile(InputStream input)
Creates a new file resource in the selected container and with the selected name. Creates any missing resource containers along the path; does nothing if the container resources already exist.

In normal usage, this method is invoked after the user has pressed Finish on the wizard; the enablement of the Finish button implies that all controls on on this page currently contain valid values.

Note that this page caches the new file once it has been successfully created; subsequent invocations of this method will answer the same file resource without attempting to create it again.

This method should be called within a workspace modify operation since it creates resources.

Parameters:
input - An input stream for the external document being imported. If no document is being imported, this parameter is ignored and may be null.
Returns:
the created file resource, or null if the file was not created

getContainerFullPath

public IPath getContainerFullPath()
Returns the current full path of the containing resource as entered or selected by the user, or its anticipated initial value.

Returns:
the container's full path, anticipated initial value, or null if no path is known

getFileName

public String getFileName()
Returns the current file name as entered by the user, or its anticipated initial value.

Returns:
the file name, its anticipated initial value, or null if no file name is known

getInitialContents

protected InputStream getInitialContents()
Returns a stream containing the initial contents to be given to new file resource instances. Subclasses may wish to override. This default implementation provides no initial contents.

Returns:
initial contents to be given to new file resource instances

openStream

public InputStream openStream()
                       throws IOException
Returns an input stream for importing an external document.

Returns:
An open input stream to the import URL, or null if a document is not being imported.
Throws:
IOException - if the document cannot be opened from the specified import URL

getNewFileLabel

protected String getNewFileLabel()
Returns the label to display in the file name specification visual component group.

Subclasses may reimplement.

Returns:
the label to display in the file name specification visual component group

getXMLBase

protected String getXMLBase()
Retrieves the user-provided XML base for the new OWL document.

Returns:
The value from the XML base text box.

handleEvent

public void handleEvent(Event event)
The WizardNewFileCreationPage implementation of this Listener method handles all events and enablements for controls on this page. Subclasses may extend.

Parameters:
event - The event to handle

initialPopulateContainerNameField

protected void initialPopulateContainerNameField()
Sets the initial contents of the container name entry field, based upon either a previously-specified initial value or the ability to determine such a value.


setContainerFullPath

public void setContainerFullPath(IPath path)
Sets the value of this page's container name field, or stores it for future use if this page's controls do not exist yet.

Parameters:
path - the full path to the container

setFileName

public void setFileName(String value)
Sets the value of this page's file name field, or stores it for future use if this page's controls do not exist yet.

Parameters:
value - new file name

validatePage

protected boolean validatePage()
Returns whether this page's controls currently all contain valid values.

Returns:
true if all controls are valid, and false if at least one is invalid

setVisible

public void setVisible(boolean visible)


Copyright © 2004-2005 BBN Technologies. All Rights Reserved.