/** throws IllegalComponentStateException when can not return the data in AWT. */ private String getCurrentElement(final ElementKind kind, final String[] elementSignaturePtr) throws java.awt.IllegalComponentStateException { return getCurrentElement(contextDispatcher.getCurrentFile(), contextDispatcher.getCurrentEditor(), kind, elementSignaturePtr); }
/** throws IllegalComponentStateException when can not return the data in AWT. */ private String getCurrentElement(final ElementKind kind, final String[] elementSignaturePtr) throws java.awt.IllegalComponentStateException { return getCurrentElement(contextDispatcher.getCurrentFile(), contextDispatcher.getCurrentEditor(), kind, elementSignaturePtr); }
/** * Returns number of line currently selected in editor or <code>-1</code>. * * @return number of line currently selected in editor or <code>-1</code> */ public int getCurrentOffset() { JEditorPane ep = contextDispatcher.getCurrentEditor(); if (ep == null) { return -1; } Caret caret = ep.getCaret(); if (caret == null) { return -1; } return caret.getDot(); }
/** * Returns number of line currently selected in editor or <code>-1</code>. * * @return number of line currently selected in editor or <code>-1</code> */ public int getCurrentOffset () { JEditorPane ep = contextDispatcher.getCurrentEditor(); if (ep == null) { return -1; } Caret caret = ep.getCaret (); if (caret == null) { return -1; } return caret.getDot(); }
/** * Returns number of line currently selected in editor or <code>-1</code>. * * @return number of line currently selected in editor or <code>-1</code> */ public int getCurrentOffset () { JEditorPane ep = contextDispatcher.getCurrentEditor(); if (ep == null) { return -1; } Caret caret = ep.getCaret (); if (caret == null) { return -1; } return caret.getDot(); }
/** * Returns identifier currently selected in editor or <code>null</code>. * * @return identifier currently selected in editor or <code>null</code> */ @Override public String getSelectedIdentifier() { JEditorPane ep = contextDispatcher.getCurrentEditor(); if (ep == null) { return null; } String s = ep.getSelectedText(); if (s == null) { return null; } if (Utilities.isJavaIdentifier(s)) { return s; } return null; }
/** * Returns identifier currently selected in editor or <code>null</code>. * * @return identifier currently selected in editor or <code>null</code> */ @Override public String getSelectedIdentifier () { JEditorPane ep = contextDispatcher.getCurrentEditor (); if (ep == null) { return null; } String s = ep.getSelectedText (); if (s == null) { return null; } if (Utilities.isJavaIdentifier (s)) { return s; } return null; }
/** @return declared class name */ public String getCurrentClassDeclaration() { FileObject fo = contextDispatcher.getCurrentFile(); if (fo == null) { return null; } JEditorPane ep = contextDispatcher.getCurrentEditor(); final int currentOffset = (ep == null) ? 0 : ep.getCaretPosition(); //final int currentOffset = org.netbeans.editor.Registry.getMostActiveComponent().getCaretPosition(); return EditorContextSupport.getClassDeclaredAt(fo, currentOffset); }
/** @return { "method name", "method signature", "enclosing class name" } */ @Override public String[] getCurrentMethodDeclaration() { FileObject fo = contextDispatcher.getCurrentFile(); if (fo == null) { return null; } JEditorPane ep = contextDispatcher.getCurrentEditor(); final int currentOffset = (ep == null) ? 0 : ep.getCaretPosition(); return EditorContextSupport.getMethodDeclaredAt(fo, currentOffset); }
/** * Returns identifier currently selected in editor or <code>null</code>. * * @return identifier currently selected in editor or <code>null</code> */ @Override public String getSelectedIdentifier () { JEditorPane ep = contextDispatcher.getCurrentEditor (); if (ep == null) { return null; } Caret caret = ep.getCaret(); if (caret == null) { // No caret => no selected text return null; } String s = ep.getSelectedText (); if (s == null) { return null; } if (Utilities.isJavaIdentifier (s)) { return s; } return null; }
public static boolean isScriptlet() { JEditorPane ep = EditorContextDispatcher.getDefault().getCurrentEditor(); if (ep == null) { return false; } return isScriptlet( (StyledDocument) ep.getDocument (), ep, ep.getCaret ().getDot () ); }
public static String getJavaIdentifier () { JEditorPane ep = EditorContextDispatcher.getDefault().getCurrentEditor(); if (ep == null) { return null; } return getJavaIdentifier ( (StyledDocument) ep.getDocument (), ep, ep.getCaret ().getDot () ); }
private String getSelectedMethodName_() { JEditorPane ep = contextDispatcher.getCurrentEditor(); if (ep == null) { return "";
private String getSelectedMethodName_() { JEditorPane ep = contextDispatcher.getCurrentEditor (); if (ep == null) { return "";
private String getSelectedMethodName_() { JEditorPane ep = contextDispatcher.getCurrentEditor (); if (ep == null) { return "";
return null; JEditorPane ep = contextDispatcher.getCurrentEditor(); Source source = Source.create(fo); if (source == null) {
return null; JEditorPane ep = contextDispatcher.getCurrentEditor(); JavaSource js = JavaSource.forFileObject(fo); if (js == null) {
return ; JEditorPane ep = EditorContextDispatcher.getDefault().getCurrentEditor (); if (ep == null) return ; int offset;
final StyledDocument doc = ec.openDocument(); JEditorPane ep = EditorContextDispatcher.getDefault().getCurrentEditor(); if (ep == null) { return;
JEditorPane ep = EditorContextDispatcher.getDefault().getCurrentEditor(); String textForTooltip = "";