List of usage examples for com.intellij.openapi.actionSystem DataConstants VIRTUAL_FILE
String VIRTUAL_FILE
To view the source code for com.intellij.openapi.actionSystem DataConstants VIRTUAL_FILE.
Click Source Link
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. java2 s. c o m * * @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; }
From source file:com.intellij.lang.properties.editor.ResourceBundleStructureViewComponent.java
License:Apache License
public Object getData(String dataId) { if (dataId.equals(DataConstants.VIRTUAL_FILE)) { return new ResourceBundleAsVirtualFile(myResourceBundle); }// w w w . ja v a 2 s. co m return super.getData(dataId); }
From source file:com.intellij.lang.properties.projectView.ResourceBundleGrouper.java
License:Apache License
public Object getData(Collection<AbstractTreeNode> selected, String dataName) { if (selected == null) return null; for (AbstractTreeNode selectedElement : selected) { Object element = selectedElement.getValue(); if (DataConstants.VIRTUAL_FILE.equals(dataName)) { if (element instanceof ResourceBundle) { return new ResourceBundleAsVirtualFile((ResourceBundle) element); }//from ww w . jav a 2 s. c o m } if (DataConstants.PSI_ELEMENT_ARRAY.equals(dataName)) { if (element instanceof ResourceBundle) { List<PropertiesFile> propertiesFiles = ((ResourceBundle) element).getPropertiesFiles(myProject); return propertiesFiles.toArray(PsiElement.EMPTY_ARRAY); } } if (DataConstants.DELETE_ELEMENT_PROVIDER.equals(dataName)) { if (element instanceof ResourceBundle) { return new ResourceBundleDeleteProvider((ResourceBundle) element); } } } if (DataConstantsEx.RESOURCE_BUNDLE_ARRAY.equals(dataName)) { final List<ResourceBundle> selectedElements = new ArrayList<ResourceBundle>(); for (AbstractTreeNode node : selected) { final Object value = node.getValue(); if (value instanceof ResourceBundle) { selectedElements.add((ResourceBundle) value); } } return selectedElements.isEmpty() ? null : selectedElements.toArray(new ResourceBundle[selectedElements.size()]); } return null; }
From source file:com.intellij.lang.properties.structureView.PropertiesFileStructureViewComponent.java
License:Apache License
public Object getData(String dataId) { if (dataId.equals(DataConstants.VIRTUAL_FILE)) { return myPropertiesFile.getVirtualFile(); }//ww w . ja v a 2s . c om if (dataId.equals(DataConstants.PSI_ELEMENT)) { return myPropertiesFile; } return super.getData(dataId); }
From source file:org.codehaus.groovy.intellij.actions.ActionEvents.java
License:Apache License
public VirtualFile getVirtualFile(AnActionEvent event) { return (VirtualFile) event.getDataContext().getData(DataConstants.VIRTUAL_FILE); }
From source file:org.codehaus.groovy.intellij.actions.ActionEventsTest.java
License:Apache License
protected void setUp() { AnAction action = new AnAction() { public void actionPerformed(AnActionEvent event) { }//w ww. ja v a2 s.c o m }; actionEvent = new AnActionEvent(null, (DataContext) mockDataContext.proxy(), "", action.getTemplatePresentation(), null, -1); mockDataContext.stubs().method("getData").with(eq(DataConstants.VIRTUAL_FILE)) .will(returnValue(virtualFileBuilder.build())); mockDataContext.stubs().method("getData").with(eq(DataConstants.PROJECT)).will(returnValue(projectMock)); mockDataContext.stubs().method("getData").with(eq(DataConstants.MODULE)).will(returnValue(moduleMock)); GroovyJProjectComponent.setInstance(projectMock, projectComponentMock); }
From source file:org.codehaus.groovy.intellij.actions.ActionEventsTest.java
License:Apache License
public void testDeterminesThatAnEventDidNotOriginateFromAGroovyFileWhenNoFileWasSelected() { mockDataContext.expects(once()).method("getData").with(eq(DataConstants.VIRTUAL_FILE)) .will(returnValue(null));//from ww w . j a v a 2 s. com ; assertFalse(actionEvents.isEventOriginatingFromGroovyFile(actionEvent)); }