use of org.jcryptool.core.operations.algorithm.modern.AbstractModernAlgorithm 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);
}
});
}
}
Aggregations