/** Parses the primary file of this data object. * and provide different implementation. * * @return the document in the primary file * @exception IOException if error during parsing occures */ final Document parsePrimaryFile () throws IOException, SAXException { emgr().log ("parsePrimaryFile"); String loc = getPrimaryFile().getURL().toExternalForm(); try { return XMLUtil.parse(new InputSource(loc), false, /* #36295 */true, errorHandler, getSystemResolver()); } catch (IOException e) { // Perhaps this document was not on a mounted filesystem. // Try again with an input stream - no relative URLs will work, but this // is extremely unlikely to matter. Cf. #36340. InputStream is = getPrimaryFile().getInputStream(); try { return XMLUtil.parse(new InputSource(is), false, true, errorHandler, getSystemResolver()); } finally { is.close(); } } }
public String instanceName() { return holder.getName(); }
private static Document getDocument(File tomcatUsersFile) throws IOException { FileObject fo = FileUtil.toFileObject(tomcatUsersFile); if (fo == null) { throw new IOException(NbBundle.getMessage(TomcatUsers.class, "MSG_FileNotFound", tomcatUsersFile.getPath())); } XMLDataObject dobj = (XMLDataObject) DataObject.find(fo); try { return dobj.getDocument(); } catch (SAXException ex) { throw (IOException) (new IOException()).initCause(ex); } }
/** Fired when a file is changed. * @param fe the event describing context where action has taken place */ public void fileChanged (FileEvent fe) { if (getPrimaryFile ().equals (fe.getFile ())) { // the main file changed => invalidate DOM document //resolveInfo (getPrimaryFile ()); //reparse info again clearDocument (); String prevId = parsedId; parsedId = null; // parse update only if the ID is different waitFinished (prevId); } }
public HelpCtx getHelpCtx () { // help for fix #23528, objects represents 'settings' nodes in Options dialog // returns DEFAULT_HELP for next processing try { if (getPrimaryFile ().getFileSystem ().isDefault ()) { if (getCookie (InstanceCookie.class)!=null) { return HelpCtx.DEFAULT_HELP; } } } catch (FileStateInvalidException fsie) { // cannot determine type of this file object ==> return help id as normal } return new HelpCtx (XMLDataObject.class); }
public Object instanceCreate() throws java.io.IOException, ClassNotFoundException { synchronized (this) { Object o = refPlatform.get(); if (o != null) return o; H handler = new H(); try { XMLReader reader = XMLUtil.createXMLReader(); InputSource is = new org.xml.sax.InputSource( holder.getPrimaryFile().getInputStream()); is.setSystemId(holder.getPrimaryFile().getURL().toExternalForm()); reader.setContentHandler(handler); reader.setErrorHandler(handler); reader.setEntityResolver(handler); reader.parse(is); } catch (SAXException ex) { Exception x = ex.getException(); ex.printStackTrace(); if (x instanceof java.io.IOException) throw (IOException)x; else throw new java.io.IOException(ex.getMessage()); } ScalaPlatform inst = createPlatform(handler); refPlatform = new WeakReference<ScalaPlatform>(inst); return inst; } }
private ComponentProducer deserializeComponentCreatorFromXML (XMLDataObject xmlDataObject, Map<TypeID, FileObject> fileObjects) { Document document; try { document = xmlDataObject.getDocument (); if (document == null) return null; } catch (IOException e) { ErrorManager.getDefault ().notify (e); return null; } catch (SAXException e) { ErrorManager.getDefault ().notify (e); return null; } XMLComponentProducer producer = XMLComponentProducer.deserialize (projectType, document); if (producer != null) { fileObjects.put(producer.getMainComponentTypeID(), xmlDataObject.getPrimaryFile()); return producer; } Debug.warning ("Error during deserialization", xmlDataObject.getPrimaryFile ()); // NOI18N return null; }
public <T extends Node.Cookie> T getCookie(Class<T> c) { Node.Cookie retValue = null; if (ValidateXMLCookie.class.isAssignableFrom(c)) { if (validateCookie == null) { InputSource in = DataObjectAdapters.inputSource(this); validateCookie = new ValidateXMLSupport(in); } return (T) validateCookie; } else if (CheckXMLCookie.class.isAssignableFrom(c)) { if (checkCookie == null) { InputSource in = DataObjectAdapters.inputSource(this); checkCookie = new CheckXMLSupport(in); } return (T) checkCookie; } if (retValue == null) { retValue = super.getCookie(c); } return (T) retValue; }
/** Creates the right data object for given primary file. * It is guaranteed that the provided file is realy primary file * returned from the method findPrimaryFile. * * @param primaryFile the primary file * @return the data object for this file * @exception DataObjectExistsException if the primary file already has data object */ protected MultiDataObject createMultiObject (FileObject primaryFile) throws DataObjectExistsException { return new XMLDataObject (primaryFile, this); }
final XMLReader reader = XMLUtil.createXMLReader(); final InputSource is = new org.xml.sax.InputSource( holder.getPrimaryFile().getInputStream()); is.setSystemId(holder.getPrimaryFile().getPath()); reader.setContentHandler(handler); reader.setErrorHandler(handler);
private ComponentDescriptor deserializeComponentDescriptorFromXML (XMLDataObject xmlDataObject) { Document document; try { document = xmlDataObject.getDocument (); if (document == null) return null; } catch (IOException e) { ErrorManager.getDefault ().notify (e); return null; } catch (SAXException e) { ErrorManager.getDefault ().notify (e); return null; } XMLComponentDescriptor descriptor = new XMLComponentDescriptor (); if (descriptor.deserialize (projectType, document)) return descriptor; Debug.warning ("Error during deserialization", xmlDataObject.getPrimaryFile ()); // NOI18N return null; }
XMLReader reader = XMLUtil.createXMLReader(); InputSource is = new org.xml.sax.InputSource( holder.getPrimaryFile().getInputStream()); is.setSystemId(holder.getPrimaryFile().getURL().toExternalForm()); reader.setContentHandler(handler); reader.setErrorHandler(handler);
public String instanceName() { return holder.getName(); }
public static boolean setShutdownPort(int port, File tomcatConf) { FileObject fo = FileUtil.toFileObject(tomcatConf); if (fo != null) { try { XMLDataObject dobj = (XMLDataObject)DataObject.find(fo); org.w3c.dom.Document doc = dobj.getDocument(); org.w3c.dom.Element root = doc.getDocumentElement(); root.setAttribute("port", String.valueOf(port)); //NOI18N updateDocument(dobj,doc); return true; } catch(org.xml.sax.SAXException ex){ Exceptions.printStackTrace(ex); } catch(org.openide.loaders.DataObjectNotFoundException ex){ Exceptions.printStackTrace(ex); } catch(javax.swing.text.BadLocationException ex){ Exceptions.printStackTrace(ex); } catch(java.io.IOException ex){ Exceptions.printStackTrace(ex); } } return false; }
/** Return ErrorManager for this instance. */ private ErrorManager emgr() { synchronized (emgrLock) { if (err == null) { err = ErrorManager.getDefault ().getInstance( "org.openide.loaders.XMLDataObject[" + getPrimaryFile().getPath() + "]" // NOI18N ); } } return err; }
public String instanceName() { return holder.getName(); }
try { XMLDataObject dobj = (XMLDataObject)DataObject.find(fo); org.w3c.dom.Document doc = dobj.getDocument(); org.w3c.dom.Element root = doc.getDocumentElement(); org.w3c.dom.NodeList list = root.getElementsByTagName("Service"); //NOI18N
public void run() { PropertyChangeEvent e; synchronized (this) { e = keepAlive.removeFirst(); } ScalaPlatform plat = (ScalaPlatform)e.getSource(); try { holder.getPrimaryFile().getFileSystem().runAtomicAction( new W(plat, holder, defaultPlatform)); } catch (java.io.IOException ex) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); } }
private CodeClipItemNode createPaletteItemNode(CodeClipHandler handler) { String name = xmlDataObject.getName(); InstanceContent ic = new InstanceContent(); // if (handler.getBody() != null && handler.getBundleName() != null) { if (handler.getBody() != null) { ArrayList<Object> codeclipArray = new ArrayList<Object>(2); codeclipArray.add(0, handler.getBundleName()); codeclipArray.add(1, handler.getBody()); codeclipArray.add(2, handler.getDisplayNameKey()); ic.add( codeclipArray , ActiveEditorDropCodeClipProvider.getInstance()); } CodeClipItemNode node = new CodeClipItemNode( new DataNode(xmlDataObject, Children.LEAF), name, handler.getBundleName(), handler.getDisplayNameKey(), handler.getTooltipKey(), handler.getIcon16URL(), handler.getIcon32URL(), handler.getBody(), ic ); return node; } }
Document doc = ((XMLDataObject) dObj).getDocument();