public void setEditorSource(final Project project, final EditorSource source) { MyState state = new MyState(); myEditorSource = source; myLineMarker.attach(myEditorSource); Editor editor = myEditorSource.getEditor(); final FileEditor fileEditor = myEditorSource.getFileEditor(); if (editor == null) { insertComponent(fileEditor == null ? MOCK_COMPONENT : fileEditor.getComponent()); DataManager.registerDataProvider(myPanel, new DataProvider() { @Override public Object getData(@NonNls String dataId) { if (CommonDataKeys.PROJECT.is(dataId)) {return project;} if (PlatformDataKeys.FILE_EDITOR.is(dataId)) {return fileEditor;} return null; } }); if (fileEditor != null) { ScrollUtil.scrollVertically(fileEditor.getComponent(), 0); ScrollUtil.scrollHorizontally(fileEditor.getComponent(), 0); UIUtil.removeScrollBorder(fileEditor.getComponent()); } } else { DataManager.removeDataProvider(myPanel); editor.getScrollingModel().scrollHorizontally(0); insertComponent(editor.getComponent()); applyHighlighter(); setMouseListeners(source); MyEditorFocusListener.install(this); UIUtil.removeScrollBorder(editor.getComponent()); state.restore(); } }
public void setEditorSource(final Project project, final EditorSource source) { MyState state = new MyState(); myEditorSource = source; myLineMarker.attach(myEditorSource); Editor editor = myEditorSource.getEditor(); final FileEditor fileEditor = myEditorSource.getFileEditor(); if (editor == null) { insertComponent(fileEditor == null ? MOCK_COMPONENT : fileEditor.getComponent()); DataManager.registerDataProvider(myPanel, new DataProvider() { @Override public Object getData(@NonNls String dataId) { if (PlatformDataKeys.PROJECT.is(dataId)) {return project;} if (PlatformDataKeys.FILE_EDITOR.is(dataId)) {return fileEditor;} return null; } }); if (fileEditor != null) { ScrollUtil.scrollVertically(fileEditor.getComponent(), 0); ScrollUtil.scrollHorizontally(fileEditor.getComponent(), 0); } } else { DataManager.removeDataProvider(myPanel); editor.getScrollingModel().scrollHorizontally(0); insertComponent(editor.getComponent()); applyHighlighter(); setMouseListeners(source); MyEditorFocusListener.install(this); state.restore(); } }
public void setEditorSource(final Project project, final EditorSource source) { MyState state = new MyState(); myEditorSource = source; myLineMarker.attach(myEditorSource); Editor editor = myEditorSource.getEditor(); final FileEditor fileEditor = myEditorSource.getFileEditor(); if (editor == null) { insertComponent(fileEditor == null ? MOCK_COMPONENT : fileEditor.getComponent()); DataManager.registerDataProvider(myPanel, new DataProvider() { @Override public Object getData(@Nonnull @NonNls Key<?> dataId) { if (CommonDataKeys.PROJECT == dataId) { return project; } if (PlatformDataKeys.FILE_EDITOR == dataId) { return fileEditor; } return null; } }); if (fileEditor != null) { ScrollUtil.scrollVertically(fileEditor.getComponent(), 0); ScrollUtil.scrollHorizontally(fileEditor.getComponent(), 0); } } else { DataManager.removeDataProvider(myPanel); editor.getScrollingModel().scrollHorizontally(0); insertComponent(editor.getComponent()); applyHighlighter(); setMouseListeners(source); MyEditorFocusListener.install(this); state.restore(); } }