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


Java NbEditorUtilities.getLine方法代码示例

本文整理汇总了Java中org.netbeans.modules.editor.NbEditorUtilities.getLine方法的典型用法代码示例。如果您正苦于以下问题:Java NbEditorUtilities.getLine方法的具体用法?Java NbEditorUtilities.getLine怎么用?Java NbEditorUtilities.getLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.netbeans.modules.editor.NbEditorUtilities的用法示例。


在下文中一共展示了NbEditorUtilities.getLine方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkPluginList

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
private void checkPluginList(List<Plugin> plugins, POMModel model, List<ErrorDescription> toRet, Map<String, String> managed) {
    if (plugins != null) {
        for (Plugin plg : plugins) {
            String ver = plg.getVersion();
            if (ver != null) {
                String art = plg.getArtifactId();
                String gr = plg.getGroupId();
                gr = gr != null ? gr : Constants.GROUP_APACHE_PLUGINS;
                String key = gr + ":" + art; //NOI18N
                if (managed.keySet().contains(key)) {
                    int position = plg.findChildElementPosition(model.getPOMQNames().VERSION.getQName());
                    Line line = NbEditorUtilities.getLine(model.getBaseDocument(), position, false);
                    String managedver = managed.get(key);
                    toRet.add(ErrorDescriptionFactory.createErrorDescription(
                                   configuration.getSeverity(configuration.getPreferences()).toEditorSeverity(),
                            NbBundle.getMessage(OverridePluginManagementError.class, "TXT_OverridePluginManagementError", managedver),
                            Collections.<Fix>singletonList(new OverrideFix(plg)),
                            model.getBaseDocument(), line.getLineNumber() + 1));
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:OverridePluginManagementError.java

示例2: checkPluginList

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
private void checkPluginList(List<Plugin> plugins, POMModel model, List<ErrorDescription> toRet, boolean release, boolean latest, boolean snapshot) {
    if (plugins != null) {
        for (Plugin plg : plugins) {
            String ver = plg.getVersion();
            if (ver != null && ((release && "RELEASE".equals(ver)) ||  //NOI18N
                    (latest &&"LATEST".equals(ver)) || //NOI18N
                    (snapshot && ver.endsWith("SNAPSHOT")) //NOI18N
                )) {
                int position = plg.findChildElementPosition(model.getPOMQNames().VERSION.getQName());
                Line line = NbEditorUtilities.getLine(model.getBaseDocument(), position, false);
                toRet.add(ErrorDescriptionFactory.createErrorDescription(
                               configuration.getSeverity(configuration.getPreferences()).toEditorSeverity(),
                        NbBundle.getMessage(ReleaseVersionError.class, "DESC_RELEASE_VERSION"),
                        Collections.<Fix>emptyList(), //Collections.<Fix>singletonList(new ReleaseFix(plg)),
                        model.getBaseDocument(), line.getLineNumber() + 1));
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ReleaseVersionError.java

示例3: getStateAtCaretPosition

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
/**
 * Finds the state which is at current caret position.
 *
 * @return state number or -1 if no state was found
 */
private int getStateAtCaretPosition() {
    Document doc = WindowHelper.getLastFocusedEditor().getDocument();
    int dot = WindowHelper.getLastFocusedEditor().getCaret().getDot();
    Line l = NbEditorUtilities.getLine(doc, dot, false);
    int lNr = l.getLineNumber();
    int col = 0;
    try {
        col = Utilities.getVisualColumn((BaseDocument) doc, dot);
    } catch (BadLocationException e) {

    }
    if (col == 0) {
    dot += detectFirstCharPositionInLine(l.getText());
    }
    int column = dot - getLineStartOffset(lNr) + 1;
    lNr++;
    return getState(lNr, column);
}
 
开发者ID:iti-luebeck,项目名称:RTeasy2,代码行数:24,代码来源:BreakPointManager.java

示例4: Bookmark

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
/**
 * Construct new instance of bookmark.
 *
 * <p>
 * The constructor is not public intentionally.
 * Please see <code>BookmarksApiPackageAccessor</code> for details.
 */
Bookmark (BookmarkList bookmarkList, BookmarkInfo info, int offset) {
    if (info == null) {
        throw new IllegalArgumentException("info cannot be null"); // NOI18N
    }
    this.bookmarkList = bookmarkList;
    this.info = info;
    Document document = bookmarkList.getDocument ();
    int lineIndex = BookmarkUtils.offset2LineIndex(document, offset);
    DataObject dataObject = NbEditorUtilities.getDataObject (document);
    for (Line _line : lineToAnnotation.keySet ()) {
        if (_line.getLineNumber () == lineIndex &&
            _line.getLookup().lookup (DataObject.class).equals (dataObject)
        ) {
            this.line = _line;
            Reference<Annotation> annoRef = lineToAnnotation.get (_line);
            Annotation a = annoRef.get();
            if (a != null) {
                info.setAnnotationRef(annoRef);
            }
        }
    }
    line = NbEditorUtilities.getLine (bookmarkList.getDocument (), offset, false);
    if (line != null) { // In tests it may be null
        if (info.getAnnotation() == null) {
            AAnnotation annotation = new AAnnotation ();
            info.setAnnotationRef(new WeakReference<Annotation>(annotation));
            annotation.attach (line);
        } 
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:Bookmark.java

示例5: checkRepositoryList

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
@NbBundle.Messages("TXT_UsesJavanetRepository=References a blacklisted repository")
private void checkRepositoryList( List<Repository> repositories, POMModel model, RepositoryContainer container, boolean isPlugin, List<ErrorDescription> toRet) {
    if (repositories != null) {
        boolean justSelected = configuration.getPreferences().getBoolean(PROP_SELECTED, true);
        Set<String> forbidden = getForbidden();
        for (Repository rep : repositories) {
            String url = rep.getUrl();
            if (url != null) {
                if (!url.endsWith("/")) {
                    url = url + "/"; //just to make queries consistent
                }
                if (!justSelected || forbidden.contains(url)) {
                    int position = rep.findChildElementPosition(model.getPOMQNames().URL.getQName());
                    try {
                        Line line = NbEditorUtilities.getLine(model.getBaseDocument(), position, false);
                        OverrideFix basefix = new OverrideFix(rep, container, isPlugin);
                        toRet.add(ErrorDescriptionFactory.createErrorDescription(
                                                        configuration.getSeverity(configuration.getPreferences()).toEditorSeverity(),
                                                 TXT_UsesJavanetRepository(),
                                                 Collections.<Fix>singletonList(ErrorDescriptionFactory.attachSubfixes(basefix, Collections.singletonList(new Configure(configuration)))),
                                                 model.getBaseDocument(), line.getLineNumber() + 1));
                    } catch (IndexOutOfBoundsException e) {
                        LOG.log(Level.INFO, "wrong repository pos in model for : " + url, e);
                    }
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:JavaNetRepositoryError.java

示例6: getErrorsForDocument

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
@Override
public List<ErrorDescription> getErrorsForDocument(POMModel model, Project prj,
        int selectionStart, int selectionEnd, int caretPosition) {
    List<ErrorDescription> err = new ArrayList<ErrorDescription>();
    if (prj == null) {
        return err;
    }
    DocumentComponent comp1 = model.findComponent(selectionStart);
    DocumentComponent comp2 = model.findComponent(selectionEnd);
    if (comp1 == null || comp2 == null) { //#157213
        return err;
    }
 
    List<Dependency> deps = getSelectedDependencies(model, selectionStart, selectionEnd);
    if (deps != null && !deps.isEmpty()) { //NOI18N
        try {
            Line line = NbEditorUtilities.getLine(model.getBaseDocument(), caretPosition, false);
            err.add(ErrorDescriptionFactory.createErrorDescription(
                    Severity.HINT,
                    NbBundle.getMessage(MoveToDependencyManagementHint.class, "TEXT_MoveToDependencyManagementHint"),
                    Collections.<Fix>singletonList(new MoveFix(selectionStart, selectionEnd, model, prj)),
                    model.getBaseDocument(), line.getLineNumber() + 1));
        } catch (IndexOutOfBoundsException ioob) {
            //#214527
            LOG.log(Level.FINE, "document changed", ioob);
        }
    }
    return err;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:MoveToDependencyManagementHint.java

示例7: addAnnotation

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
/**
 * Adds annotation for the given state.
 *
 * @param state Index of the state
 */
private void addAnnotation(Integer state) {
    PositionRange pR = getPositionRangeOfState(state);
    int pos = getLineStartOffset(pR.beginLine - 1) + pR.beginColumn;
    JTextComponent ed = WindowHelper.getLastFocusedEditor();
    Document doc = ed.getDocument();
    //int pos = ed.getCaret().getDot();
    Line l = NbEditorUtilities.getLine(doc, pos, false);
    Annotation a = new BreakPointAnnotation();
    a.attach(l);
    annotations.put(state, a);
}
 
开发者ID:iti-luebeck,项目名称:RTeasy2,代码行数:17,代码来源:BreakPointManager.java

示例8: getErrorsForDocument

import org.netbeans.modules.editor.NbEditorUtilities; //导入方法依赖的package包/类
@Override
public List<ErrorDescription> getErrorsForDocument(POMModel model, Project prj,
        int selectionStart, int selectionEnd, int caretPosition) {
    List<ErrorDescription> err = new ArrayList<ErrorDescription>();
    if (prj == null) {
        return err;
    }
    DocumentComponent comp1 = model.findComponent(selectionStart);
    DocumentComponent comp2 = model.findComponent(selectionEnd);
    if (comp1 == null || comp2 == null) { //#157213
        return err;
    }
    if (comp1 == comp2 && comp1 instanceof POMExtensibilityElement) {
        POMExtensibilityElement el = (POMExtensibilityElement) comp1;
        int startPos = el.findPosition();
        startPos = startPos + el.getQName().getLocalPart().length() + 2; //2 is brackets
        String text = el.getElementText();
        int endPos = startPos + text.length();
        if (selectionStart >= startPos && selectionEnd <= endPos) {
            //we are in actual text now..
            //TODO also skip when inside expression as well..
            int offset = selectionStart - startPos;
            int endOffset = selectionEnd - startPos;
            String s = text.substring(offset, endOffset);
            if (s.length() > 0) {
                List<Fix> fixes = new ArrayList<Fix>();
                String elementName = el.getQName().getLocalPart();
                Map<String, String> props = loadAllProperties(prj, model, el, selectionStart);
                for (Map.Entry<String, String> ent : props.entrySet()) {
                    if (s.equals(ent.getValue()) && !elementName.equals(ent.getKey())) { //do not want to complete the cycle
                        fixes.add(new PropFix(text, offset, endOffset, el, model, ent.getKey()));
                    }
                }
                fixes.add(new PropFix(text, offset, endOffset, el, model));
                try {
                    Line line = NbEditorUtilities.getLine(model.getBaseDocument(), selectionEnd, false);
                    err.add(ErrorDescriptionFactory.createErrorDescription(
                            Severity.HINT,
                            TIT_TurnToPropertyHint(),
                            fixes,
                            model.getBaseDocument(), line.getLineNumber() + 1));
                } catch (IndexOutOfBoundsException iiob) {
                    //#214527
                    LOG.log(Level.FINE, "document changed", iiob);
                }
                
            }
        }
    }
    return err;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:52,代码来源:TurnToPropertyHint.java


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