Example usage for com.intellij.openapi.actionSystem DataConstants VIRTUAL_FILE_ARRAY

List of usage examples for com.intellij.openapi.actionSystem DataConstants VIRTUAL_FILE_ARRAY

Introduction

In this page you can find the example usage for com.intellij.openapi.actionSystem DataConstants VIRTUAL_FILE_ARRAY.

Prototype

String VIRTUAL_FILE_ARRAY

To view the source code for com.intellij.openapi.actionSystem DataConstants VIRTUAL_FILE_ARRAY.

Click Source Link

Document

Returns array of com.intellij.openapi.vfs.VirtualFile

Usage

From source file:com.echologic.xfiles.XFilesToolWindow.java

License:Open Source License

/**
 * Implements DataProvider interface so that the popup menu actions know
 * which files to operate on.//from  w  w  w.j  a v a2  s .  c om
 *
 * @param string a value DataConstants indicating what kind of data is being
 *               requested
 * @return virtual files or psi elements of the selected files, and null for
 *         all other types of data requested 
 */
@Nullable
public Object getData(String string) {
    if (DataConstants.VIRTUAL_FILE.equals(string)) {
        return list.getSelectedValue();
    } else if (DataConstants.VIRTUAL_FILE_ARRAY.equals(string)) {
        Object[] selectedValues = list.getSelectedValues();
        VirtualFile[] files = new VirtualFile[selectedValues.length];
        System.arraycopy(selectedValues, 0, files, 0, selectedValues.length);
        return files;
    } else if (DataConstants.PSI_FILE.equals(string) || DataConstants.PSI_ELEMENT.equals(string)) {
        VirtualFile selectedValue = (VirtualFile) list.getSelectedValue();
        if (selectedValue != null)
            return PsiManager.getInstance(project).findFile(selectedValue);
    }
    return null;
}