Examples of EditorCookie


Examples of org.openide.cookies.EditorCookie

            DataObject dataObj = DataObject.find(fileObj);
            if (dataObj == null) {
                return null;
            }

            EditorCookie editor = dataObj.getLookup().lookup(EditorCookie.class);
            if (editor == null) {
                LOGGER.log(Level.WARNING, "EditorCookie cannot be found for file: {0}", fileObj);
                return null;
            }
View Full Code Here

Examples of org.openide.cookies.EditorCookie

    public void componentClosed() {
    }

    @Override
    public void componentShowing() {
        final EditorCookie ec = context.lookup(EditorCookie.class);
        if (ec != null) {
            RP.post(new Runnable() {
                @Override
                public void run() {
                    try {
                        final StyledDocument localSourceDoc = ec.openDocument();
                        setSourceDocument(localSourceDoc);
                        doUpdatePreview();
                    }
                    catch (IOException ex) {
                        Exceptions.printStackTrace(ex);
View Full Code Here

Examples of org.openide.cookies.EditorCookie

    }

    private String getSourceText(Set<RenderOption> renderOptions) throws IOException {
        String sourceText = null;
        if (renderOptions.contains(RenderOption.PREFER_EDITOR)) {
            EditorCookie ec = context.getLookup().lookup(EditorCookie.class);
            final StyledDocument sourceDoc = ec.getDocument();
            if (sourceDoc != null) {
                sourceText = getDocumentText(sourceDoc);
            }
        }
        if (sourceText == null) {
View Full Code Here

Examples of org.openide.cookies.EditorCookie

import org.openide.util.actions.CookieAction;

public final class copy_scrap extends CookieAction {

    protected void performAction(Node[] activatedNodes) {
        EditorCookie editorCookie = activatedNodes[0].getLookup().lookup(EditorCookie.class);
    // TODO use editorCookie
        JEditorPane[] panes=editorCookie.getOpenedPanes();
        System.out.println("sel"+panes[0].getSelectedText());
        copy_new(panes[0].getSelectedText());  

    }
View Full Code Here

Examples of org.openide.cookies.EditorCookie

            LOGGER.log(Level.WARNING, "Not found wp-config.php");
            return;
        }
        try {
            Lookup lookup = config.getLookup();
            EditorCookie ec = lookup.lookup(EditorCookie.class);
            if (ec == null) {
                return;
            }
            final StyledDocument docment = ec.openDocument();
            if (docment == null) {
                return;
            }
            List<String> lines = config.asLines(Charset.UTF8);
            Pattern pattern = Pattern.compile(DEBUG_REGEX);
            int lineNumber = 0;
            for (String line : lines) {
                Matcher matcher = pattern.matcher(line);
                if (matcher.find()) {
                    // change
                    final int startOffset = NbDocument.findLineOffset(docment, lineNumber);
                    final int removeLength = line.length();

                    NbDocument.runAtomic(docment, new Runnable() {
                        @Override
                        public void run() {
                            try {
                                docment.remove(startOffset, removeLength);
                                docment.insertString(startOffset, String.format(WP_DEBUG_FORMAT, debugLv), null);
                            } catch (BadLocationException ex) {
                                Exceptions.printStackTrace(ex);
                            }
                        }
                    });
                }
                lineNumber++;
            }
            ec.saveDocument();
        } catch (IOException ex) {
            LOGGER.log(Level.WARNING, null, ex);
        }
    }
View Full Code Here

Examples of org.openide.cookies.EditorCookie

    private void openEditorAndJump(final DataObject dataObj, final int line) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                try {
                    EditorCookie ck = dataObj.getCookie(EditorCookie.class);
                    final Observable ec = dataObj.getCookie(Observable.class);
                    if (ck != null && ec != null) {
                        ec.open();
                        //open the document
                        JEditorPane[] p = ck.getOpenedPanes();
                        if (p.length > 0) {
                            //Need to do this since we're disabling the window system's
                            //auto focus mechanism
                            p[0].requestFocus();
                            if (dataObj != null) {
                                LineCookie lc = dataObj.getCookie(LineCookie.class);
                                if (lc == null) {
                                    return;
                                }
                                Line l = lc.getLineSet().getOriginal(line);
                                l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
                            }
                        }

                        //highlight the line
                        StyledDocument document = ck.getDocument();
                        if(document != null) {
                            Element e = document.getDefaultRootElement();
                            if (e != null && line != -1) {
                                e = e.getElement(line);
                                final int startOfLine = e.getStartOffset();
View Full Code Here

Examples of org.openide.cookies.EditorCookie

    private void jumpToLine(final DataObject dataObj, final int line) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                try {
                    EditorCookie ck = dataObj.getCookie(EditorCookie.class);
                    if (ck != null) {
                        //ck.openDocument();
                        JEditorPane[] p = ck.getOpenedPanes();
                        if (p.length > 0) {
                            //Need to do this since we're disabling the window system's
                            //auto focus mechanism
                            p[0].requestFocus();
                            if (dataObj != null) {
View Full Code Here

Examples of org.openide.cookies.EditorCookie

            dataObject = DataObject.find(fo);
        } catch (DataObjectNotFoundException exception) {
        }

        try {
            EditorCookie ck = dataObject.getCookie(EditorCookie.class);
            if (ck != null) {
                StyledDocument document = ck.getDocument();
                int lineNumber = line - 1;
                if(document != null) {
                   
                    Element e = document.getDefaultRootElement();
                    if (e != null && lineNumber != -1) {
View Full Code Here

Examples of org.openide.cookies.EditorCookie

            DataObject dob = DataObject.find(fileObjectToOpen);

            //Bug fix: now actually make sure it's open in the editor
            openEditor(dob);

            EditorCookie ck = dob.getCookie(EditorCookie.class);
            if (ck != null) {
                ck.openDocument();
                JEditorPane[] p = ck.getOpenedPanes();
                if (p.length > 0) {
                    //Need to do this since we're disabling the window system's
                    //auto focus mechanism
                    p[0].requestFocus();
                    if (dob != null) {
View Full Code Here

Examples of org.openide.cookies.EditorCookie

        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                Node[] n = TopComponent.getRegistry().getActivatedNodes();
                if (n.length == 1) {
                    EditorCookie ec = n[0].getCookie(EditorCookie.class);
                    if (ec != null) {
                        JEditorPane[] panes = ec.getOpenedPanes();
                        if (panes.length > 0) {
                            int cursor = panes[0].getCaret().getDot();
                            Line line = NbEditorUtilities.getLine(panes[0].getDocument(), cursor, true);
                            FileObject fo = NbEditorUtilities.getFileObject(panes[0].getDocument());
                            CompilerFileDescriptor cfd = compiler.getFileDescriptor(fo);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.