Search in sources :

Example 1 with ImportUtils

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;
}
Also used : ImportUtils(org.jcryptool.actions.core.utils.ImportUtils)

Example 2 with ImportUtils

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;
}
Also used : ImportUtils(org.jcryptool.actions.core.utils.ImportUtils) ISelection(org.eclipse.jface.viewers.ISelection) IFileStore(org.eclipse.core.filesystem.IFileStore) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException) ActionCascadeService(org.jcryptool.actions.core.registry.ActionCascadeService)

Example 3 with ImportUtils

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;
}
Also used : ImportUtils(org.jcryptool.actions.core.utils.ImportUtils) ActionView(org.jcryptool.actions.ui.views.ActionView) ActionCascadeService(org.jcryptool.actions.core.registry.ActionCascadeService) FileDialog(org.eclipse.swt.widgets.FileDialog)

Aggregations

ImportUtils (org.jcryptool.actions.core.utils.ImportUtils)3 ActionCascadeService (org.jcryptool.actions.core.registry.ActionCascadeService)2 IFileStore (org.eclipse.core.filesystem.IFileStore)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1 PartInitException (org.eclipse.ui.PartInitException)1 ActionView (org.jcryptool.actions.ui.views.ActionView)1