Initial commit from SVN.

This commit is contained in:
wcrisman
2014-05-30 10:31:51 -07:00
commit b45e56b890
1968 changed files with 370949 additions and 0 deletions

View File

@@ -0,0 +1,138 @@
package com.eua.application;
import java.io.File;
import com.common.debug.*;
import com.common.thread.*;
import com.foundation.application.Application;
import com.foundation.view.resource.ResourceService;
import com.foundation.view.swt.EventLoop;
import com.foundation.view.swt.SwtViewContext;
/**
* Copyright Declarative Engineering LLC 2009<p>
*/
public class EncryptionUtilityApplication extends Application {
private static final EncryptionUtilityApplication singleton = new EncryptionUtilityApplication();
/**
* Starts the Encryption Utility Application application.
* @param args None expected.
*/
public static void main(String[] args) {
// try {
// System.out.println("In Main");
// System.out.println("Absolute app root path: " + new File(".").getAbsolutePath());
// System.out.println("Canonical app root path: " + new File(".").getCanonicalPath());
// }//try//
// catch(Throwable e) {
// Debug.log(e);
// }//catch//
EventLoop.getSingleton().startOnThisThread(new Runnable() {
public void run() {
getSingleton().startup();
}//run()//
});
}//main()//
/**
* Gets the one and only instance of the application.
* @return The singleton instance.
*/
public static EncryptionUtilityApplication getSingleton() {
return singleton;
}//getSingleton()//
/**
* EncryptionUtilityApplication constructor.
*/
public EncryptionUtilityApplication() {
super();
}//EncryptionUtilityApplication()//
/* (non-Javadoc)
* @see com.foundation.application.Application#getDefaultRepositoryIdentifier()
*/
public Object getDefaultRepositoryIdentifier() {
return null;
}//getDefaultRepositoryIdentifier()//
/* (non-Javadoc)
* @see com.foundation.application.Application#getResourcesPath()
*/
public File getResourcesPath() {
String path = System.getProperty("eua.resources.path");
return path == null ? super.getResourcesPath() : new File(path);
}//getResourcesPath()//
/* (non-Javadoc)
* @see com.foundation.application.Application#getMetadataLocation()
*/
public Object getMetadataLocation() {
String path = System.getProperty("eua.metadata.path");
return (path == null ? "." : path) + "/metadata.xml";
}//getMetadataLocation()//
/* (non-Javadoc)
* @see com.foundation.application.Application#initializeResources(com.foundation.view.resource.ResourceService)
*/
protected void initializeResources(ResourceService resourceService) {
}//initializeResources()//
/* (non-Javadoc)
* @see com.foundation.application.Application#internalShutdown()
*/
protected void internalShutdown() {
SwtViewContext.getSingleton().shutdown();
Scheduler.shutdown();
ActiveScheduler.getSingleton().shutdown();
super.internalShutdown();
}//internalShutdown()//
/* (non-Javadoc)
* @see com.foundation.application.Application#startup()
*/
protected void startup() {
// try {
// Debug.log("In startup");
// Debug.log("Absolute app root path: " + new File(".").getAbsolutePath());
// Debug.log("Canonical app root path: " + new File(".").getCanonicalPath());
// Debug.log("Expecting resources at: " + getResourcesPath());
// Debug.log("Expecting metadata at: " + getMetadataLocation());
// }//try//
// catch(Throwable e) {
// Debug.log(e);
// }//catch//
//Setup the debug log.//
Debug.setLog(new DefaultLog());
//Setup the metadata service.//
setupMetadataService();
//Setup the resource service.//
setupResourceService();
try {
//Start the application specific code.//
startApplication();
}//try//
catch(Throwable e) {
//Log all errors that are not caught earlier in the program.//
Debug.log(e);
}//catch//
//waitForShutdown();
}//startup()//
/**
* Starts the actual application.
*/
private void startApplication() {
try {
//Run the view in the swt event loop so that any reflections it creates upon startup will be done in the correct thread.//
SwtViewContext.getSingleton().getRequestHandler().executeAsync(new com.common.thread.IRunnable() {
public Object run() {
com.eua.local.view.controller.MainViewController controller = new com.eua.local.view.controller.MainViewController(SwtViewContext.getSingleton());
controller.open();
return null;
}//run()//
});
}//try//
catch(Throwable e) {
Debug.log(e);
}//catch//
}//startApplication()//
}//EncryptionUtilityApplication//

View File

@@ -0,0 +1,23 @@
package com.eua.controller;
import com.foundation.application.*;
import com.eua.application.*;
/**
*
*/
public abstract class AbstractController extends com.foundation.controller.Controller {
/**
* AbstractController constructor.
*/
public AbstractController() {
super();
}//AbstractController()//
/**
* Gets the application object that this object is running under. The application object provides the object various services that it will need.
* @return The application reference for the application this object is running under.
*/
public IApplication getApplication() {
return EncryptionUtilityApplication.getSingleton();
}//getApplication()//
}//AbstractController//

View File

@@ -0,0 +1,215 @@
package com.eua.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.util.Properties;
import com.common.debug.Debug;
import com.foundation.metadata.Attribute;
/**
* Copyright Declarative Engineering LLC 2009<p>
*/
public class SettingsController extends AbstractController {
private static final File settingsFilePath = new File(new File(System.getProperty("user.home"), "Brainstorm Archiver"), "settings.properties");
private static final File settingsLockFilePath = new File(new File(System.getProperty("user.home"), "Brainstorm Archiver"), "settings.lock");
private static final String ENCRYPTION_OUTPUT_DIRECTORY = "encryption.output.directory";
private static final String ENCRYPTED_FILE_DIRECTORY = "encrypted.file.directory";
private static final String ENCRYPTED_FILE_NAME = "encrypted.file.name";
private static final String DECRYPTION_OUTPUT_DIRECTORY = "decryption.output.directory";
private static final String INPUT_DIRECTORY = "input.directory";
public static final Attribute PROPERTIES = registerAttribute(SettingsController.class, "properties", AO_REFERENCED);
public static final Attribute PROPERTIES_DATE = registerAttribute(SettingsController.class, "propertiesDate");
/** The one and only instance of this class. */
private static final SettingsController singleton = new SettingsController();
/**
* Gets the only instance of this class.
* @return The one and only instance.
*/
public static SettingsController getSingleton() {
return singleton;
}//getSingleton()//
/**
* SettingsController constructor.
*/
private SettingsController() {
updateProperties();
}//SettingsController()//
/**
* Reads the properties file.
* @return The properties read from disk.
*/
private void updateProperties() {
Properties properties = new Properties();
Long lastModified = null;
if(settingsFilePath.exists() && settingsFilePath.canRead()) {
FileInputStream fin = null;
lastModified = new Long(settingsFilePath.lastModified());
try {
fin = new FileInputStream(settingsFilePath);
properties.load(fin);
fin.close();
fin = null;
}//try//
catch(Throwable e) {
Debug.log(e);
}//catch//
finally {
if(fin != null) try {fin.close();} catch(Throwable e) {}
}//finally//
}//if//
else {
try {
settingsFilePath.getParentFile().mkdirs();
settingsFilePath.createNewFile();
lastModified = new Long(settingsFilePath.lastModified());
}//try//
catch(Throwable e) {
Debug.log(e);
}//catch//
}//else//
setProperties(properties);
setPropertiesDate(lastModified);
}//updateProperties()//
/**
* Modifies the settings properties using a file lock.
* <p>Locks on the settings properties file, then updates if necessary the in memory properties, then runs the operation passed to this method, then stores the properties back to file.</p>
* @param operation The operation that will update the properties object.
*/
private void modifyProperties(Runnable operation) {
//The properties date will only be null if we cannot store properties due to permission problems.//
if(getPropertiesDate() != null) {
FileLock lock = null;
FileChannel channel = null;
FileOutputStream fout = null;
try {
long lastModifiedDate = settingsFilePath.lastModified();
channel = new RandomAccessFile(settingsLockFilePath, "rw").getChannel();
lock = channel.lock();
//Update the in memory settings first.//
if(getPropertiesDate().longValue() != lastModifiedDate) {
updateProperties();
}//if//
//Modify the properties.//
operation.run();
//Write the properties to a byte array.//
fout = new FileOutputStream(settingsFilePath, false);
getProperties().store(fout, "Brainstorm Archiver Settings");
}//try//
catch(Throwable e) {
Debug.log(e);
}//catch//
finally {
if(fout != null) try {fout.close();} catch(Throwable e) {}
if(lock != null) try {lock.release();} catch(Throwable e) {}
if(channel != null) try {channel.close();} catch(Throwable e) {}
}//if//
setPropertiesDate(new Long(settingsFilePath.lastModified()));
}//if//
}//modifyProperties()//
/**
* Gets the default output path for encrypted files.
* @return The last used path for placing encrypted files.
*/
public String getEncryptionOutputDirectory() {
return getProperties().getProperty(ENCRYPTION_OUTPUT_DIRECTORY);
}//getEncryptionOutputDirectory()//
/**
* Gets the default file name for the encrypted files.
* @return The last used file name for encrypting files.
*/
public String getEncryptedFileName() {
return getProperties().getProperty(ENCRYPTED_FILE_NAME);
}//getEncryptedFileName()//
/**
* Gets the last used directory for selecting input files for encrypting.
* @return The last used directory for the selection of files to encrypt.
*/
public String getInputDirectory() {
return getProperties().getProperty(INPUT_DIRECTORY);
}//getInputDirectory()//
/**
* Sets settings for encrypting.
* @param encryptionOutputDirectory The last used path for placing encrypted files.
* @param encryptedFileName The last used file name for encrypting files.
*/
public void setEncryptionSettings(final String encryptionOutputDirectory, final String encryptedFileName, final String inputDirectory) {
modifyProperties(new Runnable() {
public void run() {
getProperties().setProperty(ENCRYPTION_OUTPUT_DIRECTORY, encryptionOutputDirectory);
getProperties().setProperty(ENCRYPTED_FILE_NAME, encryptedFileName);
getProperties().setProperty(INPUT_DIRECTORY, inputDirectory);
}//run()//
});
}//setEncryptionSettings()//
/**
* Gets the default directory containing encrypted files to be decrypted.
* @return The directory of the last decrypted file.
*/
public String getEncryptedFileDirectory() {
return getProperties().getProperty(ENCRYPTED_FILE_DIRECTORY);
}//getEncryptedFileDirectory()//
/**
* Gets the default output path for decrypted files.
* @return The last used path for placing decrypted files.
*/
public String getDecryptionOutputDirectory() {
return getProperties().getProperty(DECRYPTION_OUTPUT_DIRECTORY);
}//getDecryptionOutputDirectory()//
/**
* Sets the settings for decrypting.
* @param decryptionOutputDirectory The directory of the last decrypted file.
* @param encryptedFileDirectory The directory of the last decrypted file.
*/
public void setDecryptionSettings(final String decryptionOutputDirectory, final String encryptedFileDirectory) {
modifyProperties(new Runnable() {
public void run() {
getProperties().setProperty(ENCRYPTED_FILE_DIRECTORY, encryptedFileDirectory);
getProperties().setProperty(DECRYPTION_OUTPUT_DIRECTORY, decryptionOutputDirectory);
}//run()//
});
}//setDecryptionSettings()//
/**
* Gets the properties value.
* @return The properties value.
*/
private Properties getProperties() {
return (Properties) getAttributeValue(PROPERTIES);
}//getProperties()//
/**
* Sets the properties value.
* @param properties The properties value.
*/
private void setProperties(Properties properties) {
setAttributeValue(PROPERTIES, properties);
}//setProperties()//
/**
* Gets the propertiesDate value.
* @return The propertiesDate value.
*/
private Long getPropertiesDate() {
return (Long) getAttributeValue(PROPERTIES_DATE);
}//getPropertiesDate()//
/**
* Sets the propertiesDate value.
* @param propertiesDate The propertiesDate value.
*/
private void setPropertiesDate(Long propertiesDate) {
setAttributeValue(PROPERTIES_DATE, propertiesDate);
}//setPropertiesDate()//
}//SettingsController//

View File

