Search in sources :

Example 1 with IONode

use of org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.io.IONode in project core by jcryptool.

the class FlexiProviderOperationsView method hookActions.

/**
 * Adds a listener, which will fold or unfold the nodes.
 */
private void hookActions() {
    doubleClickHandler = new AbstractHandler() {

        private ToolTip keyTipViewer;

        @Override
        public Object execute(ExecutionEvent event) {
            ISelection selection = viewer.getSelection();
            Object obj = ((IStructuredSelection) selection).getFirstElement();
            if (obj instanceof TreeNode) {
                if (viewer.getTree().getSelection()[0].getExpanded()) {
                    viewer.collapseToLevel(obj, 1);
                } else {
                    viewer.expandToLevel(obj, 1);
                }
            } else if (obj instanceof OperationsNode) {
            // OperationsManager.getInstance().algorithmCalled(((AlgorithmNode)
            // obj).getAlgorithm());
            }
            if (obj instanceof KeyNode) {
                if (keyTipViewer != null && !keyTipViewer.isDisposed())
                    keyTipViewer.dispose();
                keyTipViewer = new ToolTip(viewer.getControl().getShell(), SWT.BALLOON);
                keyTipViewer.setMessage(Messages.FlexiProviderOperationsView_keystore_hint);
                keyTipViewer.setAutoHide(true);
                keyTipViewer.setLocation(MouseInfo.getPointerInfo().getLocation().x, MouseInfo.getPointerInfo().getLocation().y);
                keyTipViewer.setVisible(true);
            }
            if (obj instanceof IONode || obj instanceof InputNode || obj instanceof SignatureNode) {
                // Event e = new Event();
                // e.widget = viewer.getTree();
                // e.x = viewer.getTree().toControl(MouseInfo.getPointerInfo().getLocation().x,
                // MouseInfo.getPointerInfo().getLocation().y).x;
                // e.y = viewer.getTree().toControl(MouseInfo.getPointerInfo().getLocation().x,
                // MouseInfo.getPointerInfo().getLocation().y).y;
                // e.button = 3;
                // e.stateMask = 0;
                // e.count = 1;
                // MouseEvent mE = new MouseEvent(e);
                // viewer.getTree().notifyListeners(SWT.MouseDown, e);
                viewer.getControl().getMenu().setVisible(true);
                viewer.getControl().getMenu().setEnabled(true);
            }
            if (obj instanceof OperationsNode) {
                if (obj instanceof TreeNode) {
                    currentEntryNode = getCurrentEntryNode((TreeNode) obj);
                    if (displayOperationContextMenu(currentEntryNode)) {
                        viewer.getControl().getMenu().setVisible(true);
                        viewer.getControl().getMenu().setEnabled(true);
                    } else {
                        if (keyTipViewer != null && !keyTipViewer.isDisposed())
                            keyTipViewer.dispose();
                        keyTipViewer = new ToolTip(viewer.getControl().getShell(), SWT.BALLOON);
                        keyTipViewer.setMessage(Messages.FlexiProviderOperationsView_keystore_hint_operations);
                        keyTipViewer.setAutoHide(true);
                        keyTipViewer.setLocation(MouseInfo.getPointerInfo().getLocation().x, MouseInfo.getPointerInfo().getLocation().y);
                        keyTipViewer.setVisible(true);
                    }
                }
            }
            return (null);
        }
    };
    viewer.getControl().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(final MouseEvent e) {
            if (e.button == 1) {
                // only left button double clicks
                try {
                    // run assigned action
                    doubleClickHandler.execute(null);
                } catch (Exception ex) {
                    LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, ex);
                }
            }
        }
    });
}
Also used : ToolTip(org.eclipse.swt.widgets.ToolTip) InputNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.io.InputNode) MouseEvent(org.eclipse.swt.events.MouseEvent) MouseAdapter(org.eclipse.swt.events.MouseAdapter) OperationsNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.ops.OperationsNode) SignatureNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.io.SignatureNode) AbstractHandler(org.eclipse.core.commands.AbstractHandler) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) TreeNode(org.jcryptool.crypto.flexiprovider.ui.nodes.TreeNode) ITreeNode(org.jcryptool.crypto.flexiprovider.ui.nodes.ITreeNode) ISelection(org.eclipse.jface.viewers.ISelection) IONode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.io.IONode) KeyNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.keys.KeyNode)

Aggregations

AbstractHandler (org.eclipse.core.commands.AbstractHandler)1 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)1 ISelection (org.eclipse.jface.viewers.ISelection)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 ToolTip (org.eclipse.swt.widgets.ToolTip)1 IONode (org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.io.IONode)1 InputNode (org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.io.InputNode)1 SignatureNode (org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.io.SignatureNode)1 KeyNode (org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.keys.KeyNode)1 OperationsNode (org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.ops.OperationsNode)1 ITreeNode (org.jcryptool.crypto.flexiprovider.ui.nodes.ITreeNode)1 TreeNode (org.jcryptool.crypto.flexiprovider.ui.nodes.TreeNode)1