本文整理了Java中org.openide.text.Line
类的一些代码示例,展示了Line
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Line
类的具体详情如下:
包路径:org.openide.text.Line
类名称:Line
[英]Represents one line in a text document. The line number may change when the text is modified, but the identity of the line is retained. It is designed to allow line-dependent modules of the IDE (such as the compiler and debugger) to make use of a line consistently even as the text is modified.
[中]表示文本文档中的一行。修改文本时,行号可能会更改,但行的标识将保留。它的设计允许IDE的行相关模块(如编译器和调试器)在修改文本时一致地使用行。
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-maven-junit
@Override
public void run() {
try {
EditorCookie ed = dob.getLookup().lookup(EditorCookie.class);
if (ed != null && /* not true e.g. for *_ja.properties */
file == dob.getPrimaryFile()) {
if (lineNum == -1) {
// OK, just open it.
ed.open();
} else {
ed.openDocument();//XXX getLineSet doesn't do it for you
try {
Line l = ed.getLineSet().getOriginal(lineNum - 1);
if (!l.isDeleted()) {
l.show(ShowOpenType.OPEN, ShowVisibilityType.FOCUS);
}
} catch (IndexOutOfBoundsException ioobe) {
// Probably harmless. Bogus line number.
ed.open();
}
}
} else {
java.awt.Toolkit.getDefaultToolkit().beep();
}
} catch (Exception ex2) {
// XXX see above, should not be necessary to call openDocument
// at all
}
}
});
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide-loaders
/** Computes display name for a line based on the
* name of the associated DataObject and the line number.
*
* @param line the line object to compute display name for
* @return display name for the line like "MyFile.java:243"
*
* @since 4.3
*/
protected String messageLine (Line line) {
return NbBundle.getMessage(DataObject.class, "FMT_LineDisplayName2",
obj.getPrimaryFile().getNameExt(),
FileUtil.getFileDisplayName(obj.getPrimaryFile()),
new Integer(line.getLineNumber() + 1));
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javascript2-debug-ui
public LineDelegate(Line line) {
this.line = line;
lineChangesWeak = WeakListeners.propertyChange(lineChangeslistener, line);
line.addPropertyChangeListener(lineChangesWeak);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-toolchain
private void showLine(boolean openTab) {
try {
DataObject dob = DataObject.find(file);
LineCookie lc = dob.getLookup().lookup(LineCookie.class);
if (lc != null) {
try {
Line l = lc.getLineSet().getOriginal(line);
if (!l.isDeleted()) {
if (openTab) {
l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
} else {
l.show(Line.ShowOpenType.NONE, Line.ShowVisibilityType.NONE);
if (dob.isValid()) {
EditorCookie ec = dob.getLookup().lookup(EditorCookie.class);
if (ec != null) {
doc = ec.getDocument();
代码示例来源: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.modules/org-netbeans-modules-debugger-jpda-projectsui
/** Add the line offset into the jump history */
private void addPositionToJumpList(String url, Line l, int column) {
DataObject dataObject = getDataObject (url);
if (dataObject != null) {
EditorCookie ec = dataObject.getLookup().lookup(EditorCookie.class);
if (ec != null) {
try {
StyledDocument doc = ec.openDocument();
JEditorPane[] eps = ec.getOpenedPanes();
if (eps != null && eps.length > 0) {
JumpList.addEntry(eps[0], NbDocument.findLineOffset(doc, l.getLineNumber()) + column);
}
} catch (java.io.IOException ioex) {
ErrorManager.getDefault().notify(ioex);
}
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javascript2-debug-ui
doc = ec.openDocument();
} catch (IOException ex) {
return ;
int lineNo = lp.getLine().getLineNumber();
int column = lp.getColumn();
final int offset = NbDocument.findLineOffset(doc, lineNo) + column;
return;
final FileObject fo = line.getLookup().lookup(FileObject.class);
if (isFunctionPtr[0]) {
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-inspect
DataObject dob = DataObject.find(fob);
Lookup dobLookup = dob.getLookup();
EditorCookie ec = dobLookup.lookup(EditorCookie.class);
LineCookie lc = dobLookup.lookup(LineCookie.class);
OpenCookie oc = dobLookup.lookup(OpenCookie.class);
doc = ec.openDocument();
} catch (UserQuestionException uqe) {
String title = NbBundle.getMessage(
doc = ec.openDocument();
int column = offset ? columnNo - NbDocument.findLineOffset(doc, line) : columnNo;
if (line != -1) {
Line l = lc.getLineSet().getCurrent(line);
if (l != null) {
l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS, column);
return true;
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projects
String text = l.getText();
if (text.trim().length() == 0 && text.indexOf('\n') >= 0) {
line.removePropertyChangeListener(this);
if (dataObject == null) {
return ;
LineCookie lc = dobj.getLookup().lookup (LineCookie.class);
Line newLine;
try {
int lineNumber = l.getLineNumber();
int newLineNumber = lc.getLineSet().getOriginal(lineNumber).getLineNumber();
for (int i = lineNumber + 1; i < newLineNumber; i++) {
if (lc.getLineSet().getCurrent(i).getText().trim().length() != 0) {
newLineNumber = i;
break;
newLine = lc.getLineSet().getCurrent(newLineNumber);
newLine.addPropertyChangeListener(this);
} catch (IndexOutOfBoundsException ioobex) {
return ;
DataObject dobj;
synchronized (this) {
line.removePropertyChangeListener(this);
if (dataObject == null) {
return ;
LineCookie lc = dobj.getLookup().lookup (LineCookie.class);
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projects
dobj = this.dataObject;
LineCookie lc = dobj.getLookup().lookup (LineCookie.class);
if (lc == null) {
return ;
final Line lineNew = lc.getLineSet().getCurrent(lb.getLineNumber() - 1);
synchronized (this) {
if (line != null) {
line.removePropertyChangeListener(this);
lineNew.addPropertyChangeListener(this);
StyledDocument document = NbDocument.getDocument(new Lookup.Provider() {
@Override
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-java-testrunner-ui
EditorCookie ed = file.getLookup().lookup(EditorCookie.class);
if (ed != null) {
if (lineNum == -1) {
ed.open();
} else {
ed.openDocument();//XXX getLineSet doesn't do it for you
try {
Line l = ed.getLineSet().getOriginal(lineNum - 1);
if (!l.isDeleted()) {
if (columnNum != Integer.MIN_VALUE) {
l.show(ShowOpenType.OPEN, ShowVisibilityType.FOCUS, columnNum);
} else {
l.show(ShowOpenType.OPEN, ShowVisibilityType.FOCUS);
代码示例来源: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: org.netbeans.modules/org-netbeans-modules-javascript2-debug-ui
if (lb != null) {
Line line = JSUtils.getLine(lb);
FileObject fo = line.getLookup().lookup(FileObject.class);
if (fo != null) {
File file = FileUtil.toFile(fo);
lineTextField.setText(Integer.toString(line.getLineNumber() + 1));
Object[] conditions = getSavedConditions();
conditionComboBox.setModel(new DefaultComboBoxModel(conditions));
代码示例来源:origin: org.codehaus.mevenide/nb-project
DataObject dob = DataObject.find(file);
EditorCookie ed = dob.getCookie(EditorCookie.class);
if (ed != null && file == dob.getPrimaryFile()) {
if (lineNum == -1) {
ed.open();
} else {
ed.openDocument();
try {
Line l = ed.getLineSet().getOriginal(lineNum - 1);
if (! l.isDeleted()) {
l.show(Line.SHOW_GOTO);
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-junit-ui
final DataObject dataObject;
try {
dataObject = DataObject.find(fileObject);
} catch (DataObjectNotFoundException e) {
getLogger().log(Level.INFO, null, e);
final EditorCookie editorCookie = dataObject.getCookie(EditorCookie.class);
if (editorCookie != null) {
doc = editorCookie.openDocument();
} catch (IOException ex) {
String msg = ex.getLocalizedMessage();
editorCookie.open();
int lineNum = NbDocument.findLineNumber(doc, startPos);
if (lineNum != -1) {
Line line = lineCookie.getLineSet().getCurrent(lineNum);
try {
int lineOffset = NbDocument.findLineOffset(doc,
lineNum);
int column = startPos - lineOffset;
line.show(ShowOpenType.OPEN, ShowVisibilityType.FOCUS, column);
} catch (IndexOutOfBoundsException ex) {
Logger.getLogger(OpenTestAction.class.getName())
.log(Level.INFO, null, ex);
line.show(ShowOpenType.OPEN, ShowVisibilityType.FOCUS);
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-swingapp
EditorCookie editorCookie = DataObject.find(sourceFile).getCookie(EditorCookie.class);
if (editorCookie != null) {
if(editorCookie.getDocument() == null) {
editorCookie.openDocument();
editorCookie.open();
StyledDocument doc = editorCookie.getDocument();
Line.Set lineSet = editorCookie.getLineSet();
int line = doc.getParagraphElement(0).getParentElement().getElementIndex(position);
lineObj = lineSet.getCurrent(line);
Toolkit.getDefaultToolkit().beep();
} else {
lineObj.show(ShowOpenType.OPEN, ShowVisibilityType.FOCUS);
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-tomcat5
if (sourceFile != null) {
try {
dataObject = DataObject.find(sourceFile);
} catch(DataObjectNotFoundException ex) {
Logger.getLogger(LogSupport.class.getName()).log(Level.INFO, null, ex);
EditorCookie editorCookie = (EditorCookie)dataObject.getCookie(EditorCookie.class);
if (editorCookie == null) {
return;
editorCookie.open();
Line errorLine = null;
try {
errorLine = editorCookie.getLineSet().getCurrent(line - 1);
} catch (IndexOutOfBoundsException iobe) {
return;
errAnnot.attach(errorLine);
errAnnot.moveToFront();
errorLine.show(ShowOpenType.OPEN, ShowVisibilityType.NONE);
代码示例来源:origin: org.netbeans.api/org-openide-text
@Override
public void run() {
l.show(openType, visibilityType, column);
}
});
代码示例来源: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: hmvictor/radar-netbeans
private void openIssueLocation(IssueLocation issueLocation) {
try {
FileObject fileObject = issueLocation.getFileObject(projectContext, projectKeyChecker);
if (fileObject == null) {
notifyFileObjectNotFound(issueLocation);
} else {
EditorCookie editorCookie = IssueLocation.getEditorCookie(fileObject);
if (editorCookie != null) {
editorCookie.openDocument();
editorCookie.open();
Line line = issueLocation.getLine(editorCookie);
line.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
}
}
} catch (IOException ex) {
LOGGER.log(Level.WARNING, ex.getMessage(), ex);
Exceptions.printStackTrace(ex);
} catch (ProjectNotFoundException ex) {
String message = org.openide.util.NbBundle.getMessage(SonarIssuesTopComponent.class, "ProjectNotFound", ex.getShortProjectKey());
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(message, NotifyDescriptor.ERROR_MESSAGE));
}
}
内容来源于网络,如有侵权,请联系作者删除!