@@ -0,0 +1,477 @@
package com.eua.local.view;
/**
* DecryptView
*/
public class DecryptView extends com.foundation.view.swt.Panel implements com.foundation.view.IAssociationHandler {
//Component Names//
public static final String CONTROLLER_HOLDER_COMPONENT = "controllerHolder";
public static final String MAIN_COMPONENT = "main";
public static final String INPUT_FILE_LABEL_COMPONENT = "inputFileLabel";
public static final String INPUT_FILE_FIELD_COMPONENT = "inputFileField";
public static final String INPUT_FILE_EDIT_BUTTON_COMPONENT = "inputFileEditButton";
public static final String OUTPUT_DIRECTORY_LABEL_COMPONENT = "outputDirectoryLabel";
public static final String OUTPUT_DIRECTORY_FIELD_COMPONENT = "outputDirectoryField";
public static final String OUTPUT_DIRECTORY_EDIT_BUTTON_COMPONENT = "outputDirectoryEditButton";
public static final String PASSWORD_LABEL_COMPONENT = "passwordLabel";
public static final String PASSWORD_FIELD_COMPONENT = "passwordField";
public static final String SPACER_COMPONENT = "spacer";
public static final String BUTTON_PANEL_COMPONENT = "buttonPanel";
public static final String DECRYPT_BUTTON_COMPONENT = "decryptButton";
public static final String DECRYPT_VIEW_COMPONENT = "DecryptView";
//Association Identifiers//
protected static final int INPUT_FILE_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0 = 0;
protected static final int OUTPUT_DIRECTORY_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0 = 1;
protected static final int PASSWORD_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0 = 2;
protected static final int DECRYPT_BUTTON_ASSOCIATION_IS_ENABLED_ASSOCIATION_0 = 3;
//Method Association Identifiers//
protected static final int INPUT_FILE_EDIT_BUTTON_SELECTION_METHOD_ASSOCIATION = 0;
protected static final int OUTPUT_DIRECTORY_EDIT_BUTTON_SELECTION_METHOD_ASSOCIATION = 1;
protected static final int DECRYPT_BUTTON_SELECTION_METHOD_ASSOCIATION = 2;
//View Components//
private com.foundation.view.swt.ValueHolder controllerHolder = null;
private com.foundation.view.swt.Panel main = null;
private com.foundation.view.swt.Label inputFileLabel = null;
private com.foundation.view.swt.TextField inputFileField = null;
private com.foundation.view.swt.Button inputFileEditButton = null;
private com.foundation.view.swt.Label outputDirectoryLabel = null;
private com.foundation.view.swt.TextField outputDirectoryField = null;
private com.foundation.view.swt.Button outputDirectoryEditButton = null;
private com.foundation.view.swt.Label passwordLabel = null;
private com.foundation.view.swt.TextField passwordField = null;
private com.foundation.view.swt.Panel spacer = null;
private com.foundation.view.swt.Panel buttonPanel = null;
private com.foundation.view.swt.Button decryptButton = null;
/**
* DecryptView default constructor.
* <p>Warning: This constructor is intended for use by the metadata service <b>only</b>. This constructor should <b>never</b> be called by the view's controller.</p>
*/
public DecryptView() {
}//DecryptView()//
/**
* DecryptView constructor.
* @param controller The view controller which will be assigned to the value holder(s) that don't depend on another value holder for their value.
* @param parentComponent The non-null parent view component which this frame will be contained in.
*/
public DecryptView(com.foundation.controller.ViewController controller, com.foundation.view.IView parentComponent) {
super((com.foundation.view.IAbstractContainer) parentComponent, DECRYPT_VIEW_COMPONENT, 0);
setController(controller);
}//DecryptView()//
public void initializeControllerHolder(com.foundation.view.swt.Container parent) {
controllerHolder = new com.foundation.view.swt.ValueHolder(parent, CONTROLLER_HOLDER_COMPONENT, com.eua.local.view.controller.DecryptViewController.class);
}//initializeControllerHolder()//
public void initializeInputFileLabel(com.foundation.view.swt.Container parent) {
inputFileLabel = new com.foundation.view.swt.Label(parent, INPUT_FILE_LABEL_COMPONENT, 0);
inputFileLabel.setText("Encrypted File");
}//initializeInputFileLabel()//
public void initializeInputFileField(com.foundation.view.swt.Container parent) {
inputFileField = new com.foundation.view.swt.TextField(parent, INPUT_FILE_FIELD_COMPONENT, com.foundation.view.swt.TextField.STYLE_BORDER|com.foundation.view.swt.TextField.STYLE_SINGLE|com.foundation.view.swt.TextField.STYLE_READ_ONLY);
com.foundation.view.swt.TextField.TextFormat inputFileFieldFormat = (com.foundation.view.swt.TextField.TextFormat) inputFileField.initializeFormat(com.foundation.view.swt.TextField.TextFormat.class);
inputFileFieldFormat.setValueAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.eua.local.view.controller.DecryptViewController.class, INPUT_FILE_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.eua.local.view.controller.DecryptViewController.class, com.eua.local.view.controller.DecryptViewController.INPUT_FILE)}, null,true,com.eua.local.view.controller.DecryptViewController.INPUT_FILE)}));
inputFileField.setSelectOnFocus(true);
inputFileField.setDefaultToolTipText("The file being decrypted.");
}//initializeInputFileField()//
public void initializeInputFileEditButton(com.foundation.view.swt.Container parent) {
inputFileEditButton = new com.foundation.view.swt.Button(parent, INPUT_FILE_EDIT_BUTTON_COMPONENT, 0);
inputFileEditButton.setText("..");
inputFileEditButton.setSelectionMethod(new com.foundation.view.MethodAssociation(this, INPUT_FILE_EDIT_BUTTON_SELECTION_METHOD_ASSOCIATION, inputFileEditButton, "controllerHolder", null, null));
inputFileEditButton.setDefaultToolTipText("Click to change the file to be decrypted.");
}//initializeInputFileEditButton()//
public void initializeOutputDirectoryLabel(com.foundation.view.swt.Container parent) {
outputDirectoryLabel = new com.foundation.view.swt.Label(parent, OUTPUT_DIRECTORY_LABEL_COMPONENT, 0);
outputDirectoryLabel.setText("Output Directory");
}//initializeOutputDirectoryLabel()//
public void initializeOutputDirectoryField(com.foundation.view.swt.Container parent) {
outputDirectoryField = new com.foundation.view.swt.TextField(parent, OUTPUT_DIRECTORY_FIELD_COMPONENT, com.foundation.view.swt.TextField.STYLE_BORDER|com.foundation.view.swt.TextField.STYLE_SINGLE|com.foundation.view.swt.TextField.STYLE_READ_ONLY);
com.foundation.view.swt.TextField.TextFormat outputDirectoryFieldFormat = (com.foundation.view.swt.TextField.TextFormat) outputDirectoryField.initializeFormat(com.foundation.view.swt.TextField.TextFormat.class);
outputDirectoryFieldFormat.setValueAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.eua.local.view.controller.DecryptViewController.class, OUTPUT_DIRECTORY_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.eua.local.view.controller.DecryptViewController.class, com.eua.local.view.controller.DecryptViewController.OUTPUT_DIRECTORY)}, null,true,com.eua.local.view.controller.DecryptViewController.OUTPUT_DIRECTORY)}));
outputDirectoryField.setSelectOnFocus(true);
outputDirectoryField.setDefaultToolTipText("All decrypted files will be placed here, overwriting files with the same names.");
}//initializeOutputDirectoryField()//
public void initializeOutputDirectoryEditButton(com.foundation.view.swt.Container parent) {
outputDirectoryEditButton = new com.foundation.view.swt.Button(parent, OUTPUT_DIRECTORY_EDIT_BUTTON_COMPONENT, 0);
outputDirectoryEditButton.setText("..");
outputDirectoryEditButton.setSelectionMethod(new com.foundation.view.MethodAssociation(this, OUTPUT_DIRECTORY_EDIT_BUTTON_SELECTION_METHOD_ASSOCIATION, outputDirectoryEditButton, "controllerHolder", null, null));
outputDirectoryEditButton.setDefaultToolTipText("Click to change the output directory.");
}//initializeOutputDirectoryEditButton()//
public void initializePasswordLabel(com.foundation.view.swt.Container parent) {
passwordLabel = new com.foundation.view.swt.Label(parent, PASSWORD_LABEL_COMPONENT, 0);
passwordLabel.setText("Password");
}//initializePasswordLabel()//
public void initializePasswordField(com.foundation.view.swt.Container parent) {
passwordField = new com.foundation.view.swt.TextField(parent, PASSWORD_FIELD_COMPONENT, com.foundation.view.swt.TextField.STYLE_BORDER|com.foundation.view.swt.TextField.STYLE_SINGLE);
com.foundation.view.swt.TextField.TextFormat passwordFieldFormat = (com.foundation.view.swt.TextField.TextFormat) passwordField.initializeFormat(com.foundation.view.swt.TextField.TextFormat.class);
passwordFieldFormat.setEchoCharacter(new Character('*'));
passwordFieldFormat.setValueAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.eua.local.view.controller.DecryptViewController.class, PASSWORD_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.eua.local.view.controller.DecryptViewController.class, com.eua.local.view.controller.DecryptViewController.PASSWORD)}, null,true,com.eua.local.view.controller.DecryptViewController.PASSWORD)}));
passwordField.setAutoSynchronizeValue(true);
passwordField.setAutoSynchronizeValueDelay(10l);
passwordField.setAutoValidate(true);
passwordField.setSelectOnFocus(true);
passwordField.setDefaultToolTipText("The password used to encrypt the files originally.");
}//initializePasswordField()//
public void initializeSpacer(com.foundation.view.swt.Container parent) {
spacer = new com.foundation.view.swt.Panel(parent, SPACER_COMPONENT, 0);
spacer.setTabOrder(new com.common.util.LiteList(new Object[] {}));
}//initializeSpacer()//
public void initializeDecryptButton(com.foundation.view.swt.Container parent) {
decryptButton = new com.foundation.view.swt.Button(parent, DECRYPT_BUTTON_COMPONENT, com.foundation.view.swt.Button.STYLE_PUSH);
decryptButton.setText("Decrypt");
decryptButton.setSelectionMethod(new com.foundation.view.MethodAssociation(this, DECRYPT_BUTTON_SELECTION_METHOD_ASSOCIATION, decryptButton, "controllerHolder", null, null));
decryptButton.setDefaultFont(com.foundation.view.JefFont.getJefFonts("8, bold"));
decryptButton.setIsEnabledAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.eua.local.view.controller.DecryptViewController.class, DECRYPT_BUTTON_ASSOCIATION_IS_ENABLED_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.eua.local.view.controller.DecryptViewController.class, com.eua.local.view.controller.DecryptViewController.INPUT_FILE)}, null,true)}));
}//initializeDecryptButton()//
public void initializeButtonPanel(com.foundation.view.swt.Container parent) {
buttonPanel = new com.foundation.view.swt.Panel(parent, BUTTON_PANEL_COMPONENT, 0);
initializeDecryptButton(buttonPanel);
com.foundation.view.swt.RowLayout layout = new com.foundation.view.swt.RowLayout(buttonPanel);
layout.setSpacing(10);
layout.setMarginHeight(0);
layout.setMarginWidth(0);
layout.setWrap(false);
layout.setPack(false);
layout.setJustify(false);
buttonPanel.setLayout(layout);
buttonPanel.setTabOrder(new com.common.util.LiteList(new Object[] {decryptButton}));
}//initializeButtonPanel()//
public void initializeMain(com.foundation.view.swt.Container parent) {
main = new com.foundation.view.swt.Panel(parent, MAIN_COMPONENT, 0);
initializeInputFileLabel(main);
initializeInputFileField(main);
initializeInputFileEditButton(main);
initializeOutputDirectoryLabel(main);
initializeOutputDirectoryField(main);
initializeOutputDirectoryEditButton(main);
initializePasswordLabel(main);
initializePasswordField(main);
initializeSpacer(main);
initializeButtonPanel(main);
com.foundation.view.swt.GridLayout layout = new com.foundation.view.swt.GridLayout(main);
layout.setNumColumns(3);
layout.setMakeColumnsEqualWidth(false);
layout.setMarginHeight(9);
layout.setMarginWidth(6);
layout.setHorizontalSpacing(10);
layout.setVerticalSpacing(3);
main.setLayout(layout);
main.setTabOrder(new com.common.util.LiteList(new Object[] {inputFileEditButton, outputDirectoryEditButton, passwordField, buttonPanel}));
}//initializeMain()//
/* (non-Javadoc)
* @see com.foundation.view.IView#internalViewInitialize()
*/
public void internalViewInitialize() {
initializeControllerHolder(this);
initializeMain(this);
com.foundation.view.swt.FillLayout layout = new com.foundation.view.swt.FillLayout(this);
layout.setMarginHeight(4);
layout.setMarginWidth(4);
this.setLayout(layout);
this.setTabOrder(new com.common.util.LiteList(new Object[] {main}));
this.setDefaultContainerTitle("Decrypt");
this.setDefaultButton(decryptButton);
layoutComponents();
super.internalViewInitialize();
setupLinkages();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.view.IAssociationHandler#invokeGetMethod(int, Object)
*/
public Object invokeGetMethod(int associationNumber, Object value) {
Object retVal = null;
switch(associationNumber) {
default:
com.common.debug.Debug.log("Attribute association broken.");
break;
}//switch//
return retVal;
}//invokeGetMethod()//
/* (non-Javadoc)
* @see com.foundation.view.IAssociationHandler#invokeSetMethod(int, Object, Object)
*/
public void invokeSetMethod(int associationNumber, Object value, Object parameter) {
switch(associationNumber) {
default:
com.common.debug.Debug.log("Attribute association broken.");
break;
}//switch//
}//invokeSetMethod()//
/* (non-Javadoc)
* @see com.foundation.view.IAssociationHandler#invokeMethod(int, Object, Object[])
*/
public Object invokeMethod(int associationNumber, Object value, Object[] parameters) {
Object retVal = null;
switch(associationNumber) {
case INPUT_FILE_EDIT_BUTTON_SELECTION_METHOD_ASSOCIATION:
((com.eua.local.view.controller.DecryptViewController) value).doSelectInputFile();
break;
case OUTPUT_DIRECTORY_EDIT_BUTTON_SELECTION_METHOD_ASSOCIATION:
((com.eua.local.view.controller.DecryptViewController) value).doSelectOutputDirectory();
break;
case DECRYPT_BUTTON_SELECTION_METHOD_ASSOCIATION:
((com.eua.local.view.controller.DecryptViewController) value).doDecrypt();
break;
default:
com.common.debug.Debug.log("Method association broken.");
break;
}//switch//
return retVal;
}//invokeMethod()//
/* (non-Javadoc)
* @see com.foundation.view.IAssociationHandler#invokeMethod(int, Object, Object[], byte)
*/
public Object invokeMethod(int associationNumber, Object value, Object[] parameters, byte flags) {
Object result = null;
if(flags == INVOKE_GETTER_METHOD_FLAG) {
switch(associationNumber) {
case INPUT_FILE_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0:
result = ((com.eua.local.view.controller.DecryptViewController) value).getInputFile();
break;
case OUTPUT_DIRECTORY_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0:
result = ((com.eua.local.view.controller.DecryptViewController) value).getOutputDirectory();
break;
case PASSWORD_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0:
result = ((com.eua.local.view.controller.DecryptViewController) value).getPassword();
break;
case DECRYPT_BUTTON_ASSOCIATION_IS_ENABLED_ASSOCIATION_0:
result = ((com.eua.local.view.controller.DecryptViewController) value).getInputFile();
break;
default:
com.common.debug.Debug.log("Association (getter) broken.");
break;
}//switch//
}//if//
else if(flags == INVOKE_ORIGINAL_VALUE_GETTER_METHOD_FLAG) {
switch(associationNumber) {
case INPUT_FILE_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0:
result = ((com.eua.local.view.controller.DecryptViewController) value).getOldAttributeValue(com.eua.local.view.controller.DecryptViewController.INPUT_FILE);
break;
case OUTPUT_DIRECTORY_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0:
result = ((com.eua.local.view.controller.DecryptViewController) value).getOldAttributeValue(com.eua.local.view.controller.DecryptViewController.OUTPUT_DIRECTORY);
break;
case PASSWORD_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0:
result = ((com.eua.local.view.controller.DecryptViewController) value).getOldAttributeValue(com.eua.local.view.controller.DecryptViewController.PASSWORD);
break;
case DECRYPT_BUTTON_ASSOCIATION_IS_ENABLED_ASSOCIATION_0:
result = ((com.eua.local.view.controller.DecryptViewController) value).getOldAttributeValue(com.eua.local.view.controller.DecryptViewController.INPUT_FILE);
break;
default:
com.common.debug.Debug.log("Association (original value getter) broken.");
break;
}//switch//
}//if//
else {
switch(associationNumber) {
case PASSWORD_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0:
((com.eua.local.view.controller.DecryptViewController) value).setPassword((java.lang.String) parameters[0]);
break;
default:
com.common.debug.Debug.log("Association (setter) broken.");
break;
}//switch//
}//else//
return result;
}//invokeMethod()//
/**
* Lays out the components.
*/
public void layoutComponents() {
{ //inputFileLabel//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.END;
layoutData.grabExcessHorizontalSpace = false;
inputFileLabel.setLayoutData(layoutData);
}//block//
{ //inputFileField//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.FILL;
layoutData.grabExcessHorizontalSpace = true;
inputFileField.setLayoutData(layoutData);
}//block//
{ //outputDirectoryLabel//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.END;
layoutData.grabExcessHorizontalSpace = false;
outputDirectoryLabel.setLayoutData(layoutData);
}//block//
{ //outputDirectoryField//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.FILL;
layoutData.grabExcessHorizontalSpace = true;
outputDirectoryField.setLayoutData(layoutData);
}//block//
{ //passwordLabel//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.END;
passwordLabel.setLayoutData(layoutData);
}//block//
{ //passwordField//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.FILL;
layoutData.horizontalSpan = 2;
layoutData.grabExcessHorizontalSpace = true;
passwordField.setLayoutData(layoutData);
}//block//
{ //spacer//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.minimumHeight = 10;
layoutData.heightHint = 10;
layoutData.horizontalSpan = 2;
layoutData.grabExcessHorizontalSpace = true;
spacer.setLayoutData(layoutData);
}//block//
{ //buttonPanel//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.CENTER;
layoutData.horizontalSpan = 2;
buttonPanel.setLayoutData(layoutData);
}//block//
{ //decryptButton//
com.foundation.view.swt.layout.RowData layoutData = new com.foundation.view.swt.layout.RowData();
decryptButton.setLayoutData(layoutData);
}//block//
}//layoutComponents()//
/**
* Initializes the direct linkages between the components.
*/
public void setupLinkages() {
}//setupLinkages()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.ValueHolder getVpControllerHolder() {
return controllerHolder;
}//getVpControllerHolder()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Panel getVpMain() {
return main;
}//getVpMain()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Label getVpInputFileLabel() {
return inputFileLabel;
}//getVpInputFileLabel()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.TextField getVpInputFileField() {
return inputFileField;
}//getVpInputFileField()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Button getVpInputFileEditButton() {
return inputFileEditButton;
}//getVpInputFileEditButton()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Label getVpOutputDirectoryLabel() {
return outputDirectoryLabel;
}//getVpOutputDirectoryLabel()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.TextField getVpOutputDirectoryField() {
return outputDirectoryField;
}//getVpOutputDirectoryField()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Button getVpOutputDirectoryEditButton() {
return outputDirectoryEditButton;
}//getVpOutputDirectoryEditButton()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Label getVpPasswordLabel() {
return passwordLabel;
}//getVpPasswordLabel()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.TextField getVpPasswordField() {
return passwordField;
}//getVpPasswordField()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Panel getVpSpacer() {
return spacer;
}//getVpSpacer()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Panel getVpButtonPanel() {
return buttonPanel;
}//getVpButtonPanel()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Button getVpDecryptButton() {
return decryptButton;
}//getVpDecryptButton()//
}//DecryptView//

View File

