[Jsxe-cvs] SF.net SVN: jsxe: [1228] branches/jsxe2/src/net/sourceforge/jsxe
Status: Inactive
Brought to you by:
ian_lewis
From: <ian...@us...> - 2006-09-02 16:17:52
|
Revision: 1228 http://svn.sourceforge.net/jsxe/?rev=1228&view=rev Author: ian_lewis Date: 2006-09-02 09:17:37 -0700 (Sat, 02 Sep 2006) Log Message: ----------- More compatibility changes Modified Paths: -------------- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLElement.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLError.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java branches/jsxe2/src/net/sourceforge/jsxe/io/FileVFS.java branches/jsxe2/src/net/sourceforge/jsxe/util/MiscUtilities.java Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-09-02 15:59:17 UTC (rev 1227) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-09-02 16:17:37 UTC (rev 1228) @@ -154,7 +154,7 @@ * @param properties the properties to assign this XMLDocument on creation. * @throws IOException if there was a problem reading the document */ - public XMLDocument(String uri, InputStream reader, EntityResolver resolver, Map properties) throws IOException { + public XMLDocument(String uri, InputStream reader, EntityResolver resolver, Properties properties) throws IOException { m_entityResolver = resolver; setURI(uri); @@ -162,8 +162,8 @@ if (properties != null) { Iterator propertyNames = properties.keySet().iterator(); while (propertyNames.hasNext()) { - Object key = propertyNames.next(); - putProperty(key, properties.get(key)); + String key = propertyNames.next().toString(); + setProperty(key, properties.getProperty(key)); } } @@ -358,7 +358,7 @@ String o = m_properties.getProperty(key); if (o == null) { // Now try xml.document.<property> - o = jsXe.getProperty("xml.document." + name); + o = jsXe.getProperty("xml.document." + key); } return o; } @@ -380,10 +380,10 @@ * Returns the value of a boolean property. This method is thread-safe. * @param name The property name */ - public boolean getBooleanProperty(String name) { + public boolean getBooleanProperty(String name, boolean defValue) { String obj = getProperty(name); if (obj == null) { - return null; + return defValue; } return Boolean.valueOf(obj).booleanValue(); @@ -407,7 +407,7 @@ public int getIntegerProperty(String name, int defaultValue) { boolean defaultValueFlag; - String obj = getProperty(); + String obj = getProperty(name); if (obj == null) { return defaultValue; @@ -567,7 +567,7 @@ * @param data the text contents of the comment */ public XMLComment newCommentNode(String data) { - return new XMLComment(m_document.createCommentNode(data)); + return new XMLComment(m_document.createComment(data)); }//}}} //{{{ newProcessingInstruction() Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLElement.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLElement.java 2006-09-02 15:59:17 UTC (rev 1227) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLElement.java 2006-09-02 16:17:37 UTC (rev 1228) @@ -31,10 +31,6 @@ import net.sourceforge.jsxe.util.MiscUtilities; //}}} -//{{{ Swing classes -import javax.swing.text.*; -//}}} - //{{{ DOM classes import org.w3c.dom.*; import org.w3c.dom.events.*; @@ -42,6 +38,7 @@ //{{{ Java classes import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; //}}} @@ -84,7 +81,7 @@ for (int i=0; i<len; i++) { Node attr = attributes.item(i); XMLAttribute xmlAttr = (XMLAttribute)attr.getUserData(USER_DATA_KEY); - attrSet.put(xmlAttr.getName(), xmlAttr.getValue()); + attrSet.put(xmlAttr.getQualifiedName(), xmlAttr.getValue()); } return attrSet; }//}}} Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLError.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLError.java 2006-09-02 15:59:17 UTC (rev 1227) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLError.java 2006-09-02 16:17:37 UTC (rev 1228) @@ -53,23 +53,22 @@ }//}}} //{{{ getDocument() - public javax.swing.text.Document getDocument() { + public XMLDocument getDocument() { return m_document; }//}}} - //{{{ getElement() - public javax.swing.text.Element getElement(int index) { + //{{{ getChild() + public XMLNode getChild(int index) { return null; }//}}} - //{{{ getElementCount() - public int getElementCount() { + //{{{ getChildCount() + public int getChildCount() { return 0; }//}}} - //{{{ getName() - public String getName() { - //TODO + //{{{ getQualifiedName() + public String getQualifiedName() { if (m_warning) { return Messages.getMessage("common.warning"); } else { @@ -77,8 +76,8 @@ } }//}}} - //{{{ getParentElement() - public javax.swing.text.Element getParentElement() { + //{{{ getParentNode() + public XMLNode getParentNode() { return m_parent; }//}}} Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java 2006-09-02 15:59:17 UTC (rev 1227) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java 2006-09-02 16:17:37 UTC (rev 1228) @@ -38,12 +38,11 @@ import org.w3c.dom.events.*; //}}} -//{{{ Swing classes -import javax.swing.text.*; +//{{{ Java classes +import java.util.ArrayList; +import java.util.Map; //}}} -import java.util.ArrayList; - //}}} /** @@ -139,8 +138,6 @@ } }//}}} - //{{{ javax.swing.text.Element methods - //{{{ getAttributes() /** * Attributes in an XMLNode are implemented as the attributes in a @@ -149,57 +146,83 @@ * DocumentView. * @return the attributes of the XMLElement node or null. */ - public AttributeSet getAttributes() { + public Map getAttributes() { //no attributes by default. Subclasses may override this behavior return null; }//}}} //{{{ getDocument() - public javax.swing.text.Document getDocument() { - return (javax.swing.text.Document)m_domNode.getOwnerDocument().getUserData(USER_DATA_KEY); + public XMLDocument getDocument() { + Document doc = m_domNode.getOwnerDocument(); + if (doc != null) { + return (XMLDocument)doc.getUserData(USER_DATA_KEY); + } else { + return null; + } }//}}} - //{{{ getElement() + //{{{ getChild() - public javax.swing.text.Element getElement(int index) { - return (javax.swing.text.Element)m_children.get(index); + public XMLNode getChild(int index) { + return (XMLNode)m_children.get(index); }//}}} - //{{{ getElementCount() + //{{{ getChildCount() - public int getElementCount() { + public int getChildCount() { return m_children.size(); }//}}} - //{{{ getElementIndex() - - public int getElementIndex(int offset) { + //{{{ getChildIndex() + /** + * Gets the child index closest to the given offset. The offset is + * specified relative to the beginning of the document. + * Returns -1 if the child is a leaf, otherwise returns the index of the + * child that best represents the given location. Returns 0 if the location + * is less than the start offset. Returns getChildCount() - 1 + * if the location is greater than or equal to the end offset. + * @param offset the specified offset >= 0 + */ + public int getChildIndex(int offset) { //TODO: implement offsets return 0; }//}}} //{{{ getEndOffset() - + /** + * Fetches the offset from the beginning of the document that this node + * ends at. If this node has children, this will be the end offset of the + * last child. As a document position, there is an implied backward bias. + * + * @return the ending offset > getStartOffset() and <= getDocument().getLength() + 1 + */ public int getEndOffset() { //TODO: implement offsets //TODO: should this be abstract? return 0; }//}}} - //{{{ getName() + //{{{ getQualifiedName() /** * Gets the qualified name of the node. This will be the namespace * prefix + ":" + the locale name. * @return the qualified name */ - public String getName() { + public String getQualifiedName() { return m_domNode.getNodeName(); }//}}} - //{{{ getParentElement() - - public javax.swing.text.Element getParentElement() { - return (javax.swing.text.Element)m_domNode.getParentNode().getUserData(USER_DATA_KEY); + //{{{ getParentNode() + /** + * Gets the parent node of this node. + */ + public XMLNode getParentNode() { + Node parent = m_domNode.getParentNode(); + if (parent != null) { + return (XMLNode)parent.getUserData(USER_DATA_KEY); + } else { + return null; + } }//}}} //{{{ getStartOffset() @@ -216,27 +239,30 @@ return m_domNode.hasChildNodes(); }//}}} - //}}} + //{{{ addEventListener() - //{{{ addEventListener() + //TODO: redo change listeners to be XMLNode friendly public void addEventListener(java.lang.String type, EventListener listener, boolean useCapture) { ((EventTarget)m_domNode).addEventListener(type, listener, useCapture); }//}}} //{{{ removeEventListener() + + //TODO: redo change listeners to be XMLNode friendly public void removeEventListener(java.lang.String type, EventListener listener, boolean useCapture) { ((EventTarget)m_domNode).removeEventListener(type, listener, useCapture); }//}}} //{{{ appendNode() public XMLNode appendNode(XMLNode newChild) throws DOMException { - if (((XMLDocument)getDocument()).isReadOnly()) { + XMLDocument doc = getDocument(); + if (doc != null && doc.isReadOnly()) { throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, Messages.getMessage("XML.Read.Only.Node")); } if (newChild != null) { if (!(newChild instanceof XMLError)) { - XMLNode parent = (XMLNode)newChild.getParentElement(); + XMLNode parent = newChild.getParentNode(); if (parent != null) { parent.removeNode(newChild); } @@ -285,13 +311,14 @@ //{{{ insertNode() public XMLNode insertNode(XMLNode node, int index) throws DOMException { - if (((XMLDocument)getDocument()).isReadOnly()) { + XMLDocument doc = getDocument(); + if (doc != null && doc.isReadOnly()) { throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, Messages.getMessage("XML.Read.Only.Node")); } if (node != null) { if (!(node instanceof XMLError)) { - XMLNode parent = (XMLNode)node.getParentElement(); + XMLNode parent = node.getParentNode(); if (parent != null) { parent.removeNode(node); } Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java 2006-09-02 15:59:17 UTC (rev 1227) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java 2006-09-02 16:17:37 UTC (rev 1228) @@ -33,6 +33,7 @@ import net.sourceforge.jsxe.io.*; import net.sourceforge.jsxe.*; import net.sourceforge.jsxe.gui.TabbedView; +import net.sourceforge.jsxe.gui.Messages; import net.sourceforge.jsxe.dom2.XMLDocument; import net.sourceforge.jsxe.util.*; //}}} @@ -199,10 +200,10 @@ String[] args = { vfs.getFileName(path) }; setAbortable(true); - if (!buffer.isTemporary()) { - setStatus(Messages.getMessage("DocumentBuffer.Loading.Message",args)); - setProgressValue(0); - } + // if (!buffer.isTemporary()) { + // setStatus(Messages.getMessage("DocumentBuffer.Loading.Message",args)); + // setProgressValue(0); + // } path = vfs._canonPath(session,path,view); @@ -285,11 +286,11 @@ private Reader autodetect(InputStream in) throws IOException { in = new BufferedInputStream(in); - String encoding = buffer.getStringProperty(XMLDocument.ENCODING); + String encoding = buffer.getProperty(XMLDocument.ENCODING); if (!in.markSupported()) { Log.log(Log.WARNING,this,"Mark not supported: " + in); } else { - if(buffer.getBooleanProperty(XMLDocument.ENCODING_AUTODETECT)) { + if (buffer.getBooleanProperty(XMLDocument.ENCODING_AUTODETECT, true)) { in.mark(XML_PI_LENGTH); int b1 = in.read(); int b2 = in.read(); @@ -531,7 +532,7 @@ // 0-byte files should open using // the default line seperator" lineSeparator = jsXe.getProperty( - "xml.document."+XMLDocumen.LINE_SEPARATOR, + "xml.document."+XMLDocument.LINE_SEPARATOR, System.getProperty("line.separator")); } else { if (CRLF) { Modified: branches/jsxe2/src/net/sourceforge/jsxe/io/FileVFS.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/io/FileVFS.java 2006-09-02 15:59:17 UTC (rev 1227) +++ branches/jsxe2/src/net/sourceforge/jsxe/io/FileVFS.java 2006-09-02 16:17:37 UTC (rev 1228) @@ -101,9 +101,12 @@ //{{{ save() method public boolean save(TabbedView view, XMLDocument buffer, String path) { if (OperatingSystem.isUnix()) { - int permissions = getPermissions(buffer.getPath()); - Log.log(Log.DEBUG,this,buffer.getPath() + " has permissions 0" + int permissions = getPermissions(path); + Log.log(Log.DEBUG,this, path + " has permissions 0" + Integer.toString(permissions,8)); + // int permissions = getPermissions(buffer.getPath()); + // Log.log(Log.DEBUG,this,buffer.getPath() + " has permissions 0" + // + Integer.toString(permissions,8)); buffer.setIntegerProperty(PERMISSIONS_PROPERTY,permissions); } @@ -407,8 +410,8 @@ //{{{ Permission preservation code - /** Code borrowed from j text editor (http://www.armedbear.org) */ - /** I made some changes to make it support suid, sgid and sticky files */ + /** Code jEdit borrowed from j text editor (http://www.armedbear.org) */ + /** Slava made some changes to make it support suid, sgid and sticky files */ //{{{ getPermissions() method /** @@ -418,7 +421,7 @@ public static int getPermissions(String path) { int permissions = 0; - if (jsXe.getBooleanProperty("chmodDisabled")) { + if (jsXe.getBooleanProperty("chmodDisabled", true)) { return permissions; } @@ -456,7 +459,7 @@ * does nothing. */ public static void setPermissions(String path, int permissions) { - if (jsXe.getBooleanProperty("chmodDisabled")) + if (jsXe.getBooleanProperty("chmodDisabled", true)) return; if (permissions != 0) { Modified: branches/jsxe2/src/net/sourceforge/jsxe/util/MiscUtilities.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/util/MiscUtilities.java 2006-09-02 15:59:17 UTC (rev 1227) +++ branches/jsxe2/src/net/sourceforge/jsxe/util/MiscUtilities.java 2006-09-02 16:17:37 UTC (rev 1228) @@ -29,6 +29,9 @@ //{{{ Imports import net.sourceforge.jsxe.OperatingSystem; +import net.sourceforge.jsxe.io.*; +import net.sourceforge.jsxe.jsXe; + import javax.swing.text.Segment; import java.io.*; import java.util.*; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |