use of org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.io.SignatureNode 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.io.SignatureNode 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