@@ -0,0 +1,64 @@
<?xml version="1.0"?>
<vml>
<metadata>
<platform name="thick:swt"/>
</metadata>
<panel name="DecryptView" style="" container-image="" container-title="Decrypt" default-button="decryptButton">
<fill-layout margin-height="4" margin-width="4"/>
<value-holder name="controllerHolder" type="com.eua.local.view.controller.DecryptViewController"/>
<panel name="main" style="" tab-order="1">
<grid-layout column-count="3" margin-height="9" margin-width="6" equal-width-columns="false" horizontal-spacing="10" vertical-spacing="3"/>
<label name="inputFileLabel" text="Encrypted File">
<grid-layout-data horizontal-alignment="end" horizontal-fill="false"/>
</label>
<text name="inputFileField" select-on-focus="true" style="single line|border|read only" tool-tip-text="The file being decrypted.">
<grid-layout-data horizontal-alignment="fill" horizontal-fill="true"/>
<text-format>
<association function="text" attribute="inputFile" value-holder="controllerHolder" decorate="true"/>
</text-format>
</text>
<button name="inputFileEditButton" text=".." tool-tip-text="Click to change the file to be decrypted." tab-order="1">
<method function="selection" name="doSelectInputFile" value-holder="controllerHolder"/>
</button>
<label name="outputDirectoryLabel" text="Output Directory">
<grid-layout-data horizontal-alignment="end" horizontal-fill="false"/>
</label>
<text name="outputDirectoryField" select-on-focus="true" style="single line|border|read only" tool-tip-text="All decrypted files will be placed here, overwriting files with the same names.">
<grid-layout-data horizontal-alignment="fill" horizontal-fill="true"/>
<text-format>
<association function="text" attribute="outputDirectory" value-holder="controllerHolder" decorate="true"/>
</text-format>
</text>
<button name="outputDirectoryEditButton" text=".." tool-tip-text="Click to change the output directory." tab-order="1">
<method function="selection" name="doSelectOutputDirectory" value-holder="controllerHolder"/>
</button>
<label name="passwordLabel" text="Password">
<grid-layout-data horizontal-alignment="end"/>
</label>
<text name="passwordField" select-on-focus="true" style="single line|border" tab-order="1" auto-synchronize-text="true" auto-synchronize-text-delay="10" auto-validate="true" tool-tip-text="The password used to encrypt the files originally.">
<grid-layout-data horizontal-alignment="fill" horizontal-fill="true" horizontal-span="2"/>
<text-format echo-char="*">
<association function="text" attribute="password" value-holder="controllerHolder" decorate="true"/>
</text-format>
</text>
<panel name="spacer">
<grid-layout-data horizontal-fill="true" horizontal-span="2" minimum-height="10"/>
</panel>
<panel name="buttonPanel" tab-order="1">
<grid-layout-data horizontal-span="2" horizontal-alignment="center"/>
<row-layout spacing="10" wrap="false" pack="false" fill="true" justify="false" margin-width="0" margin-height="0"/>
<button name="decryptButton" style="push" text="Decrypt" font="8, bold" tab-order="1">
<row-layout-data/>
<method function="selection" name="doDecrypt" signature="" value-holder="controllerHolder"/>
<association function="is-enabled" attribute="inputFile" value-holder="controllerHolder"/>
</button>
</panel>
</panel>
</panel>
</vml>

View File

