Refine search
@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 } } });
/** 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)); }
public LineDelegate(Line line) { this.line = line; lineChangesWeak = WeakListeners.propertyChange(lineChangeslistener, line); line.addPropertyChangeListener(lineChangesWeak); }
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();
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 (); } } };
/** 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); } } } }
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]) {
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;
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);
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
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);
@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); }
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));
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);
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);
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);
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);
@Override public void run() { l.show(openType, visibilityType, column); } });
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); }
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)); } }