use of org.jcryptool.crypto.flexiprovider.descriptors.IFlexiProviderOperation in project core by jcryptool.
the class OperationsManager method saveXML.
public void saveXML() {
FileOutputStream fos;
try {
root = new OperationsViewEntryRootElement();
Iterator<IFlexiProviderOperation> it = newOperations.values().iterator();
while (it.hasNext()) {
root.addEntry(it.next());
}
document = new Document(root);
fos = new FileOutputStream(operationsFile);
new XMLOutputter(Format.getPrettyFormat()).output(document, fos);
} catch (FileNotFoundException e) {
LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "FileNotFoundException while attempting to write the operations.xml file", e, true);
} catch (IOException e) {
LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "IOException while attempting to write the operations.xml file", e, true);
}
}
use of org.jcryptool.crypto.flexiprovider.descriptors.IFlexiProviderOperation in project core by jcryptool.
the class OperationsManager method loadOperations.
private static void loadOperations() {
File flexiprovider = new File(DirectoryService.getWorkspaceDir(), FLEXIPROVIDER_FOLDER);
if (!flexiprovider.exists()) {
flexiprovider.mkdir();
}
operationsFile = new File(flexiprovider, OPERATIONS_FILE_NAME);
if (operationsFile != null && operationsFile.exists() && !loaded) {
// ensure FlexiProvider is initialized
ProviderManager2.getInstance();
// load xml structure
document = loadXML();
if (document != null) {
root = new OperationsViewEntryRootElement(document.getRootElement());
Iterator<EntryNode> it = root.getEntryNodes().iterator();
while (it.hasNext()) {
IFlexiProviderOperation current = it.next();
newOperations.put(current.getTimestamp(), current);
}
loaded = true;
}
}
}
use of org.jcryptool.crypto.flexiprovider.descriptors.IFlexiProviderOperation in project core by jcryptool.
the class OperationsManager method getTreeModel.
public ITreeNode getTreeModel() {
loadOperations();
// $NON-NLS-1$
ITreeNode _invisibleRoot = new TreeNode("INVISIBLE_ROOT");
for (IFlexiProviderOperation node : newOperations.values()) {
if (node instanceof EntryNode) {
_invisibleRoot.addChild((EntryNode) node);
}
}
return _invisibleRoot;
}
use of org.jcryptool.crypto.flexiprovider.descriptors.IFlexiProviderOperation in project core by jcryptool.
the class OperationsManager method importOperation.
public void importOperation(String fileName) {
try {
// $NON-NLS-1$
LogUtil.logInfo("1");
IFileStore store = EFS.getStore(URIUtil.toURI(fileName));
// $NON-NLS-1$
LogUtil.logInfo("2");
InputStream is = store.openInputStream(SWT.NONE, null);
// $NON-NLS-1$
LogUtil.logInfo("3");
SAXBuilder sax = new SAXBuilder();
// $NON-NLS-1$
LogUtil.logInfo("4");
Document doc = sax.build(is);
// $NON-NLS-1$
LogUtil.logInfo("5");
is.close();
// $NON-NLS-1$
LogUtil.logInfo("6");
ExportRootElement root = new ExportRootElement(doc.getRootElement());
// $NON-NLS-1$
LogUtil.logInfo("7");
IFlexiProviderOperation importEntry = root.getEntryNode();
// $NON-NLS-1$
LogUtil.logInfo("8");
newOperations.put(importEntry.getTimestamp(), importEntry);
// $NON-NLS-1$
LogUtil.logInfo("9");
Iterator<IOperationChangedListener> it = listeners.iterator();
while (it.hasNext()) {
it.next().addOperation();
}
// $NON-NLS-1$
LogUtil.logInfo("10");
} catch (CoreException e) {
LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "CoreException while importing an operation", e, true);
} catch (JDOMException e) {
LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "JDOMException while importing an operation", e, true);
} catch (IOException e) {
LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "IOException while importing an operation", e, false);
}
}
use of org.jcryptool.crypto.flexiprovider.descriptors.IFlexiProviderOperation in project core by jcryptool.
the class ExportOperationHandler method execute.
public Object execute(ExecutionEvent event) {
IFlexiProviderOperation descriptor = listener.getFlexiProviderOperation();
if (descriptor != null) {
// $NON-NLS-1$ //$NON-NLS-2$
LogUtil.logInfo("exporting... (" + descriptor.getTimestamp() + ")");
FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
dialog.setFilterPath(DirectoryService.getUserHomeDir());
dialog.setFilterExtensions(new String[] { IConstants.ALL_FILTER_EXTENSION });
dialog.setFilterNames(new String[] { IConstants.ALL_FILTER_NAME });
dialog.setOverwrite(true);
String filename = dialog.open();
if (filename != null) {
OperationsManager.getInstance().export(descriptor.getTimestamp(), filename);
}
}
return (null);
}
Aggregations