本文整理汇总了Java中org.openide.text.NbDocument.openDocument方法的典型用法代码示例。如果您正苦于以下问题:Java NbDocument.openDocument方法的具体用法?Java NbDocument.openDocument怎么用?Java NbDocument.openDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.text.NbDocument
的用法示例。
在下文中一共展示了NbDocument.openDocument方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doOpen
import org.openide.text.NbDocument; //导入方法依赖的package包/类
private static boolean doOpen(FileObject fo, int offset) {
try {
DataObject od = DataObject.find(fo);
return NbDocument.openDocument(od, offset, Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
} catch (DataObjectNotFoundException e) {
LOG.log(Level.FINE, null, e);
}
return false;
}
示例2: doOpen
import org.openide.text.NbDocument; //导入方法依赖的package包/类
static boolean doOpen(FileObject fo, PositionBounds bounds) {
try {
final int begin = bounds.getBegin().getOffset();
final int end = bounds.getEnd().getOffset();
DataObject od = DataObject.find(fo);
final EditorCookie ec = od.getLookup().lookup(org.openide.cookies.EditorCookie.class);
boolean opened = NbDocument.openDocument(od, begin, Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
if (opened) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
JEditorPane textC = NbDocument.findRecentEditorPane(ec);
if(textC != null) {
textC.setSelectionStart(begin);
textC.setSelectionEnd(end);
}
}
});
return true;
}
return opened;
} catch (DataObjectNotFoundException e) {
StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(
Call.class, "Call.open.warning", FileUtil.getFileDisplayName(fo))); // NOI18N
}
return false;
}
示例3: openInEditor
import org.openide.text.NbDocument; //导入方法依赖的package包/类
@Override
public void openInEditor() {
if(fo == null || !fo.isValid()) {
StatusDisplayer.getDefault().setStatusText(WARN_ElementNotFound());
} else {
try {
DataObject od = DataObject.find(fo);
NbDocument.openDocument(od, 0, Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
} catch (DataObjectNotFoundException ex) {
// ignore
}
}
}
示例4: open
import org.openide.text.NbDocument; //导入方法依赖的package包/类
@Override
public void open() {
try {
if(fo.isValid()) {
DataObject od = DataObject.find(fo);
NbDocument.openDocument(od, 0, Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
}
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
}
示例5: handleResult
import org.openide.text.NbDocument; //导入方法依赖的package包/类
public void handleResult(LocationResult opposite) {
FileObject fileObject = opposite.getFileObject();
if (fileObject != null) {
NbDocument.openDocument(fileObject, opposite.getOffset(), Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
} else if (opposite.getErrorMessage() != null) {
String msg = opposite.getErrorMessage();
NotifyDescriptor descr = new NotifyDescriptor.Message(msg,
NotifyDescriptor.INFORMATION_MESSAGE);
DialogDisplayer.getDefault().notify(descr);
}
}
示例6: doOpen
import org.openide.text.NbDocument; //导入方法依赖的package包/类
private static boolean doOpen(FileObject fo, int offset, String search) {
try {
DataObject od = DataObject.find(fo);
EditorCookie ec = od.getCookie(EditorCookie.class);
LineCookie lc = od.getCookie(LineCookie.class);
// If the caller hasn't specified an offset, and the document is
// already open, don't jump to a particular line!
if (ec != null && offset == -1 && ec.getDocument() != null && search == null) {
ec.open();
return true;
}
// Simple text search if no known offset (e.g. broken/unparseable source)
if ((search != null) && (offset == -1)) {
StyledDocument doc = NbDocument.getDocument(od);
try {
String text = doc.getText(0, doc.getLength());
int caretDelta = search.indexOf('^');
if (caretDelta != -1) {
search = search.substring(0, caretDelta) + search.substring(caretDelta+1);
} else {
caretDelta = 0;
}
offset = text.indexOf(search);
if (offset != -1) {
offset += caretDelta;
}
} catch (BadLocationException ble) {
LOG.log(Level.WARNING, null, ble);
}
}
return NbDocument.openDocument(od, offset, Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
} catch (IOException e) {
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
}
return false;
}