• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LineCookie类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openide.cookies.LineCookie的典型用法代码示例。如果您正苦于以下问题:Java LineCookie类的具体用法?Java LineCookie怎么用?Java LineCookie使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LineCookie类属于org.openide.cookies包,在下文中一共展示了LineCookie类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: prepareLine

import org.openide.cookies.LineCookie; //导入依赖的package包/类
private void prepareLine() {
    if (dobj == null || !dobj.isValid()) {
        lineObj = null;
    } else if (lineObj == null) { // try to get Line from DataObject
        LineCookie lineCookie = dobj.getLookup().lookup(LineCookie.class);
        if (lineCookie != null) {
            Line.Set lineSet = lineCookie.getLineSet();
            try {
                lineObj = lineSet.getOriginal(line - 1);
            } catch (IndexOutOfBoundsException ioobex) {
                // The line doesn't exist - go to the last line
                lineObj = lineSet.getOriginal(findMaxLine(lineSet));
                column = markLength = 0;
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:TextDetail.java


示例2: openFileAtOffset

import org.openide.cookies.LineCookie; //导入依赖的package包/类
private static boolean openFileAtOffset(DataObject dataObject, int offset) throws IOException {
    EditorCookie ec = dataObject.getCookie(EditorCookie.class);
    LineCookie lc = dataObject.getCookie(LineCookie.class);
    if (ec != null && lc != null) {
        StyledDocument doc = ec.openDocument();
        if (doc != null) {
            int lineNumber = NbDocument.findLineNumber(doc, offset);
            if (lineNumber != -1) {
                Line line = lc.getLineSet().getCurrent(lineNumber);
                if (line != null) {
                    int lineOffset = NbDocument.findLineOffset(doc, lineNumber);
                    int column = offset - lineOffset;
                    line.show(ShowOpenType.OPEN, ShowVisibilityType.FOCUS, column);
                    return true;
                }
            }
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:SpringXMLConfigEditorUtils.java


示例3: openErrorDescription

import org.openide.cookies.LineCookie; //导入依赖的package包/类
@Messages("ERR_CannotOpen=Cannot open target file")
static void openErrorDescription(AnalyzerFactory analyzer, ErrorDescription ed) throws IndexOutOfBoundsException {
    try {
        DataObject od = DataObject.find(ed.getFile());
        LineCookie lc = od.getLookup().lookup(LineCookie.class);

        if (lc != null) {
            Line line = lc.getLineSet().getCurrent(ed.getRange().getBegin().getLine());

            line.show(ShowOpenType.OPEN, ShowVisibilityType.FOCUS);
            analyzer.warningOpened(ed);
        }
    } catch (IOException ex) {
        Exceptions.printStackTrace(Exceptions.attachLocalizedMessage(Exceptions.attachSeverity(ex, Level.WARNING), Bundle.ERR_CannotOpen()));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:Nodes.java


示例4: openAtSource

import org.openide.cookies.LineCookie; //导入依赖的package包/类
/**
 * Opens a pom file at location defined in InputLocation parameter
 * @since 2.77
 * @param location 
 */
public static void openAtSource(InputLocation location) {
    InputSource source = location.getSource();
    if (source != null && source.getLocation() != null) {
        FileObject fobj = FileUtilities.convertStringToFileObject(source.getLocation());
        if (fobj != null) {
            try {
                DataObject dobj = DataObject.find(NodeUtils.readOnlyLocalRepositoryFile(fobj));
                EditCookie edit = dobj.getLookup().lookup(EditCookie.class);
                if (edit != null) {
                    edit.edit();
                }
                LineCookie lc = dobj.getLookup().lookup(LineCookie.class);
                lc.getLineSet().getOriginal(location.getLineNumber() - 1).show(Line.ShowOpenType.REUSE, Line.ShowVisibilityType.FOCUS, location.getColumnNumber() - 1);
            } catch (DataObjectNotFoundException ex) {
                LOG.log(Level.FINE, "dataobject not found", ex);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ModelUtils.java


示例5: GsfDataObject

import org.openide.cookies.LineCookie; //导入依赖的package包/类
public GsfDataObject(FileObject pf, MultiFileLoader loader, Language language) throws DataObjectExistsException {
    super(pf, loader);

    // If the user creates a file with a filename where we can't figure out the language
    // (e.g. the PHP New File wizard doesn't enforce a file extension, so if you create
    // a file named "pie.class" (issue 124044) the data loader doesn't know which language
    // to associate this with since it isn't a GSF file extension or mimetype). However
    // during template creation we know the language anyway so we can use it. On subsequent
    // IDE restarts the file won't be recognized so the user will have to rename or
    // add a new file extension to file type mapping.
    if (language == null) {
        language = templateLanguage;
    }
    this.language = language;
    getCookieSet().add(new Class[]{
            GenericEditorSupport.class, // NOI18N
            SaveAsCapable.class, Openable.class, EditorCookie.Observable.class, 
            PrintCookie.class, CloseCookie.class, Editable.class, LineCookie.class,
            DataEditorSupport.class, CloneableEditorSupport.class,
            CloneableOpenSupport.class
        }, new EditorSupportFactory());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:GsfDataObject.java


示例6: createCookie

import org.openide.cookies.LineCookie; //导入依赖的package包/类
@Override
public <T extends Cookie> T createCookie(Class<T> klass) {
        if (
        klass.isAssignableFrom(DataEditorSupport.class) || 
        DataEditorSupport.class.isAssignableFrom(klass) || 
        klass.isAssignableFrom(Openable.class) || 
        klass.isAssignableFrom(Editable.class) || 
        klass.isAssignableFrom(EditorCookie.Observable.class) || 
        klass.isAssignableFrom(PrintCookie.class) || 
        klass.isAssignableFrom(CloseCookie.class) || 
        klass.isAssignableFrom(LineCookie.class)
    ) {
        return klass.cast(createEditorSupport());
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:GsfDataObject.java


示例7: openAtSource

import org.openide.cookies.LineCookie; //导入依赖的package包/类
public static void openAtSource(InputLocation location) {
    InputSource source = location.getSource();
    if (source != null && source.getLocation() != null) {
        FileObject fobj = FileUtilities.convertStringToFileObject(source.getLocation());
        if (fobj != null) {
            try {
                DataObject dobj = DataObject.find(NodeUtils.readOnlyLocalRepositoryFile(fobj));
                EditCookie edit = dobj.getLookup().lookup(EditCookie.class);
                if (edit != null) {
                    edit.edit();
                }
                LineCookie lc = dobj.getLookup().lookup(LineCookie.class);
                lc.getLineSet().getOriginal(location.getLineNumber() - 1).show(Line.ShowOpenType.REUSE, Line.ShowVisibilityType.FOCUS, location.getColumnNumber() - 1);
            } catch (DataObjectNotFoundException ex) {
                LOG.log(Level.FINE, "dataobject not found", ex);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:HyperlinkProviderImpl.java


示例8: getLineSet

import org.openide.cookies.LineCookie; //导入依赖的package包/类
Line.Set getLineSet (String url, Object timeStamp) {
    DataObject dataObject = getDataObject (url);
    if (dataObject == null) {
        return null;
    }
    
    if (timeStamp != null) {
        // get original
        synchronized (this) {
            Registry registry = timeStampToRegistry.get (timeStamp);
            if (registry != null) {
                Line.Set ls = registry.getLineSet (dataObject);
                if (ls != null) {
                    return ls;
                }
            }
        }
    }
    
    // get current
    LineCookie lineCookie = dataObject.getLookup().lookup(LineCookie.class);
    if (lineCookie == null) {
        return null;
    }
    return lineCookie.getLineSet ();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:LineTranslations.java


示例9: canOpenTask

import org.openide.cookies.LineCookie; //导入依赖的package包/类
private boolean canOpenTask() {
    if( null != Accessor.getDefaultAction( task ) )
        return true;

    URL url = Accessor.getURL( task );
    if( null != url )
        return true;

    FileObject fo = Accessor.getFile(task);
    if( null == fo )
        return false;

    DataObject dob = null;
    try {
        dob = DataObject.find( fo );
    } catch( DataObjectNotFoundException donfE ) {
        return false;
    }
    if( Accessor.getLine( task ) > 0 ) {
        return null != dob.getCookie( LineCookie.class );
    }

    return null != dob.getCookie( OpenCookie.class )
        || null != dob.getCookie( EditCookie.class )
        || null != dob.getCookie( ViewCookie.class );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:OpenTaskAction.java


示例10: JShellDataObject

import org.openide.cookies.LineCookie; //导入依赖的package包/类
public JShellDataObject(FileObject fo, MultiFileLoader loader) throws DataObjectExistsException {
    super(fo, loader);
    CookieSet cks = getCookieSet();
    cks.add(new Class[] {
            OpenCookie.class,
            EditorCookie.Observable.class,
            CloseCookie.class,
            LineCookie.class,
            SimpleES.class,
        }, new CookieSet.Factory() {
        private CloneableEditorSupport supp;
        public <T extends Node.Cookie> T createCookie(Class<T> klass) {
            if (supp != null) {
                return klass.cast(supp);
            }
            return klass.cast(
                    /*
                    supp = DataEditorSupport.create(JShellDataObject.this, 
                            getPrimaryEntry(), getCookieSet(), 
                            () -> createPane())
                    );*/
                    supp = new SimpleES(JShellDataObject.this, getPrimaryEntry())
            );
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:JShellDataObject.java


示例11: getLine

import org.openide.cookies.LineCookie; //导入依赖的package包/类
private Line getLine (FileObject file, int lineNumber) {
    if (file == null) return null;
    DataObject dataObject;
    try {
        dataObject = DataObject.find (file);
    } catch (DataObjectNotFoundException ex) {
        return null;
    }
    if (dataObject == null) return null;
    LineCookie lineCookie = dataObject.getLookup().lookup(LineCookie.class);
    if (lineCookie == null) return null;
    Line.Set ls = lineCookie.getLineSet ();
    if (ls == null) return null;
    try {
        return ls.getCurrent (lineNumber);
    } catch (IndexOutOfBoundsException | IllegalArgumentException e) {
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:WatchAnnotationProvider.java


示例12: getLine

import org.openide.cookies.LineCookie; //导入依赖的package包/类
public static Line getLine(final FileObject fileObject, final int lineNumber) {
    if (fileObject != null) {
        LineCookie lineCookie = JSUtils.getLineCookie(fileObject);
        if (lineCookie != null) {
            Line.Set ls = lineCookie.getLineSet();
            if (ls != null) {
                try {
                    return ls.getCurrent(lineNumber - 1);
                } catch (IndexOutOfBoundsException ioob) {
                    List<? extends Line> lines = ls.getLines();
                    if (lines.size() > 0) {
                        return lines.get(lines.size() - 1);
                    } else {
                        return null;
                    }
                }
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:JSUtils.java


示例13: get

import org.openide.cookies.LineCookie; //导入依赖的package包/类
@Override
public EditorLineHandler get(FileObject fo, int lineNumber) {
    try {
        DataObject dobj = DataObject.find(fo);
        LineCookie lineCookie = dobj.getLookup().lookup(LineCookie.class);
        if (lineCookie == null) {
            return null;
        }
        try {
            Line line = lineCookie.getLineSet().getCurrent(lineNumber - 1);
            return new LineDelegate(line);
        } catch (IndexOutOfBoundsException ioobex) {
            // The line is gone.
            return null;
        }
    } catch (DataObjectNotFoundException ex) {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:EditorLineHandlerFactoryImpl.java


示例14: getFileObject

import org.openide.cookies.LineCookie; //导入依赖的package包/类
@Override
public FileObject getFileObject() {
    if (line instanceof FutureLine) {
        URL url = getURL();
        FileObject fo = URLMapper.findFileObject(url);
        if (fo != null) {
            try {
                DataObject dobj = DataObject.find(fo);
                LineCookie lineCookie = dobj.getLookup().lookup(LineCookie.class);
                if (lineCookie == null) {
                    return null;
                }
                Line l = lineCookie.getLineSet().getCurrent(getLineNumber() - 1);
                setLine(l);
            } catch (DataObjectNotFoundException ex) {
            }
        }
        return fo;
    } else {
        return line.getLookup().lookup(FileObject.class);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:LineDelegate.java


示例15: setLineNumber

import org.openide.cookies.LineCookie; //导入依赖的package包/类
@Override
public void setLineNumber(int lineNumber) {
    lineNumber--; // Line works with 0-based lines.
    if (line.getLineNumber() == lineNumber) {
        return ;
    }
    LineCookie lineCookie = line.getLookup().lookup(LineCookie.class);
    Line.Set lineSet = lineCookie.getLineSet();
    List<? extends Line> lines = lineSet.getLines();
    if (lines.size() > 0) {
        int lastLineNumber = lines.get(lines.size() - 1).getLineNumber();
        if (lineNumber > lastLineNumber) {
            lineNumber = lastLineNumber;
        }
    }
    Line cline;
    try {
        cline = lineSet.getCurrent(lineNumber);
    } catch (IndexOutOfBoundsException ioobex) {
        cline = lineSet.getCurrent(0);
    }
    setLine(cline);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:LineDelegate.java


示例16: getLine

import org.openide.cookies.LineCookie; //导入依赖的package包/类
/** Get the line object from the given position.
* @param doc document for which the line is being retrieved
* @param offset position in the document
* @param original whether to retrieve the original line (true) before
*   the modifications were done or the current line (false)
* @return the line object
* @deprecated Replaced by more generic method having {@link javax.swing.text.Document} parameter.
*/
public static Line getLine(BaseDocument doc, int offset, boolean original) {
    DataObject dob = getDataObject(doc);
    if (dob != null) {
        LineCookie lc = (LineCookie)dob.getCookie(LineCookie.class);
        if (lc != null) {
            Line.Set lineSet = lc.getLineSet();
            if (lineSet != null) {
                try {
                    int lineOffset = Utilities.getLineOffset(doc, offset);
                    return original
                           ? lineSet.getOriginal(lineOffset)
                           : lineSet.getCurrent(lineOffset);
                } catch (BadLocationException e) {
                }

            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:NbEditorUtilities.java


示例17: createAnnotation

import org.openide.cookies.LineCookie; //导入依赖的package包/类
public static void createAnnotation(final DataObject dataObject, final LineCookie lineCookie, final JSHintError error) {
    final Line currentLine = lineCookie.getLineSet().getCurrent(error.getLine() - 1);
    final Line.Part currentPartLine = currentLine.createPart(error.getCharacter() - 1, error.getLength());

    final JSHintErrorAnnotation annotation = new JSHintErrorAnnotation(error.getReason(), error.getCharacter());
    getAnnotationList(dataObject).add(annotation);

    annotation.attach(currentPartLine);

    currentPartLine.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent ev) {
            String type = ev.getPropertyName();
            if (type == null || type.equals(Annotatable.PROP_TEXT)) {
                currentPartLine.removePropertyChangeListener(this);
                annotation.detach();
                JSHintErrorAnnotation.remove(dataObject, annotation);
            }
        }
    });
}
 
开发者ID:panga,项目名称:netbeans-jshint,代码行数:23,代码来源:JSHintErrorAnnotation.java


示例18: attachAnnotationsTo

import org.openide.cookies.LineCookie; //导入依赖的package包/类
@Override
public void attachAnnotationsTo(Options options, DataObject dataObject, Set<ScanMessage> scanMessages) {
    final FileObject fileObject = dataObject.getPrimaryFile();

    if (attachedAnnotations.containsKey(fileObject)) {
        throw new IllegalArgumentException("EasyPmd annotations have already been attached to this file.\nYou must detach them before attaching new ones.");
    }

    LineCookie lineCookie = dataObject.getLookup().lookup(LineCookie.class);
    Line.Set lineSet = lineCookie.getLineSet();

    Set<Annotation> annotations = scanMessages
            .stream()
            .map(scanMessage -> {
                Annotation annotation = scanMessage.createAnnotation(options);

                Line line = lineSet.getOriginal(scanMessage.getLineNumber() - 1);
                annotation.attach(line);
                return annotation;
            }).collect(Collectors.toSet());

    attachedAnnotations.put(fileObject, annotations);

    registerFileEventHandlers(fileObject);
}
 
开发者ID:giancosta86,项目名称:EasyPmd,代码行数:26,代码来源:DefaultAnnotationService.java


示例19: show

import org.openide.cookies.LineCookie; //导入依赖的package包/类
void show () {
    DataObject dataObject = NbEditorUtilities.getDataObject (document);
    LineCookie lineCookie = dataObject.getCookie (LineCookie.class);
    Line.Set lineSet = lineCookie.getLineSet ();
    Line line = lineSet.getCurrent (NbDocument.findLineNumber (document, item.getOffset ()));
    int column = NbDocument.findLineColumn (document, item.getOffset ());
    line.show (ShowOpenType.OPEN, ShowVisibilityType.FOCUS, column);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:LanguagesNavigatorModel.java


示例20: openAtLine

import org.openide.cookies.LineCookie; //导入依赖的package包/类
private static boolean openAtLine(CompilationController controller, Document doc, String methodName, int line) {
    try {
        if (line > -1) {
            DataObject od = DataObject.find(controller.getFileObject());
            int offset = NbDocument.findLineOffset((StyledDocument) doc, line);
            ExecutableElement parentMethod = controller.getTreeUtilities().scopeFor(offset).getEnclosingMethod();
            if (parentMethod != null) {
                String offsetMethodName = parentMethod.getSimpleName().toString();
                if (methodName.equals(offsetMethodName)) {
                    LineCookie lc = od.getLookup().lookup(LineCookie.class);
                    if (lc != null) {
                        final Line l = lc.getLineSet().getCurrent(line - 1);

                        if (l != null) {
                            CommonUtils.runInEventDispatchThread(new Runnable() {
                                @Override
                                public void run() {
                                    l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
                                }
                            });
                            return true;
                        }
                    }
                }
            }
        }
    } catch (DataObjectNotFoundException e) {
        LOG.log(Level.WARNING, "Error accessing dataobject", e);
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:GoToJavaSourceProvider.java



注:本文中的org.openide.cookies.LineCookie类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CouchbaseTemplate类代码示例发布时间:2022-05-22
下一篇:
Java MD2类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap