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);
}
}
}
});
}
Aggregations