use of org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.EntryNode 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.operations.ui.views.nodes.EntryNode 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.operations.ui.views.nodes.EntryNode in project core by jcryptool.
the class FlexiProviderOperationsView method hookContextMenu.
// private IExtendedOperationDescriptor currentOperation;
private void hookContextMenu() {
// $NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
if (viewer.getTree().getSelection().length > 0) {
Object selection = viewer.getTree().getSelection()[0].getData();
if (selection instanceof TreeNode) {
currentEntryNode = getCurrentEntryNode((TreeNode) selection);
}
if (selection instanceof EntryNode) {
fillEntryNodeContextMenu(manager);
} else if (selection instanceof OperationsNode) {
if (displayOperationContextMenu(currentEntryNode)) {
fillEncryptDecryptNodeContextMenu(manager);
}
} else if (selection instanceof InputNode) {
fillInputContextMenu(manager);
} else if (selection instanceof OutputNode) {
fillOutputContextMenu(manager);
} else if (selection instanceof SignatureNode) {
fillSignatureOutputContextMenu(manager);
} else if (selection instanceof KeyNode) {
fillKeyNodeContextMenu(manager);
}
}
}
});
Menu menu = menuMgr.createContextMenu(viewer.getControl());
viewer.getControl().setMenu(menu);
getSite().registerContextMenu("org.jcryptool.crypto.flexiprovider.operations.popup", menuMgr, viewer);
}
use of org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.EntryNode in project core by jcryptool.
the class OperationsManager method addOperation.
public void addOperation(AlgorithmDescriptor operation) {
// $NON-NLS-1$
LogUtil.logInfo("adding algorithm descriptor: " + operation.getClass().getName());
long timestamp = System.currentTimeMillis();
// $NON-NLS-1$
newOperations.put(timestamp, new EntryNode("no name", timestamp, operation));
Iterator<IOperationChangedListener> it = listeners.iterator();
while (it.hasNext()) {
it.next().addOperation();
}
// $NON-NLS-1$
LogUtil.logInfo("operation 2.0 added");
}
use of org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.EntryNode in project core by jcryptool.
the class SelectKeyHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
Object selectedNode = ((IStructuredSelection) selection).getFirstElement();
if (selectedNode instanceof KeyNode) {
KeyNode keyNode = (KeyNode) selectedNode;
IKeyStoreAlias selectionFromDialog = null;
if (keyNode instanceof KeyPairNode) {
selectionFromDialog = select(Style.SHOW_PRIVATEKEYNODES | Style.SHOW_PUBLICKEYNODES, event);
if (this.cancel)
return null;
if (selectionFromDialog != null) {
if (!(selectionFromDialog.getKeyStoreEntryType() == KeyType.KEYPAIR_PRIVATE_KEY || selectionFromDialog.getKeyStoreEntryType() == KeyType.KEYPAIR_PUBLIC_KEY)) {
selectionFromDialog = null;
}
}
}
if (keyNode instanceof SecretKeyNode) {
selectionFromDialog = select(Style.SHOW_SECRETKEYNODES, event);
if (this.cancel)
return null;
if (selectionFromDialog != null) {
if (!(selectionFromDialog.getKeyStoreEntryType() == KeyType.SECRETKEY)) {
selectionFromDialog = null;
}
}
}
if (selectionFromDialog == null) {
JCTMessageDialog.showInfoDialog(new Status(IStatus.INFO, FlexiProviderOperationsPlugin.PLUGIN_ID, Messages.SelectKeyHandler_WrongKey));
return null;
}
FlexiProviderOperationsView operationsView = (FlexiProviderOperationsView) HandlerUtil.getActivePart(event);
EntryNode operationNode = operationsView.getFlexiProviderOperation();
operationNode.setKeyStoreAlias(selectionFromDialog);
}
}
return null;
}
Aggregations