Search in sources :

Example 1 with SkipTaskException

use of org.freeplane.plugin.workspace.io.SkipTaskException in project freeplane by freeplane.

the class FileExistsConflictDialog method resolveConflict.

public void resolveConflict(File file, Properties properties) throws IOException {
    if (properties == null) {
        properties = new Properties();
    }
    FileExistsDialogPanel dialog = new FileExistsDialogPanel(file, FileExistsDialogPanel.class.getSimpleName().toLowerCase(Locale.ENGLISH) + ".file.text");
    int opt = JOptionPane.showConfirmDialog(UITools.getFrame(), dialog, TextUtils.getText("workspace.fileexists.title." + properties.getProperty("opType", "1")), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    if (opt == JOptionPane.CANCEL_OPTION) {
        throw new CancelExecutionException();
    }
    if (opt == JOptionPane.NO_OPTION) {
        throw new SkipTaskException();
    }
    properties.setProperty("overwriteAll", String.valueOf(dialog.applyToAll()));
}
Also used : FileExistsDialogPanel(org.freeplane.plugin.workspace.components.dialog.FileExistsDialogPanel) SkipTaskException(org.freeplane.plugin.workspace.io.SkipTaskException) CancelExecutionException(org.freeplane.plugin.workspace.io.CancelExecutionException) Properties(java.util.Properties)

Example 2 with SkipTaskException

use of org.freeplane.plugin.workspace.io.SkipTaskException in project freeplane by freeplane.

the class FileFolderDropHandler method getPostOperation.

private ITask getPostOperation(final AWorkspaceTreeNode targetNode, final AWorkspaceTreeNode node, final File srcFile, final File destFile) {
    return new ITask() {

        public void exec(Properties properties) throws IOException {
            if (onSkipList(destFile.getParentFile(), properties)) {
                throw new SkipTaskException();
            }
            AWorkspaceTreeNode parent = node.getParent();
            targetNode.getModel().cutNodeFromParent(node);
            parent.refresh();
            targetNode.getModel().nodeMoved(node, srcFile, destFile);
        }

        private boolean onSkipList(File dest, Properties properties) {
            if (properties == null || dest == null) {
                return false;
            }
            String list = properties.getProperty("skippedDirs", "");
            String entry = dest.getPath() + ";";
            if (list.contains(entry)) {
                return true;
            }
            return false;
        }
    };
}
Also used : ITask(org.freeplane.plugin.workspace.io.ITask) AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) SkipTaskException(org.freeplane.plugin.workspace.io.SkipTaskException) Properties(java.util.Properties) File(java.io.File)

Example 3 with SkipTaskException

use of org.freeplane.plugin.workspace.io.SkipTaskException in project freeplane by freeplane.

the class DirectoryMergeConflictDialog method resolveConflict.

public void resolveConflict(File file, Properties properties) throws IOException {
    if (properties == null) {
        properties = new Properties();
    }
    FileExistsDialogPanel dialog = new FileExistsDialogPanel(file, FileExistsDialogPanel.class.getSimpleName().toLowerCase(Locale.ENGLISH) + ".dir.text");
    int opt = JOptionPane.showConfirmDialog(UITools.getFrame(), dialog, TextUtils.getText("workspace.directory.merge.title"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    if (opt == JOptionPane.CANCEL_OPTION) {
        throw new CancelExecutionException();
    }
    if (opt == JOptionPane.NO_OPTION) {
        throw new SkipTaskException();
    }
    properties.setProperty("mergeAll", String.valueOf(dialog.applyToAll()));
}
Also used : FileExistsDialogPanel(org.freeplane.plugin.workspace.components.dialog.FileExistsDialogPanel) SkipTaskException(org.freeplane.plugin.workspace.io.SkipTaskException) CancelExecutionException(org.freeplane.plugin.workspace.io.CancelExecutionException) Properties(java.util.Properties)

Aggregations

Properties (java.util.Properties)3 SkipTaskException (org.freeplane.plugin.workspace.io.SkipTaskException)3 FileExistsDialogPanel (org.freeplane.plugin.workspace.components.dialog.FileExistsDialogPanel)2 CancelExecutionException (org.freeplane.plugin.workspace.io.CancelExecutionException)2 File (java.io.File)1 ITask (org.freeplane.plugin.workspace.io.ITask)1 AWorkspaceTreeNode (org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)1