本文整理汇总了Java中com.intellij.openapi.editor.ScrollingModel类的典型用法代码示例。如果您正苦于以下问题:Java ScrollingModel类的具体用法?Java ScrollingModel怎么用?Java ScrollingModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScrollingModel类属于com.intellij.openapi.editor包,在下文中一共展示了ScrollingModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: execute
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
@Override
public void execute(Editor editor, DataContext dataContext) {
editor.getCaretModel().removeSecondaryCarets();
editor.getCaretModel().moveToOffset(0);
editor.getSelectionModel().removeSelection();
ScrollingModel scrollingModel = editor.getScrollingModel();
scrollingModel.disableAnimation();
scrollingModel.scrollToCaret(ScrollType.RELATIVE);
scrollingModel.enableAnimation();
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project != null) {
IdeDocumentHistory instance = IdeDocumentHistory.getInstance(project);
if (instance != null) {
instance.includeCurrentCommandAsNavigation();
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TextStartAction.java
示例2: execute
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
@Override
public void execute(Editor editor, DataContext dataContext) {
editor.getCaretModel().removeSecondaryCarets();
int offset = editor.getDocument().getTextLength();
if (editor instanceof EditorImpl && ((EditorImpl)editor).myUseNewRendering) {
editor.getCaretModel().moveToLogicalPosition(editor.offsetToLogicalPosition(offset).leanForward(true));
}
else {
editor.getCaretModel().moveToOffset(offset);
}
editor.getSelectionModel().removeSelection();
ScrollingModel scrollingModel = editor.getScrollingModel();
scrollingModel.disableAnimation();
scrollingModel.scrollToCaret(ScrollType.CENTER);
scrollingModel.enableAnimation();
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project != null) {
IdeDocumentHistory instance = IdeDocumentHistory.getInstance(project);
if (instance != null) {
instance.includeCurrentCommandAsNavigation();
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:TextEndAction.java
示例3: execute
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
@Override
public void execute(Editor editor, DataContext dataContext) {
editor.getCaretModel().moveToOffset(0);
editor.getSelectionModel().removeSelection();
ScrollingModel scrollingModel = editor.getScrollingModel();
scrollingModel.disableAnimation();
scrollingModel.scrollToCaret(ScrollType.RELATIVE);
scrollingModel.enableAnimation();
Project project = PlatformDataKeys.PROJECT.getData(dataContext);
if (project != null) {
IdeDocumentHistory instance = IdeDocumentHistory.getInstance(project);
if (instance != null) {
instance.includeCurrentCommandAsNavigation();
}
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:TextStartAction.java
示例4: execute
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
@Override
public void execute(Editor editor, DataContext dataContext) {
int offset = editor.getDocument().getTextLength();
editor.getCaretModel().moveToOffset(offset);
editor.getSelectionModel().removeSelection();
ScrollingModel scrollingModel = editor.getScrollingModel();
scrollingModel.disableAnimation();
scrollingModel.scrollToCaret(ScrollType.CENTER);
scrollingModel.enableAnimation();
Project project = PlatformDataKeys.PROJECT.getData(dataContext);
if (project != null) {
IdeDocumentHistory instance = IdeDocumentHistory.getInstance(project);
if (instance != null) {
instance.includeCurrentCommandAsNavigation();
}
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:TextEndAction.java
示例5: openSingleSelection
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
private static void openSingleSelection(Project project, Object selection, Optional<UIRegion<Object>> region)
{
if (selection instanceof FileResource)
{
FileResource<?> resource = (FileResource<?>) selection;
File file = resource.getUnderlyingResourceObject();
openFile(project, file);
region.ifPresent(r ->
{
Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
if (editor == null)
{
return;
}
SelectionModel selectionModel = editor.getSelectionModel();
ScrollingModel scrollingModel = editor.getScrollingModel();
LogicalPosition from = new LogicalPosition(r.getStartLine() - 1, r.getStartPosition());
LogicalPosition to = new LogicalPosition(r.getEndLine() - 1, r.getEndPosition(), true);
selectionModel.setBlockSelection(from, to);
scrollingModel.scrollTo(from, ScrollType.CENTER);
});
}
}
开发者ID:forge,项目名称:intellij-idea-plugin,代码行数:26,代码来源:IDEUtil.java
示例6: execute
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
@Override
public void execute(Editor editor, DataContext dataContext) {
editor.getCaretModel().removeSecondaryCarets();
editor.getCaretModel().moveToOffset(0);
editor.getSelectionModel().removeSelection();
ScrollingModel scrollingModel = editor.getScrollingModel();
scrollingModel.disableAnimation();
scrollingModel.scrollToCaret(ScrollType.RELATIVE);
scrollingModel.enableAnimation();
Project project = dataContext.getData(CommonDataKeys.PROJECT);
if (project != null) {
IdeDocumentHistory instance = IdeDocumentHistory.getInstance(project);
if (instance != null) {
instance.includeCurrentCommandAsNavigation();
}
}
}
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:TextStartAction.java
示例7: execute
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
@Override
public void execute(Editor editor, DataContext dataContext) {
editor.getCaretModel().removeSecondaryCarets();
int offset = editor.getDocument().getTextLength();
if (editor instanceof EditorImpl) {
editor.getCaretModel().moveToLogicalPosition(editor.offsetToLogicalPosition(offset).leanForward(true));
}
else {
editor.getCaretModel().moveToOffset(offset);
}
editor.getSelectionModel().removeSelection();
ScrollingModel scrollingModel = editor.getScrollingModel();
scrollingModel.disableAnimation();
scrollingModel.scrollToCaret(ScrollType.CENTER);
scrollingModel.enableAnimation();
Project project = dataContext.getData(CommonDataKeys.PROJECT);
if (project != null) {
IdeDocumentHistory instance = IdeDocumentHistory.getInstance(project);
if (instance != null) {
instance.includeCurrentCommandAsNavigation();
}
}
}
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:TextEndAction.java
示例8: invoke
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
public void invoke(@NotNull Project project,
Editor editor,
PsiFile file,
DataContext dataContext){
final ScrollingModel scrollingModel = editor.getScrollingModel();
scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE);
final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
PsiMethod selectedMethod = null;
if(element instanceof PsiMethod){
selectedMethod = (PsiMethod) element;
} else{
final CaretModel caretModel = editor.getCaretModel();
final int position = caretModel.getOffset();
PsiElement selectedElement = file.findElementAt(position);
while(selectedElement != null){
if(selectedElement instanceof PsiMethod){
selectedMethod = (PsiMethod) selectedElement;
break;
}
selectedElement = selectedElement.getParent();
}
}
if(selectedMethod == null){
CommonRefactoringUtil.showErrorHint(project, editor, RefactorJBundle.message("cannot.perform.the.refactoring") + RefactorJBundle.message(
"the.caret.should.be.positioned.at.the.name.of.the.method.to.be.refactored"), null, this.getHelpID());
return;
}
invoke(project, selectedMethod, editor);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:WrapReturnValueHandler.java
示例9: invoke
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
final ScrollingModel scrollingModel = editor.getScrollingModel();
scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE);
PsiMethod selectedMethod = getSelectedMethod(editor, file, dataContext);
if (selectedMethod == null) {
final String message = RefactorJBundle.message("cannot.perform.the.refactoring") +
RefactorJBundle.message("the.caret.should.be.positioned.at.the.name.of.the.method.to.be.refactored");
CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.IntroduceParameterObject);
return;
}
invoke(project, selectedMethod, editor);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:IntroduceParameterObjectHandler.java
示例10: invoke
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
final ScrollingModel scrollingModel = editor.getScrollingModel();
scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE);
final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
if (!(element instanceof PsiField)) {
CommonRefactoringUtil.showErrorHint(project, editor, RefactorJBundle.message("cannot.perform.the.refactoring") + RefactorJBundle.message(
"the.caret.should.be.positioned.at.the.name.of.the.field.to.be.refactored"), null, getHelpID());
return;
}
invoke((PsiField)element, editor);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:RemoveMiddlemanHandler.java
示例11: invoke
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
final ScrollingModel scrollingModel = editor.getScrollingModel();
scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE);
final CaretModel caretModel = editor.getCaretModel();
final int position = caretModel.getOffset();
final PsiElement element = file.findElementAt(position);
final PsiMember selectedMember = PsiTreeUtil.getParentOfType(element, PsiMember.class, true);
if (selectedMember == null) {
//todo
return;
}
PsiClass containingClass = selectedMember.getContainingClass();
if (containingClass == null && selectedMember instanceof PsiClass) {
containingClass = (PsiClass)selectedMember;
}
final String cannotRefactorMessage = getCannotRefactorMessage(containingClass);
if (cannotRefactorMessage != null) {
CommonRefactoringUtil.showErrorHint(project, editor,
RefactorJBundle.message("cannot.perform.the.refactoring") + cannotRefactorMessage,
null, getHelpID());
return;
}
new ExtractClassDialog(containingClass, selectedMember).show();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:ExtractClassHandler.java
示例12: doScrollVertically
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
private static void doScrollVertically(@NotNull ScrollingModel model, int offset) {
model.disableAnimation();
try {
model.scrollVertically(offset);
}
finally {
model.enableAnimation();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:SyncScrollSupport.java
示例13: doScrollHorizontally
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
private static void doScrollHorizontally(@NotNull ScrollingModel model, int offset) {
model.disableAnimation();
try {
model.scrollHorizontally(offset);
}
finally {
model.enableAnimation();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:SyncScrollSupport.java
示例14: scrollEditor
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
public static void scrollEditor(@NotNull Editor editor, int logicalLine) {
editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(logicalLine, 0));
ScrollingModel scrollingModel = editor.getScrollingModel();
scrollingModel.disableAnimation();
scrollingModel.scrollToCaret(ScrollType.CENTER);
scrollingModel.enableAnimation();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:SyncScrollSupport.java
示例15: navigateToError
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
static void navigateToError(Project project, final Editor editor, HighlightInfo info) {
int oldOffset = editor.getCaretModel().getOffset();
final int offset = getNavigationPositionFor(info, editor.getDocument());
final int endOffset = info.getActualEndOffset();
final ScrollingModel scrollingModel = editor.getScrollingModel();
if (offset != oldOffset) {
ScrollType scrollType = offset > oldOffset ? ScrollType.CENTER_DOWN : ScrollType.CENTER_UP;
editor.getSelectionModel().removeSelection();
editor.getCaretModel().removeSecondaryCarets();
editor.getCaretModel().moveToOffset(offset);
scrollingModel.scrollToCaret(scrollType);
}
scrollingModel.runActionOnScrollingFinished(
new Runnable(){
@Override
public void run() {
int maxOffset = editor.getDocument().getTextLength() - 1;
if (maxOffset == -1) return;
scrollingModel.scrollTo(editor.offsetToLogicalPosition(Math.min(maxOffset, endOffset)), ScrollType.MAKE_VISIBLE);
scrollingModel.scrollTo(editor.offsetToLogicalPosition(Math.min(maxOffset, offset)), ScrollType.MAKE_VISIBLE);
}
}
);
IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:GotoNextErrorHandler.java
示例16: setSelected
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
@Override
public void setSelected(AnActionEvent e, boolean state) {
final Editor variablesEditor = getVariablesEditor(e);
if (variablesEditor != null) {
final Editor queryEditor = variablesEditor.getUserData(JSGraphQLLanguageUIProjectService.GRAPH_QL_QUERY_EDITOR);
if(queryEditor == null) {
// not linked to a query editor
return;
}
final ScrollingModel scroll = queryEditor.getScrollingModel();
final int currentScroll = scroll.getVerticalScrollOffset();
variablesEditor.putUserData(JS_GRAPH_QL_VARIABLES_MODEL, state ? Boolean.TRUE : Boolean.FALSE);
variablesEditor.getComponent().setVisible(state);
if (state) {
variablesEditor.getContentComponent().grabFocus();
} else {
ApplicationManager.getApplication().runWriteAction(() -> {
variablesEditor.getDocument().setText("");
});
queryEditor.getContentComponent().grabFocus();
}
// restore scroll position after the editor has had a chance to re-layout
ApplicationManager.getApplication().invokeLater(() -> {
UIUtil.invokeLaterIfNeeded(() -> scroll.scrollVertically(currentScroll));
});
}
}
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:36,代码来源:JSGraphQLToggleVariablesAction.java
示例17: EditorTopBottom
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
EditorTopBottom(Editor editor) {
this.editor = editor;
ScrollingModel scrolling = editor.getScrollingModel();
verticalScrollOffset = scrolling.getVerticalScrollOffset();
// convert to visual position (including folding) if this is logical (ignoring folding).
VisualPosition vp = editor.xyToVisualPosition(
new Point(scrolling.getVisibleArea().x, verticalScrollOffset));
topLine = vp.line;
column = vp.column;
bottomLine = editor.xyToVisualPosition(
new Point(scrolling.getVisibleArea().x,
verticalScrollOffset + scrolling.getVisibleArea().height)).line;
linesVisible = bottomLine - topLine + 1; // inclusive of both lines, so add one.
Preconditions.checkState(linesVisible >= 0, "Invalid lines visible calculation - bug!");
}
开发者ID:jawspeak,项目名称:intellij-joined-tab-scrolling,代码行数:16,代码来源:JoinedScroller.java
示例18: doScrollVertically
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
private static void doScrollVertically(@NotNull ScrollingModel model, int offset) {
model.disableAnimation();
try {
model.scrollVertically(offset);
} finally {
model.enableAnimation();
}
}
开发者ID:jawspeak,项目名称:intellij-joined-tab-scrolling,代码行数:9,代码来源:JoinedScroller.java
示例19: updateInUI
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
private void updateInUI(Editor editor) {
VisualPosition visualPosition = editor.getCaretModel().getVisualPosition();
Point point = editor.visualPositionToXY(visualPosition);
ScrollingModel scrollingModel = editor.getScrollingModel();
point.x = point.x - scrollingModel.getHorizontalScrollOffset();
point.y = point.y - scrollingModel.getVerticalScrollOffset();
final ParticleContainer particleContainer = particleContainers.get(editor);
if (particleContainer != null) {
particleContainer.update(point);
}
}
开发者ID:baptistemesta,项目名称:power-mode-intellij-plugin,代码行数:12,代码来源:ParticleContainerManager.java
示例20: invoke
import com.intellij.openapi.editor.ScrollingModel; //导入依赖的package包/类
public void invoke(@NotNull Project project,
Editor editor,
PsiFile file,
DataContext dataContext){
final ScrollingModel scrollingModel = editor.getScrollingModel();
scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE);
final PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataContext);
PsiMethod selectedMethod = null;
if(element instanceof PsiMethod){
selectedMethod = (PsiMethod) element;
} else{
final CaretModel caretModel = editor.getCaretModel();
final int position = caretModel.getOffset();
PsiElement selectedElement = file.findElementAt(position);
while(selectedElement != null){
if(selectedElement instanceof PsiMethod){
selectedMethod = (PsiMethod) selectedElement;
break;
}
selectedElement = selectedElement.getParent();
}
}
if(selectedMethod == null){
CommonRefactoringUtil.showErrorHint(project, editor, RefactorJBundle.message("cannot.perform.the.refactoring") + RefactorJBundle.message(
"the.caret.should.be.positioned.at.the.name.of.the.method.to.be.refactored"), null, this.getHelpID());
return;
}
invoke(project, selectedMethod, editor);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:30,代码来源:WrapReturnValueHandler.java
注:本文中的com.intellij.openapi.editor.ScrollingModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论