当前位置: 首页>>代码示例>>Java>>正文


Java CaretModel.moveCaretRelatively方法代码示例

本文整理汇总了Java中com.intellij.openapi.editor.CaretModel.moveCaretRelatively方法的典型用法代码示例。如果您正苦于以下问题:Java CaretModel.moveCaretRelatively方法的具体用法?Java CaretModel.moveCaretRelatively怎么用?Java CaretModel.moveCaretRelatively使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.editor.CaretModel的用法示例。


在下文中一共展示了CaretModel.moveCaretRelatively方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleInsert

import com.intellij.openapi.editor.CaretModel; //导入方法依赖的package包/类
@Override
public void handleInsert(final InsertionContext context) {
    if (element.getParent() instanceof FieldReference) {
        final Editor     editor     = context.getEditor();
        final CaretModel caretModel = editor.getCaretModel();
        final Document   document   = editor.getDocument();

        document.insertString(caretModel.getOffset(), "()");
        caretModel.moveCaretRelatively(1, 0, false, false, false);
    }
}
 
开发者ID:rentalhost,项目名称:laravel-insight,代码行数:12,代码来源:ScopeCompletionContributor.java

示例2: handleInsert

import com.intellij.openapi.editor.CaretModel; //导入方法依赖的package包/类
public void handleInsert(InsertionContext context, LookupElement lookupItem) {
    final Object object = lookupItem.getObject();
    LOG.debug("object = " + object);

    handleInsertImpl(context, lookupItem, context.getCompletionChar());

  final Editor editor = context.getEditor();
  final CharSequence charsSequence = editor.getDocument().getCharsSequence();
    final CaretModel caretModel = editor.getCaretModel();
    int offset = caretModel.getOffset();

    if (object instanceof Lookup) {
        final Lookup item = (Lookup)object;

        if (item.isFunction()) {
            if (charAt(charsSequence, offset) != '(') {
                EditorModificationUtil.insertStringAtCaret(editor, "()");
                if (item.hasParameters()) {
                    caretModel.moveCaretRelatively(-1, 0, false, false, true);
                }
            } else {
                caretModel.moveCaretRelatively(1, 0, false, false, true);
            }
        } else if (item instanceof NamespaceLookup) {
            if (charAt(charsSequence, offset) != ':') {
                EditorModificationUtil.insertStringAtCaret(editor, ":");
                return;
            }
        }
    }

    if (context.getCompletionChar() == '\t') {
        if (charAt(charsSequence, offset) == ',') {
            offset++;
            caretModel.moveCaretRelatively(1, 0, false, false, true);
            while (charAt(charsSequence, offset++) == ' ') {
                caretModel.moveCaretRelatively(1, 0, false, false, true);
            }
        } else if (isIdentifier(charAt(charsSequence, offset)) && isIdentifier(charAt(charsSequence, offset - 1))) {
            EditorModificationUtil.insertStringAtCaret(editor, " ");
        } else if (charAt(charsSequence, offset) == ':') {
            caretModel.moveCaretRelatively(1, 0, false, false, true);
        }
    } 
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:46,代码来源:XPathInsertHandler.java

示例3: createNodeTypeView

import com.intellij.openapi.editor.CaretModel; //导入方法依赖的package包/类
private void createNodeTypeView(final Project project, final String directory, final String viewFileName, final String propertiesFileName) {
    File folder = new File(directory);
    if(!folder.exists() || !folder.isDirectory()) {
        folder.mkdirs();
    }
    VirtualFile nodeTypeFolder = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(folder);

    File viewFile = new File(nodeTypeFolder.getCanonicalPath(), viewFileName);
    File properties = new File(nodeTypeFolder.getCanonicalPath(), propertiesFileName);

    //Copying default content files to create the new files
    try {
        if (!viewFile.exists()) {
            Path defaultViewPath;
            if (viewFileName.endsWith(".jsp")) {
                defaultViewPath = CndPluginUtil.getPluginFilePath("default/view.jsp");
            } else {
                defaultViewPath = CndPluginUtil.getPluginFilePath("default/view.default");
            }
            Files.copy(defaultViewPath, viewFile.toPath());
            
            if (viewFileName.endsWith(".jsp")) {
                appendAvailableResources(viewFile);
            }
        }

        if (!properties.exists()) {
            Path defaultPropertiesPath = CndPluginUtil.getPluginFilePath("default/view.properties");
            Files.copy(defaultPropertiesPath, properties.toPath());
        }
    } catch (IOException e) {
        throw new IncorrectOperationException(e);
    }

    //Open new files in editor
    VirtualFile propertiesFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(properties);
    FileEditorManager.getInstance(project).openFile(propertiesFile, false);
    
    VirtualFile viewVirtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(viewFile);
    FileEditorManager.getInstance(project).openFile(viewVirtualFile, true);

    //Expand folder in Project view
    ProjectView.getInstance(project).select(null, viewVirtualFile, false);

    //Caret at the end of the file
    ((Navigatable) PsiManager.getInstance(project).findFile(viewVirtualFile).getLastChild().getLastChild().getLastChild().getNavigationElement()).navigate(true);
    CaretModel caretModel = FileEditorManager.getInstance(project).getSelectedTextEditor().getCaretModel();
    caretModel.moveCaretRelatively(-caretModel.getLogicalPosition().column, 2, false, false, false);
}
 
开发者ID:Tolc,项目名称:IntelliJ_Jahia_plugin,代码行数:50,代码来源:CreateNodeTypeViewQuickFix.java


注:本文中的com.intellij.openapi.editor.CaretModel.moveCaretRelatively方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。