com.groovemanager.app.sse
Class SaveAudioFileAsAction

java.lang.Object
  extended by org.eclipse.jface.action.Action
      extended by com.groovemanager.app.sse.SaveAudioFileAsAction
All Implemented Interfaces:
org.eclipse.jface.action.IAction

public class SaveAudioFileAsAction
extends org.eclipse.jface.action.Action

This class can be used for saving audio files. In addition to what a FileSaveAsAction does, this class will also ensure that a dialog for format selection will be shown to the user.

Author:
Manu Robledo

Field Summary
private  boolean allowOverwrite
          Allow the user to select already existing files
private  AudioManager audioManager
          The AudioManager to be used by this action
private  javax.sound.sampled.AudioFormat format
          The audio format to write
private  ChooseFormatDialog formatDialog
          The dialog to use for selection of the audio format
private  java.util.ArrayList listeners
          List of Listeners registered with this action
private  org.eclipse.swt.widgets.Shell shell
          The parent shell to be used for the dialog
private  java.io.File source
          The source file that should be saved.
 
Fields inherited from interface org.eclipse.jface.action.IAction
AS_CHECK_BOX, AS_DROP_DOWN_MENU, AS_PUSH_BUTTON, AS_RADIO_BUTTON, AS_UNSPECIFIED, CHECKED, DESCRIPTION, ENABLED, IMAGE, TEXT, TOOL_TIP_TEXT
 
Constructor Summary
SaveAudioFileAsAction(java.lang.String s, boolean allowOverwrite)
          Create a new SaveAudioFileAsAction
 
Method Summary
 void addAudioFileSaveListener(AudioFileSaveListener listener)
          Add an AudioFileSaveListener to this action
protected  org.eclipse.swt.widgets.Shell getShell()
          Get the currently assigned parent shell
 java.io.File getSource()
          Get the source file currently assigned to this action
 void removeAudioFileSaveListener(AudioFileSaveListener listener)
          Remove an AudioFileSaveListener from this action
 void run()
          Perform this action.
 void setAudioManager(AudioManager manager)
          Set the AudioManager to be used by this action
 void setFormat(javax.sound.sampled.AudioFormat format)
          Set the default format to be used for saving
 void setFormatDialog(ChooseFormatDialog dialog)
          Set the ChooseFormatDialog to be shown to the user
 void setShell(org.eclipse.swt.widgets.Shell shell)
          Set the shell to be used as parent shell for the dialogs
 void setSourceFile(java.io.File f)
          Set the source file that should be saved.
 
Methods inherited from class org.eclipse.jface.action.Action
addPropertyChangeListener, convertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, firePropertyChange, firePropertyChange, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, removeAcceleratorText, removePropertyChangeListener, runWithEvent, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

allowOverwrite

private boolean allowOverwrite
Allow the user to select already existing files


audioManager

private AudioManager audioManager
The AudioManager to be used by this action


format

private javax.sound.sampled.AudioFormat format
The audio format to write


formatDialog

private ChooseFormatDialog formatDialog
The dialog to use for selection of the audio format


listeners

private java.util.ArrayList listeners
List of Listeners registered with this action


shell

private org.eclipse.swt.widgets.Shell shell
The parent shell to be used for the dialog


source

private java.io.File source
The source file that should be saved.

Constructor Detail

SaveAudioFileAsAction

public SaveAudioFileAsAction(java.lang.String s,
                             boolean allowOverwrite)
Create a new SaveAudioFileAsAction

Parameters:
s - The name of the action
allowOverwrite - true, if the user should be able to overwrite existing files, false otherwise
Method Detail

addAudioFileSaveListener

public void addAudioFileSaveListener(AudioFileSaveListener listener)
Add an AudioFileSaveListener to this action

Parameters:
listener - The AudioFileSaveListener to be added

getShell

protected org.eclipse.swt.widgets.Shell getShell()
Get the currently assigned parent shell

Returns:
The shell currently assigned to this action

getSource

public java.io.File getSource()
Get the source file currently assigned to this action

Returns:
The source file currently assigned to this action

removeAudioFileSaveListener

public void removeAudioFileSaveListener(AudioFileSaveListener listener)
Remove an AudioFileSaveListener from this action

Parameters:
listener - The AudioFileSaveListener to be removed

run

public void run()
Perform this action. First, the format dialog will be opened and the user will be asked to select a format. After that a file dialog will be shown for user selection of the target file. If both dialogs have been accepted, all listeners will be notified.

Specified by:
run in interface org.eclipse.jface.action.IAction
Overrides:
run in class org.eclipse.jface.action.Action
See Also:
IAction.run()

setAudioManager

public void setAudioManager(AudioManager manager)
Set the AudioManager to be used by this action

Parameters:
manager - The AudioManager to be used

setFormat

public void setFormat(javax.sound.sampled.AudioFormat format)
Set the default format to be used for saving

Parameters:
format - The AudioFormat, the format dialog will show first when opened

setFormatDialog

public void setFormatDialog(ChooseFormatDialog dialog)
Set the ChooseFormatDialog to be shown to the user

Parameters:
dialog - The dialog that will be shown to the user for format selection

setShell

public void setShell(org.eclipse.swt.widgets.Shell shell)
Set the shell to be used as parent shell for the dialogs

Parameters:
shell - The parent shell for the dialogs

setSourceFile

public void setSourceFile(java.io.File f)
Set the source file that should be saved. If the argument is null, the action will be disabled. Otherwise it will be enabled.

Parameters:
f - The file to save or null