public Node.Cookie getCookie (Class c) { if (c.isInstance (this)) { return this; } return original.getCookie (this, c); }
/** * Get the NB (data) cookie of a specified type for a given FileObject. * * @param file The given FileObject. * @param type The cookie type to get. * @return The cookie. */ public static org.openide.nodes.Node.Cookie getCookie(FileObject file, Class type) { DataObject dobj = findDataObject(file); return dobj != null ? dobj.getCookie(type) : null; }
/** Method that allows environment to find its * cloneable open support. * @return the support or null if the environemnt is not in valid * state and the CloneableOpenSupport cannot be found for associated * data object */ public CloneableOpenSupport findCloneableOpenSupport() { return (CloneableOpenSupport)getDataObject ().getCookie (CloneableOpenSupport.class); }
/** Find the editor support this environment represents. * Note that we have to look it up, as keeping a direct * reference would not permit this environment to be serialized. * @return the editor support */ @Override public org.openide.windows.CloneableOpenSupport findCloneableOpenSupport () { return (TLDEditorSupport) getDataObject ().getCookie (TLDEditorSupport.class); } }
private void assignDocumentListener(final DataObject od) { EditorCookie.Observable ec = od.getCookie(EditorCookie.Observable.class); if (ec != null) { docListener = new DocListener (ec); } }
/** Find the editor support this environment represents. * Note that we have to look it up, as keeping a direct * reference would not permit this environment to be serialized. * @return the editor support */ @Override public org.openide.windows.CloneableOpenSupport findCloneableOpenSupport() { return (JSFConfigEditorSupport) getDataObject().getCookie(JSFConfigEditorSupport.class); } }
synchronized void register (DataObject dataObject) { LineCookie lc = dataObject.getCookie (LineCookie.class); if (lc == null) return; dataObjectToLineSet.put (dataObject, lc.getLineSet ()); }
private static TagLibParseSupport getTagLibParseSupport(FileObject fo) { TagLibParseSupport tlps = null; if (fo != null && fo.isValid()){ try { tlps = (TagLibParseSupport)DataObject.find(fo).getCookie(TagLibParseSupport.class); } catch (org.openide.loaders.DataObjectNotFoundException e){ Logger.getLogger("global").log(Level.INFO, null, e); } } return tlps; }
public <T extends Cookie> T getCookie(Class<T> type) { if (type.equals(SaveCookie.class)) { return pc.getConfigDataObject().getCookie(type); } return original.getCookie(type); }
public HighlightAnnotatable(AttributeSet attrs, int start, int end, FileObject fo) { this.attrs = attrs; this.start = start; this.end = end; try { DataObject dobj = DataObject.find(fo); EditorCookie ec = dobj.getCookie(EditorCookie.class); doc = ec.getDocument(); } catch (DataObjectNotFoundException ex) { } }
public Object readResolve () { DataObject obj = entry.getDataObject (); OpenSupport os = (OpenSupport)obj.getCookie (OpenSupport.class); if (os == null) { // problem! no replace!? return this; } // use the editor support's CloneableTopComponent.Ref return os.allEditors (); } }
public static void updateDocument(DataObject dobj, org.w3c.dom.Document doc) throws javax.swing.text.BadLocationException, java.io.IOException { org.openide.cookies.EditorCookie editor = (EditorCookie)dobj.getCookie(EditorCookie.class); javax.swing.text.Document textDoc = editor.getDocument(); if (textDoc == null) { textDoc = editor.openDocument(); } TomcatInstallUtil.updateDocument(textDoc,TomcatInstallUtil.getDocumentText(doc),"<Server"); //NOI18N SaveCookie savec = (SaveCookie) dobj.getCookie(SaveCookie.class); if (savec!=null) savec.save(); }
/** Helper method. Adds save cookie to the data object. */ private void addSaveCookie() { DataObject obj = getDataObject(); // Adds save cookie to the data object. if(obj.getCookie(SaveCookie.class) == null) { set.add(saveCookie); obj.setModified(true); } }
private void bEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bEditActionPerformed String mimeType = (String) lFiles.getSelectedValue (); if (mimeType == null) return; FileObject fileObject = Repository.getDefault ().getDefaultFileSystem ().findResource ("Editors/" + mimeType + "/language.nbs"); try { DataObject dataObject = DataObject.find (fileObject); OpenCookie openCookie = dataObject.getCookie (OpenCookie.class); openCookie.open (); } catch (DataObjectNotFoundException ex) { Exceptions.printStackTrace (ex); } }//GEN-LAST:event_bEditActionPerformed
/** Removes save cookie from the DO. */ final void removeSaveCookie() { DataObject dataObj = getDataObject (); // add Save cookie to the data object if (dataObj instanceof MultiDataObject) { if (dataObj.getCookie(SaveCookie.class) == this) { getCookieSet((MultiDataObject)dataObj).remove(this); } } }
protected static EditorCookie getTextComponent(Node n) { DataObject dobj = n.getCookie(DataObject.class); if (dobj != null) { EditorCookie ec = dobj.getCookie(EditorCookie.class); if (ec != null) { TopComponent activetc = TopComponent.getRegistry().getActivated(); if (activetc instanceof Pane) { return ec; } } } return null; }
protected void notifyUnmodified () { super.notifyUnmodified (); SaveCookie save = (SaveCookie) getDataObject ().getCookie (SaveCookie.class); if (save != null) { ((XMLDataObject) getDataObject ()).removeSaveCookie (save); getDataObject ().setModified (false); } }
public synchronized void attach() throws IOException { this.lc = dataObject.getCookie (LineCookie.class); if (lc == null) return ; lb.addPropertyChangeListener(this); try { this.line = lc.getLineSet().getCurrent(lb.getLineNumber() - 1); line.addPropertyChangeListener(this); } catch (IndexOutOfBoundsException ioobex) { // ignore document changes for BP with bad line number } }
protected boolean notifyModified () { if (! super.notifyModified ()) { return false; } if (getDataObject ().getCookie (SaveCookie.class) == null) { ((XMLDataObject) getDataObject ()).addSaveCookie (new Save ()); getDataObject ().setModified (true); } return true; } protected void notifyUnmodified () {
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); }