Package com.intellij.openapi.editor

Examples of com.intellij.openapi.editor.Editor


        e.getPresentation().setEnabled(WicketForgeFacet.hasFacetOrIsFromLibrary(psiFile));
    }

    @Override
    public void actionPerformed(AnActionEvent event) {
        Editor editor = event.getData(DataKeys.EDITOR);
        if (editor == null) {
            return;
        }

        PsiFile psiFile = event.getData(DataKeys.PSI_FILE);
        if (psiFile == null) {
            return;
        }

        if (!WicketForgeFacet.hasFacetOrIsFromLibrary(psiFile)) {
            return;
        }

        if (psiFile instanceof XmlFile) {
            PsiClass psiClass = ClassIndex.getAssociatedClass(psiFile);
            if (psiClass == null) {
                HintManager.getInstance().showInformationHint(editor, "No corresponding java class found");
            } else {
                PsiFile classFile =  psiClass.getContainingFile();
                // if file alredy open just navigate to file (and not to class) so caret position gets not changed (issue 92)
                if (classFile != null) {
                    VirtualFile vf = classFile.getVirtualFile();
                    if (vf != null && FileEditorManager.getInstance(psiClass.getProject()).isFileOpen(vf)) {
                        classFile.navigate(true);
                        return;
                    }
                }
                psiClass.navigate(true);
            }
        } else if (psiFile instanceof PsiJavaFile) {
            PsiClass psiClass = null;
            // look for wicket class at caret
            int offset = editor.getCaretModel().getOffset();
            if (offset >= 0) {
                PsiElement currentElement = psiFile.findElementAt(offset);
                if (currentElement != null) {
                    psiClass = WicketPsiUtil.getParentWicketClass(currentElement);
                }
View Full Code Here


                                ConnectionHandler activeConnection = connectionMappingManager.getActiveConnection(openFile);
                                if (activeConnection == connectionHandler) {
                                    FileEditor[] fileEditors = fileEditorManager.getEditors(openFile);
                                    for (FileEditor fileEditor : fileEditors) {
                                        Editor editor = null;
                                        if (fileEditor instanceof TextEditor) {
                                            TextEditor textEditor = (TextEditor) fileEditor;
                                            editor = textEditor.getEditor();
                                        }
                                        else if (fileEditor instanceof BasicTextEditor) {
View Full Code Here

        DataContext dataContext = e.getDataContext();
        Project project = PlatformDataKeys.PROJECT.getData(dataContext);
        if (project == null) {
            return;
        }
        Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
        if (editor == null) {
            return;
        }
        PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
        if (psiFile == null) {
            return;
        }
        int offset = editor.getCaretModel().getOffset();
        if (offset <= 0) {
            return;
        }
        PsiElement currentElement = psiFile.findElementAt(offset);
        if (currentElement == null) {
View Full Code Here

        Project project = PlatformDataKeys.PROJECT.getData(dataContext);
        if (project == null) {
            presentation.setEnabled(false);
            return;
        }
        Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
        if (editor == null) {
            presentation.setEnabled(false);
            return;
        }

        PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
        if (psiFile == null) {
            presentation.setEnabled(false);
            return;
        }
        final VirtualFile virtualFile = psiFile.getVirtualFile();
View Full Code Here

        this.connectionHandler = connectionHandler;
    }

    public void actionPerformed(AnActionEvent e) {
        Project project = ActionUtil.getProject(e);
        Editor editor = e.getData(PlatformDataKeys.EDITOR);
        if (project != null && editor != null) {
            FileConnectionMappingManager.getInstance(project).selectActiveConnectionForEditor(editor, connectionHandler);
        }
    }
View Full Code Here

        Project project = ActionUtil.getProject(e);
        if (project != null && !project.isDisposed()) {
            new BackgroundTask(project, "Reverting local changes", false) {
                @Override
                protected void execute(@NotNull ProgressIndicator progressIndicator) throws InterruptedException {
                    final Editor editor = getEditor(e);
                    final SourceCodeFile sourceCodeFile = getSourcecodeFile(e);

                    if (editor != null && sourceCodeFile != null) {
                        boolean reloaded = sourceCodeFile.reloadFromDatabase();

                        if (reloaded) {
                            new WriteActionRunner() {
                                public void run() {
                                    editor.getDocument().setText(sourceCodeFile.getContent());
                                    sourceCodeFile.setModified(false);
                                }
                            }.start();

                            sourceCodeFile.getDatabaseFile().updateDDLFiles(sourceCodeFile.getContentType());
View Full Code Here

        if (project != null) {
            new BackgroundTask(project, "Loading database source code", false, true) {
                @Override
                protected void execute(@NotNull ProgressIndicator progressIndicator) throws InterruptedException {
                    SourceCodeFile virtualFile = getSourcecodeFile(e);
                    Editor editor = getEditor(e);
                    if (virtualFile != null && editor != null) {
                        String content = editor.getDocument().getText();
                        virtualFile.setContent(content);
                        DBSchemaObject object = virtualFile.getObject();
                        if (object != null) {
                            try {
                                SourceCodeManager sourceCodeManager = SourceCodeManager.getInstance(project);
View Full Code Here

        }

    }

    public void update(AnActionEvent e) {
        Editor editor = getEditor(e);
        e.getPresentation().setText("Compare with database");
        e.getPresentation().setEnabled(editor != null);
    }
View Full Code Here

    public CompareWithOriginalAction() {
        super("Compare with original", null, Icons.CODE_EDITOR_DIFF);
    }

    public void actionPerformed(AnActionEvent e) {
        Editor editor = getEditor(e);
        SourceCodeFile virtualFile = getSourcecodeFile(e);
        String content = editor.getDocument().getText();
        virtualFile.setContent(content);
        String referenceText = virtualFile.getOriginalContent();

        openDiffWindow(e, referenceText, "Original version", "Local version");
    }
View Full Code Here

        super("", null, Icons.CODE_EDITOR_SAVE);
    }

    public void actionPerformed(final AnActionEvent e) {
        final Project project = ActionUtil.getProject(e);
        final Editor editor = getEditor(e);
        final SourceCodeFile virtualFile = getSourcecodeFile(e);

        new WriteActionRunner() {
            public void run() {
                FileDocumentManager.getInstance().saveAllDocuments();
View Full Code Here

TOP

Related Classes of com.intellij.openapi.editor.Editor

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.