public void run () { if (ec.getOpenedPanes () != null && ec.getOpenedPanes ().length > 0 ) setCurrentEditor (ec.getOpenedPanes () [0]); else setCurrentEditor (null); } });
public JTextComponent getJTextComponent () { if (component == null) { DataObject dob = NbEditorUtilities.getDataObject (doc); EditorCookie ec = dob.getLookup ().lookup (EditorCookie.class); if (ec.getOpenedPanes ().length > 0) component = ec.getOpenedPanes () [0]; } return component; }
private static JEditorPane getCurrentEditor(EditorCookie e) { if (e == null) e = getCurrentEditorCookie(); if (e == null) return null; JEditorPane[] op = e.getOpenedPanes(); if (op == null || op.length < 1) return null; return op[0]; }
public void propertyChange(PropertyChangeEvent evt) { if (EditorCookie.Observable.PROP_OPENED_PANES.equals(evt.getPropertyName())) { if (editorCookie.getOpenedPanes() == null) { opened = false; ((EditorCookie.Observable)editorCookie).removePropertyChangeListener(this); } } } });
private int getOffset(EditorCookie editorCookie) { if (editorCookie == null) { return DEFAULT_OFFSET; } JEditorPane[] openedPanes = editorCookie.getOpenedPanes(); if (openedPanes == null || openedPanes.length == 0) { return DEFAULT_OFFSET; } return openedPanes[0].getCaretPosition(); } }
private JEditorPane getCurrentEditor () { Node[] ns = TopComponent.getRegistry ().getActivatedNodes (); if (ns.length != 1) return null; EditorCookie editorCookie = ns [0].getLookup (). lookup (EditorCookie.class); if (editorCookie == null) return null; if (editorCookie.getOpenedPanes () == null) return null; if (editorCookie.getOpenedPanes ().length < 1) return null; return editorCookie.getOpenedPanes () [0]; }
public JTextComponent getJTextComponent () { if (component == null) { DataObject dob = NbEditorUtilities.getDataObject (doc); EditorCookie ec = dob.getLookup ().lookup (EditorCookie.class); if (ec.getOpenedPanes ().length > 0) component = ec.getOpenedPanes () [0]; } return component; }
public javax.swing.JEditorPane[] getOpenedPanes() { return currentEditorCookie().getOpenedPanes(); }
/** * Gets recently selected editor pane opened by editor cookie * Can be called from AWT event thread only. * * @param ec EditorCookie used to find out recently selected editor pane * @return pane or null * * @since 6.24 * */ public static JEditorPane findRecentEditorPane (EditorCookie ec) { // expected in AWT only assert SwingUtilities.isEventDispatchThread() : "NbDocument.findInitializedPaneForActiveTC must be called from AWT thread only"; // NOI18N if (ec instanceof CloneableEditorSupport) { // find if initialized or return null immediately JEditorPane pane = ((CloneableEditorSupport) ec).getRecentPane(); return pane; } else { JEditorPane [] panes = ec.getOpenedPanes(); if (panes != null) { return panes[0]; } return null; } }
private static boolean isFromEditor(EditorCookie ec) { if (ec != null && ec.getOpenedPanes() != null) { TopComponent activetc = TopComponent.getRegistry().getActivated(); if (activetc instanceof CloneableEditorSupport.Pane) { return true; } } return false; }
public static boolean isFromEditor(EditorCookie ec) { if (ec != null && ec.getOpenedPanes() != null) { TopComponent activetc = TopComponent.getRegistry().getActivated(); if (activetc instanceof CloneableEditorSupport.Pane) { return true; } } return false; }
private static boolean isFromEditor(EditorCookie ec) { if (ec != null && ec.getOpenedPanes() != null) { TopComponent activetc = TopComponent.getRegistry().getActivated(); if (activetc instanceof CloneableEditorSupport.Pane) { return true; } } return false; } }
public TextComponentTask(EditorCookie ec) { JTextComponent textC = ec.getOpenedPanes()[0]; this.document = textC.getDocument(); this.caretOffset = textC.getCaretPosition(); this.selectionStart = textC.getSelectionStart(); this.selectionEnd = textC.getSelectionEnd(); }
public TextComponentTask(EditorCookie ec) { this.textC = ec.getOpenedPanes()[0]; this.caret = textC.getCaretPosition(); this.start = textC.getSelectionStart(); this.end = textC.getSelectionEnd(); assert caret != -1; assert start != -1; assert end != -1; }
public void run() { Iterator it = TopComponent.getRegistry ().getOpened ().iterator (); while (it.hasNext ()) { TopComponent tc = (TopComponent) it.next (); EditorCookie ec = tc.getLookup ().lookup (EditorCookie.class); if (ec == null) continue; JEditorPane[] eps = ec.getOpenedPanes (); if (eps == null) continue; int i, k = eps.length; for (i = 0; i < k; i++) { if (eps [i].getDocument () == doc) { final JEditorPane ep = eps [i]; if (ep != null) try { ep.scrollRectToVisible (ep.modelToView (offset)); } catch (BadLocationException ex) { ErrorManager.getDefault ().notify (ex); } } } } } });
@Override protected void performContextAction(Node[] nodes) { if (visible(nodes)) { JEditorPane pane = activatedEditorPane(nodes); AnnotationBarManager.hideAnnotationBar(pane); } else { EditorCookie ec = activatedEditorCookie(nodes); if (ec == null) return; final File file = activatedFile(nodes); JEditorPane[] panes = ec.getOpenedPanes(); if (panes == null) { ec.open(); panes = ec.getOpenedPanes(); } if (panes == null) { return; } final JEditorPane currentPane = panes[0]; showAnnotations(currentPane, file, null, true); } }
/** 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); } } } }
/** 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); } } } }
/** 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); } } } }
@Override public void valueChanged(ListSelectionEvent event) { final int selectedRow = ((ListSelectionModel) event.getSource()).getMinSelectionIndex(); if (event.getValueIsAdjusting() || selectedRow < 0) { return; } final MappedElement mappedElement = mappedElementsModel.getElementAt(table.convertRowIndexToModel(selectedRow)); ElementOpen.open(mappedElement.getFileObject(), mappedElement.getHandle()); try { final DataObject dataObject = DataObject.find(mappedElement.getFileObject()); final EditorCookie editorCookie = dataObject.getLookup().lookup(EditorCookie.class); if (editorCookie != null) { editorCookie.openDocument(); JEditorPane[] p = editorCookie.getOpenedPanes(); if (p.length > 0) { p[0].requestFocus(); } } } catch (IOException e) { } } });