@@ -0,0 +1,898 @@
package com.eua.local.view;
/**
* EncryptView
*/
public class EncryptView extends com.foundation.view.swt.Panel implements com.foundation.view.IAssociationHandler {
//Component Names//
public static final String CONTROLLER_HOLDER_COMPONENT = "controllerHolder";
public static final String MAIN_COMPONENT = "main";
public static final String FILES_LABEL_COMPONENT = "filesLabel";
public static final String ADD_LINK_COMPONENT = "addLink";
public static final String REMOVE_LINK_COMPONENT = "removeLink";
public static final String FILES_LIST_COMPONENT = "filesList";
public static final String PASSWORD_LABEL_COMPONENT = "passwordLabel";
public static final String PASSWORD_FIELD_COMPONENT = "passwordField";
public static final String OUTPUT_DIRECTORY_LABEL_COMPONENT = "outputDirectoryLabel";
public static final String OUTPUT_DIRECTORY_FIELD_COMPONENT = "outputDirectoryField";
public static final String OUTPUT_DIRECTORY_EDIT_BUTTON_COMPONENT = "outputDirectoryEditButton";
public static final String OUTPUT_NAME_LABEL_COMPONENT = "outputNameLabel";
public static final String OUTPUT_NAME_FIELD_COMPONENT = "outputNameField";
public static final String SPLIT_CHECK_BOX_COMPONENT = "splitCheckBox";
public static final String MAXIMUM_OUTPUT_SIZE_LABEL_COMPONENT = "maximumOutputSizeLabel";
public static final String MAXIMUM_OUTPUT_SIZE_FIELD_COMPONENT = "maximumOutputSizeField";
public static final String MAXIMUM_OUTPUT_METRIC_LABEL_COMPONENT = "maximumOutputMetricLabel";
public static final String BUTTON_PANEL_COMPONENT = "buttonPanel";
public static final String ENCRYPT_BUTTON_COMPONENT = "encryptButton";
public static final String ENCRYPT_VIEW_COMPONENT = "EncryptView";
//Association Identifiers//
protected static final int REMOVE_LINK_ASSOCIATION_IS_ENABLED_ASSOCIATION_0 = 0;
protected static final int FILES_LIST_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0 = 1;
protected static final int FILES_LIST_COLUMN_PART1_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0 = 2;
protected static final int FILES_LIST_COLUMN_PART2_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0 = 3;
protected static final int FILES_LIST_ASSOCIATION_COLLECTION_ASSOCIATION_0 = 4;
protected static final int FILES_LIST_ASSOCIATION_SELECTION_ASSOCIATION_0 = 5;
protected static final int PASSWORD_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0 = 6;
protected static final int OUTPUT_DIRECTORY_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0 = 7;
protected static final int OUTPUT_NAME_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0 = 8;
protected static final int SPLIT_CHECK_BOX_ASSOCIATION_SELECTION_ASSOCIATION_0 = 9;
protected static final int MAXIMUM_OUTPUT_SIZE_FIELD_FORMAT_FORMAT_ASSOCIATION_VALUE_ASSOCIATION_0 = 10;
protected static final int UNNAMED_COMPONENT4_ASSOCIATION_COLLECTION_ASSOCIATION_0 = 11;
protected static final int UNNAMED_COMPONENT4_ASSOCIATION_SELECTION_ASSOCIATION_0 = 12;
protected static final int UNNAMED_COMPONENT4_ASSOCIATION_ITEM_TEXT_ASSOCIATION_0 = 13;
protected static final int UNNAMED_COMPONENT3_ASSOCIATION_IS_ENABLED_ASSOCIATION_0 = 14;
protected static final int ENCRYPT_BUTTON_ASSOCIATION_IS_ENABLED_ASSOCIATION_0 = 15;
//Attribute Association Identifiers//
protected static final int REMOVE_LINK_ASSOCIATION_IS_ENABLED_AA0_ATTRIBUTE_ASSOCIATION = 0;
protected static final int ENCRYPT_BUTTON_ASSOCIATION_IS_ENABLED_AA0_ATTRIBUTE_ASSOCIATION = 1;
//Method Association Identifiers//
protected static final int ADD_LINK_SELECTION_METHOD_ASSOCIATION = 0;
protected static final int REMOVE_LINK_SELECTION_METHOD_ASSOCIATION = 1;
protected static final int OUTPUT_DIRECTORY_EDIT_BUTTON_SELECTION_METHOD_ASSOCIATION = 2;
protected static final int ENCRYPT_BUTTON_SELECTION_METHOD_ASSOCIATION = 3;
//View Components//
private com.foundation.view.swt.ValueHolder controllerHolder = null;
private com.foundation.view.swt.Panel main = null;
private com.foundation.view.swt.Panel unnamedComponent0 = null;
private com.foundation.view.swt.Label filesLabel = null;
private com.foundation.view.swt.Link addLink = null;
private com.foundation.view.swt.Link removeLink = null;
private com.foundation.view.swt.SimpleTable filesList = null;
private com.foundation.view.swt.Panel unnamedComponent1 = null;
private com.foundation.view.swt.Label passwordLabel = null;
private com.foundation.view.swt.TextField passwordField = null;
private com.foundation.view.swt.Label outputDirectoryLabel = null;
private com.foundation.view.swt.TextField outputDirectoryField = null;
private com.foundation.view.swt.Button outputDirectoryEditButton = null;
private com.foundation.view.swt.Label outputNameLabel = null;
private com.foundation.view.swt.TextField outputNameField = null;
private com.foundation.view.swt.Panel unnamedComponent2 = null;
private com.foundation.view.swt.Button splitCheckBox = null;
private com.foundation.view.swt.Group unnamedComponent3 = null;
private com.foundation.view.swt.Label maximumOutputSizeLabel = null;
private com.foundation.view.swt.TextField maximumOutputSizeField = null;
private com.foundation.view.swt.Label maximumOutputMetricLabel = null;
private com.foundation.view.swt.ComboBox unnamedComponent4 = null;
private com.foundation.view.swt.Panel unnamedComponent5 = null;
private com.foundation.view.swt.Panel buttonPanel = null;
private com.foundation.view.swt.Button encryptButton = null;
/**
* EncryptView default constructor.
* <p>Warning: This constructor is intended for use by the metadata service <b>only</b>. This constructor should <b>never</b> be called by the view's controller.</p>
*/
public EncryptView() {
}//EncryptView()//
/**
* EncryptView constructor.
* @param controller The view controller which will be assigned to the value holder(s) that don't depend on another value holder for their value.
* @param parentComponent The non-null parent view component which this frame will be contained in.
*/
public EncryptView(com.foundation.controller.ViewController controller, com.foundation.view.IView parentComponent) {
super((com.foundation.view.IAbstractContainer) parentComponent, ENCRYPT_VIEW_COMPONENT, 0);
setController(controller);
}//EncryptView()//
public void initializeControllerHolder(com.foundation.view.swt.Container parent) {
controllerHolder = new com.foundation.view.swt.ValueHolder(parent, CONTROLLER_HOLDER_COMPONENT, com.eua.local.view.controller.EncryptViewController.class);
}//initializeControllerHolder()//
public void initializeFilesLabel(com.foundation.view.swt.Container parent) {
filesLabel = new com.foundation.view.swt.Label(parent, FILES_LABEL_COMPONENT, 0);
filesLabel.setText("Files");
}//initializeFilesLabel()//
public void initializeAddLink(com.foundation.view.swt.Container parent) {
addLink = new com.foundation.view.swt.Link(parent, ADD_LINK_COMPONENT, 0);
addLink.setText("<a>Add...</a>");
addLink.setSelectionMethod(new com.foundation.view.MethodAssociation(this, ADD_LINK_SELECTION_METHOD_ASSOCIATION, addLink, "controllerHolder", null, null));
}//initializeAddLink()//
public void initializeRemoveLink(com.foundation.view.swt.Container parent) {
removeLink = new com.foundation.view.swt.Link(parent, REMOVE_LINK_COMPONENT, 0);
removeLink.setText("<a>Remove</a>");
removeLink.setSelectionMethod(new com.foundation.view.MethodAssociation(this, REMOVE_LINK_SELECTION_METHOD_ASSOCIATION, removeLink, "controllerHolder", null, null));
removeLink.setDefaultIsEnabled(false);
removeLink.setIsEnabledAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.eua.local.view.controller.EncryptViewController.class, REMOVE_LINK_ASSOCIATION_IS_ENABLED_ASSOCIATION_0, this, false, new com.foundation.view.AssociationAttribute[] {new com.foundation.view.AssociationAttribute(com.eua.local.view.controller.EncryptViewController.SELECTED_FILES, REMOVE_LINK_ASSOCIATION_IS_ENABLED_AA0_ATTRIBUTE_ASSOCIATION, this, false)}, new com.foundation.view.AssociationNode[] {new com.foundation.view.AssociationNode("com.foundation.util.IManagedList", null, new int[] {com.foundation.util.IManagedList.SIZE.getNumber()})}, new com.foundation.view.EventAssociation[] {}, null,true)}));
}//initializeRemoveLink()//
public void initializeUnnamedComponent0(com.foundation.view.swt.Container parent) {
unnamedComponent0 = new com.foundation.view.swt.Panel(parent, null, 0);
initializeFilesLabel(unnamedComponent0);
initializeAddLink(unnamedComponent0);
initializeRemoveLink(unnamedComponent0);
com.foundation.view.swt.GridLayout layout = new com.foundation.view.swt.GridLayout(unnamedComponent0);
layout.setNumColumns(3);
unnamedComponent0.setLayout(layout);
unnamedComponent0.setTabOrder(new com.common.util.LiteList(new Object[] {addLink, removeLink}));
}//initializeUnnamedComponent0()//
public void initializeFilesList(com.foundation.view.swt.Container parent) {
filesList = new com.foundation.view.swt.SimpleTable(parent, FILES_LIST_COMPONENT, com.foundation.view.swt.SimpleTable.STYLE_BORDER|com.foundation.view.swt.SimpleTable.STYLE_MULTI);
filesList.setFillOnInitialize(true);
com.foundation.view.swt.SimpleTable.ColumnData filesListColumnPart0 = filesList.addColumn();
filesListColumnPart0.setHeaderText("Name");
filesListColumnPart0.setCellTextAssociation(new com.foundation.view.MultiAssociationContainer(new com.foundation.view.MultiAssociation[] {new com.foundation.view.MultiAssociation(com.eua.model.FileMetadata.class, FILES_LIST_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.eua.model.FileMetadata.class, com.eua.model.FileMetadata.NAME)}, null,true)}));
com.foundation.view.swt.SimpleTable.ColumnData filesListColumnPart1 = filesList.addColumn();
filesListColumnPart1.setHeaderText("Path");
filesListColumnPart1.setCellTextAssociation(new com.foundation.view.MultiAssociationContainer(new com.foundation.view.MultiAssociation[] {new com.foundation.view.MultiAssociation(com.eua.model.FileMetadata.class, FILES_LIST_COLUMN_PART1_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.eua.model.FileMetadata.class, com.eua.model.FileMetadata.PATH)}, null,true)}));
com.foundation.view.swt.SimpleTable.ColumnData filesListColumnPart2 = filesList.addColumn();
filesListColumnPart2.setHeaderText("Size");
filesListColumnPart2.setCellTextAssociation(new com.foundation.view.MultiAssociationContainer(new com.foundation.view.MultiAssociation[] {new com.foundation.view.MultiAssociation(com.eua.model.FileMetadata.class, FILES_LIST_COLUMN_PART2_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.eua.model.FileMetadata.class, com.eua.model.FileMetadata.SIZE)}, null,true)}));
filesList.setAutoSynchronizeSelection(true);
filesList.setCollectionAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.eua.local.view.controller.EncryptViewController.class, FILES_LIST_ASSOCIATION_COLLECTION_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.eua.local.view.controller.EncryptViewController.class, com.eua.local.view.controller.EncryptViewController.FILES)}, null,true)}));
filesList.setSelectionAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.eua.local.view.controller.EncryptViewController.class, FILES_LIST_ASSOCIATION_SELECTION_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.eua.local.view.controller.EncryptViewController.class, com.eua.local.view.controller.EncryptViewController.SELECTED_FILES)}, null,true)}));
}//initializeFilesList()//
public void initializeUnnamedComponent1(com.foundation.view.swt.Container parent) {
unnamedComponent1 = new com.foundation.view.swt.Panel(parent, null, 0);
unnamedComponent1.setTabOrder(new com.common.util.LiteList(new Object[] {}));
}//initializeUnnamedComponent1()//
public void initializePasswordLabel(com.foundation.view.swt.Container parent) {
passwordLabel = new com.foundation.view.swt.Label(parent, PASSWORD_LABEL_COMPONENT, 0);
passwordLabel.setText("Password");
}//initializePasswordLabel()//
public void initializePasswordField(com.foundation.view.swt.Container parent) {
passwordField = new com.foundation.view.swt.TextField(parent, PASSWORD_FIELD_COMPONENT, com.foundation.view.swt.TextField.STYLE_BORDER|com.foundation.view.swt.TextField.STYLE_SINGLE);
com.foundation.view.swt.TextField.TextFormat passwordFieldFormat = (com.foundation.view.swt.TextField.TextFormat) passwordField.initializeFormat(com.foundation.view.swt.TextField.TextFormat.class);
passwordFieldFormat.setEchoCharacter(new Character('*'));
passwordFieldFormat.setValueAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.eua.local.view.controller.EncryptViewController.class, PASSWORD_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.eua.local.view.controller.EncryptViewController.class, com.eua.local.view.controller.EncryptViewController.PASSWORD)}, null,true,com.eua.local.view.controller.EncryptViewController.PASSWORD)}));
passwordField.setAutoSynchronizeValue(true);
passwordField.setAutoSynchronizeValueDelay(10l);
passwordField.setAutoValidate(true);
passwordField.setSelectOnFocus(true);
}//initializePasswordField()//
public void initializeOutputDirectoryLabel(com.foundation.view.swt.Container parent) {
outputDirectoryLabel = new com.foundation.view.swt.Label(parent, OUTPUT_DIRECTORY_LABEL_COMPONENT, 0);
outputDirectoryLabel.setText("Output Directory");
}//initializeOutputDirectoryLabel()//
public void initializeOutputDirectoryField(com.foundation.view.swt.Container parent) {
outputDirectoryField = new com.foundation.view.swt.TextField(parent, OUTPUT_DIRECTORY_FIELD_COMPONENT, com.foundation.view.swt.TextField.STYLE_BORDER|com.foundation.view.swt.TextField.STYLE_SINGLE|com.foundation.view.swt.TextField.STYLE_READ_ONLY);
com.foundation.view.swt.TextField.TextFormat outputDirectoryFieldFormat = (com.foundation.view.swt.TextField.TextFormat) outputDirectoryField.initializeFormat(com.foundation.view.swt.TextField.TextFormat.class);
outputDirectoryFieldFormat.setValueAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.eua.local.view.controller.EncryptViewController.class, OUTPUT_DIRECTORY_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.eua.local.view.controller.EncryptViewController.class, com.eua.local.view.controller.EncryptViewController.OUTPUT_DIRECTORY)}, null,true,com.eua.local.view.controller.EncryptViewController.OUTPUT_DIRECTORY)}));
outputDirectoryField.setSelectOnFocus(true);
}//initializeOutputDirectoryField()//
public void initializeOutputDirectoryEditButton(com.foundation.view.swt.Container parent) {
outputDirectoryEditButton = new com.foundation.view.swt.Button(parent, OUTPUT_DIRECTORY_EDIT_BUTTON_COMPONENT, 0);
outputDirectoryEditButton.setText("..");
outputDirectoryEditButton.setSelectionMethod(new com.foundation.view.MethodAssociation(this, OUTPUT_DIRECTORY_EDIT_BUTTON_SELECTION_METHOD_ASSOCIATION, outputDirectoryEditButton, "controllerHolder", null, null));
}//initializeOutputDirectoryEditButton()//
public void initializeOutputNameLabel(com.foundation.view.swt.Container parent) {
outputNameLabel = new com.foundation.view.swt.Label(parent, OUTPUT_NAME_LABEL_COMPONENT, 0);
outputNameLabel.setText("Encrypted File Name");
}//initializeOutputNameLabel()//
public void initializeOutputNameField(com.foundation.view.swt.Container parent) {
outputNameField = new com.foundation.view.swt.TextField(parent, OUTPUT_NAME_FIELD_COMPONENT, com.foundation.view.swt.TextField.STYLE_BORDER|com.foundation.view.swt.TextField.STYLE_SINGLE);
com.foundation.view.swt.TextField.TextFormat outputNameFieldFormat = (com.foundation.view.swt.TextField.TextFormat) outputNameField.initializeFormat(com.foundation.view.swt.TextField.TextFormat.class);
outputNameFieldFormat.setValueAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.eua.local.view.controller.EncryptViewController.class, OUTPUT_NAME_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.eua.local.view.controller.EncryptViewController.class, com.eua.local.view.controller.EncryptViewController.OUTPUT_NAME)}, null,true,com.eua.local.view.controller.EncryptViewController.OUTPUT_NAME)}));
outputNameField.setAutoSynchronizeValue(true);
outputNameField.setAutoSynchronizeValueDelay(10l);
outputNameField.setAutoValidate(true);
outputNameField.setSelectOnFocus(true);
}//initializeOutputNameField()//
public void initializeUnnamedComponent2(com.foundation.view.swt.Container parent) {
unnamedComponent2 = new com.foundation.view.swt.Panel(parent, null, 0);
unnamedComponent2.setTabOrder(new com.common.util.LiteList(new Object[] {}));
}//initializeUnnamedComponent2()//
public void initializeSplitCheckBox(com.foundation.view.swt.Container parent) {
splitCheckBox = new com.foundation.view.swt.Button(parent, SPLIT_CHECK_BOX_COMPONENT, com.foundation.view.swt.Button.STYLE_CHECK);
splitCheckBox.setText("Split Output File");
splitCheckBox.setAutoSynchronizeSelection(true);
splitCheckBox.setAutoSynchronizeSelectionDelay(10l);
splitCheckBox.setSelectionAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.eua.local.view.controller.EncryptViewController.class, SPLIT_CHECK_BOX_ASSOCIATION_SELECTION_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.eua.local.view.controller.EncryptViewController.class, com.eua.local.view.controller.EncryptViewController.SPLIT)}, null,true)}));
}//initializeSplitCheckBox()//
public void initializeMaximumOutputSizeLabel(com.foundation.view.swt.Container parent) {
maximumOutputSizeLabel = new com.foundation.view.swt.Label(parent, MAXIMUM_OUTPUT_SIZE_LABEL_COMPONENT, 0);
maximumOutputSizeLabel.setText("Maximum Ouptut Size");
}//initializeMaximumOutputSizeLabel()//
public void initializeMaximumOutputSizeField(com.foundation.view.swt.Container parent) {
maximumOutputSizeField = new com.foundation.view.swt.TextField(parent, MAXIMUM_OUTPUT_SIZE_FIELD_COMPONENT, com.foundation.view.swt.TextField.STYLE_BORDER|com.foundation.view.swt.TextField.STYLE_SINGLE);
com.foundation.view.swt.TextField.IntegerFormat maximumOutputSizeFieldFormat = (com.foundation.view.swt.TextField.IntegerFormat) maximumOutputSizeField.initializeFormat(com.foundation.view.swt.TextField.IntegerFormat.class);
maximumOutputSizeFieldFormat.setModelType(com.foundation.view.swt.TextField.IntegerFormat.DATA_TYPE_LONG);
maximumOutputSizeFieldFormat.setMaxValue(new java.math.BigDecimal("9223372036854775807"));
maximumOutputSizeFieldFormat.setMinValue(new java.math.BigDecimal("1"));
maximumOutputSizeFieldFormat.setValueAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.eua.local.view.controller.EncryptViewController.class, MAXIMUM_OUTPUT_SIZE_FIELD_FORMAT_FORMAT_ASSOCIATION_VALUE_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.eua.local.view.controller.EncryptViewController.class, com.eua.local.view.controller.EncryptViewController.MAXIMUM_OUTPUT_SIZE)}, null,true,com.eua.local.view.controller.EncryptViewController.MAXIMUM_OUTPUT_SIZE)}));
maximumOutputSizeField.setAutoSynchronizeValue(true);
maximumOutputSizeField.setAutoSynchronizeValueDelay(10l);
maximumOutputSizeField.setAutoValidate(true);
maximumOutputSizeField.setSelectOnFocus(true);
}//initializeMaximumOutputSizeField()//
public void initializeMaximumOutputMetricLabel(com.foundation.view.swt.Container parent) {
maximumOutputMetricLabel = new com.foundation.view.swt.Label(parent, MAXIMUM_OUTPUT_METRIC_LABEL_COMPONENT, 0);
maximumOutputMetricLabel.setText("Metric");
}//initializeMaximumOutputMetricLabel()//
public void initializeUnnamedComponent4(com.foundation.view.swt.Container parent) {
unnamedComponent4 = new com.foundation.view.swt.ComboBox(parent, null, com.foundation.view.swt.ComboBox.STYLE_BORDER);
unnamedComponent4.setAutoSynchronizeSelection(true);
unnamedComponent4.setCollectionAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.eua.local.view.controller.EncryptViewController.class, UNNAMED_COMPONENT4_ASSOCIATION_COLLECTION_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[0], null,true)}));
unnamedComponent4.setSelectionAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.eua.local.view.controller.EncryptViewController.class, UNNAMED_COMPONENT4_ASSOCIATION_SELECTION_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.eua.local.view.controller.EncryptViewController.class, com.eua.local.view.controller.EncryptViewController.MAXIMUM_OUTPUT_METRIC)}, null,true)}));
unnamedComponent4.setItemTextAssociation(new com.foundation.view.MultiAssociationContainer(new com.foundation.view.MultiAssociation[] {new com.foundation.view.MultiAssociation(java.lang.Integer.class, UNNAMED_COMPONENT4_ASSOCIATION_ITEM_TEXT_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[0],"controllerHolder",true)}));
}//initializeUnnamedComponent4()//
public void initializeUnnamedComponent3(com.foundation.view.swt.Container parent) {
unnamedComponent3 = new com.foundation.view.swt.Group(parent, null, 0);
initializeMaximumOutputSizeLabel(unnamedComponent3);
initializeMaximumOutputSizeField(unnamedComponent3);
initializeMaximumOutputMetricLabel(unnamedComponent3);
initializeUnnamedComponent4(unnamedComponent3);
com.foundation.view.swt.GridLayout layout = new com.foundation.view.swt.GridLayout(unnamedComponent3);
layout.setNumColumns(2);
layout.setMarginHeight(4);
layout.setMarginWidth(4);
unnamedComponent3.setLayout(layout);
unnamedComponent3.setTabOrder(new com.common.util.LiteList(new Object[] {maximumOutputSizeField, unnamedComponent4}));
unnamedComponent3.setIsEnabledAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.eua.local.view.controller.EncryptViewController.class, UNNAMED_COMPONENT3_ASSOCIATION_IS_ENABLED_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.eua.local.view.controller.EncryptViewController.class, com.eua.local.view.controller.EncryptViewController.SPLIT)}, null,true)}));
unnamedComponent3.setDefaultContainerTitle("Split Options");
}//initializeUnnamedComponent3()//
public void initializeUnnamedComponent5(com.foundation.view.swt.Container parent) {
unnamedComponent5 = new com.foundation.view.swt.Panel(parent, null, 0);
unnamedComponent5.setTabOrder(new com.common.util.LiteList(new Object[] {}));
}//initializeUnnamedComponent5()//
public void initializeEncryptButton(com.foundation.view.swt.Container parent) {
encryptButton = new com.foundation.view.swt.Button(parent, ENCRYPT_BUTTON_COMPONENT, com.foundation.view.swt.Button.STYLE_PUSH);
encryptButton.setText("Encrypt");
encryptButton.setSelectionMethod(new com.foundation.view.MethodAssociation(this, ENCRYPT_BUTTON_SELECTION_METHOD_ASSOCIATION, encryptButton, "controllerHolder", null, null));
encryptButton.setDefaultIsEnabled(false);
encryptButton.setDefaultFont(com.foundation.view.JefFont.getJefFonts("8, bold"));
encryptButton.setIsEnabledAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.eua.local.view.controller.EncryptViewController.class, ENCRYPT_BUTTON_ASSOCIATION_IS_ENABLED_ASSOCIATION_0, this, false, new com.foundation.view.AssociationAttribute[] {new com.foundation.view.AssociationAttribute(com.eua.local.view.controller.EncryptViewController.FILES, ENCRYPT_BUTTON_ASSOCIATION_IS_ENABLED_AA0_ATTRIBUTE_ASSOCIATION, this, false)}, new com.foundation.view.AssociationNode[] {new com.foundation.view.AssociationNode("com.foundation.util.IManagedList", null, new int[] {com.foundation.util.IManagedList.SIZE.getNumber()})}, new com.foundation.view.EventAssociation[] {}, null,true)}));
}//initializeEncryptButton()//
public void initializeButtonPanel(com.foundation.view.swt.Container parent) {
buttonPanel = new com.foundation.view.swt.Panel(parent, BUTTON_PANEL_COMPONENT, 0);
initializeEncryptButton(buttonPanel);
com.foundation.view.swt.RowLayout layout = new com.foundation.view.swt.RowLayout(buttonPanel);
layout.setSpacing(10);
layout.setMarginHeight(0);
layout.setMarginWidth(0);
layout.setWrap(false);
layout.setPack(false);
layout.setJustify(false);
buttonPanel.setLayout(layout);
buttonPanel.setTabOrder(new com.common.util.LiteList(new Object[] {encryptButton}));
}//initializeButtonPanel()//
public void initializeMain(com.foundation.view.swt.Container parent) {
main = new com.foundation.view.swt.Panel(parent, MAIN_COMPONENT, 0);
initializeUnnamedComponent0(main);
initializeFilesList(main);
initializeUnnamedComponent1(main);
initializePasswordLabel(main);
initializePasswordField(main);
initializeOutputDirectoryLabel(main);
initializeOutputDirectoryField(main);
initializeOutputDirectoryEditButton(main);
initializeOutputNameLabel(main);
initializeOutputNameField(main);
initializeUnnamedComponent2(main);
initializeSplitCheckBox(main);
initializeUnnamedComponent3(main);
initializeUnnamedComponent5(main);
initializeButtonPanel(main);
com.foundation.view.swt.GridLayout layout = new com.foundation.view.swt.GridLayout(main);
layout.setNumColumns(3);
layout.setMakeColumnsEqualWidth(false);
layout.setMarginHeight(9);
layout.setMarginWidth(6);
layout.setHorizontalSpacing(8);
layout.setVerticalSpacing(6);
main.setLayout(layout);
main.setTabOrder(new com.common.util.LiteList(new Object[] {passwordField, outputDirectoryEditButton, outputNameField, splitCheckBox, unnamedComponent3, buttonPanel}));
}//initializeMain()//
/* (non-Javadoc)
* @see com.foundation.view.IView#internalViewInitialize()
*/
public void internalViewInitialize() {
initializeControllerHolder(this);
initializeMain(this);
com.foundation.view.swt.FillLayout layout = new com.foundation.view.swt.FillLayout(this);
layout.setMarginHeight(4);
layout.setMarginWidth(4);
this.setLayout(layout);
this.setTabOrder(new com.common.util.LiteList(new Object[] {main}));
this.setDefaultContainerTitle("Encrypt");
this.setDefaultButton(encryptButton);
layoutComponents();
super.internalViewInitialize();
setupLinkages();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.view.IAssociationHandler#invokeGetMethod(int, Object)
*/
public Object invokeGetMethod(int associationNumber, Object value) {
Object retVal = null;
switch(associationNumber) {
case REMOVE_LINK_ASSOCIATION_IS_ENABLED_AA0_ATTRIBUTE_ASSOCIATION:
retVal = ((com.eua.local.view.controller.EncryptViewController) value).getSelectedFiles();
break;
case ENCRYPT_BUTTON_ASSOCIATION_IS_ENABLED_AA0_ATTRIBUTE_ASSOCIATION:
retVal = ((com.eua.local.view.controller.EncryptViewController) value).getFiles();
break;
default:
com.common.debug.Debug.log("Attribute association broken.");
break;
}//switch//
return retVal;
}//invokeGetMethod()//
/* (non-Javadoc)
* @see com.foundation.view.IAssociationHandler#invokeSetMethod(int, Object, Object)
*/
public void invokeSetMethod(int associationNumber, Object value, Object parameter) {
switch(associationNumber) {
default:
com.common.debug.Debug.log("Attribute association broken.");
break;
}//switch//
}//invokeSetMethod()//
/* (non-Javadoc)
* @see com.foundation.view.IAssociationHandler#invokeMethod(int, Object, Object[])
*/
public Object invokeMethod(int associationNumber, Object value, Object[] parameters) {
Object retVal = null;
switch(associationNumber) {
case ADD_LINK_SELECTION_METHOD_ASSOCIATION:
((com.eua.local.view.controller.EncryptViewController) value).doAddFiles();
break;
case REMOVE_LINK_SELECTION_METHOD_ASSOCIATION:
((com.eua.local.view.controller.EncryptViewController) value).doRemoveFiles();
break;
case OUTPUT_DIRECTORY_EDIT_BUTTON_SELECTION_METHOD_ASSOCIATION:
((com.eua.local.view.controller.EncryptViewController) value).doChangeOutputDirectory();
break;
case ENCRYPT_BUTTON_SELECTION_METHOD_ASSOCIATION:
((com.eua.local.view.controller.EncryptViewController) value).doEncrypt();
break;
default:
com.common.debug.Debug.log("Method association broken.");
break;
}//switch//
return retVal;
}//invokeMethod()//
/* (non-Javadoc)
* @see com.foundation.view.IAssociationHandler#invokeMethod(int, Object, Object[], byte)
*/
public Object invokeMethod(int associationNumber, Object value, Object[] parameters, byte flags) {
Object result = null;
if(flags == INVOKE_GETTER_METHOD_FLAG) {
switch(associationNumber) {
case REMOVE_LINK_ASSOCIATION_IS_ENABLED_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getSelectedFiles();
break;
case FILES_LIST_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0:
result = ((com.eua.model.FileMetadata) value).getName();
break;
case FILES_LIST_COLUMN_PART1_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0:
result = ((com.eua.model.FileMetadata) value).getPath();
break;
case FILES_LIST_COLUMN_PART2_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0:
result = ((com.eua.model.FileMetadata) value).getSize();
break;
case FILES_LIST_ASSOCIATION_COLLECTION_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getFiles();
break;
case FILES_LIST_ASSOCIATION_SELECTION_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getSelectedFiles();
break;
case PASSWORD_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getPassword();
break;
case OUTPUT_DIRECTORY_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getOutputDirectory();
break;
case OUTPUT_NAME_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getOutputName();
break;
case SPLIT_CHECK_BOX_ASSOCIATION_SELECTION_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getSplit();
break;
case MAXIMUM_OUTPUT_SIZE_FIELD_FORMAT_FORMAT_ASSOCIATION_VALUE_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getMaximumOutputSize();
break;
case UNNAMED_COMPONENT4_ASSOCIATION_COLLECTION_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getMetrics();
break;
case UNNAMED_COMPONENT4_ASSOCIATION_SELECTION_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getMaximumOutputMetric();
break;
case UNNAMED_COMPONENT4_ASSOCIATION_ITEM_TEXT_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getMetricName((java.lang.Integer) parameters[0]);
break;
case UNNAMED_COMPONENT3_ASSOCIATION_IS_ENABLED_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getSplit();
break;
case ENCRYPT_BUTTON_ASSOCIATION_IS_ENABLED_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getFiles();
break;
default:
com.common.debug.Debug.log("Association (getter) broken.");
break;
}//switch//
}//if//
else if(flags == INVOKE_ORIGINAL_VALUE_GETTER_METHOD_FLAG) {
switch(associationNumber) {
case FILES_LIST_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0:
result = ((com.eua.model.FileMetadata) value).getOldAttributeValue(com.eua.model.FileMetadata.NAME);
break;
case FILES_LIST_COLUMN_PART1_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0:
result = ((com.eua.model.FileMetadata) value).getOldAttributeValue(com.eua.model.FileMetadata.PATH);
break;
case FILES_LIST_COLUMN_PART2_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0:
result = ((com.eua.model.FileMetadata) value).getOldAttributeValue(com.eua.model.FileMetadata.SIZE);
break;
case FILES_LIST_ASSOCIATION_COLLECTION_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getOldAttributeValue(com.eua.local.view.controller.EncryptViewController.FILES);
break;
case FILES_LIST_ASSOCIATION_SELECTION_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getOldAttributeValue(com.eua.local.view.controller.EncryptViewController.SELECTED_FILES);
break;
case PASSWORD_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getOldAttributeValue(com.eua.local.view.controller.EncryptViewController.PASSWORD);
break;
case OUTPUT_DIRECTORY_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getOldAttributeValue(com.eua.local.view.controller.EncryptViewController.OUTPUT_DIRECTORY);
break;
case OUTPUT_NAME_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getOldAttributeValue(com.eua.local.view.controller.EncryptViewController.OUTPUT_NAME);
break;
case SPLIT_CHECK_BOX_ASSOCIATION_SELECTION_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getOldAttributeValue(com.eua.local.view.controller.EncryptViewController.SPLIT);
break;
case MAXIMUM_OUTPUT_SIZE_FIELD_FORMAT_FORMAT_ASSOCIATION_VALUE_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getOldAttributeValue(com.eua.local.view.controller.EncryptViewController.MAXIMUM_OUTPUT_SIZE);
break;
case UNNAMED_COMPONENT4_ASSOCIATION_SELECTION_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getOldAttributeValue(com.eua.local.view.controller.EncryptViewController.MAXIMUM_OUTPUT_METRIC);
break;
case UNNAMED_COMPONENT3_ASSOCIATION_IS_ENABLED_ASSOCIATION_0:
result = ((com.eua.local.view.controller.EncryptViewController) value).getOldAttributeValue(com.eua.local.view.controller.EncryptViewController.SPLIT);
break;
default:
com.common.debug.Debug.log("Association (original value getter) broken.");
break;
}//switch//
}//if//
else {
switch(associationNumber) {
case PASSWORD_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0:
((com.eua.local.view.controller.EncryptViewController) value).setPassword((java.lang.String) parameters[0]);
break;
case OUTPUT_NAME_FIELD_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0:
((com.eua.local.view.controller.EncryptViewController) value).setOutputName((java.lang.String) parameters[0]);
break;
case SPLIT_CHECK_BOX_ASSOCIATION_SELECTION_ASSOCIATION_0:
((com.eua.local.view.controller.EncryptViewController) value).setSplit((java.lang.Boolean) parameters[0]);
break;
case MAXIMUM_OUTPUT_SIZE_FIELD_FORMAT_FORMAT_ASSOCIATION_VALUE_ASSOCIATION_0:
((com.eua.local.view.controller.EncryptViewController) value).setMaximumOutputSize((java.lang.Long) parameters[0]);
break;
case UNNAMED_COMPONENT4_ASSOCIATION_SELECTION_ASSOCIATION_0:
((com.eua.local.view.controller.EncryptViewController) value).setMaximumOutputMetric((java.lang.Integer) parameters[0]);
break;
default:
com.common.debug.Debug.log("Association (setter) broken.");
break;
}//switch//
}//else//
return result;
}//invokeMethod()//
/**
* Lays out the components.
*/
public void layoutComponents() {
{ //null//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.FILL;
layoutData.horizontalSpan = 3;
layoutData.grabExcessHorizontalSpace = true;
unnamedComponent0.setLayoutData(layoutData);
}//block//
{ //filesLabel//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.BEGINNING;
layoutData.grabExcessHorizontalSpace = true;
filesLabel.setLayoutData(layoutData);
}//block//
{ //addLink//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.END;
layoutData.grabExcessHorizontalSpace = false;
addLink.setLayoutData(layoutData);
}//block//
{ //removeLink//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.END;
layoutData.grabExcessHorizontalSpace = false;
removeLink.setLayoutData(layoutData);
}//block//
{ //filesList//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.FILL;
layoutData.minimumHeight = 140;
layoutData.heightHint = 140;
layoutData.horizontalSpan = 3;
layoutData.grabExcessHorizontalSpace = true;
filesList.setLayoutData(layoutData);
}//block//
{ //null//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.minimumHeight = 10;
layoutData.heightHint = 10;
layoutData.horizontalSpan = 3;
layoutData.grabExcessHorizontalSpace = true;
unnamedComponent1.setLayoutData(layoutData);
}//block//
{ //passwordLabel//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.END;
passwordLabel.setLayoutData(layoutData);
}//block//
{ //passwordField//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.FILL;
layoutData.horizontalSpan = 2;
layoutData.grabExcessHorizontalSpace = true;
passwordField.setLayoutData(layoutData);
}//block//
{ //outputDirectoryLabel//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.END;
outputDirectoryLabel.setLayoutData(layoutData);
}//block//
{ //outputDirectoryField//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.FILL;
layoutData.grabExcessHorizontalSpace = true;
outputDirectoryField.setLayoutData(layoutData);
}//block//
{ //outputNameLabel//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.END;
outputNameLabel.setLayoutData(layoutData);
}//block//
{ //outputNameField//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.FILL;
layoutData.horizontalSpan = 2;
layoutData.grabExcessHorizontalSpace = true;
outputNameField.setLayoutData(layoutData);
}//block//
{ //null//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.minimumHeight = 10;
layoutData.heightHint = 10;
layoutData.horizontalSpan = 3;
layoutData.grabExcessHorizontalSpace = true;
unnamedComponent2.setLayoutData(layoutData);
}//block//
{ //splitCheckBox//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.BEGINNING;
layoutData.horizontalSpan = 3;
splitCheckBox.setLayoutData(layoutData);
}//block//
{ //null//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.FILL;
layoutData.horizontalSpan = 3;
layoutData.grabExcessHorizontalSpace = true;
unnamedComponent3.setLayoutData(layoutData);
}//block//
{ //maximumOutputSizeLabel//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.END;
maximumOutputSizeLabel.setLayoutData(layoutData);
}//block//
{ //maximumOutputSizeField//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.FILL;
layoutData.grabExcessHorizontalSpace = true;
maximumOutputSizeField.setLayoutData(layoutData);
}//block//
{ //maximumOutputMetricLabel//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.END;
maximumOutputMetricLabel.setLayoutData(layoutData);
}//block//
{ //null//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.BEGINNING;
layoutData.grabExcessHorizontalSpace = true;
unnamedComponent4.setLayoutData(layoutData);
}//block//
{ //null//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.minimumHeight = 2;
layoutData.heightHint = 2;
layoutData.horizontalSpan = 3;
layoutData.grabExcessHorizontalSpace = true;
unnamedComponent5.setLayoutData(layoutData);
}//block//
{ //buttonPanel//
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.CENTER;
layoutData.horizontalSpan = 3;
buttonPanel.setLayoutData(layoutData);
}//block//
{ //encryptButton//
com.foundation.view.swt.layout.RowData layoutData = new com.foundation.view.swt.layout.RowData();
encryptButton.setLayoutData(layoutData);
}//block//
}//layoutComponents()//
/**
* Initializes the direct linkages between the components.
*/
public void setupLinkages() {
}//setupLinkages()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.ValueHolder getVpControllerHolder() {
return controllerHolder;
}//getVpControllerHolder()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Panel getVpMain() {
return main;
}//getVpMain()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Panel getVpUnnamedComponent0() {
return unnamedComponent0;
}//getVpUnnamedComponent0()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Label getVpFilesLabel() {
return filesLabel;
}//getVpFilesLabel()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Link getVpAddLink() {
return addLink;
}//getVpAddLink()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Link getVpRemoveLink() {
return removeLink;
}//getVpRemoveLink()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.SimpleTable getVpFilesList() {
return filesList;
}//getVpFilesList()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Panel getVpUnnamedComponent1() {
return unnamedComponent1;
}//getVpUnnamedComponent1()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Label getVpPasswordLabel() {
return passwordLabel;
}//getVpPasswordLabel()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.TextField getVpPasswordField() {
return passwordField;
}//getVpPasswordField()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Label getVpOutputDirectoryLabel() {
return outputDirectoryLabel;
}//getVpOutputDirectoryLabel()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.TextField getVpOutputDirectoryField() {
return outputDirectoryField;
}//getVpOutputDirectoryField()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Button getVpOutputDirectoryEditButton() {
return outputDirectoryEditButton;
}//getVpOutputDirectoryEditButton()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Label getVpOutputNameLabel() {
return outputNameLabel;
}//getVpOutputNameLabel()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.TextField getVpOutputNameField() {
return outputNameField;
}//getVpOutputNameField()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Panel getVpUnnamedComponent2() {
return unnamedComponent2;
}//getVpUnnamedComponent2()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Button getVpSplitCheckBox() {
return splitCheckBox;
}//getVpSplitCheckBox()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Group getVpUnnamedComponent3() {
return unnamedComponent3;
}//getVpUnnamedComponent3()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Label getVpMaximumOutputSizeLabel() {
return maximumOutputSizeLabel;
}//getVpMaximumOutputSizeLabel()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.TextField getVpMaximumOutputSizeField() {
return maximumOutputSizeField;
}//getVpMaximumOutputSizeField()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Label getVpMaximumOutputMetricLabel() {
return maximumOutputMetricLabel;
}//getVpMaximumOutputMetricLabel()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.ComboBox getVpUnnamedComponent4() {
return unnamedComponent4;
}//getVpUnnamedComponent4()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Panel getVpUnnamedComponent5() {
return unnamedComponent5;
}//getVpUnnamedComponent5()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Panel getVpButtonPanel() {
return buttonPanel;
}//getVpButtonPanel()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.Button getVpEncryptButton() {
return encryptButton;
}//getVpEncryptButton()//
}//EncryptView//

