use of org.jcryptool.actions.core.utils.ImportUtils in project core by jcryptool.
the class ImportSampleHandler method execute.
/* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
String filename = getCascadeFilename(event);
if (filename != null && filename.length() > 0) {
ImportUtils importUtil = new ImportUtils(filename);
boolean isValid = importUtil.validateActionCascade();
if (isValid) {
openDefaultPerspective();
openActionView();
openSamplefileInEditor();
ActionCascadeService.getInstance().setCurrentActionCascade(importUtil.createActionCascade());
} else {
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), Messages.ImportHandler_2, Messages.ImportHandler_3);
}
}
return null;
}
use of org.jcryptool.actions.core.utils.ImportUtils in project core by jcryptool.
the class ImportActionCascadeHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
ActionCascadeService service = ActionCascadeService.getInstance();
if (service.getCurrentActionCascade() != null && service.getCurrentActionCascade().getSize() > 0) {
boolean confirmImport = MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), Messages.ImportHandler_0, Messages.ImportHandler_1);
if (!confirmImport) {
return null;
}
}
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
IFileStore file = (IFileStore) ((IStructuredSelection) selection).getFirstElement();
if (file != null) {
ImportUtils importUtil = new ImportUtils(file.getParent().toURI().getPath() + File.separatorChar + file.getName());
if (importUtil.validateActionCascade()) {
service.setCurrentActionCascade(importUtil.createActionCascade());
try {
HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().showView(ActionView.ID);
} catch (PartInitException ex) {
LogUtil.logError(ActionsUIPlugin.PLUGIN_ID, Messages.ImportActionCascadeHandler_0, ex, true);
}
} else {
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), Messages.ImportHandler_2, Messages.ImportHandler_3);
}
}
}
return null;
}
use of org.jcryptool.actions.core.utils.ImportUtils in project core by jcryptool.
the class ImportHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
ActionCascadeService service = ActionCascadeService.getInstance();
if (service.getCurrentActionCascade() != null && service.getCurrentActionCascade().getSize() > 0) {
boolean confirmImport = MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), Messages.ImportHandler_0, Messages.ImportHandler_1);
if (!confirmImport) {
return null;
}
}
ActionView view = (ActionView) HandlerUtil.getActivePart(event);
FileDialog dialog = new FileDialog(HandlerUtil.getActiveShell(event), SWT.OPEN);
dialog.setFilterPath(DirectoryService.getUserHomeDir());
dialog.setFilterNames(Constants.FILTER_NAMES);
dialog.setFilterExtensions(Constants.FILTER_EXTENSIONS);
String filename = dialog.open();
if (filename != null && filename.length() > 0) {
view.setImportPath(ImportUtils.getPathFromFile(filename));
ImportUtils importUtil = new ImportUtils(filename);
boolean isValid = importUtil.validateActionCascade();
if (isValid) {
service.setCurrentActionCascade(importUtil.createActionCascade());
} else {
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), Messages.ImportHandler_2, Messages.ImportHandler_3);
}
}
return null;
}
Aggregations