List of usage examples for com.intellij.openapi.actionSystem PlatformDataKeys FILE_TEXT
DataKey FILE_TEXT
To view the source code for com.intellij.openapi.actionSystem PlatformDataKeys FILE_TEXT.
Click Source Link
From source file:com.intellij.ide.actions.SaveFileAsTemplateAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { Project project = e.getData(CommonDataKeys.PROJECT); String fileText = e.getData(PlatformDataKeys.FILE_TEXT); VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE); String extension = file.getExtension(); String nameWithoutExtension = file.getNameWithoutExtension(); AllFileTemplatesConfigurable fileTemplateOptions = new AllFileTemplatesConfigurable(); ConfigureTemplatesDialog dialog = new ConfigureTemplatesDialog(project, fileTemplateOptions); PsiFile psiFile = e.getData(LangDataKeys.PSI_FILE); for (SaveFileAsTemplateHandler handler : Extensions.getExtensions(SaveFileAsTemplateHandler.EP_NAME)) { String textFromHandler = handler.getTemplateText(psiFile, fileText, nameWithoutExtension); if (textFromHandler != null) { fileText = textFromHandler;//from w w w . j av a 2 s. c om break; } } fileTemplateOptions.createNewTemplate(nameWithoutExtension, extension, fileText); dialog.show(); }
From source file:com.intellij.ide.actions.SaveFileAsTemplateAction.java
License:Apache License
@Override public void update(AnActionEvent e) { VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE); String fileText = e.getData(PlatformDataKeys.FILE_TEXT); e.getPresentation().setEnabled((fileText != null) && (file != null)); }
From source file:com.intellij.ide.impl.DataManagerImpl.java
License:Apache License
private void registerRules() { myDataConstantToRuleMap.put(PlatformDataKeys.COPY_PROVIDER.getName(), new CopyProviderRule()); myDataConstantToRuleMap.put(PlatformDataKeys.CUT_PROVIDER.getName(), new CutProviderRule()); myDataConstantToRuleMap.put(PlatformDataKeys.PASTE_PROVIDER.getName(), new PasteProviderRule()); myDataConstantToRuleMap.put(PlatformDataKeys.FILE_TEXT.getName(), new FileTextRule()); myDataConstantToRuleMap.put(PlatformDataKeys.FILE_EDITOR.getName(), new FileEditorRule()); myDataConstantToRuleMap.put(CommonDataKeys.NAVIGATABLE_ARRAY.getName(), new NavigatableArrayRule()); myDataConstantToRuleMap.put(CommonDataKeys.EDITOR_EVEN_IF_INACTIVE.getName(), new InactiveEditorRule()); }