View File

@@ -0,0 +1,143 @@
<?xml version="1.0"?>
<vml>
<metadata>
<platform name="thick:swt"/>
</metadata>
<panel name="EncryptView" style="" container-image="" container-title="Encrypt" default-button="encryptButton">
<fill-layout margin-height="4" margin-width="4"/>
<value-holder name="controllerHolder" type="com.eua.local.view.controller.EncryptViewController"/>
<panel name="main" style="" tab-order="1">
<grid-layout column-count="3" margin-height="9" margin-width="6" equal-width-columns="false" horizontal-spacing="8" vertical-spacing="6"/>
<panel>
<grid-layout column-count="3"/>
<grid-layout-data horizontal-span="3" horizontal-fill="true" horizontal-alignment="fill"/>
<label name="filesLabel" text="Files">
<grid-layout-data horizontal-alignment="beginning" horizontal-fill="true"/>
</label>
<hyperlink name="addLink" text="&lt;a&gt;Add...&lt;/a&gt;" tab-order="1">
<grid-layout-data horizontal-alignment="end" horizontal-fill="false"/>
<method function="selection" name="doAddFiles" value-holder="controllerHolder"/>
</hyperlink>
<hyperlink name="removeLink" text="&lt;a&gt;Remove&lt;/a&gt;" is-enabled="false" tab-order="1">
<grid-layout-data horizontal-alignment="end" horizontal-fill="false"/>
<association function="is-enabled" getter="getSelectedFiles" value-holder="controllerHolder">
<association-attribute attribute="selectedFiles"/>
<association-node row-type="com.foundation.util.IManagedList">
<association-event event="size"/>
</association-node>
</association>
<method function="selection" name="doRemoveFiles" value-holder="controllerHolder"/>
</hyperlink>
</panel>
<simple-table name="filesList" style="border | multi selection" fill-on-initialize="true" auto-synchronize-selection="true">
<grid-layout-data horizontal-span="3" horizontal-fill="true" horizontal-alignment="fill" minimum-height="140"/>
<association function="collection" attribute="files" value-holder="controllerHolder"/>
<association function="selection" attribute="selectedFiles" value-holder="controllerHolder"/>
<columns>
<column header-text="Name">
<association function="cell-text" attribute="name" row-type="com.eua.model.FileMetadata"/>
</column>
<column header-text="Path">
<association function="cell-text" attribute="path" row-type="com.eua.model.FileMetadata"/>
</column>
<column header-text="Size">
<association function="cell-text" attribute="size" row-type="com.eua.model.FileMetadata"/>
</column>
</columns>
</simple-table>
<panel>
<grid-layout-data horizontal-fill="true" horizontal-span="3" minimum-height="10"/>
</panel>
<label name="passwordLabel" text="Password">
<grid-layout-data horizontal-alignment="end"/>
</label>
<text name="passwordField" select-on-focus="true" style="single line|border" tab-order="1" auto-synchronize-text="true" auto-synchronize-text-delay="10" auto-validate="true">
<grid-layout-data horizontal-alignment="fill" horizontal-fill="true" horizontal-span="2"/>
<text-format echo-char="*">
<association function="text" attribute="password" value-holder="controllerHolder" decorate="true"/>
</text-format>
</text>
<label name="outputDirectoryLabel" text="Output Directory">
<grid-layout-data horizontal-alignment="end"/>
</label>
<text name="outputDirectoryField" select-on-focus="true" style="single line|border|read only">
<grid-layout-data horizontal-alignment="fill" horizontal-fill="true"/>
<text-format>
<association function="text" attribute="outputDirectory" value-holder="controllerHolder" decorate="true"/>
</text-format>
</text>
<button name="outputDirectoryEditButton" text=".." tab-order="1">
<method function="selection" name="doChangeOutputDirectory" value-holder="controllerHolder"/>
</button>
<label name="outputNameLabel" text="Encrypted File Name">
<grid-layout-data horizontal-alignment="end"/>
</label>
<text name="outputNameField" select-on-focus="true" style="single line|border" tab-order="1" auto-synchronize-text="true" auto-synchronize-text-delay="10" auto-validate="true">
<grid-layout-data horizontal-alignment="fill" horizontal-fill="true" horizontal-span="2"/>
<text-format>
<association function="text" attribute="outputName" value-holder="controllerHolder" decorate="true"/>
</text-format>
</text>
<panel>
<grid-layout-data horizontal-fill="true" horizontal-span="3" minimum-height="10"/>
</panel>
<button-toggle style="check" name="splitCheckBox" text="Split Output File" tab-order="1" auto-synchronize-selection="true" auto-synchronize-selection-delay="10">
<grid-layout-data horizontal-span="3" horizontal-alignment="beginning"/>
<association function="selection" attribute="split" value-holder="controllerHolder"/>
</button-toggle>
<group style="" container-title="Split Options" tab-order="1">
<grid-layout column-count="2" margin-height="4" margin-width="4"/>
<grid-layout-data horizontal-span="3" horizontal-fill="true" horizontal-alignment="fill"/>
<association function="is-enabled" attribute="split" value-holder="controllerHolder"/>
<label name="maximumOutputSizeLabel" text="Maximum Ouptut Size">
<grid-layout-data horizontal-alignment="end"/>
</label>
<text name="maximumOutputSizeField" select-on-focus="true" style="single line|border" tab-order="1" auto-synchronize-text="true" auto-synchronize-text-delay="10" auto-validate="true">
<grid-layout-data horizontal-alignment="fill" horizontal-fill="true"/>
<integer-format model-type="long" min-value="1">
<association function="value" attribute="maximumOutputSize" value-holder="controllerHolder" decorate="true"/>
</integer-format>
</text>
<label name="maximumOutputMetricLabel" text="Metric">
<grid-layout-data horizontal-alignment="end"/>
</label>
<combo style="border" auto-synchronize-selection="true" tab-order="1">
<grid-layout-data horizontal-alignment="beginning" horizontal-fill="true"/>
<association function="collection" getter="getMetrics" value-holder="controllerHolder"/>
<association function="selection" attribute="maximumOutputMetric" value-holder="controllerHolder"/>
<association function="item-text" getter="getMetricName" getter-signature="Ljava.lang.Integer;" row-type="java.lang.Integer" value-holder="controllerHolder"/>
</combo>
</group>
<panel>
<grid-layout-data horizontal-fill="true" horizontal-span="3" minimum-height="2"/>
</panel>
<panel name="buttonPanel" tab-order="1">
<grid-layout-data horizontal-span="3" horizontal-alignment="center"/>
<row-layout spacing="10" wrap="false" pack="false" fill="true" justify="false" margin-width="0" margin-height="0"/>
<button name="encryptButton" style="push" text="Encrypt" font="8, bold" tab-order="1" is-enabled="false">
<row-layout-data/>
<method function="selection" name="doEncrypt" signature="" value-holder="controllerHolder"/>
<association function="is-enabled" getter="getFiles" value-holder="controllerHolder">
<association-attribute attribute="files"/>
<association-node row-type="com.foundation.util.IManagedList">
<association-event event="size"/>
</association-node>
</association>
</button>
</panel>
</panel>
</panel>
</vml>

