Package floobits.actions

Source Code of floobits.actions.DeleteFromWorkspace

package floobits.actions;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.vfs.VirtualFile;
import floobits.FloobitsPlugin;
import floobits.utilities.IntelliUtils;
import floobits.common.EditorEventHandler;
import floobits.common.interfaces.IContext;

import java.util.ArrayList;
import java.util.HashSet;

public class DeleteFromWorkspace extends IsJoinedAction {
    @Override
    public void actionPerformed(AnActionEvent e, EditorEventHandler editorEventHandler) {
        final HashSet<String> fileHashSet = new HashSet<String>();
        final VirtualFile[] virtualFiles = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(e.getDataContext());

        if (editorEventHandler == null || virtualFiles == null) {
            return;
        }
        IContext context = FloobitsPlugin.getInstance(e.getProject()).context;
        for (final VirtualFile virtualFile : virtualFiles) {
            if (fileHashSet.contains(virtualFile.getPath())) {
                continue;
            }
            if (!context.isShared(virtualFile.getPath())) {
                continue;
            }
            ArrayList<String> allNestedFilePaths = IntelliUtils.getAllNestedFilePaths(virtualFile);
            fileHashSet.addAll(allNestedFilePaths);
        }

        editorEventHandler.softDelete(fileHashSet);
    }
}
TOP

Related Classes of floobits.actions.DeleteFromWorkspace

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.