本文整理汇总了Java中org.openide.text.Line.Set方法的典型用法代码示例。如果您正苦于以下问题:Java Line.Set方法的具体用法?Java Line.Set怎么用?Java Line.Set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.text.Line
的用法示例。
在下文中一共展示了Line.Set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareLine
import org.openide.text.Line; //导入方法依赖的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;
}
}
}
}
示例2: getLineSet
import org.openide.text.Line; //导入方法依赖的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 ();
}
示例3: openEditor
import org.openide.text.Line; //导入方法依赖的package包/类
public static void openEditor(EditorCookie ec, int lineIndex) {
Line.Set lineSet = ec.getLineSet();
if (lineSet != null) {
try {
Line line = lineSet.getCurrent(lineIndex);
if (line != null) {
line.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
}
} catch (IndexOutOfBoundsException ex) {
// attempt at least to open the editor
ec.open();
// expected, bookmark contains an invalid line
StatusDisplayer.getDefault().setStatusText(
NbBundle.getMessage(BookmarkUtils.class, "MSG_InvalidLineNumnber", lineIndex));
}
JEditorPane[] panes = ec.getOpenedPanes();
if (panes.length > 0) {
panes[0].requestFocusInWindow();
}
}
}
示例4: getLine
import org.openide.text.Line; //导入方法依赖的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;
}
示例5: getMostRecentLine
import org.openide.text.Line; //导入方法依赖的package包/类
/**
* Get the line of the caret in the most recent editor.
* This returns the current line in the current editor if there's one,
* or a line of the caret in the editor, that was most recently active.
* @return the line or <code>null</code> when there was no recent active editor.
*/
public Line getMostRecentLine() {
EditorCookie e = getMostRecentEditorCookie ();
if (e == null) return null;
JEditorPane ep = getMostRecentEditor ();
if (ep == null) return null;
StyledDocument d = e.getDocument ();
if (d == null) return null;
Caret caret = ep.getCaret ();
if (caret == null) return null;
int lineNumber = NbDocument.findLineNumber(d, caret.getDot());
Line.Set lineSet = e.getLineSet();
try {
return lineSet.getCurrent(lineNumber);
} catch (IndexOutOfBoundsException ex) {
return null;
}
}
示例6: getLine
import org.openide.text.Line; //导入方法依赖的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;
}
示例7: setLineNumber
import org.openide.text.Line; //导入方法依赖的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);
}
示例8: getLine
import org.openide.text.Line; //导入方法依赖的package包/类
/** Get the line object from the given position.
* @param doc document for which the line is being retrieved
* @param offset position in the document
* @param original whether to retrieve the original line (true) before
* the modifications were done or the current line (false)
* @return the line object
* @deprecated Replaced by more generic method having {@link javax.swing.text.Document} parameter.
*/
public static Line getLine(BaseDocument doc, int offset, boolean original) {
DataObject dob = getDataObject(doc);
if (dob != null) {
LineCookie lc = (LineCookie)dob.getCookie(LineCookie.class);
if (lc != null) {
Line.Set lineSet = lc.getLineSet();
if (lineSet != null) {
try {
int lineOffset = Utilities.getLineOffset(doc, offset);
return original
? lineSet.getOriginal(lineOffset)
: lineSet.getCurrent(lineOffset);
} catch (BadLocationException e) {
}
}
}
}
return null;
}
示例9: create
import org.openide.text.Line; //导入方法依赖的package包/类
public static List<Task> create(TextlintJsonResult[] results, FileObject fileObject) {
List<Task> tasks = new ArrayList<>();
final DataObject dataObject = getDataObject(fileObject);
if (results != null && dataObject != null) {
Line.Set lineSet = getLineSet(dataObject);
if (lineSet != null) {
for (TextlintJsonResult result : results) {
result.getMessages().forEach((message) -> {
Line line = getCurrentLine(lineSet, message.getLine());
OpenAction defaultAction = line != null ? new OpenAction(line) : null;
Action[] popupActions = createPopupActions(dataObject, fileObject, message.getFix());
String description = String.format(MESSAGE_FORMAT,
message.getRuleId(),
message.getMessage(),
message.getLine(),
message.getIndex());
String groupName = message.getFix() != null ? TEXTLINT_FIXABLE_GROUP_NAME : TEXTLINT_GROUP_NAME;
tasks.add(Task.create(fileObject.toURL(), groupName, description, defaultAction, popupActions));
});
}
}
}
return tasks;
}
示例10: documentOpened
import org.openide.text.Line; //导入方法依赖的package包/类
void documentOpened(Line.Set lineSet, FileObject fileObject) {
for (ProfilingPoint profilingPoint : profilingPoints) {
if (profilingPoint instanceof CodeProfilingPoint) {
CodeProfilingPoint cpp = (CodeProfilingPoint) profilingPoint;
for (CodeProfilingPoint.Annotation cppa : cpp.getAnnotations()) {
File annotationFile = new File(cpp.getLocation(cppa).getFile());
if ((annotationFile == null) || (fileObject == null)) {
continue; // see #98535
}
File adeptFile = FileUtil.toFile(fileObject);
if (adeptFile == null) {
continue; // see #98535
}
if (adeptFile.equals(annotationFile)) {
deannotateProfilingPoint(cpp);
annotateProfilingPoint(cpp);
break;
}
}
}
}
}
示例11: annotate
import org.openide.text.Line; //导入方法依赖的package包/类
public void annotate(Line.Set lineSet, Lookup context) {
FileObject fileObject = (FileObject) context.lookup(FileObject.class);
if (fileObject != null) {
ProfilingPointsManager.getDefault().documentOpened(lineSet, fileObject);
}
}
示例12: show
import org.openide.text.Line; //导入方法依赖的package包/类
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);
}
示例13: openAt
import org.openide.text.Line; //导入方法依赖的package包/类
private boolean openAt( LineCookie lineCookie, int lineNo ) {
Line.Set lines = lineCookie.getLineSet();
try {
Line line = lines.getCurrent( lineNo );
if( null == line )
line = lines.getCurrent( 0 );
if( null != line ) {
line.show( ShowOpenType.OPEN , ShowVisibilityType.FOCUS);
return true;
}
} catch( IndexOutOfBoundsException e ) {
//probably the document has been modified but not saved yet
}
return false;
}
示例14: getCurrentLine
import org.openide.text.Line; //导入方法依赖的package包/类
private static Line getCurrentLine(Line.Set lineSet, int lineNumber) throws IndexOutOfBoundsException {
Line line;
if (lineNumber > 0) {
line = lineSet.getCurrent(lineNumber - 1);
} else {
line = lineSet.getCurrent(0);
}
return line;
}
示例15: getLineSet
import org.openide.text.Line; //导入方法依赖的package包/类
private static Line.Set getLineSet(DataObject dataObject) {
LineCookie lineCookie = dataObject.getLookup().lookup(LineCookie.class);
if (lineCookie != null) {
return lineCookie.getLineSet();
}
return null;
}