public static FileObject getCurrentFileObject() { return contextDispatcher.getMostRecentFile(); }
public static String getCurrentFilePath() { FileObject currentFile = contextDispatcher.getMostRecentFile(); if (currentFile != null) { return currentFile.getPath(); } return ""; }
public static String getCurrentMIMEType() { FileObject fo = contextDispatcher.getMostRecentFile(); return fo != null ? fo.getMIMEType() : ""; // NOI18N }
@Override public boolean isDefault() { FileObject mostRecentFile = EditorContextDispatcher.getDefault().getMostRecentFile(); if (mostRecentFile == null) { return false; } String mimeType = mostRecentFile.getMIMEType(); return JSUtils.JS_MIME_TYPE.equals(mimeType); }
@Override public boolean isDefault() { FileObject mostRecentFile = EditorContextDispatcher.getDefault().getMostRecentFile(); if (mostRecentFile == null) { return false; } String mimeType = mostRecentFile.getMIMEType(); return JSUtils.JS_MIME_TYPE.equals(mimeType); }
/** throws IllegalComponentStateException when can not return the data in AWT. */ private String getMostRecentElement(final ElementKind kind, final String[] elementSignaturePtr) throws java.awt.IllegalComponentStateException { return getCurrentElement(contextDispatcher.getMostRecentFile(), contextDispatcher.getMostRecentEditor(), kind, elementSignaturePtr); }
/** throws IllegalComponentStateException when can not return the data in AWT. */ private String getMostRecentElement(final ElementKind kind, final String[] elementSignaturePtr) throws java.awt.IllegalComponentStateException { return getCurrentElement(contextDispatcher.getMostRecentFile(), contextDispatcher.getMostRecentEditor(), kind, elementSignaturePtr); }
private Lookup getLookup () { Node[] nodes = TopComponent.getRegistry ().getActivatedNodes (); int i, k = nodes.length; ArrayList<DataObject> l = new ArrayList<DataObject>(); for (i = 0; i < k; i++) { DataObject dobj = nodes [i].getLookup().lookup (DataObject.class); if (dobj != null && dobj.isValid()) { l.add (dobj); } } if (l.isEmpty()) { FileObject fo = EditorContextDispatcher.getDefault().getMostRecentFile(); if (fo != null) { try { DataObject dobj = DataObject.find(fo); l.add(dobj); } catch (DataObjectNotFoundException ex) {} } } return Lookups.fixed ((Object[]) l.toArray (new DataObject [l.size ()])); }
private Lookup getLookup () { Node[] nodes = TopComponent.getRegistry ().getActivatedNodes (); int i, k = nodes.length; ArrayList<DataObject> l = new ArrayList<DataObject>(); for (i = 0; i < k; i++) { DataObject dobj = nodes [i].getLookup().lookup (DataObject.class); if (dobj != null && dobj.isValid()) { l.add (dobj); } } if (l.isEmpty()) { FileObject fo = EditorContextDispatcher.getDefault().getMostRecentFile(); if (fo != null) { try { DataObject dobj = DataObject.find(fo); l.add(dobj); } catch (DataObjectNotFoundException ex) {} } } return Lookups.fixed ((Object[]) l.toArray (new DataObject [l.size ()])); }
public static boolean isInDisasm() { if (opened) { //TODO: optimize FileObject fobj = EditorContextDispatcher.getDefault().getCurrentFile(); if (fobj == null) { fobj = EditorContextDispatcher.getDefault().getMostRecentFile(); } if (fobj != null) { try { return DataObject.find(fobj).equals(getDataObject()); } catch(DataObjectNotFoundException doe) { Exceptions.printStackTrace(doe); } } } return false; }
@Override public Component getEditorComponent() { FileObject file = EditorContextDispatcher.getDefault().getMostRecentFile(); int line = EditorContextDispatcher.getDefault().getMostRecentLineNumber(); if (file != null && line != -1) { DialogBinding.bindComponentToFile(file, line, 0, 0, pane); } return pane; }
static File getCurrentSourceRoot() { FileObject fo = EditorContextDispatcher.getDefault().getMostRecentFile(); if (fo == null) { return null; } ClassPath cp = ClassPath.getClassPath(fo, ClassPath.SOURCE); if (cp == null) { return null; } fo = cp.findOwnerRoot(fo); if (fo == null) { return null; } return FileUtil.toFile(fo); }
static File getCurrentSourceRoot() { FileObject fo = EditorContextDispatcher.getDefault().getMostRecentFile(); if (fo == null) { return null; } ClassPath cp = ClassPath.getClassPath(fo, ClassPath.SOURCE); if (cp == null) { return null; } fo = cp.findOwnerRoot(fo); if (fo == null) { return null; } return FileUtil.toFile(fo); }
public static JComponent[] createEditorComponent() { FileObject file = EditorContextDispatcher.getDefault().getMostRecentFile(); int line = EditorContextDispatcher.getDefault().getMostRecentLineNumber(); // Add JEditorPane and context // There is no need to define the mimetype here! JComponent[] editorComponents = Utilities.createSingleLineEditor("text/plain"); // NOI18N JTextComponent textComponent = (JTextComponent) editorComponents[1]; if (file != null && line >= 0) { DialogBinding.bindComponentToFile(file, line, 0, 0, textComponent); } return editorComponents; } }