org.gcn.plinguaplugin.wizardCommonComponents
Class FileCreator

java.lang.Object
  extended by org.gcn.plinguaplugin.wizardCommonComponents.FileCreator

public abstract class FileCreator
extends java.lang.Object

This abstract class creates files and reports errors on shells in case they occurred. It's intended to provide support for wizard actions, as many of them create new files when they finish

Author:
Manuel Garcia-Quismondo-Fernandez

Constructor Summary
FileCreator()
           
 
Method Summary
static void copyAndCloseStreams(java.io.InputStream inputStream, java.io.OutputStream outputStream)
          Copies an input stream to an output stream and closes them
static void copyStreams(java.io.InputStream inputStream, java.io.OutputStream outputStream)
          Copies an input stream to an output stream
static void createFile(java.io.InputStream content, java.lang.String fileName, java.lang.String containerName, org.eclipse.swt.widgets.Shell shell, org.eclipse.core.runtime.IProgressMonitor monitor)
          Creates a new file on the container and file specified with the workspace
static boolean executeContainerAction(org.eclipse.jface.wizard.IWizard wizard, org.eclipse.jface.operation.IRunnableWithProgress operation, org.eclipse.swt.widgets.Shell shell)
          Executes an action on the container provided by a wizard
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileCreator

public FileCreator()
Method Detail

createFile

public static void createFile(java.io.InputStream content,
                              java.lang.String fileName,
                              java.lang.String containerName,
                              org.eclipse.swt.widgets.Shell shell,
                              org.eclipse.core.runtime.IProgressMonitor monitor)
                       throws org.eclipse.core.runtime.CoreException
Creates a new file on the container and file specified with the workspace

Parameters:
content - the content of the file to create
fileName - the name of the file to create
containerName - the name of the container where create the file in
shell - the shell to show if errors occur
monitor - the monitor which show the file creatin progress
Throws:
org.eclipse.core.runtime.CoreException - if the file couldn't be created

executeContainerAction

public static boolean executeContainerAction(org.eclipse.jface.wizard.IWizard wizard,
                                             org.eclipse.jface.operation.IRunnableWithProgress operation,
                                             org.eclipse.swt.widgets.Shell shell)
Executes an action on the container provided by a wizard

Parameters:
wizard - the wizard which executed the action
operation - the operation which executes the action
shell - the shell where the error messages are displayed
Returns:
true if the file has been successfully created, false otherwise

copyStreams

public static void copyStreams(java.io.InputStream inputStream,
                               java.io.OutputStream outputStream)
                        throws java.io.IOException
Copies an input stream to an output stream

Parameters:
inputStream - the input stream to copy
outputStream - the destination output stream to write the input stream content
Throws:
java.io.IOException - if errors ocurred during the stream copy

copyAndCloseStreams

public static void copyAndCloseStreams(java.io.InputStream inputStream,
                                       java.io.OutputStream outputStream)
                                throws java.io.IOException
Copies an input stream to an output stream and closes them

Parameters:
inputStream - the input stream to copy
outputStream - the destination output stream to write the input stream content
Throws:
java.io.IOException - if errors ocurred during the stream copy