View File

@@ -0,0 +1,168 @@
package com.eua.local.view;
/**
* MainView
*/
public class MainView extends com.foundation.view.swt.Window implements com.foundation.view.IAssociationHandler {
//Component Names//
public static final String CONTROLLER_HOLDER_COMPONENT = "controllerHolder";
public static final String MAIN_VIEW_COMPONENT = "MainView";
//Association Identifiers//
protected static final int UNNAMED_COMPONENT0_ASSOCIATION_PAGES_ASSOCIATION_0 = 0;
//Method Association Identifiers//
protected static final int THIS_CLOSED_METHOD_ASSOCIATION = 0;
//View Components//
private com.foundation.view.swt.ValueHolder controllerHolder = null;
private com.foundation.view.swt.TabPanel unnamedComponent0 = null;
/**
* MainView default constructor.
* <p>Warning: This constructor is intended for use by the metadata service <b>only</b>. This constructor should <b>never</b> be called by the view's controller.</p>
*/
public MainView() {
}//MainView()//
/**
* MainView constructor.
* @param controller The view controller which will be assigned to the value holder(s) that don't depend on another value holder for their value.
*/
public MainView(com.foundation.controller.ViewController controller) {
super((com.foundation.controller.ViewController) controller.getParent(), MAIN_VIEW_COMPONENT, com.foundation.view.swt.Window.STYLE_SHELL_TRIM, controller.getContext(), controller);
}//MainView()//
public void initializeControllerHolder(com.foundation.view.swt.Container parent) {
controllerHolder = new com.foundation.view.swt.ValueHolder(parent, CONTROLLER_HOLDER_COMPONENT, com.eua.local.view.controller.MainViewController.class);
}//initializeControllerHolder()//
public void initializeUnnamedComponent0(com.foundation.view.swt.Container parent) {
unnamedComponent0 = new com.foundation.view.swt.TabPanel(parent, null, 0);
com.foundation.view.swt.TabPanel.IPagesHolder pagesHolder = unnamedComponent0.addPages();
pagesHolder.setPagesAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.eua.local.view.controller.MainViewController.class, UNNAMED_COMPONENT0_ASSOCIATION_PAGES_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.eua.local.view.controller.MainViewController.class, com.eua.local.view.controller.MainViewController.TAB_VIEWS)}, null,true)}));
unnamedComponent0.setTabOrder(new com.common.util.LiteList(new Object[] {}));
}//initializeUnnamedComponent0()//
/* (non-Javadoc)
* @see com.foundation.view.IView#internalViewInitialize()
*/
public void internalViewInitialize() {
this.setDefaultContainerImages(new com.foundation.view.resource.ResourceReference("res://Application/General/WindowIcon"));
this.setClosedMethod(new com.foundation.view.MethodAssociation(this, THIS_CLOSED_METHOD_ASSOCIATION, this, "controllerHolder", null, null));
initializeControllerHolder(this);
initializeUnnamedComponent0(this);
com.foundation.view.swt.FillLayout layout = new com.foundation.view.swt.FillLayout(this);
layout.setMarginHeight(4);
layout.setMarginWidth(4);
this.setLayout(layout);
this.setTabOrder(new com.common.util.LiteList(new Object[] {}));
this.setDefaultContainerTitle("Brainstorm Encryption Tool");
layoutComponents();
super.internalViewInitialize();
setupLinkages();
}//internalViewInitialize()//
/* (non-Javadoc)
* @see com.foundation.view.IAssociationHandler#invokeGetMethod(int, Object)
*/
public Object invokeGetMethod(int associationNumber, Object value) {
Object retVal = null;
switch(associationNumber) {
default:
com.common.debug.Debug.log("Attribute association broken.");
break;
}//switch//
return retVal;
}//invokeGetMethod()//
/* (non-Javadoc)
* @see com.foundation.view.IAssociationHandler#invokeSetMethod(int, Object, Object)
*/
public void invokeSetMethod(int associationNumber, Object value, Object parameter) {
switch(associationNumber) {
default:
com.common.debug.Debug.log("Attribute association broken.");
break;
}//switch//
}//invokeSetMethod()//
/* (non-Javadoc)
* @see com.foundation.view.IAssociationHandler#invokeMethod(int, Object, Object[])
*/
public Object invokeMethod(int associationNumber, Object value, Object[] parameters) {
Object retVal = null;
switch(associationNumber) {
case THIS_CLOSED_METHOD_ASSOCIATION:
((com.eua.local.view.controller.MainViewController) value).doClose();
break;
default:
com.common.debug.Debug.log("Method association broken.");
break;
}//switch//
return retVal;
}//invokeMethod()//
/* (non-Javadoc)
* @see com.foundation.view.IAssociationHandler#invokeMethod(int, Object, Object[], byte)
*/
public Object invokeMethod(int associationNumber, Object value, Object[] parameters, byte flags) {
Object result = null;
if(flags == INVOKE_GETTER_METHOD_FLAG) {
switch(associationNumber) {
case UNNAMED_COMPONENT0_ASSOCIATION_PAGES_ASSOCIATION_0:
result = ((com.eua.local.view.controller.MainViewController) value).getTabViews();
break;
default:
com.common.debug.Debug.log("Association (getter) broken.");
break;
}//switch//
}//if//
else if(flags == INVOKE_ORIGINAL_VALUE_GETTER_METHOD_FLAG) {
switch(associationNumber) {
case UNNAMED_COMPONENT0_ASSOCIATION_PAGES_ASSOCIATION_0:
result = ((com.eua.local.view.controller.MainViewController) value).getOldAttributeValue(com.eua.local.view.controller.MainViewController.TAB_VIEWS);
break;
default:
com.common.debug.Debug.log("Association (original value getter) broken.");
break;
}//switch//
}//if//
else {
switch(associationNumber) {
default:
com.common.debug.Debug.log("Association (setter) broken.");
break;
}//switch//
}//else//
return result;
}//invokeMethod()//
/**
* Lays out the components.
*/
public void layoutComponents() {
}//layoutComponents()//
/**
* Initializes the direct linkages between the components.
*/
public void setupLinkages() {
}//setupLinkages()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.ValueHolder getVpControllerHolder() {
return controllerHolder;
}//getVpControllerHolder()//
/**
* Gets the view component.
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
* @return The view component.
*/
protected com.foundation.view.swt.TabPanel getVpUnnamedComponent0() {
return unnamedComponent0;
}//getVpUnnamedComponent0()//
}//MainView//

View File

@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<vml>
<metadata>
<platform name="thick:swt"/>
</metadata>
<window name="MainView" style="window trim" container-image="" container-images="res://Application/General/WindowIcon" container-title="Brainstorm Encryption Tool">
<fill-layout margin-height="4" margin-width="4"/>
<method function="closed" name="doClose" signature="" value-holder="controllerHolder"/>
<value-holder name="controllerHolder" type="com.eua.local.view.controller.MainViewController"/>
<tab-panel>
<pages>
<association function="pages" attribute="tabViews" value-holder="controllerHolder"/>
</pages>
</tab-panel>
</window>
</vml>

View File

@@ -0,0 +1,98 @@
package com.eua.local.view.controller;
import com.foundation.controller.ViewController;
import com.foundation.view.IViewContext;
import com.foundation.application.*;
import com.foundation.attribute.ReflectionContext;
import com.foundation.view.resource.ResourceReference;
import com.foundation.view.swt.MessageDialog;
import com.eua.application.*;
/**
* Copyright Declarative Engineering LLC 2009<p>
*/
public abstract class AbstractViewController extends ViewController {
protected static final int SEQUENCE_MAGIC_NUMBER = 0xFEED03E1;
protected static final int SEQUENCE_VERSION = 0x01;
protected static final int MAGIC_NUMBER = 0xFEED03E0;
protected static final int VERSION = 0x02;
public static final ResourceReference IMAGE_ERROR = new ResourceReference("res://Application/General/ErrorImage");
public static final ResourceReference IMAGE_WARN = new ResourceReference("res://Application/General/WarningImage");
public static final ResourceReference IMAGE_INFO = new ResourceReference("res://Application/General/InformationImage");
/**
* AbstractViewController constructor.
* @param viewContext The view's context under which it will operate.
*/
public AbstractViewController(IViewContext viewContext) {
super(viewContext);
}//AbstractViewController()//
/**
* AbstractViewController constructor.
* @param viewContext The view's context under which it will operate.
* @param reflectionContext The reflection context to be used by the view.
*/
public AbstractViewController(IViewContext context, ReflectionContext reflectionContext) {
super(context, reflectionContext);
}//AbstractViewController()//
/**
* AbstractViewController constructor.
* @param viewContext The view's context under which it will operate.
* @param validateOnOpen Whether the view should perform validation immediately after opening. This is true by default.
*/
public AbstractViewController(IViewContext viewContext, boolean validateOnOpen) {
super(viewContext, validateOnOpen);
}//AbstractViewController()//
/**
* AbstractViewController constructor.
* @param viewContext The view's context under which it will operate.
* @param reflectionContext The reflection context to be used by the view.
* @param validateOnOpen Whether the view should perform validation immediately after opening. This is true by default.
*/
public AbstractViewController(IViewContext context, ReflectionContext reflectionContext, boolean validateOnOpen) {
super(context, reflectionContext, validateOnOpen);
}//AbstractViewController()//
/**
* Gets the application object that this object is running under. The application object provides the object various services that it will need.
* @return The application reference for the application this object is running under.
*/
public IApplication getApplication() {
return EncryptionUtilityApplication.getSingleton();
}//getApplication()//
/**
* Displays an error message to the user.
* @param title
* @param message
*/
public void displayError(String title, String message) {
MessageDialog dialog = new MessageDialog(getView(), MessageDialog.STYLE_ICON_ERROR | MessageDialog.STYLE_OK);
dialog.setText(title);
dialog.setMessage(message);
dialog.open();
}//displayError()//
/**
* Displays an warning message to the user.
* @param title
* @param message
*/
public void displayWarning(String title, String message) {
MessageDialog dialog = new MessageDialog(getView(), MessageDialog.STYLE_ICON_WARNING | MessageDialog.STYLE_OK);
dialog.setText(title);
dialog.setMessage(message);
dialog.open();
}//displayWarning()//
/**
* Displays an information message to the user.
* @param title
* @param message
*/
public void displayInformation(String title, String message) {
MessageDialog dialog = new MessageDialog(getView(), MessageDialog.STYLE_ICON_INFORMATION | MessageDialog.STYLE_OK);
dialog.setText(title);
dialog.setMessage(message);
dialog.open();
}//displayInformation()//
}//AbstractViewController//

View File

