Package com.dci.intellij.dbn.editor.code

Examples of com.dci.intellij.dbn.editor.code.SourceCodeEditor


    private void navigateInEditor(final DatabaseEditableObjectFile databaseFile, final int line) {
        new SimpleLaterInvocator() {
            public void execute() {
                // todo review this!!!
                SourceCodeEditor sourceCodeEditor = null;
                if (databaseFile.getContentFiles().size() > 1) {
                    FileEditorManager editorManager = FileEditorManager.getInstance(databaseFile.getProject());
                    FileEditor[] fileEditors = editorManager.getEditors(databaseFile);
                    if (fileEditors.length >= runtimeInfo.getNamespace()) {
                        FileEditor fileEditor = fileEditors[runtimeInfo.getNamespace() -1];
                        sourceCodeEditor = (SourceCodeEditor) fileEditor;
                        databaseFile.FAKE_DOCUMENT.set(sourceCodeEditor.getEditor().getDocument());
                    } else {
                        FileEditor fileEditor = EditorUtil.getFileEditor(databaseFile, databaseFile.getMainContentFile());
                        if (fileEditor != null && fileEditor instanceof SourceCodeEditor) {
                            sourceCodeEditor = (SourceCodeEditor) fileEditor;
                        }
                    }
                } else {
                    FileEditor fileEditor = EditorUtil.getFileEditor(databaseFile, databaseFile.getMainContentFile());
                    if (fileEditor != null && fileEditor instanceof SourceCodeEditor) {
                        sourceCodeEditor = (SourceCodeEditor) fileEditor;
                    }
                }
                LogicalPosition position = new LogicalPosition(line, 0);
                EditorUtil.selectEditor(databaseFile, sourceCodeEditor);
                if (sourceCodeEditor != null) sourceCodeEditor.getEditor().getScrollingModel().scrollTo(position, ScrollType.CENTER);
            }
        }.start();
    }
View Full Code Here


    }

    private void navigateInEditor(CompilerMessage compilerMessage, BasicTextEditor textEditor, DatabaseEditableObjectFile databaseFile) {
        Editor editor = textEditor.getEditor();
        Document document = editor.getDocument();
        SourceCodeEditor codeEditor = (SourceCodeEditor) textEditor;
        int lineShifting = document.getLineNumber(codeEditor.getHeaderEndOffset());

        if (document.getLineCount() <= compilerMessage.getLine()) {
            compilerMessage.setLine(0);
            compilerMessage.setPosition(0);
            compilerMessage.setSubjectIdentifier(null);
        }
        int lineStartOffset = document.getLineStartOffset(compilerMessage.getLine() + lineShifting);
        int newCaretOffset = lineStartOffset + compilerMessage.getPosition();
        if (document.getTextLength() > newCaretOffset) {
            editor.getCaretModel().moveToOffset(newCaretOffset);

            String identifier = compilerMessage.getSubjectIdentifier();
            if (identifier != null) {
                int lineEndOffset = document.getLineEndOffset(compilerMessage.getLine() + lineShifting);
                String lineText = document.getText().substring(lineStartOffset, lineEndOffset).toUpperCase();
                int selectionOffset = lineText.indexOf(identifier, compilerMessage.getPosition()) + lineStartOffset;
                if (selectionOffset > -1) {
                    editor.getSelectionModel().setSelection(selectionOffset, selectionOffset + identifier.length());
                }
            }
            editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
        }

        EditorUtil.selectEditor(databaseFile, textEditor);
        VirtualFile virtualFile = DocumentUtil.getVirtualFile(textEditor.getEditor());
        OpenFileDescriptor openFileDescriptor = new OpenFileDescriptor(compilerMessage.getProject(), virtualFile);
        codeEditor.navigateTo(openFileDescriptor);
    }
View Full Code Here

TOP

Related Classes of com.dci.intellij.dbn.editor.code.SourceCodeEditor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.