com.kirkwarez.wdysdv.control
Class DisplayControl

java.lang.Object
  extended byjava.awt.event.WindowAdapter
      extended bycom.kirkwarez.wdysdv.control.DisplayControl
All Implemented Interfaces:
ActionListener, EventListener, WindowFocusListener, WindowListener, WindowStateListener

public class DisplayControl
extends WindowAdapter
implements ActionListener

This class controls the seperate windows and processes their events.

Since:
5.00
Version:
5.00
Author:
Berend "Kirk" Wouda

Field Summary
protected  ArrayList windowlist
          The list with open windows.
 
Constructor Summary
DisplayControl()
          Constructs a new DisplayControl.
 
Method Summary
 void actionPerformed(ActionEvent event)
          Processes an event created by an extra window because of user interaction.
protected  File browse(DisplayFrame frame)
          Makes the window ask the user for a file and returns that.
 void closeAllWindows()
          Closes all the windows controlled by this class.
 void openWindow(File file, int type, int mode)
          This method opens a new window on the GUI, that contains the contents of the given file for editing.
 void saveDecrypted(String text, File file)
          Saves the given text into the given file.
 void saveEncrypted(int type, String text, File file)
          Encrypts the given text into the correct type of encryption, and writes it to the given file.
 void windowClosing(WindowEvent event)
          Closes the DisplayWindow indicated by the given WindowEvent after doing stuff.
 
Methods inherited from class java.awt.event.WindowAdapter
windowActivated, windowClosed, windowDeactivated, windowDeiconified, windowGainedFocus, windowIconified, windowLostFocus, windowOpened, windowStateChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

windowlist

protected ArrayList windowlist
The list with open windows.

Constructor Detail

DisplayControl

public DisplayControl()
Constructs a new DisplayControl.

Method Detail

windowClosing

public void windowClosing(WindowEvent event)
Closes the DisplayWindow indicated by the given WindowEvent after doing stuff.

Specified by:
windowClosing in interface WindowListener
Parameters:
event - The event that happened.

actionPerformed

public void actionPerformed(ActionEvent event)
Processes an event created by an extra window because of user interaction.

Specified by:
actionPerformed in interface ActionListener
Parameters:
event - The event that happened.
See Also:
ActionListener.actionPerformed(java.awt.event.ActionEvent)

saveEncrypted

public void saveEncrypted(int type,
                          String text,
                          File file)
                   throws IOException
Encrypts the given text into the correct type of encryption, and writes it to the given file.

Parameters:
type - The encryption type to use.
text - The text to encrypt and save.
file - The file to save to.
Throws:
IOException - When streamstuffs go wrong.

saveDecrypted

public void saveDecrypted(String text,
                          File file)
                   throws IOException
Saves the given text into the given file.

Parameters:
text - The text to save.
file - The file to save to.
Throws:
IOException - When streamstuffs go wrong.

browse

protected File browse(DisplayFrame frame)
Makes the window ask the user for a file and returns that.

Returns:
The selected file.

openWindow

public void openWindow(File file,
                       int type,
                       int mode)
                throws IOException

This method opens a new window on the GUI, that contains the contents of the given file for editing. The contents are decrypted using the given type of encryption depending on the mode.

If the mode is to decrypt, the file will be decrypted before it is shown. However if the mode is to encrypt, the file will be shown as is, because one can assume that is what the user wants to see.

Parameters:
file - The file to show.
type - The type of encryption (Uru ot MYST V).
mode - The mode of encryption (encrypt or decrypt).
Throws:
IOException - When the window can't do its streamstuff without errors.

closeAllWindows

public void closeAllWindows()
Closes all the windows controlled by this class.