org.openide.cookies.LineCookie.getLineSet()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中org.openide.cookies.LineCookie.getLineSet()方法的一些代码示例,展示了LineCookie.getLineSet()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LineCookie.getLineSet()方法的具体详情如下:
包路径:org.openide.cookies.LineCookie
类名称:LineCookie
方法名:getLineSet

LineCookie.getLineSet介绍

[英]Creates new line set.
[中]创建新的线集。

代码示例

代码示例来源:origin: dcaoyuan/nbscala

synchronized void register (DataObject dataObject) {
  LineCookie lc = dataObject.getCookie (LineCookie.class);
  if (lc == null) return;
  dataObjectToLineSet.put (dataObject, lc.getLineSet ());
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projectsui

synchronized void register (DataObject dataObject) {
  LineCookie lc = dataObject.getLookup().lookup (LineCookie.class);
  if (lc == null) {
    return;
  }
  dataObjectToLineSet.put (dataObject, lc.getLineSet ());
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projects

synchronized void register (DataObject dataObject) {
  LineCookie lc = dataObject.getLookup().lookup (LineCookie.class);
  if (lc == null) {
    return;
  }
  dataObjectToLineSet.put (dataObject, lc.getLineSet ());
}

代码示例来源:origin: stackoverflow.com

FileObject fo = null;
 LineCookie lc = DataObject.find(fo).getLookup().lookup(LineCookie.class);
 int lineNumber=42;
 int colNumber=43;
 Line line = lc.getLineSet().getOriginal(lineNumber);
 line.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FRONT, colNumber);

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-apisupport-project

public @Override void run() {
    lineCookie.getLineSet().getCurrent(line.get() - 1).show(ShowOpenType.OPEN, ShowVisibilityType.FOCUS);
  }
});

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-terminal-nb

private void doEDT() {
  if (lc != null) {
    // XXX opens +-1 line
    Line l = lc.getLineSet().getOriginal(lineNumber);
    l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
  }
}

代码示例来源:origin: hmvictor/radar-netbeans

private boolean isFileOpen(FileObject fileObject) throws DataObjectNotFoundException {
  DataObject dataObject = DataObject.find(fileObject);
  Lookup lookup = dataObject.getLookup();
  LineCookie lineCookie = lookup.lookup(LineCookie.class);
  Line.Set lineSet = lineCookie.getLineSet();
  return !lineSet.getLines().isEmpty();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javascript2-debug-ui

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;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projects

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 ();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projectsui

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 ();
}

代码示例来源:origin: dcaoyuan/nbscala

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.getCookie(LineCookie.class);
  if (lineCookie == null) return null;
  return lineCookie.getLineSet ();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javascript2-debug-ui

@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;
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javascript2-debug-ui

@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);
}

代码示例来源:origin: dcaoyuan/nbscala

public synchronized void attach() throws IOException {
  this.lc = dataObject.getCookie (LineCookie.class);
  if (lc == null) return ;
  lb.addPropertyChangeListener(this);
  try {
    this.line = lc.getLineSet().getCurrent(lb.getLineNumber() - 1);
    line.addPropertyChangeListener(this);
  } catch (IndexOutOfBoundsException ioobex) {
    // ignore document changes for BP with bad line number
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui

Line l = null;
try {
  l = lc.getLineSet().getCurrent(line - 1);
} catch (IndexOutOfBoundsException e) { // try to open at least the file (line no. is too high?)
  l = lc.getLineSet().getCurrent(0);

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javascript2-debug-ui

@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);
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-languages

public void run () {
    int definitionOffset = definition.getOffset ();
    try {
      DataObject dobj = DataObject.find (fo);
      EditorCookie ec = dobj.getCookie (EditorCookie.class);
      StyledDocument doc2 = ec.openDocument ();
      LineCookie lc = dobj.getCookie (LineCookie.class);
      Line.Set lineSet = lc.getLineSet ();
      Line line = lineSet.getCurrent (NbDocument.findLineNumber (doc2, definitionOffset));
      int column = NbDocument.findLineColumn (doc2, definitionOffset);
      line.show (ShowOpenType.OPEN, ShowVisibilityType.FOCUS, column);
    } catch (IOException ex) {
      ex.printStackTrace ();
    }
  }
};

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-languages

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);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-spring-beans

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;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf

private static boolean doOpen(FileObject fo, int offset) {
  try {
    DataObject od = DataObject.find(fo);
    EditorCookie ec = od.getCookie(EditorCookie.class);
    LineCookie lc = od.getCookie(LineCookie.class);
    if ((ec != null) && (lc != null) && (offset != -1)) {
      StyledDocument doc = ec.openDocument();
      if (doc != null) {
        int line = NbDocument.findLineNumber(doc, offset);
        int lineOffset = NbDocument.findLineOffset(doc, line);
        int column = offset - lineOffset;
        if (line != -1) {
          Line l = lc.getLineSet().getCurrent(line);
          if (l != null) {
            l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS, column);
            return true;
          }
        }
      }
    }
    OpenCookie oc = od.getCookie(OpenCookie.class);
    if (oc != null) {
      oc.open();
      return true;
    }
  } catch (IOException e) {
    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
  }
  return false;
}

相关文章

微信公众号

最新文章

更多

LineCookie类方法