Search in sources :

Example 1 with EntryNode

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;
        }
    }
}
Also used : OperationsViewEntryRootElement(org.jcryptool.crypto.flexiprovider.operations.xml.OperationsViewEntryRootElement) EntryNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.EntryNode) File(java.io.File) IFlexiProviderOperation(org.jcryptool.crypto.flexiprovider.descriptors.IFlexiProviderOperation)

Example 2 with EntryNode

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;
}
Also used : ITreeNode(org.jcryptool.crypto.flexiprovider.ui.nodes.ITreeNode) TreeNode(org.jcryptool.crypto.flexiprovider.ui.nodes.TreeNode) ITreeNode(org.jcryptool.crypto.flexiprovider.ui.nodes.ITreeNode) EntryNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.EntryNode) IFlexiProviderOperation(org.jcryptool.crypto.flexiprovider.descriptors.IFlexiProviderOperation)

Example 3 with EntryNode

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);
}
Also used : InputNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.io.InputNode) OutputNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.io.OutputNode) TreeNode(org.jcryptool.crypto.flexiprovider.ui.nodes.TreeNode) ITreeNode(org.jcryptool.crypto.flexiprovider.ui.nodes.ITreeNode) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) EntryNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.EntryNode) KeyNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.keys.KeyNode) IMenuManager(org.eclipse.jface.action.IMenuManager) OperationsNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.ops.OperationsNode) Menu(org.eclipse.swt.widgets.Menu) SignatureNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.io.SignatureNode) IMenuListener(org.eclipse.jface.action.IMenuListener)

Example 4 with EntryNode

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");
}
Also used : EntryNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.EntryNode) IOperationChangedListener(org.jcryptool.crypto.flexiprovider.operations.ui.listeners.IOperationChangedListener)

Example 5 with EntryNode

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;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) FlexiProviderOperationsView(org.jcryptool.crypto.flexiprovider.operations.ui.views.FlexiProviderOperationsView) ISelection(org.eclipse.jface.viewers.ISelection) EntryNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.EntryNode) SecretKeyNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.keys.SecretKeyNode) KeyNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.keys.KeyNode) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SecretKeyNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.keys.SecretKeyNode) IKeyStoreAlias(org.jcryptool.crypto.keystore.keys.IKeyStoreAlias) KeyPairNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.keys.KeyPairNode)

Aggregations

EntryNode (org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.EntryNode)8 ITreeNode (org.jcryptool.crypto.flexiprovider.ui.nodes.ITreeNode)3 TreeNode (org.jcryptool.crypto.flexiprovider.ui.nodes.TreeNode)3 IFlexiProviderOperation (org.jcryptool.crypto.flexiprovider.descriptors.IFlexiProviderOperation)2 AlgorithmDescriptor (org.jcryptool.crypto.flexiprovider.descriptors.algorithms.AlgorithmDescriptor)2 KeyNode (org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.keys.KeyNode)2 AlgorithmDescriptorElement (org.jcryptool.crypto.flexiprovider.operations.xml.algorithms.AlgorithmDescriptorElement)2 BlockCipherDescriptorElement (org.jcryptool.crypto.flexiprovider.operations.xml.algorithms.BlockCipherDescriptorElement)2 SecureRandomDescriptorElement (org.jcryptool.crypto.flexiprovider.operations.xml.algorithms.SecureRandomDescriptorElement)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 Menu (org.eclipse.swt.widgets.Menu)1 Tree (org.eclipse.swt.widgets.Tree)1