@@ -0,0 +1,337 @@
package com.eua.local.view.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Random;
import java.util.zip.ZipInputStream;
import com.common.debug.Debug;
import com.common.io.StreamSupport;
import com.common.io.SymmetricInputStream;
import com.common.security.ISymmetricAlgorithm;
import com.common.security.Rijndael;
import com.common.security.Sha1;
import com.common.util.StringSupport;
import com.eua.controller.SettingsController;
import com.eua.local.view.DecryptView;
import com.foundation.view.ControlDecoration;
import com.foundation.view.IViewContext;
import com.foundation.view.swt.DirectoryDialog;
import com.foundation.view.swt.FileDialog;
import com.foundation.metadata.Attribute;
/**
* Copyright Declarative Engineering LLC 2009<p>
*/
public class DecryptViewController extends AbstractViewController {
public static final Attribute PASSWORD = registerAttribute(DecryptViewController.class, "password");
public static final Attribute INPUT_FILE = registerAttribute(DecryptViewController.class, "inputFile");
public static final Attribute OUTPUT_DIRECTORY = registerAttribute(DecryptViewController.class, "outputDirectory", AO_LAZY);
/**
* DecryptViewController constructor.
* @param viewContext The view context under which this view operates.
*/
public DecryptViewController(IViewContext viewContext) {
super(viewContext, false);
}//DecryptViewController()//
/* (non-Javadoc)
* @see com.foundation.common.Entity#lazyLoadAttribute(int)
*/
protected Object lazyLoadAttribute(Attribute attributeNumber) {
Object result = null;
if(attributeNumber == OUTPUT_DIRECTORY) {
result = SettingsController.getSingleton().getDecryptionOutputDirectory();
if(result == null) {
File desktop = new File(System.getProperty("user.home"), "desktop");
if(desktop.exists()) {
result = desktop.getAbsolutePath();
}//if//
else {
result = System.getProperty("user.dir");
}//else//
}//if//
}//if//
else {
result = super.lazyLoadAttribute(attributeNumber);
}//else//
return result;
}//lazyLoadAttribute()//
/* (non-Javadoc)
* @see com.foundation.controller.AbstractViewController#getViewClass()
*/
protected Class getViewClass() {
return DecryptView.class;
}//getViewClass()//
/* (non-Javadoc)
* @see com.foundation.controller.AbstractViewController#validate()
*/
public boolean validate() {
boolean result = true;
getDecorationManager().clearDecorations();
if(getPassword() == null || getPassword().length() == 0) {
getDecorationManager().addDecoration(this, PASSWORD, new ControlDecoration(IMAGE_ERROR, "Password required."));
result = false;
}//if//
if(getOutputDirectory() == null || getOutputDirectory().trim().length() == 0) {
getDecorationManager().addDecoration(this, OUTPUT_DIRECTORY, new ControlDecoration(IMAGE_ERROR, "Output directory required."));
result = false;
}//if//
getDecorationManager().applyDecorationChanges();
return result;
}//validate()//
/**
* Displays a dialog to allow selection of an encrypted file.
*/
public void doSelectInputFile() {
FileDialog dialog = new FileDialog(getView(), FileDialog.STYLE_OPEN);
String path = SettingsController.getSingleton().getEncryptedFileDirectory();
dialog.setText("Select an encrypted file.");
dialog.setFilterExtensions(new String[] {"*.enc"});
if(path != null) {
dialog.setFilterPath(path);
}//if//
if(dialog.open() != null) {
setInputFile(new File(dialog.getPathAndFileName()));
}//if//
}//doSelectInputFile()//
/**
* Displays a dialog to allow selection of a directory where the decrypted file(s) will be placed.
*/
public void doSelectOutputDirectory() {
DirectoryDialog dialog = new DirectoryDialog(getView(), 0);
String result;
dialog.setMessage("Select a folder to contain the decrypted file(s).");
dialog.setText("Decrypt Location");
if((result = dialog.open()) != null) {
setOutputDirectory(result);
}//if//
}//doSelectOutputDirectory()//
/**
* Decrpyts the selected encrypted volume.
*/
public void doDecrypt() {
synchronize();
if(validate()) {
File inputFile = getInputFile();
File tempFile = null;
FileInputStream fin = null;
FileOutputStream fout = null;
try {
int magicNumber;
int version;
byte[] buffer = new byte[100000]; //100k
fin = new FileInputStream(inputFile);
magicNumber = StreamSupport.readInt(fin);
version = StreamSupport.readInt(fin);
//If this is a sequence then rebuild the entire file.//
if(magicNumber == SEQUENCE_MAGIC_NUMBER) {
int fileCount = StreamSupport.readInt(fin);
boolean hasAllFiles = true;
if(version > SEQUENCE_VERSION) {
displayError("Tool Version Error", "You must upgrade this tool to read the encrypted content. It was written out with a newer version of this tool.");
//Debug.log(new RuntimeException("You must upgrade this tool to read the encrypted content. It was written out with a newer version of this tool."));
fin.close();
fin = null;
}//if//
else {
//Verify we have access to all the encrypted file pieces.//
for(int index = 0; hasAllFiles && index < fileCount; index++) {
File next = new File(inputFile.getAbsolutePath() + "." + (index + 1));
hasAllFiles = (next.exists() && next.canRead());
if(!hasAllFiles) {
displayError("Missing File Error", "Missing the file: " + next);
//Debug.log(new RuntimeException("Missing the file: " + next));
fin = null;
}//if//
}//for//
if(hasAllFiles) {
tempFile = File.createTempFile("encrypted", ".enc");
fin.close();
fout = new FileOutputStream(tempFile);
//Read each file and write to the temporary output file.//
for(int fileIndex = 0; fileIndex < fileCount; fileIndex++) {
fin = new FileInputStream(inputFile.getAbsolutePath() + "." + (fileIndex + 1));
while(fin != null) {
int readCount = StreamSupport.readBytes(fin, buffer, 0, buffer.length);
fout.write(buffer, 0, readCount);
if(readCount != buffer.length) {
fin.close();
fin = null;
}//if//
}//while//
}//for//
inputFile = tempFile;
fin = new FileInputStream(inputFile);
magicNumber = StreamSupport.readInt(fin);
version = StreamSupport.readInt(fin);
}//if//
}//else//
}//if//
if(fin != null && magicNumber == MAGIC_NUMBER) {
if(version > VERSION) {
displayError("Tool Version Error", "You must upgrade this tool to read the encrypted content. It was written out with a newer version of this tool.");
//Debug.log(new RuntimeException("You must upgrade this tool to read the encrypted content. It was written out with a newer version of this tool."));
fin.close();
fin = null;
}//if//
else {
if(version == 1) {
displayWarning("Tool Version Warning", "The encrypted file was created with version 1.0 of this tool. Version 1.0 has some technical problems on certain operating systems (ahhem.. Mac) due a poor implementation of Java.");
}//if//
int fileCount;
String[] fileNames;
long[] fileLengths;
//ISymmetricAlgorithm algorithm = new Rijndael(new Sha1().hashToString(getPassword()));
ISymmetricAlgorithm algorithm = new Rijndael(new Random(StringSupport.hash(getPassword())));
SymmetricInputStream sin = new SymmetricInputStream(fin, algorithm);
ZipInputStream zin = new ZipInputStream(sin);
sin.decrypt(true);
//Start the only zip entry.//
zin.getNextEntry();
//Read the count of output files.//
fileCount = StreamSupport.readInt(zin);
fileNames = new String[fileCount];
fileLengths = new long[fileCount];
//Read the file names and lengths for each output file.//
for(int fileIndex = 0; fileIndex < fileCount; fileIndex++) {
fileNames[fileIndex] = StreamSupport.readString(zin);
fileLengths[fileIndex] = StreamSupport.readLong(zin);
}//for//
//Decrypt the content to each file in order.//
for(int fileIndex = 0; fileIndex < fileCount; fileIndex++) {
long remaining = fileLengths[fileIndex];
fout = new FileOutputStream(new File(getOutputDirectory(), fileNames[fileIndex]));
//Keep reading encrypted content and writing decrypted content until all the decrypted content has been read for the current file.//
while(remaining > 0) {
int expected = buffer.length > remaining ? (int) remaining : buffer.length;
int readCount = StreamSupport.readBytes(zin, buffer, 0, expected);
fout.write(buffer, 0, readCount);
if(readCount < expected) {
displayError("Corrupt File Error", "Failed to finish decrypting the volume due to an unexpected input stream end.");
//Debug.log(new RuntimeException("Failed to finish decrypting the volume due to an unexpected input stream end."));
fin.close();
fin = null;
sin = null;
zin = null;
}//if//
else {
remaining -= readCount;
}//else//
}//while//
fout.close();
fout = null;
}//for//
zin.closeEntry();
zin.close();
sin.close();
fin.close();
zin = null;
sin = null;
fin = null;
}//else//
}//if//
if(tempFile != null) {
tempFile.delete();
}//if//
SettingsController.getSingleton().setDecryptionSettings(getOutputDirectory(), getInputFile().getParent());
displayInformation("Decryption Successful", "The volume was successfully decrypted. All files placed in \"" + new File(getOutputDirectory()).getCanonicalPath() + "\".");
}//try//
catch(Throwable e) {
displayError("Incorrect Password", "Failed to decrypt the volume, most likely due to an invalid password. It is also possible the volume was corrupted.");
Debug.log(e);
}//catch//
finally {
if(fin != null) {
try {fin.close();}catch(Throwable e) {}
}//if//
if(fout != null) {
try {fout.close();}catch(Throwable e) {}
}//if//
}//finally//
}//if//
}//doDecrypt()//
/**
* Gets the encrypted file's password.
* @return The password.
*/
public String getPassword() {
return (String) getAttributeValue(PASSWORD);
}//getPassword()//
/**
* Sets the encrypted file's password.
* @param password The password.
*/
public void setPassword(String password) {
setAttributeValue(PASSWORD, password);
}//setPassword()//
/**
* Gets the encrypted input file.
* @return The encrypted input file.
*/
public File getInputFile() {
return (File) getAttributeValue(INPUT_FILE);
}//getInputFile()//
/**
* Sets the encrypted input file.
* @param inputFile The encrypted input file.
*/
public void setInputFile(File inputFile) {
setAttributeValue(INPUT_FILE, inputFile);
}//setInputFile()//
/**
* Gets the directory where the decrypted file(s) will be placed.
* @return The directory where the decrypted file(s) will be placed.
*/
public String getOutputDirectory() {
return (String) getAttributeValue(OUTPUT_DIRECTORY);
}//getOutputDirectory()//
/**
* Sets the directory where the decrypted file(s) will be placed.
* @param outputDirectory The directory where the decrypted file(s) will be placed.
*/
public void setOutputDirectory(String outputDirectory) {
setAttributeValue(OUTPUT_DIRECTORY, outputDirectory);
}//setOutputDirectory()//
}//DecryptViewController//

View File

