Search in sources :

Example 1 with GlobalDisplay

use of org.rstudio.studio.client.common.GlobalDisplay in project rstudio by rstudio.

the class Ignore method createIgnoreList.

// compute the new list of ignores based on the initial/existing
// set of paths and path(s) the user wants to add
private IgnoreList createIgnoreList(ArrayList<String> paths, Ignore.Strategy.Filter filter) {
    // parent path and return an empty list
    if (paths.size() == 0)
        return new IgnoreList("", new ArrayList<String>());
    // get the parent path of the first element
    FileSystemItem firstPath = FileSystemItem.createFile(paths.get(0));
    String parentPath = firstPath.getParentPathString();
    // confirm that all of the elements start with that path and take the
    // remainder of their paths for our list
    ArrayList<String> ignored = new ArrayList<String>();
    for (String path : paths) {
        String thisParent = FileSystemItem.createFile(path).getParentPathString();
        if (!parentPath.equals(thisParent)) {
            GlobalDisplay gDisp = RStudioGinjector.INSTANCE.getGlobalDisplay();
            gDisp.showMessage(MessageDialog.ERROR, "Error: Multiple Directories", "The selected files are not all within the same directory " + "(you can only ignore multiple files in one operation if " + "they are located within the same directory).");
            return null;
        }
        // apply a filter if we have one
        if (filter != null) {
            FileSystemItem file = FileSystemItem.createFile(path);
            if (!filter.includeFile(file))
                continue;
        }
        // compute the parent relative directory
        if (parentPath.length() == 0)
            ignored.add(path);
        else
            ignored.add(path.substring(thisParent.length() + 1));
    }
    return new IgnoreList(parentPath, ignored);
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) GlobalDisplay(org.rstudio.studio.client.common.GlobalDisplay) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)1 GlobalDisplay (org.rstudio.studio.client.common.GlobalDisplay)1