use of org.jcryptool.actions.core.types.ActionItem in project core by jcryptool.
the class AbstractAlgorithmHandler method addActionItem.
/**
* Adds the cryptographic action information as a new <code>ActionItem</code> to the <b>Actions view</b>. Adding the
* new ActionItem must be executed in an async way since a Job may be used to execute the cryptographic operation.
*
* @param algorithm The executed AbstractAlgorithm implementation
*/
private void addActionItem(AbstractAlgorithm algorithm) {
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
if ((Boolean) // $NON-NLS-1$
service.getCommand("org.jcryptool.actions.recordCommand").getState("org.jcryptool.actions.recordCommand.toggleState").getValue()) {
// $NON-NLS-1$
final ActionItem item = new ActionItem(output.getName(), algorithm.getAlgorithmName());
item.setPluginId(this.getId());
if (algorithm instanceof AbstractClassicAlgorithm) {
ClassicDataObject dataobject = (ClassicDataObject) dataObject;
if (dataobject.getOpmode() == 0) {
// $NON-NLS-1$
item.setActionType("encrypt");
} else if (dataobject.getOpmode() == 1) {
// $NON-NLS-1$
item.setActionType("decrypt");
}
item.setAlphabet(dataobject.getAlphabet().getName());
dataobject.setFilterNonAlphaChars(((AbstractClassicAlgorithm) algorithm).isFilter());
item.setParams(DataObjectConverter.propertiesToHashtable(dataobject));
item.setDataObjectType(dataobject.getClass().getName());
} else if (algorithm instanceof AbstractModernAlgorithm) {
ModernDataObject dataobject = (ModernDataObject) dataObject;
item.setParams(DataObjectConverter.propertiesToHashtable(dataobject));
item.setDataObjectType(dataobject.getClass().getName());
}
Display.getDefault().asyncExec(new Runnable() {
public void run() {
ActionCascadeService.getInstance().addItem(item);
}
});
}
}
use of org.jcryptool.actions.core.types.ActionItem in project core by jcryptool.
the class MoveDownHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
ActionView view = (ActionView) HandlerUtil.getActivePart(event);
TableViewer viewer = view.getViewer();
ActionItem item = (ActionItem) ((IStructuredSelection) selection).getFirstElement();
ActionCascadeService.getInstance().moveDown(item);
// Set focus on moved row
viewer.setSelection(new StructuredSelection(item));
}
return null;
}
use of org.jcryptool.actions.core.types.ActionItem in project core by jcryptool.
the class MoveUpHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
ActionView view = (ActionView) HandlerUtil.getActivePart(event);
TableViewer viewer = view.getViewer();
ActionItem item = (ActionItem) ((IStructuredSelection) selection).getFirstElement();
ActionCascadeService.getInstance().moveUp(item);
// Set focus on moved row
viewer.setSelection(new StructuredSelection(item));
}
return null;
}
use of org.jcryptool.actions.core.types.ActionItem in project core by jcryptool.
the class PerformOperationListener method addActionItem.
private void addActionItem(IFlexiProviderOperation operation) {
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
if ((Boolean) // $NON-NLS-1$
service.getCommand("org.jcryptool.actions.recordCommand").getState("org.jcryptool.actions.recordCommand.toggleState").getValue()) {
// $NON-NLS-1$
AlgorithmDescriptor descriptor = operation.getAlgorithmDescriptor();
ActionItem item = // $NON-NLS-1$
new ActionItem(EditorsManager.getInstance().getActiveEditorTitle(), descriptor.getAlgorithmName());
item.setPluginId(operation.getRegistryType().getName());
if (operation.getOperation() == OperationType.DECRYPT) {
// $NON-NLS-1$
item.setActionType("decrypt");
} else if (operation.getOperation() == OperationType.ENCRYPT) {
// $NON-NLS-1$
item.setActionType("encrypt");
} else if (operation.getOperation() == OperationType.SIGN) {
// $NON-NLS-1$
item.setActionType("sign");
} else if (operation.getOperation() == OperationType.VERIFY) {
// $NON-NLS-1$
item.setActionType("verify");
}
// item.addParam("input", operation.getInput()); //$NON-NLS-1$
// item.addParam("output", operation.getOutput()); //$NON-NLS-1$
// $NON-NLS-1$
item.addParam("signature", operation.getSignature());
// $NON-NLS-1$
item.addParam("algorithm type", operation.getAlgorithmDescriptor().getType().getName());
IKeyStoreAlias alias = operation.getKeyStoreAlias();
if (alias != null) {
// $NON-NLS-1$
item.addParam("contact", alias.getContactName());
// $NON-NLS-1$
item.addParam("key alias", alias.getAliasString());
// $NON-NLS-1$
item.addParam("key length", String.valueOf(alias.getKeyLength()));
if (operation.getPassword() != null) {
// $NON-NLS-1$
item.addParam("key password", String.valueOf(operation.getPassword()));
}
}
if (descriptor instanceof BlockCipherDescriptor) {
// $NON-NLS-1$
item.addParam("mode", ((BlockCipherDescriptor) descriptor).getMode());
// $NON-NLS-1$
item.addParam("padding scheme", ((BlockCipherDescriptor) descriptor).getPadding());
} else if (descriptor instanceof SecureRandomDescriptor) {
// $NON-NLS-1$ //$NON-NLS-2$
item.addParam("random size", "" + ((SecureRandomDescriptor) descriptor).getLength());
// byte[][] alphabets = ((SecureRandomDescriptor) descriptor).getAlphabet();
// TODO push alphapet to items property "alphabet"
}
ActionCascadeService.getInstance().addItem(item);
}
}
use of org.jcryptool.actions.core.types.ActionItem in project core by jcryptool.
the class RemoveSelectedHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
ActionItem item = (ActionItem) ((IStructuredSelection) selection).getFirstElement();
ActionCascadeService.getInstance().removeItem(item);
}
return null;
}
Aggregations