@@ -0,0 +1,531 @@
package com.eua.local.view.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.math.BigDecimal;
import java.util.Random;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import com.foundation.metadata.Attribute;
import com.foundation.util.IManagedList;
import com.foundation.util.ManagedList;
import com.foundation.view.ControlDecoration;
import com.foundation.view.IViewContext;
import com.foundation.view.swt.DirectoryDialog;
import com.foundation.view.swt.FileDialog;
import com.common.comparison.Comparator;
import com.common.debug.Debug;
import com.common.io.StreamSupport;
import com.common.io.SymmetricOutputStream;
import com.common.security.ISymmetricAlgorithm;
import com.common.security.Rijndael;
import com.common.security.Sha1;
import com.common.util.LiteHashSet;
import com.common.util.StringSupport;
import com.eua.controller.SettingsController;
import com.eua.local.view.EncryptView;
import com.eua.model.FileMetadata;
/**
* Copyright Declarative Engineering LLC 2009<p>
*/
public class EncryptViewController extends AbstractViewController {
private static final int METRIC_BYTES = 0;
private static final int METRIC_KILO_BYTES = 1;
private static final int METRIC_MEGA_BYTES = 2;
private static final int METRIC_GIGA_BYTES = 3;
//Note: The metrics must be in ascending sequential order starting with zero for both the options array and the names array.//
private static final Integer[] METRIC_OPTIONS = new Integer[] {new Integer(METRIC_BYTES), new Integer(METRIC_KILO_BYTES), new Integer(METRIC_MEGA_BYTES), new Integer(METRIC_GIGA_BYTES)};
private static final String[] METRIC_OPTION_NAMES = new String[] {"Bytes", "Kilobytes", "Megabytes", "Gigabytes"};
public static final Attribute FILES = registerCollection(EncryptViewController.class, "files", AO_REFERENCED | AO_LAZY);
public static final Attribute SELECTED_FILES = registerCollection(EncryptViewController.class, "selectedFiles", AO_REFERENCED | AO_LAZY);
public static final Attribute SPLIT = registerAttribute(EncryptViewController.class, "split", Boolean.FALSE);
public static final Attribute MAXIMUM_OUTPUT_SIZE = registerAttribute(EncryptViewController.class, "maximumOutputSize", new Long(1));
public static final Attribute MAXIMUM_OUTPUT_METRIC = registerAttribute(EncryptViewController.class, "maximumOutputMetric", new Integer(METRIC_MEGA_BYTES));
public static final Attribute PASSWORD = registerAttribute(EncryptViewController.class, "password");
public static final Attribute OUTPUT_DIRECTORY = registerAttribute(EncryptViewController.class, "outputDirectory", AO_LAZY);
public static final Attribute OUTPUT_NAME = registerAttribute(EncryptViewController.class, "outputName", AO_LAZY);
public static final Attribute FILE_METADATA_SET = registerAttribute(EncryptViewController.class, "fileMetadataSet", AO_REFERENCED | AO_LAZY);
public static final Attribute INPUT_DIRECTORY = registerAttribute(EncryptViewController.class, "inputDirectory", AO_REFERENCED | AO_LAZY);
/**
* EncryptViewController constructor.
* @param viewContext
*/
public EncryptViewController(IViewContext viewContext) {
super(viewContext);
}//EncryptViewController()//
/* (non-Javadoc)
* @see com.foundation.common.Entity#lazyLoadAttribute(int)
*/
protected Object lazyLoadAttribute(Attribute attributeNumber) {
Object result = null;
if(attributeNumber == FILES) {
result = new ManagedList(10, 100);
}//if//
else if(attributeNumber == SELECTED_FILES) {
result = new ManagedList(10, 100);
}//else if//
else if(attributeNumber == INPUT_DIRECTORY) {
result = SettingsController.getSingleton().getInputDirectory();
if(result == null) {
File desktop = new File(System.getProperty("user.home"), "desktop");
if(desktop.exists()) {
result = desktop.getAbsolutePath();
}//if//
else {
result = System.getProperty("user.dir");
}//else//
}//if//
}//else if//
else if(attributeNumber == OUTPUT_DIRECTORY) {
result = SettingsController.getSingleton().getEncryptionOutputDirectory();
if(result == null) {
File desktop = new File(System.getProperty("user.home"), "desktop");
if(desktop.exists()) {
result = desktop.getAbsolutePath();
}//if//
else {
result = System.getProperty("user.dir");
}//else//
}//if//
}//else if//
else if(attributeNumber == OUTPUT_NAME) {
result = SettingsController.getSingleton().getEncryptedFileName();
if(result == null) {
result = "encrypted";
}//if//
}//else if//
else if(attributeNumber == FILE_METADATA_SET) {
result = new LiteHashSet(10, LiteHashSet.DEFAULT_LOAD_FACTOR, Comparator.getLogicalComparator(), LiteHashSet.STYLE_NO_DUPLICATES);
}//else if//
else {
result = super.lazyLoadAttribute(attributeNumber);
}//else//
return result;
}//lazyLoadAttribute()//
/* (non-Javadoc)
* @see com.foundation.controller.ViewController#getViewClass()
*/
protected Class getViewClass() {
return EncryptView.class;
}//getViewClass()//
/* (non-Javadoc)
* @see com.foundation.controller.ViewController#validate()
*/
public boolean validate() {
boolean result = true;
getDecorationManager().clearDecorations();
if(getSplit().booleanValue() && (getMaximumOutputSize() == null || getMaximumOutputSize().longValue() <= 0)) {
getDecorationManager().addDecoration(this, MAXIMUM_OUTPUT_SIZE, new ControlDecoration(IMAGE_ERROR, "Missing output size."));
result = false;
}//if//
else if(getSplit().booleanValue() && getMaximumOutputMetric().intValue() == METRIC_BYTES && getMaximumOutputSize().longValue() < 1000) {
getDecorationManager().addDecoration(this, MAXIMUM_OUTPUT_SIZE, new ControlDecoration(IMAGE_ERROR, "Maximum output size must be greater than 1000 if measured in bytes."));
result = false;
}//else if//
if(getPassword() == null || getPassword().length() == 0) {
getDecorationManager().addDecoration(this, PASSWORD, new ControlDecoration(IMAGE_ERROR, "Password required."));
result = false;
}//if//
if(getOutputDirectory() == null || getOutputDirectory().trim().length() == 0) {
getDecorationManager().addDecoration(this, OUTPUT_DIRECTORY, new ControlDecoration(IMAGE_ERROR, "Output directory required."));
result = false;
}//if//
if(getOutputName() == null || getOutputName().trim().length() == 0) {
getDecorationManager().addDecoration(this, OUTPUT_NAME, new ControlDecoration(IMAGE_ERROR, "Output name required."));
result = false;
}//if//
getDecorationManager().applyDecorationChanges();
return result;
}//validate()//
/**
* Cancels the log-in process and closes the client.
*/
public void doCancel() {
close();
}//doCancel()//
/**
* Initiates the validation process and opens the next view upon sucsessful validation.
*/
public void doEncrypt() {
synchronize();
if(validate()) {
if(getFiles().getSize() > 0 && getPassword() != null) {
BigDecimal totalSize = new BigDecimal(0);
BigDecimal maximumOutputSize = getSplit().booleanValue() ? new BigDecimal(getMaximumOutputSize().longValue()) : null;
int currentFileIndex = 0;
FileMetadata nextFile = (FileMetadata) getFiles().getFirst();
FileInputStream fin = null;
FileOutputStream fout = null;
byte[] buffer = new byte[100000]; //100k
ISymmetricAlgorithm algorithm = new Rijndael(new Random(StringSupport.hash(getPassword())));
SymmetricOutputStream sout = null;
ZipOutputStream zout = null;
File outputFile = new File(getOutputDirectory(), getOutputName() + ".enc");
try {
fin = new FileInputStream(new File(nextFile.getPath(), nextFile.getName()));
//Calculate the maximum output size of each split segment in terms of bytes.//
if(maximumOutputSize != null) {
switch(getMaximumOutputMetric().intValue()) {
case METRIC_GIGA_BYTES: {
maximumOutputSize = maximumOutputSize.multiply(new BigDecimal(1073741824)); //1024^3
break;
}//case//
case METRIC_MEGA_BYTES: {
maximumOutputSize = maximumOutputSize.multiply(new BigDecimal(1048576)); //1024^2
break;
}//case//
case METRIC_KILO_BYTES: {
maximumOutputSize = maximumOutputSize.multiply(new BigDecimal(1024));
break;
}//case//
default: {
//Do nothing.//
break;
}//default//
}//switch//
}//if//
//Calculate the total size of all the input content.//
for(int index = 0; index < getFiles().getSize(); index++) {
FileMetadata next = (FileMetadata) getFiles().get(index);
totalSize = totalSize.add(new BigDecimal(next.getLength().longValue()));
}//for//
fout = new FileOutputStream(outputFile);
//Write the magic number which is used when reading to verify that the file is generated by this same tool.//
StreamSupport.writeInt(MAGIC_NUMBER, fout);
//Write the version number of the tool being used to generate the encrypted data.//
StreamSupport.writeInt(VERSION, fout);
//Create the symmetric encryption output stream.//
sout = new SymmetricOutputStream(fout, algorithm);
sout.encrypt(true);
//Create the zip output stream to ensure all encrypted content is first compressed.//
zout = new ZipOutputStream(sout);
zout.putNextEntry(new ZipEntry("main"));
//Write the number of input files.//
StreamSupport.writeInt(getFiles().getSize(), zout);
//Write each file name and size.//
for(int index = 0; index < getFiles().getSize(); index++) {
FileMetadata next = (FileMetadata) getFiles().get(index);
StreamSupport.writeString(next.getName(), zout);
StreamSupport.writeLong(next.getLength().longValue(), zout);
}//for//
//Write the file data as long as we have an input stream.//
while(fin != null) {
int readCount = 0;
//Read in a whole buffer of content.//
while(readCount < buffer.length && fin != null) {
readCount += StreamSupport.readBytes(fin, buffer, readCount, buffer.length - readCount);
//If we couldn't fill the buffer (due to not enough bytes in the input stream), then open a stream on the next file.//
if(readCount != buffer.length) {
fin.close();
//Increment to the next file and open an input stream.//
if(++currentFileIndex != getFiles().getSize()) {
nextFile = (FileMetadata) getFiles().get(currentFileIndex);
fin = new FileInputStream(new File(nextFile.getPath(), nextFile.getName()));
}//if//
else {
fin = null;
nextFile = null;
}//else//
}//if//
}//while//
zout.write(buffer, 0, readCount);
}//while//
zout.closeEntry();
zout.flush();
zout.finish();
sout.encrypt(false);
sout.flush();
zout.close();
sout.close();
fout.close();
//If the output should be split then split the generated file now.//
if(getSplit().booleanValue() && maximumOutputSize.compareTo(new BigDecimal(outputFile.length())) < 0) {
int outputFileIndex = 0;
BigDecimal bufferSize = new BigDecimal(buffer.length);
fin = new FileInputStream(outputFile);
fout = null;
//Keep reading and writing until the input stream is empty.//
while(fin != null) {
BigDecimal writeSize = new BigDecimal(0);
if(fout != null) {
fout.close();
}//if//
fout = new FileOutputStream(outputFile.getAbsolutePath() + "." + ++outputFileIndex);
//Keep writing to the current file until we can't write any more.//
while(fin != null && writeSize.compareTo(maximumOutputSize) < 0) {
int readCount;
BigDecimal readLength = maximumOutputSize.subtract(writeSize);
//If the read length is greater than the buffer size then use the buffer size.//
if(readLength.compareTo(bufferSize) > 0) {
readLength = bufferSize;
}//if//
readCount = StreamSupport.readBytes(fin, buffer, 0, readLength.intValue());
fout.write(buffer, 0, readCount);
writeSize = writeSize.add(new BigDecimal(readCount));
//Check to see if the input stream is empty.//
if(readCount != readLength.intValue()) {
fin.close();
fin = null;
}//if//
}//while//
}//while//
fout.close();
fout = new FileOutputStream(outputFile);
//Write the magic number which is used when reading to verify that the file is generated by this same tool.//
StreamSupport.writeInt(SEQUENCE_MAGIC_NUMBER, fout);
//Write the version number of the tool being used to generate the encrypted data.//
StreamSupport.writeInt(SEQUENCE_VERSION, fout);
//Write the number of files in the sequence.//
StreamSupport.writeInt(outputFileIndex, fout);
fout.close();
fout = null;
displayInformation("Encryption Successful", "The content was successfully encrypted and split. All results placed in \"" + outputFile.getParentFile().getCanonicalPath() + "\".");
}//if//
else {
displayInformation("Encryption Successful", "The content was successfully encrypted to \"" + outputFile.getCanonicalPath() + "\".");
}//else//
SettingsController.getSingleton().setEncryptionSettings(getOutputDirectory(), getOutputName(), getInputDirectory());
}//try//
catch(Throwable e) {
Debug.log(e);
}//catch//
finally {
if(fin != null) {
try {fin.close();}catch(Throwable e) {}
}//if//
if(fout != null) {
try {fout.close();}catch(Throwable e) {}
}//if//
}//finally//
}//if//
}//if//
}//doEncrypt()//
/**
* Changes the output directory by opening a dialog for the user to choose a location.
*/
public void doChangeOutputDirectory() {
DirectoryDialog dialog = new DirectoryDialog(getView(), 0);
String directory;
dialog.setMessage("Choose the output directory.");
if((directory = dialog.open()) != null) {
setOutputDirectory(directory);
}//if//
}//doChangeOutputDirectory()//
/**
* Adds files to the collection to be encrypted.
*/
public void doAddFiles() {
FileDialog dialog = new FileDialog(getView(), FileDialog.STYLE_MULTI);
String path;
dialog.setFilterPath(getInputDirectory());
dialog.setText("Select the files you wish to encrypt.");
if((path = dialog.open()) != null) {
String[] fileNames = dialog.getFileNames();
File pathFile = new File(path);
//Get the actual path. Doing this because the dialog's result isn't a directory path, but rather a path to the first selected file.//
path = pathFile.getParent();
setInputDirectory(path);
for(int index = 0; index < fileNames.length; index++) {
FileMetadata fileMetadata = new FileMetadata(fileNames[index], path);
if(getFileMetadataSet().add(fileMetadata) != -1) {
getFiles().add(fileMetadata);
}//if//
}//for//
}//if//
}//doAddFiles()//
/**
* Removes files from the collection to be encrypted.
*/
public void doRemoveFiles() {
if(getSelectedFiles().getSize() > 0) {
getFiles().removeAll(getSelectedFiles());
getSelectedFiles().removeAll();
}//if//
}//doRemoveFiles()//
/**
* Gets the files value.
* @return The files value.
*/
public IManagedList getFiles() {
return (IManagedList) getAttributeValue(FILES);
}//getFiles()//
/**
* Gets the selectedFiles value.
* @return The selectedFiles value.
*/
public IManagedList getSelectedFiles() {
return (IManagedList) getAttributeValue(SELECTED_FILES);
}//getSelectedFiles()//
/**
* Gets the split value.
* @return The split value.
*/
public Boolean getSplit() {
return (Boolean) getAttributeValue(SPLIT);
}//getSplit()//
/**
* Sets the split value.
* @param split The split value.
*/
public void setSplit(Boolean split) {
setAttributeValue(SPLIT, split);
}//setSplit()//
/**
* Gets the maximumOutputSize value.
* @return The maximumOutputSize value.
*/
public Long getMaximumOutputSize() {
return (Long) getAttributeValue(MAXIMUM_OUTPUT_SIZE);
}//getMaximumOutputSize()//
/**
* Sets the maximumOutputSize value.
* @param maximumOutputSize The maximumOutputSize value.
*/
public void setMaximumOutputSize(Long maximumOutputSize) {
setAttributeValue(MAXIMUM_OUTPUT_SIZE, maximumOutputSize);
}//setMaximumOutputSize()//
/**
* Gets the maximumOutputMetric value.
* @return The maximumOutputMetric value.
*/
public Integer getMaximumOutputMetric() {
return (Integer) getAttributeValue(MAXIMUM_OUTPUT_METRIC);
}//getMaximumOutputMetric()//
/**
* Sets the metric for the maximum output value.
* @param maximumOutputMetric The metric for the maximum output value.
*/
public void setMaximumOutputMetric(Integer maximumOutputMetric) {
setAttributeValue(MAXIMUM_OUTPUT_METRIC, maximumOutputMetric);
}//setMaximumOutputMetric()//
/**
* Gets the set of metrics allowed for the maximum output metric.
* @return The metrics allowed.
*/
public Integer[] getMetrics() {
return METRIC_OPTIONS;
}//getMetrics()//
/**
* Gets the metric name for the given metric identifier.
* @param metric The metric number.
* @return The name for the metric.
*/
public String getMetricName(Integer metric) {
return METRIC_OPTION_NAMES[metric.intValue()];
}//getMetricName()//
/**
* Gets the password value.
* @return The password value.
*/
public String getPassword() {
return (String) getAttributeValue(PASSWORD);
}//getPassword()//
/**
* Sets the password value.
* @param password The password value.
*/
public void setPassword(String password) {
setAttributeValue(PASSWORD, password);
}//setPassword()//
/**
* Gets the outputDirectory value.
* @return The outputDirectory value.
*/
public String getOutputDirectory() {
return (String) getAttributeValue(OUTPUT_DIRECTORY);
}//getOutputDirectory()//
/**
* Sets the outputDirectory value.
* @param outputDirectory The outputDirectory value.
*/
public void setOutputDirectory(String outputDirectory) {
setAttributeValue(OUTPUT_DIRECTORY, outputDirectory);
}//setOutputDirectory()//
/**
* Gets the outputName value.
* @return The outputName value.
*/
public String getOutputName() {
return (String) getAttributeValue(OUTPUT_NAME);
}//getOutputName()//
/**
* Sets the outputName value.
* @param outputName The outputName value.
*/
public void setOutputName(String outputName) {
setAttributeValue(OUTPUT_NAME, outputName);
}//setOutputName()//
/**
* Gets the fileMetadataSet value.
* @return The fileMetadataSet value.
*/
protected LiteHashSet getFileMetadataSet() {
return (LiteHashSet) getAttributeValue(FILE_METADATA_SET);
}//getFileMetadataSet()//
/**
* Gets the last used directory for selecting files to encrypt.
* @return The input directory path.
*/
public String getInputDirectory() {
return (String) getAttributeValue(INPUT_DIRECTORY);
}//getInputDirectory()//
/**
* Sets the last used directory for selecting files to encrypt.
* @param inputDirectory The input directory path.
*/
public void setInputDirectory(String inputDirectory) {
setAttributeValue(INPUT_DIRECTORY, inputDirectory);
}//setInputDirectory()//
}//EncryptViewController//

View File

@@ -0,0 +1,66 @@
package com.eua.local.view.controller;
import com.eua.application.EncryptionUtilityApplication;
import com.eua.local.view.MainView;
import com.foundation.util.IManagedList;
import com.foundation.util.ManagedList;
import com.foundation.view.IViewContext;
import com.foundation.metadata.Attribute;
/**
* Copyright Declarative Engineering LLC 2009<p>
* The primary view for the application.
*/
public class MainViewController extends AbstractViewController {
public static final Attribute TAB_VIEWS = registerCollection(MainViewController.class, "tabViews", AO_REFERENCED | AO_LAZY);
/**
* MainViewController constructor.
* @param context The context under which the view is being created. This context manages the threading, resources, and request handling for the view as well as ties together related views.
*/
public MainViewController(IViewContext context) {
super(context, true);
}//MainViewController()//
/* (non-Javadoc)
* @see com.foundation.controller.AbstractViewController#getViewClass()
*/
protected Class getViewClass() {
return MainView.class;
}//getViewClass()//
/* (non-Javadoc)
* @see com.declarativeengineering.jetson.view.controller.AbstractViewController#validate()
*/
public boolean validate() {
return true;
}//validate()//
/**
* Closes the window.
*/
public void doClose() {
close();
EncryptionUtilityApplication.getSingleton().shutdown();
}//doClose()//
/* (non-Javadoc)
* @see com.foundation.common.Entity#lazyLoadAttribute(int)
*/
protected Object lazyLoadAttribute(Attribute attributeNumber) {
Object result = null;
if(attributeNumber == TAB_VIEWS) {
result = new ManagedList(10, 100);
((ManagedList) result).add(new EncryptViewController(getContext()));
((ManagedList) result).add(new DecryptViewController(getContext()));
}//if//
else {
result = super.lazyLoadAttribute(attributeNumber);
}//else//
return result;
}//lazyLoadAttribute()//
/**
* Gets the tabViews value.
* @return The tabViews value.
*/
public IManagedList getTabViews() {
return (IManagedList) getAttributeValue(TAB_VIEWS);
}//getTabViews()//
}//MainViewController//

View File

@@ -0,0 +1,23 @@
package com.eua.model;
import com.foundation.application.*;
import com.eua.application.*;
/**
*
*/
public abstract class AbstractModel extends com.foundation.model.Model {
/**
* AbstractModel constructor.
*/
public AbstractModel() {
super();
}//AbstractModel()//
/**
* Gets the application object that this object is running under. The application object provides the object various services that it will need.
* @return The application reference for the application this object is running under.
*/
public IApplication getApplication() {
return EncryptionUtilityApplication.getSingleton();
}//getApplication()//
}//AbstractModel//

View File

@@ -0,0 +1,101 @@
package com.eua.model;
import java.io.File;
import com.common.comparison.Comparator;
import com.foundation.metadata.Attribute;
/**
* Copyright Declarative Engineering LLC 2009<p>
*/
public class FileMetadata extends AbstractModel {
public static final Attribute NAME = registerAttribute(FileMetadata.class, "name");
public static final Attribute PATH = registerAttribute(FileMetadata.class, "path");
public static final Attribute SIZE = registerAttribute(FileMetadata.class, "size");
public static final Attribute LENGTH = registerAttribute(FileMetadata.class, "length");
/**
* FileMetadata constructor.
*/
public FileMetadata() {
}//FileMetadata()//
/**
* FileMetadata constructor.
*/
public FileMetadata(String name, String path) {
File file = new File(path, name);
//TODO: Convert to MB, GB, or KB where appropriate. Add commas using a number format.
setSize(file.length() + " bytes");
setLength(new Long(file.length()));
setName(name);
setPath(path);
}//FileMetadata()//
/* (non-Javadoc)
* @see com.foundation.common.Entity#equals(java.lang.Object)
*/
public boolean equals(Object object) {
return object instanceof FileMetadata && Comparator.equals(((FileMetadata) object).getName(), getName()) && Comparator.equals(((FileMetadata) object).getPath(), getPath());
}//equals()//
/* (non-Javadoc)
* @see com.foundation.common.Entity#hashCode()
*/
public int hashCode() {
return getName().hashCode() ^ getPath().hashCode();
}//hashCode()//
/**
* Gets the name value.
* @return The name value.
*/
public String getName() {
return (String) getAttributeValue(NAME);
}//getName()//
/**
* Sets the name value.
* @param name The name value.
*/
public void setName(String name) {
setAttributeValue(NAME, name);
}//setName()//
/**
* Gets the path value.
* @return The path value.
*/
public String getPath() {
return (String) getAttributeValue(PATH);
}//getPath()//
/**
* Sets the path value.
* @param path The path value.
*/
public void setPath(String path) {
setAttributeValue(PATH, path);
}//setPath()//
/**
* Gets the size value.
* @return The size value.
*/
public String getSize() {
return (String) getAttributeValue(SIZE);
}//getSize()//
/**
* Sets the size value.
* @param size The size value.
*/
public void setSize(String size) {
setAttributeValue(SIZE, size);
}//setSize()//
/**
* Gets the length value.
* @return The length value.
*/
public Long getLength() {
return (Long) getAttributeValue(LENGTH);
}//getLength()//
/**
* Sets the length value.
* @param length The length value.
*/
public void setLength(Long length) {
setAttributeValue(LENGTH, length);
}//setLength()//
}//FileMetadata//

View File

@@ -0,0 +1,23 @@
package com.eua.model.controller;
import com.foundation.application.*;
import com.eua.application.*;
/**
*
*/
public abstract class AbstractModelController extends com.foundation.controller.ModelController {
/**
* AbstractModelController constructor.
*/
public AbstractModelController() {
super();
}//AbstractModelController()//
/**
* Gets the application object that this object is running under. The application object provides the object various services that it will need.
* @return The application reference for the application this object is running under.
*/
public IApplication getApplication() {
return EncryptionUtilityApplication.getSingleton();
}//getApplication()//
}//AbstractModelController//