use of org.jcryptool.crypto.flexiprovider.ui.nodes.TreeNode 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.ui.nodes.TreeNode 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.ui.nodes.TreeNode 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);
}
}
}
});
}
use of org.jcryptool.crypto.flexiprovider.ui.nodes.TreeNode in project core by jcryptool.
the class FlexiProviderAlgorithmsViewContentProvider method initialize.
private void initialize() {
// $NON-NLS-1$
_invisibleRoot = new TreeNode("INVISIBLE_ROOT");
_invisibleRoot.addChild(init(Messages.FlexiProviderAlgorithmsViewContentProvider_0, AlgorithmsXMLManager.getInstance().getAsymmetricBlockCiphers()));
_invisibleRoot.addChild(init(Messages.FlexiProviderAlgorithmsViewContentProvider_1, AlgorithmsXMLManager.getInstance().getAsymmetricHybridCiphers()));
_invisibleRoot.addChild(init(Messages.FlexiProviderAlgorithmsViewContentProvider_2, AlgorithmsXMLManager.getInstance().getBlockCiphers()));
_invisibleRoot.addChild(init(Messages.FlexiProviderAlgorithmsViewContentProvider_3, AlgorithmsXMLManager.getInstance().getCiphers()));
_invisibleRoot.addChild(init(Messages.FlexiProviderAlgorithmsViewContentProvider_4, AlgorithmsXMLManager.getInstance().getMacs()));
_invisibleRoot.addChild(init(Messages.FlexiProviderAlgorithmsViewContentProvider_5, AlgorithmsXMLManager.getInstance().getMessageDigests()));
_invisibleRoot.addChild(init(Messages.FlexiProviderAlgorithmsViewContentProvider_6, AlgorithmsXMLManager.getInstance().getSecureRandoms()));
_invisibleRoot.addChild(init(Messages.FlexiProviderAlgorithmsViewContentProvider_7, AlgorithmsXMLManager.getInstance().getSignatures()));
}
use of org.jcryptool.crypto.flexiprovider.ui.nodes.TreeNode in project core by jcryptool.
the class FlexiProviderOperationsView method handleEvent.
public void handleEvent(Event event) {
if (event.widget instanceof Tree && ((Tree) event.widget).getSelection().length > 0) {
Object obj = ((Tree) event.widget).getSelection()[0].getData();
if (obj instanceof TreeNode) {
EntryNode tmp = getCurrentEntryNode((TreeNode) obj);
if (tmp != null) {
currentEntryNode = tmp;
currentEntryLabel.setText(NLS.bind(Messages.FlexiProviderOperationsView_2, currentEntryNode.getEntryName()));
}
}
}
}
Aggregations