本文整理匯總了Java中com.intellij.openapi.fileEditor.FileEditor類的典型用法代碼示例。如果您正苦於以下問題:Java FileEditor類的具體用法?Java FileEditor怎麽用?Java FileEditor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FileEditor類屬於com.intellij.openapi.fileEditor包,在下文中一共展示了FileEditor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawAllPlaceholders
import com.intellij.openapi.fileEditor.FileEditor; //導入依賴的package包/類
public static void drawAllPlaceholders(@NotNull final Project project, @NotNull final Task task) {
VirtualFile taskDir = task.getTaskDir(project);
if (taskDir == null) {
return;
}
for (Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
String name = entry.getKey();
TaskFile taskFile = entry.getValue();
VirtualFile virtualFile = taskDir.findFileByRelativePath(name);
if (virtualFile == null) {
continue;
}
FileEditor fileEditor = FileEditorManager.getInstance(project).getSelectedEditor(virtualFile);
if (fileEditor instanceof StudyEditor) {
StudyEditor studyEditor = (StudyEditor)fileEditor;
StudyUtils.drawAllAnswerPlaceholders(studyEditor.getEditor(), taskFile);
}
}
}
示例2: createNotificationPanel
import com.intellij.openapi.fileEditor.FileEditor; //導入依賴的package包/類
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
if (!CCUtils.isCourseCreator(myProject)) {
return null;
}
boolean isTestFile = CCUtils.isTestsFile(myProject, file);
if (!isTestFile && StudyUtils.getTaskFile(myProject, file) == null) {
return null;
}
Task task = StudyUtils.getTaskForFile(myProject, file);
if (task instanceof TaskWithSubtasks) {
final TaskWithSubtasks withSubtasks = (TaskWithSubtasks)task;
EditorNotificationPanel panel = new EditorNotificationPanel(EditorColors.GUTTER_BACKGROUND);
String header = (isTestFile ? "test" : "task") + " file";
int activeSubtaskIndex = withSubtasks.getActiveSubtaskIndex() + 1;
int subtaskSize = withSubtasks.getLastSubtaskIndex() + 1;
panel.setText("This is a " + header + " for " + EduNames.SUBTASK + " " + activeSubtaskIndex + "/" + subtaskSize);
panel
.createActionLabel(SWITCH_SUBTASK, () -> createPopup(withSubtasks, myProject).show(RelativePoint.getSouthEastOf(panel)));
return panel;
}
return null;
}
示例3: createNotificationPanel
import com.intellij.openapi.fileEditor.FileEditor; //導入依賴的package包/類
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
if (!Projects.isGradleProject(myProject) || myIsImporting.get()) {
return null;
}
GradleSyncState syncState = GradleSyncState.getInstance(myProject);
if (Projects.lastGradleSyncFailed(myProject) ||
syncState.isSyncInProgress() ||
syncState.isSyncNeeded() != ThreeState.NO) {
return null;
}
if (!isGradleBuildFile(file) || isImportedGradleProjectRoot(file, myProject)) {
return null;
}
return new UnimportedModuleNotificationPanel(myProject, file.getParent());
}
示例4: getEditor
import com.intellij.openapi.fileEditor.FileEditor; //導入依賴的package包/類
protected static Editor getEditor(@NotNull DataContext dataContext) {
Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
if (editor == null) {
final PsiFile file = CommonDataKeys.PSI_FILE.getData(dataContext);
if (file != null) {
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile != null) {
final FileEditor fileEditor = FileEditorManager.getInstance(file.getProject()).getSelectedEditor(virtualFile);
if (fileEditor instanceof TextEditor) {
editor = ((TextEditor)fileEditor).getEditor();
}
}
}
}
return editor;
}
示例5: actionPerformed
import com.intellij.openapi.fileEditor.FileEditor; //導入依賴的package包/類
@Override
public void actionPerformed(AnActionEvent event) {
final Project project = event.getProject();
if (project == null) {
return;
}
FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(true, false, true, false, false, false);
VirtualFile virtualFile = FileChooser.chooseFile(chooserDescriptor, project, null);
if (virtualFile != null && virtualFile.isValid() && !virtualFile.isDirectory()) {
DeltaHexVirtualFile deltaHexVirtualFile = new DeltaHexVirtualFile(virtualFile);
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, deltaHexVirtualFile, 0);
FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
List<FileEditor> editors = fileEditorManager.openEditor(descriptor, true);
fileEditorManager.setSelectedEditor(virtualFile, DeltaHexWindowProvider.DELTAHEX_EDITOR_TYPE_ID);
for (FileEditor fileEditor : editors) {
if (fileEditor instanceof DeltaHexFileEditor) {
((DeltaHexFileEditor) fileEditor).openFile(deltaHexVirtualFile);
}
}
}
}
示例6: dotest
import com.intellij.openapi.fileEditor.FileEditor; //導入依賴的package包/類
private void dotest(CheckAction checkAction) throws Exception {
final PsiClass psiClass = JavaDirectoryService.getInstance().getClasses(getPackageDirectory("com/package1"))[0];
final VirtualFile virtualFile = psiClass.getContainingFile().getVirtualFile();
final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
FileEditor[] fileEditors = fileEditorManager.openFile(virtualFile, false);
final FileEditor fileEditor = fileEditors[0];
try {
final StructureViewComponent structureViewComponent =
(StructureViewComponent)fileEditor.getStructureViewBuilder().createStructureView(fileEditor, myProject);
checkAction.testClassStructure(structureViewComponent);
Disposer.dispose(structureViewComponent);
}
finally {
fileEditorManager.closeFile(virtualFile);
}
}
示例7: createNotificationPanel
import com.intellij.openapi.fileEditor.FileEditor; //導入依賴的package包/類
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
if (file.getFileType() == JavaClassFileType.INSTANCE) return null;
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
if (psiFile == null) {
return null;
}
if (psiFile.getLanguage() != JavaLanguage.INSTANCE) {
return null;
}
Module module = ModuleUtilCore.findModuleForPsiElement(psiFile);
if (module == null) {
return null;
}
Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
if (sdk != null) {
return null;
}
return createPanel(myProject, psiFile);
}
示例8: getThemeEditor
import com.intellij.openapi.fileEditor.FileEditor; //導入依賴的package包/類
/**
* Returns a fixture around the {@link com.android.tools.idea.editors.theme.ThemeEditor} <b>if</b> the currently
* displayed editor is a theme editor.
*/
@Nullable
public ThemeEditorFixture getThemeEditor() {
VirtualFile currentFile = getCurrentFile();
if (!(currentFile instanceof ThemeEditorVirtualFile)) {
return null;
}
return execute(new GuiQuery<ThemeEditorFixture>() {
@Override
@Nullable
protected ThemeEditorFixture executeInEDT() throws Throwable {
FileEditorManager manager = FileEditorManager.getInstance(myFrame.getProject());
FileEditor[] editors = manager.getSelectedEditors();
if (editors.length == 0) {
return null;
}
FileEditor selected = editors[0];
if (!(selected instanceof ThemeEditor)) {
return null;
}
return new ThemeEditorFixture(robot, (ThemeEditor)selected);
}
});
}
示例9: selectElement
import com.intellij.openapi.fileEditor.FileEditor; //導入依賴的package包/類
@Override
public void selectElement(PsiElement element) {
selectPsiElement(element, false);
boolean requestFocus = true;
if (element != null) {
final boolean isDirectory = element instanceof PsiDirectory;
if (!isDirectory) {
FileEditor editor = EditorHelper.openInEditor(element, false);
if (editor != null) {
ToolWindowManager.getInstance(myProject).activateEditorComponent();
requestFocus = false;
}
}
}
if (requestFocus) {
selectPsiElement(element, true);
}
}
示例10: actionPerformed
import com.intellij.openapi.fileEditor.FileEditor; //導入依賴的package包/類
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
final DataContext context = event.getDataContext();
final FileEditor editor = PlatformDataKeys.FILE_EDITOR.getData(context);
if (editor instanceof IpnbFileEditor) {
final IpnbFilePanel ipnbFilePanel = ((IpnbFileEditor)editor).getIpnbFilePanel();
CommandProcessor.getInstance().executeCommand(ipnbFilePanel.getProject(), new Runnable() {
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
ipnbFilePanel.moveCell(true);
}
});
}
}, "Ipnb.moveCell", new Object());
}
}
示例11: addFileLevelHighlight
import com.intellij.openapi.fileEditor.FileEditor; //導入依賴的package包/類
@Override
public void addFileLevelHighlight(@NotNull final Project project,
final int group,
@NotNull final HighlightInfo info,
@NotNull final PsiFile psiFile) {
VirtualFile vFile = psiFile.getViewProvider().getVirtualFile();
final FileEditorManager manager = FileEditorManager.getInstance(project);
for (FileEditor fileEditor : manager.getEditors(vFile)) {
if (fileEditor instanceof TextEditor) {
FileLevelIntentionComponent component = new FileLevelIntentionComponent(info.getDescription(), info.getSeverity(),
info.getGutterIconRenderer(), info.quickFixActionRanges,
project, psiFile, ((TextEditor)fileEditor).getEditor());
manager.addTopComponent(fileEditor, component);
List<HighlightInfo> fileLevelInfos = fileEditor.getUserData(FILE_LEVEL_HIGHLIGHTS);
if (fileLevelInfos == null) {
fileLevelInfos = new ArrayList<HighlightInfo>();
fileEditor.putUserData(FILE_LEVEL_HIGHLIGHTS, fileLevelInfos);
}
info.fileLevelComponent = component;
info.setGroup(group);
fileLevelInfos.add(info);
}
}
}
示例12: editorReleased
import com.intellij.openapi.fileEditor.FileEditor; //導入依賴的package包/類
@Override
public void editorReleased(@NotNull EditorFactoryEvent event) {
final EditorEx editor = (EditorEx)event.getEditor();
final Document document = editor.getDocument();
VirtualFile file = myDocumentManager.getFile(document);
if (file == null) {
file = editor.getVirtualFile();
}
if (file != null && file.isValid()) {
for (FileEditor fileEditor : myFileEditorManager.getAllEditors(file)) {
if (fileEditor instanceof TextEditor && ((TextEditor)fileEditor).getEditor() != editor) {
return;
}
}
}
removeDocListener(document, file);
}
示例13: createNotificationPanel
import com.intellij.openapi.fileEditor.FileEditor; //導入依賴的package包/類
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
if (file.getFileType() != PlainTextFileType.INSTANCE) return null;
final String extension = file.getExtension();
final String fileName = file.getName();
if (extension != null && isIgnored("*." + extension) || isIgnored(fileName)) return null;
final PluginsAdvertiser.KnownExtensions knownExtensions = PluginsAdvertiser.loadExtensions();
if (knownExtensions != null) {
final EditorNotificationPanel panel = extension != null ? createPanel("*." + extension, knownExtensions) : null;
if (panel != null) {
return panel;
}
return createPanel(fileName, knownExtensions);
}
return null;
}
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:PluginAdvertiserEditorNotificationProvider.java
示例14: update
import com.intellij.openapi.fileEditor.FileEditor; //導入依賴的package包/類
@Override
public void update(AnActionEvent e) {
final FileEditor fileEditor = PlatformDataKeys.FILE_EDITOR.getData(e.getDataContext());
if (fileEditor instanceof ResourceBundleEditor) {
ResourceBundleEditor resourceBundleEditor = (ResourceBundleEditor)fileEditor;
final Project project = getEventProject(e);
if (project != null) {
if (!processSelectedIncompleteProperties(new Processor<IProperty>() {
@Override
public boolean process(IProperty property) {
return false;
}
}, resourceBundleEditor, project)) {
e.getPresentation().setEnabledAndVisible(true);
return;
}
}
}
e.getPresentation().setEnabledAndVisible(false);
}
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:IgnoreIncompletePropertyPropertiesFilesAction.java
示例15: getFileLevelHighlights
import com.intellij.openapi.fileEditor.FileEditor; //導入依賴的package包/類
@Override
@NotNull
@TestOnly
public List<HighlightInfo> getFileLevelHighlights(@NotNull Project project, @NotNull PsiFile file) {
VirtualFile vFile = file.getViewProvider().getVirtualFile();
final FileEditorManager manager = FileEditorManager.getInstance(project);
List<HighlightInfo> result = new ArrayList<HighlightInfo>();
for (FileEditor fileEditor : manager.getEditors(vFile)) {
final List<HighlightInfo> infos = fileEditor.getUserData(FILE_LEVEL_HIGHLIGHTS);
if (infos == null) continue;
for (HighlightInfo info : infos) {
result.add(info);
}
}
return result;
}