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


Java LineCookie类代码示例

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


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


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