This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 136595
Collapse All | Expand All

(-)a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/UpdateProjectImpl.java (-35 / +3 lines)
Lines 53-58 Link Here
53
import org.openide.DialogDisplayer;
53
import org.openide.DialogDisplayer;
54
import org.openide.NotifyDescriptor;
54
import org.openide.NotifyDescriptor;
55
import org.openide.util.NbBundle;
55
import org.openide.util.NbBundle;
56
import org.openide.xml.XMLUtil;
56
import org.w3c.dom.Comment;
57
import org.w3c.dom.Comment;
57
import org.w3c.dom.Document;
58
import org.w3c.dom.Document;
58
import org.w3c.dom.Element;
59
import org.w3c.dom.Element;
Lines 147-153 Link Here
147
            if (oldRoot != null) {
148
            if (oldRoot != null) {
148
                Document doc = oldRoot.getOwnerDocument();
149
                Document doc = oldRoot.getOwnerDocument();
149
                Element newRoot = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
150
                Element newRoot = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
150
                copyDocument (doc, oldRoot, newRoot);
151
                XMLUtil.copyDocument (doc, oldRoot, newRoot, AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE);
151
                Element sourceRoots = doc.createElementNS(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots");  //NOI18N
152
                Element sourceRoots = doc.createElementNS(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots");  //NOI18N
152
                Element root = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root");   //NOI18N
153
                Element root = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root");   //NOI18N
153
                root.setAttribute ("id","src.dir");   //NOI18N
154
                root.setAttribute ("id","src.dir");   //NOI18N
Lines 164-170 Link Here
164
                if (oldRoot != null) {
165
                if (oldRoot != null) {
165
                    Document doc = oldRoot.getOwnerDocument();
166
                    Document doc = oldRoot.getOwnerDocument();
166
                    Element newRoot = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
167
                    Element newRoot = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
167
                    copyDocument (doc, oldRoot, newRoot);
168
                    XMLUtil.copyDocument (doc, oldRoot, newRoot, AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE);
168
                    cachedElement = updateMinAntVersion (newRoot, doc);
169
                    cachedElement = updateMinAntVersion (newRoot, doc);
169
                }
170
                }
170
            }
171
            }
Lines 187-225 Link Here
187
        return cachedProperties;
188
        return cachedProperties;
188
    }
189
    }
189
190
190
    private static void copyDocument (Document doc, Element from, Element to) {
191
        NodeList nl = from.getChildNodes();
192
        int length = nl.getLength();
193
        for (int i=0; i< length; i++) {
194
            Node node = nl.item (i);
195
            Node newNode = null;
196
            switch (node.getNodeType()) {
197
                case Node.ELEMENT_NODE:
198
                    Element oldElement = (Element) node;
199
                    newNode = doc.createElementNS(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
200
                    NamedNodeMap m = oldElement.getAttributes();
201
                    Element newElement = (Element) newNode;
202
                    for (int index = 0; index < m.getLength(); index++) {
203
                        Node attr = m.item(index);
204
                          newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
205
                    }
206
                    copyDocument(doc,oldElement,newElement);
207
                    break;
208
                case Node.TEXT_NODE:
209
                    Text oldText = (Text) node;
210
                    newNode = doc.createTextNode(oldText.getData());
211
                    break;
212
                case Node.COMMENT_NODE:
213
                    Comment oldComment = (Comment) node;
214
                    newNode = doc.createComment(oldComment.getData());
215
                    break;
216
            }
217
            if (newNode != null) {
218
                to.appendChild (newNode);
219
            }
220
        }
221
    }
222
    
223
    private static Element updateMinAntVersion (final Element root, final Document doc) {
191
    private static Element updateMinAntVersion (final Element root, final Document doc) {
224
        NodeList list = root.getElementsByTagNameNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,MINIMUM_ANT_VERSION_ELEMENT);
192
        NodeList list = root.getElementsByTagNameNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,MINIMUM_ANT_VERSION_ELEMENT);
225
        if (list.getLength() == 1) {
193
        if (list.getLength() == 1) {
(-)a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/ClassPathSupportCallbackImpl.java (-18 / +2 lines)
Lines 51-56 Link Here
51
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport.Item;
51
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport.Item;
52
import org.netbeans.modules.java.api.common.util.CommonProjectUtils;
52
import org.netbeans.modules.java.api.common.util.CommonProjectUtils;
53
import org.netbeans.spi.project.support.ant.AntProjectHelper;
53
import org.netbeans.spi.project.support.ant.AntProjectHelper;
54
import org.openide.xml.XMLUtil;
54
import org.w3c.dom.Document;
55
import org.w3c.dom.Document;
55
import org.w3c.dom.Element;
56
import org.w3c.dom.Element;
56
import org.w3c.dom.Node;
57
import org.w3c.dom.Node;
Lines 91-97 Link Here
91
        for ( int i = 0; i < libs.getLength(); i++ ) {
92
        for ( int i = 0; i < libs.getLength(); i++ ) {
92
            Element item = (Element)libs.item( i );
93
            Element item = (Element)libs.item( i );
93
            // appclient is different from other j2ee projects - it stores reference without ${ and }
94
            // appclient is different from other j2ee projects - it stores reference without ${ and }
94
            String ref = "${"+findText( item )+"}";
95
            String ref = "${"+XMLUtil.findText( item )+"}";
95
            libraries.add(ref); // NOI18N
96
            libraries.add(ref); // NOI18N
96
            String dirs = item.getAttribute(ATTR_DIRS);
97
            String dirs = item.getAttribute(ATTR_DIRS);
97
            if (Util.DESTINATION_DIRECTORY_ROOT.equals(dirs) ||
98
            if (Util.DESTINATION_DIRECTORY_ROOT.equals(dirs) ||
Lines 140-162 Link Here
140
        return libraryElement;
141
        return libraryElement;
141
    }
142
    }
142
       
143
       
143
    /**
144
     * Extracts <b>the first</b> nested text from an element.
145
     * Currently does not handle coalescing text nodes, CDATA sections, etc.
146
     * @param parent a parent element
147
     * @return the nested text, or null if none was found
148
     */
149
    private static String findText( Element parent ) {
150
        NodeList l = parent.getChildNodes();
151
        for ( int i = 0; i < l.getLength(); i++ ) {
152
            if ( l.item(i).getNodeType() == Node.TEXT_NODE ) {
153
                Text text = (Text)l.item( i );
154
                return text.getNodeValue();
155
            }
156
        }
157
        return null;
158
    }
159
160
    public void readAdditionalProperties(List<Item> items, String projectXMLElement) {
144
    public void readAdditionalProperties(List<Item> items, String projectXMLElement) {
161
        Map<String, String> destination = new HashMap<String, String>();
145
        Map<String, String> destination = new HashMap<String, String>();
162
        List<String> l = getIncludedLibraries(antProjectHelper, projectXMLElement, destination);
146
        List<String> l = getIncludedLibraries(antProjectHelper, projectXMLElement, destination);

Return to bug 136595