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 51453
Collapse All | Expand All

(-)core/windows/src/org/netbeans/core/windows/persistence/GroupParser.java (-62 / +2 lines)
Lines 36-42 Link Here
36
36
37
class GroupParser {
37
class GroupParser {
38
    
38
    
39
    private static final String INSTANCE_DTD_ID_2_0
39
    public static final String INSTANCE_DTD_ID_2_0
40
        = "-//NetBeans//DTD Group Properties 2.0//EN"; // NOI18N
40
        = "-//NetBeans//DTD Group Properties 2.0//EN"; // NOI18N
41
    
41
    
42
    private static final boolean DEBUG = Debug.isLoggable(GroupParser.class);
42
    private static final boolean DEBUG = Debug.isLoggable(GroupParser.class);
Lines 394-402 Link Here
394
        /** Internal configuration data */
394
        /** Internal configuration data */
395
        private InternalConfig internalConfig = null;
395
        private InternalConfig internalConfig = null;
396
        
396
        
397
        /** xml parser */
398
        private XMLReader parser;
399
        
400
        /** Lock to prevent mixing readData and writeData */
397
        /** Lock to prevent mixing readData and writeData */
401
        private final Object RW_LOCK = new Object();
398
        private final Object RW_LOCK = new Object();
402
        
399
        
Lines 466-472 Link Here
466
                    if (DEBUG) Debug.log(GroupParser.class, s);*/
463
                    if (DEBUG) Debug.log(GroupParser.class, s);*/
467
                    //DUMP END
464
                    //DUMP END
468
                    
465
                    
469
                    getXMLParser().parse(new InputSource(cfgFOInput.getInputStream()));
466
                    PersistenceManager.getDefault().getXMLParser(this).parse(new InputSource(cfgFOInput.getInputStream()));
470
                }
467
                }
471
            } catch (SAXException exc) {
468
            } catch (SAXException exc) {
472
                //Turn into annotated IOException
469
                //Turn into annotated IOException
Lines 506-519 Link Here
506
            throw ex;
503
            throw ex;
507
        }
504
        }
508
        
505
        
509
        public void fatalError(SAXParseException ex) throws SAXException {
510
            throw ex;
511
        }
512
        
513
        public void warning(SAXParseException ex) throws SAXException {
514
            // ignore
515
        }
516
        
517
        /** Reads element "group" */
506
        /** Reads element "group" */
518
        private void handleGroup (Attributes attrs) {
507
        private void handleGroup (Attributes attrs) {
519
            String version = attrs.getValue("version"); // NOI18N
508
            String version = attrs.getValue("version"); // NOI18N
Lines 606-646 Link Here
606
            }
595
            }
607
        }
596
        }
608
        
597
        
609
        public void endDocument() throws SAXException {
610
        }
611
        
612
        public void ignorableWhitespace(char[] values, int param, int param2) 
613
        throws SAXException {
614
        }
615
        
616
        public void endElement(String str, String str1, String str2) 
617
        throws SAXException {
618
        }
619
        
620
        public void skippedEntity(String str) throws SAXException {
621
        }
622
        
623
        public void processingInstruction(String str, String str1) 
624
        throws SAXException {
625
        }
626
                
627
        public void endPrefixMapping(String str) throws SAXException {
628
        }
629
        
630
        public void startPrefixMapping(String str, String str1) 
631
        throws SAXException {
632
        }
633
        
634
        public void characters(char[] values, int param, int param2) 
635
        throws SAXException {
636
        }
637
        
638
        public void setDocumentLocator(org.xml.sax.Locator locator) {
639
        }
640
        
641
        public void startDocument() throws SAXException {
642
        }
643
        
644
        /** Writes data from asociated group to the xml representation */
598
        /** Writes data from asociated group to the xml representation */
645
        void writeData (GroupConfig sc, InternalConfig ic) throws IOException {
599
        void writeData (GroupConfig sc, InternalConfig ic) throws IOException {
646
            final StringBuffer buff = fillBuffer(sc, ic);
600
            final StringBuffer buff = fillBuffer(sc, ic);
Lines 721-740 Link Here
721
            buff.append(" />\n"); // NOI18N
675
            buff.append(" />\n"); // NOI18N
722
        }
676
        }
723
        
677
        
724
        /** @return Newly created parser with group content handler, errror handler
725
         * and entity resolver
726
         */
727
        private XMLReader getXMLParser () throws SAXException {
728
            if (parser == null) {
729
                // get non validating, not namespace aware parser
730
                parser = XMLUtil.createXMLReader();
731
                parser.setContentHandler(this);
732
                parser.setErrorHandler(this);
733
                parser.setEntityResolver(this);
734
            }
735
            return parser;
736
        }
737
738
        /** Implementation of entity resolver. Points to the local DTD
678
        /** Implementation of entity resolver. Points to the local DTD
739
         * for our public ID */
679
         * for our public ID */
740
        public InputSource resolveEntity (String publicId, String systemId)
680
        public InputSource resolveEntity (String publicId, String systemId)
(-)core/windows/src/org/netbeans/core/windows/persistence/ModeParser.java (-87 / +6 lines)
Lines 25-31 Link Here
25
import org.openide.util.NbBundle;
25
import org.openide.util.NbBundle;
26
import org.openide.util.TopologicalSortException;
26
import org.openide.util.TopologicalSortException;
27
import org.openide.util.Utilities;
27
import org.openide.util.Utilities;
28
import org.openide.xml.XMLUtil;
29
import org.xml.sax.*;
28
import org.xml.sax.*;
30
import org.xml.sax.helpers.DefaultHandler;
29
import org.xml.sax.helpers.DefaultHandler;
31
30
Lines 43-57 Link Here
43
42
44
class ModeParser {
43
class ModeParser {
45
    
44
    
46
    private static final String INSTANCE_DTD_ID_1_0
45
    public static final String INSTANCE_DTD_ID_1_0
47
        = "-//NetBeans//DTD Mode Properties 1.0//EN"; // NOI18N
46
        = "-//NetBeans//DTD Mode Properties 1.0//EN"; // NOI18N
48
    private static final String INSTANCE_DTD_ID_1_1
47
    public static final String INSTANCE_DTD_ID_1_1
49
        = "-//NetBeans//DTD Mode Properties 1.1//EN"; // NOI18N
48
        = "-//NetBeans//DTD Mode Properties 1.1//EN"; // NOI18N
50
    private static final String INSTANCE_DTD_ID_1_2
49
    public static final String INSTANCE_DTD_ID_1_2
51
        = "-//NetBeans//DTD Mode Properties 1.2//EN"; // NOI18N
50
        = "-//NetBeans//DTD Mode Properties 1.2//EN"; // NOI18N
52
    private static final String INSTANCE_DTD_ID_2_0
51
    public static final String INSTANCE_DTD_ID_2_0
53
        = "-//NetBeans//DTD Mode Properties 2.0//EN"; // NOI18N
52
        = "-//NetBeans//DTD Mode Properties 2.0//EN"; // NOI18N
54
    private static final String INSTANCE_DTD_ID_2_1
53
    public static final String INSTANCE_DTD_ID_2_1
55
        = "-//NetBeans//DTD Mode Properties 2.1//EN"; // NOI18N
54
        = "-//NetBeans//DTD Mode Properties 2.1//EN"; // NOI18N
56
    
55
    
57
    /** Name of extended attribute for order of children */
56
    /** Name of extended attribute for order of children */
Lines 919-927 Link Here
919
        /** List to store parsed path items */
918
        /** List to store parsed path items */
920
        private List itemList = new ArrayList(10);
919
        private List itemList = new ArrayList(10);
921
        
920
        
922
        /** xml parser */
923
        private XMLReader parser;
924
        
925
        /** Lock to prevent mixing readData and writeData */
921
        /** Lock to prevent mixing readData and writeData */
926
        private final Object RW_LOCK = new Object();
922
        private final Object RW_LOCK = new Object();
927
        
923
        
Lines 993-999 Link Here
993
                    }*/
989
                    }*/
994
                    //DUMP END
990
                    //DUMP END
995
                    
991
                    
996
                    getXMLParser().parse(new InputSource(cfgFOInput.getInputStream()));
992
                    PersistenceManager.getDefault().getXMLParser(this).parse(new InputSource(cfgFOInput.getInputStream()));
997
                }
993
                }
998
            } catch (SAXException exc) {
994
            } catch (SAXException exc) {
999
                //Turn into annotated IOException
995
                //Turn into annotated IOException
Lines 1057-1070 Link Here
1057
            throw ex;
1053
            throw ex;
1058
        }
1054
        }
1059
        
1055
        
1060
        public void fatalError(SAXParseException ex) throws SAXException {
1061
            throw ex;
1062
        }
1063
        
1064
        public void warning(SAXParseException ex) throws SAXException {
1065
            // ignore
1066
        }
1067
        
1068
        /** Reads element "mode" */
1056
        /** Reads element "mode" */
1069
        private void handleMode (Attributes attrs) {
1057
        private void handleMode (Attributes attrs) {
1070
            String version = attrs.getValue("version"); // NOI18N
1058
            String version = attrs.getValue("version"); // NOI18N
Lines 1428-1470 Link Here
1428
            }
1416
            }
1429
        }
1417
        }
1430
        
1418
        
1431
        public void endDocument() throws org.xml.sax.SAXException {
1432
        }
1433
        
1434
        public void ignorableWhitespace(char[] values, int param, int param2) 
1435
        throws org.xml.sax.SAXException {
1436
        }
1437
        
1438
        public void endElement(java.lang.String str, java.lang.String str1, java.lang.String str2) 
1439
        throws org.xml.sax.SAXException {
1440
        }
1441
        
1442
        public void skippedEntity(java.lang.String str) 
1443
        throws org.xml.sax.SAXException {
1444
        }
1445
        
1446
        public void processingInstruction(java.lang.String str, java.lang.String str1) 
1447
        throws org.xml.sax.SAXException {
1448
        }
1449
                
1450
        public void endPrefixMapping(java.lang.String str) 
1451
        throws org.xml.sax.SAXException {
1452
        }
1453
        
1454
        public void startPrefixMapping(java.lang.String str, java.lang.String str1) 
1455
        throws org.xml.sax.SAXException {
1456
        }
1457
        
1458
        public void characters(char[] values, int param, int param2) 
1459
        throws org.xml.sax.SAXException {
1460
        }
1461
        
1462
        public void setDocumentLocator(org.xml.sax.Locator locator) {
1463
        }
1464
        
1465
        public void startDocument() throws org.xml.sax.SAXException {
1466
        }
1467
        
1468
        /** Writes data from asociated mode to the xml representation */
1419
        /** Writes data from asociated mode to the xml representation */
1469
        void writeData (ModeConfig mc, InternalConfig ic) throws IOException {
1420
        void writeData (ModeConfig mc, InternalConfig ic) throws IOException {
1470
            final StringBuffer buff = fillBuffer(mc, ic);
1421
            final StringBuffer buff = fillBuffer(mc, ic);
Lines 1624-1661 Link Here
1624
            buff.append("    <empty-behavior permanent=\"").append(mc.permanent).append("\"/>\n"); // NOI18N
1575
            buff.append("    <empty-behavior permanent=\"").append(mc.permanent).append("\"/>\n"); // NOI18N
1625
        }
1576
        }
1626
        
1577
        
1627
        /** @return Newly created parser with set content handler, errror handler
1628
         * and entity resolver
1629
         */
1630
        private XMLReader getXMLParser () throws SAXException {
1631
            if (parser == null) {
1632
                // get non validating, not namespace aware parser
1633
                parser = XMLUtil.createXMLReader();
1634
                parser.setContentHandler(this);
1635
                parser.setErrorHandler(this);
1636
                parser.setEntityResolver(this);
1637
            }
1638
            return parser;
1639
        }
1640
1641
        /** Implementation of entity resolver. Points to the local DTD
1642
         * for our public ID */
1643
        public InputSource resolveEntity (String publicId, String systemId)
1644
        throws SAXException {
1645
            if (INSTANCE_DTD_ID_1_0.equals(publicId)
1646
             || INSTANCE_DTD_ID_1_1.equals(publicId)
1647
             || INSTANCE_DTD_ID_1_2.equals(publicId)
1648
             || INSTANCE_DTD_ID_2_0.equals(publicId)
1649
             || INSTANCE_DTD_ID_2_1.equals(publicId)) {
1650
                InputStream is = new ByteArrayInputStream(new byte[0]);
1651
                //getClass().getResourceAsStream(INSTANCE_DTD_LOCAL);
1652
//                if (is == null) {
1653
//                    throw new IllegalStateException ("Entity cannot be resolved."); // NOI18N
1654
//                }
1655
                return new InputSource(is);
1656
            }
1657
            return null; // i.e. follow advice of systemID
1658
        }
1659
    }
1578
    }
1660
    
1579
    
1661
}
1580
}
(-)core/windows/src/org/netbeans/core/windows/persistence/PersistenceManager.java (-95 / +55 lines)
Lines 13-22 Link Here
13
13
14
package org.netbeans.core.windows.persistence;
14
package org.netbeans.core.windows.persistence;
15
15
16
import org.netbeans.core.windows.Constants;
17
import org.netbeans.core.windows.Debug;
16
import org.netbeans.core.windows.Debug;
18
import org.netbeans.core.windows.RegistryImpl;
19
import org.netbeans.core.windows.WindowManagerImpl;
20
import org.openide.ErrorManager;
17
import org.openide.ErrorManager;
21
import org.openide.cookies.InstanceCookie;
18
import org.openide.cookies.InstanceCookie;
22
import org.openide.cookies.SaveCookie;
19
import org.openide.cookies.SaveCookie;
Lines 36-47 Link Here
36
33
37
import java.beans.PropertyChangeEvent;
34
import java.beans.PropertyChangeEvent;
38
import java.beans.PropertyChangeListener;
35
import java.beans.PropertyChangeListener;
36
import java.io.ByteArrayInputStream;
39
import java.io.FileNotFoundException;
37
import java.io.FileNotFoundException;
40
import java.io.IOException;
38
import java.io.IOException;
39
import java.io.InputStream;
41
import java.io.InvalidObjectException;
40
import java.io.InvalidObjectException;
42
import java.io.NotSerializableException;
41
import java.io.NotSerializableException;
43
import java.lang.ref.WeakReference;
42
import java.lang.ref.WeakReference;
44
import java.util.*;
43
import java.util.*;
44
import org.openide.xml.XMLUtil;
45
import org.xml.sax.EntityResolver;
46
import org.xml.sax.InputSource;
47
import org.xml.sax.SAXException;
48
import org.xml.sax.XMLReader;
49
import org.xml.sax.helpers.DefaultHandler;
45
50
46
51
47
/** Manages persistent data of window system, currently stored in XML format.
52
/** Manages persistent data of window system, currently stored in XML format.
Lines 132-139 Link Here
132
    /** Lock for synchronizing access to IDs. */
137
    /** Lock for synchronizing access to IDs. */
133
    private final Object LOCK_IDS = new Object();
138
    private final Object LOCK_IDS = new Object();
134
    
139
    
135
    /** true if we are saving just now, false otherwise */
140
    /** xml parser */
136
    private boolean isSaveInProgress;
141
    private XMLReader parser;
137
    
142
    
138
    private static PersistenceManager defaultInstance;
143
    private static PersistenceManager defaultInstance;
139
    
144
    
Lines 533-546 Link Here
533
        }
538
        }
534
    }
539
    }
535
    
540
    
536
    /** Destroys settings files of component with given string ID. */ 
537
    private void deleteTopComponentFile(String stringId) throws IOException {
538
        DataObject dob = findTopComponentDataObject(getComponentsLocalFolder(), stringId);
539
        if(dob != null) {
540
            dob.delete();
541
        }
542
    }
543
544
    /** Try to find the data object representing a top component ref in some folder.
541
    /** Try to find the data object representing a top component ref in some folder.
545
     * Only the TC name is known, but we can guess at some likely filenames before
542
     * Only the TC name is known, but we can guess at some likely filenames before
546
     * doing an exhaustive search. Produces either a FileObject or DataObject,
543
     * doing an exhaustive search. Produces either a FileObject or DataObject,
Lines 810-878 Link Here
810
        return srcName;
807
        return srcName;
811
    }
808
    }
812
    
809
    
813
    /** Called during projects switch BEFORE new project is loaded and AFTER
814
     * project layer is switched. */
815
    public void resetAfterLayerSwitch() {
816
        resetAllTCPairs();
817
        resetWindowManagerParser();
818
        copySettingsFiles();
819
        restoreAllTCPairs();
820
    }
821
    
822
    /** Must be called during Project switch */
823
    private void resetAllTCPairs () {
824
        synchronized(LOCK_IDS) {
825
            invalidIds = new HashSet(topComponent2IDMap.values());
826
            /*System.out.println("-- PM.resetAllTCPairs ENTER");
827
            for (Iterator it = invalidIds.iterator(); it.hasNext(); ) {
828
                System.out.println("-- item:" + it.next());
829
            }*/
830
            
831
            id2TopComponentMap.clear();
832
        }
833
    }
834
    
835
    /** Must be called during Project switch */
836
    private void restoreAllTCPairs () {
837
        synchronized(LOCK_IDS) {
838
            //System.out.println("-- PM.restoreAllTCPairs ENTER");
839
            
840
            for (Iterator it = topComponent2IDMap.keySet().iterator(); it.hasNext(); ) {
841
                TopComponent tc = (TopComponent) it.next();
842
                String id = (String) topComponent2IDMap.get(tc);
843
                //System.out.println("-- PM.restoreAllTCPairs id:" + id);
844
                if (isInvalidId(id)) {
845
                    restorePair(tc, id);
846
                }
847
            }
848
            
849
            /*for (Iterator it = id2TopComponentMap.keySet().iterator(); it.hasNext(); ) {
850
                System.out.println("-- item:" + it.next());
851
            }*/
852
            
853
            Set toRemove = new HashSet();
854
            for (Iterator it = topComponent2IDMap.keySet().iterator(); it.hasNext(); ) {
855
                TopComponent tc = (TopComponent) it.next();
856
                String id = (String) topComponent2IDMap.get(tc);
857
                if (!id2TopComponentMap.containsKey(id)) {
858
                    //System.out.println("-- PM.restoreAllTCPairs REMOVE tc:" + tc.getName());
859
                    toRemove.add(tc);
860
                } /*else {
861
                    System.out.println("-- PM.restoreAllTCPairs KEEP tc:" + tc.getName());
862
                }*/
863
            }
864
            
865
            for (Iterator it = toRemove.iterator(); it.hasNext(); ) {
866
                topComponent2IDMap.remove(it.next());
867
            }
868
            
869
            /*System.out.println("-- PM.restoreAllTCPairs topComponent2IDMap.size:"
870
            + topComponent2IDMap.size());
871
            System.out.println("-- PM.restoreAllTCPairs id2TopComponentMap.size:"
872
            + id2TopComponentMap.size());*/
873
        }
874
    }
875
    
876
    /** Reuses existing settings files */
810
    /** Reuses existing settings files */
877
    private String restorePair (TopComponent tc, String id) {
811
    private String restorePair (TopComponent tc, String id) {
878
        //System.out.println("++ PM.restorePair ENTER"
812
        //System.out.println("++ PM.restorePair ENTER"
Lines 941-957 Link Here
941
        failedCompsMap = null;
875
        failedCompsMap = null;
942
    }
876
    }
943
    
877
    
944
    private void setSaveInProgress (boolean isSaveInProgress) {
945
        this.isSaveInProgress = isSaveInProgress;
946
    } // TEMP
947
    
948
    /** @return true if saving of window system is currently being processed,
949
     * false otherwise. Used to disallow interferation of parsing and saving.
950
     */
951
    boolean isSaveInProgress () {
952
        return isSaveInProgress;
953
    } // TEMP
954
    
955
    /** Accessor to WindowManagerParser instance. */
878
    /** Accessor to WindowManagerParser instance. */
956
    public WindowManagerParser getWindowManagerParser () {
879
    public WindowManagerParser getWindowManagerParser () {
957
        if (windowManagerParser == null) {
880
        if (windowManagerParser == null) {
Lines 960-968 Link Here
960
        return windowManagerParser;
883
        return windowManagerParser;
961
    }
884
    }
962
    
885
    
963
    /** Reset WindowManagerParser instance. Called during project switch. */
886
    /** Returns a XML parser. The same parser can be returned assuming that config files
964
    private void resetWindowManagerParser() {
887
     * are parser sequentially.
965
        windowManagerParser = null;
888
     *
889
     * @return XML parser with set content handler, errror handler
890
     * and entity resolver.
891
     */
892
    public XMLReader getXMLParser (DefaultHandler h) throws SAXException {
893
        if (parser == null) {
894
            // get non validating, not namespace aware parser
895
            parser = XMLUtil.createXMLReader();
896
            parser.setEntityResolver(new EntityResolver () {
897
                /** Implementation of entity resolver. Points to the local DTD
898
                 * for our public ID */
899
                public InputSource resolveEntity (String publicId, String systemId)
900
                throws SAXException {
901
                    if (ModeParser.INSTANCE_DTD_ID_1_0.equals(publicId)
902
                    || ModeParser.INSTANCE_DTD_ID_1_1.equals(publicId)
903
                    || ModeParser.INSTANCE_DTD_ID_1_2.equals(publicId)
904
                    || ModeParser.INSTANCE_DTD_ID_2_0.equals(publicId)
905
                    || ModeParser.INSTANCE_DTD_ID_2_1.equals(publicId)
906
                    || GroupParser.INSTANCE_DTD_ID_2_0.equals(publicId)
907
                    || TCGroupParser.INSTANCE_DTD_ID_2_0.equals(publicId)
908
                    || TCRefParser.INSTANCE_DTD_ID_1_0.equals(publicId)
909
                    || TCRefParser.INSTANCE_DTD_ID_2_0.equals(publicId)
910
                    || TCRefParser.INSTANCE_DTD_ID_2_1.equals(publicId)
911
                    || WindowManagerParser.INSTANCE_DTD_ID_1_0.equals(publicId)
912
                    || WindowManagerParser.INSTANCE_DTD_ID_1_1.equals(publicId)
913
                    || WindowManagerParser.INSTANCE_DTD_ID_2_0.equals(publicId)
914
                    || WindowManagerParser.INSTANCE_DTD_ID_2_1.equals(publicId)) {
915
                        InputStream is = new ByteArrayInputStream(new byte[0]);
916
                        return new InputSource(is);
917
                    }
918
                    return null; // i.e. follow advice of systemID
919
                }
920
            });
921
        }
922
        parser.setContentHandler(h);
923
        parser.setErrorHandler(h);
924
        return parser;
966
    }
925
    }
967
    
926
    
968
    /** Adds TopComponent Id to set of used Ids. Called from ModeParser and
927
    /** Adds TopComponent Id to set of used Ids. Called from ModeParser and
Lines 1024-1030 Link Here
1024
     * @return window system configuration
983
     * @return window system configuration
1025
     */
984
     */
1026
    public WindowManagerConfig loadWindowSystem() {
985
    public WindowManagerConfig loadWindowSystem() {
1027
        //long start = System.currentTimeMillis();
986
//        long start = System.currentTimeMillis();
1028
        
987
        
1029
        //Clear set of used tc_id
988
        //Clear set of used tc_id
1030
        synchronized (LOCK_IDS) {
989
        synchronized (LOCK_IDS) {
Lines 1050-1058 Link Here
1050
            changeHandler = new ModuleChangeHandler();
1009
            changeHandler = new ModuleChangeHandler();
1051
            changeHandler.startHandling();
1010
            changeHandler.startHandling();
1052
        }
1011
        }
1053
        //long end = System.currentTimeMillis();
1012
        parser = null; // clear the ref to XML parser
1054
        //long diff = end - start;
1013
        
1055
        //System.out.println("Loading of window system takes " + diff + " ms");
1014
//        long end = System.currentTimeMillis();
1015
//        long diff = end - start;
1016
//        System.out.println("Loading of window system takes " + diff + " ms");
1056
        return wmc;
1017
        return wmc;
1057
    }
1018
    }
1058
    
1019
    
Lines 1245-1251 Link Here
1245
            Lookup.getDefault().lookup(new Lookup.Template(ModuleInfo.class));
1206
            Lookup.getDefault().lookup(new Lookup.Template(ModuleInfo.class));
1246
        Collection infos = modulesResult.allInstances();
1207
        Collection infos = modulesResult.allInstances();
1247
        ModuleInfo curInfo = null;
1208
        ModuleInfo curInfo = null;
1248
        boolean equalsName = false;
1249
        for (Iterator iter = infos.iterator(); iter.hasNext(); ) {
1209
        for (Iterator iter = infos.iterator(); iter.hasNext(); ) {
1250
            curInfo = (ModuleInfo)iter.next();
1210
            curInfo = (ModuleInfo)iter.next();
1251
            // search for equal base name and then compare release and
1211
            // search for equal base name and then compare release and
(-)core/windows/src/org/netbeans/core/windows/persistence/TCGroupParser.java (-75 / +1 lines)
Lines 131-139 Link Here
131
        /** internal configuration data */
131
        /** internal configuration data */
132
        private InternalConfig internalConfig = null;
132
        private InternalConfig internalConfig = null;
133
        
133
        
134
        /** xml parser */
135
        private XMLReader parser;
136
        
137
        /** Lock to prevent mixing readData and writeData */
134
        /** Lock to prevent mixing readData and writeData */
138
        private final Object RW_LOCK = new Object();
135
        private final Object RW_LOCK = new Object();
139
        
136
        
Lines 202-208 Link Here
202
                    log(s);*/
199
                    log(s);*/
203
                    //DUMP END
200
                    //DUMP END
204
                    
201
                    
205
                    getXMLParser().parse(new InputSource(cfgFOInput.getInputStream()));
202
                    PersistenceManager.getDefault().getXMLParser(this).parse(new InputSource(cfgFOInput.getInputStream()));
206
                }
203
                }
207
            } catch (SAXException exc) {
204
            } catch (SAXException exc) {
208
                //Turn into annotated IOException
205
                //Turn into annotated IOException
Lines 243-256 Link Here
243
            throw ex;
240
            throw ex;
244
        }
241
        }
245
242
246
        public void fatalError(SAXParseException ex) throws SAXException {
247
            throw ex;
248
        }
249
250
        public void warning(SAXParseException ex) throws SAXException {
251
            // ignore
252
        }
253
        
254
        /** Reads element "tc-group" */
243
        /** Reads element "tc-group" */
255
        private void handleTCGroup (Attributes attrs) {
244
        private void handleTCGroup (Attributes attrs) {
256
            String version = attrs.getValue("version"); // NOI18N
245
            String version = attrs.getValue("version"); // NOI18N
Lines 383-423 Link Here
383
            }
372
            }
384
        }
373
        }
385
        
374
        
386
        public void endDocument() throws SAXException {
387
        }
388
        
389
        public void ignorableWhitespace(char[] values, int param, int param2) 
390
        throws SAXException {
391
        }
392
        
393
        public void endElement(String str, String str1, String str2) 
394
        throws SAXException {
395
        }
396
        
397
        public void skippedEntity(String str) throws SAXException {
398
        }
399
        
400
        public void processingInstruction(String str, String str1) 
401
        throws SAXException {
402
        }
403
                
404
        public void endPrefixMapping(String str) throws SAXException {
405
        }
406
        
407
        public void startPrefixMapping(String str, String str1) 
408
        throws SAXException {
409
        }
410
        
411
        public void characters(char[] values, int param, int param2) 
412
        throws SAXException {
413
        }
414
        
415
        public void setDocumentLocator(org.xml.sax.Locator locator) {
416
        }
417
        
418
        public void startDocument() throws SAXException {
419
        }
420
        
421
        /** Writes data from asociated tcRef to the xml representation */
375
        /** Writes data from asociated tcRef to the xml representation */
422
        void writeData (TCGroupConfig tcGroupCfg, InternalConfig ic) throws IOException {
376
        void writeData (TCGroupConfig tcGroupCfg, InternalConfig ic) throws IOException {
423
            final StringBuffer buff = fillBuffer(tcGroupCfg, ic);
377
            final StringBuffer buff = fillBuffer(tcGroupCfg, ic);
Lines 488-521 Link Here
488
                append("\" was-opened=\"").append(tcGroupCfg.wasOpened).append("\"/>\n"); // NOI18N
442
                append("\" was-opened=\"").append(tcGroupCfg.wasOpened).append("\"/>\n"); // NOI18N
489
        }
443
        }
490
        
444
        
491
        /** @return Newly created parser with grou content handler, errror handler
492
         * and entity resolver
493
         */
494
        private XMLReader getXMLParser () throws SAXException {
495
            if (parser == null) {
496
                // get non validating, not namespace aware parser
497
                parser = XMLUtil.createXMLReader();
498
                parser.setContentHandler(this);
499
                parser.setErrorHandler(this);
500
                parser.setEntityResolver(this);
501
            }
502
            return parser;
503
        }
504
505
        /** Implementation of entity resolver. Points to the local DTD
506
         * for our public ID */
507
        public InputSource resolveEntity (String publicId, String systemId)
508
        throws SAXException {
509
            if (INSTANCE_DTD_ID_2_0.equals(publicId)) {
510
                InputStream is = new ByteArrayInputStream(new byte[0]);
511
                //getClass().getResourceAsStream(INSTANCE_DTD_LOCAL);
512
//                if (is == null) {
513
//                    throw new IllegalStateException ("Entity cannot be resolved."); // NOI18N
514
//                }
515
                return new InputSource(is);
516
            }
517
            return null; // i.e. follow advice of systemID
518
        }
519
    }
445
    }
520
    
446
    
521
}
447
}
(-)core/windows/src/org/netbeans/core/windows/persistence/TCRefParser.java (-77 / +1 lines)
Lines 142-150 Link Here
142
        /** internal configuration data */
142
        /** internal configuration data */
143
        private InternalConfig internalConfig = null;
143
        private InternalConfig internalConfig = null;
144
        
144
        
145
        /** xml parser */
146
        private XMLReader parser;
147
        
148
        /** Lock to prevent mixing readData and writeData */
145
        /** Lock to prevent mixing readData and writeData */
149
        private final Object RW_LOCK = new Object();
146
        private final Object RW_LOCK = new Object();
150
        
147
        
Lines 212-218 Link Here
212
                    log(s);*/
209
                    log(s);*/
213
                    //DUMP END
210
                    //DUMP END
214
                    
211
                    
215
                    getXMLParser().parse(new InputSource(cfgFOInput.getInputStream()));
212
                    PersistenceManager.getDefault().getXMLParser(this).parse(new InputSource(cfgFOInput.getInputStream()));
216
                }
213
                }
217
            } catch (SAXException exc) {
214
            } catch (SAXException exc) {
218
                //Turn into annotated IOException
215
                //Turn into annotated IOException
Lines 255-268 Link Here
255
            throw ex;
252
            throw ex;
256
        }
253
        }
257
254
258
        public void fatalError(SAXParseException ex) throws SAXException {
259
            throw ex;
260
        }
261
262
        public void warning(SAXParseException ex) throws SAXException {
263
            // ignore
264
        }
265
        
266
        /** Reads element "tc-ref" */
255
        /** Reads element "tc-ref" */
267
        private void handleTCRef (Attributes attrs) {
256
        private void handleTCRef (Attributes attrs) {
268
            String version = attrs.getValue("version"); // NOI18N
257
            String version = attrs.getValue("version"); // NOI18N
Lines 381-421 Link Here
381
            }
370
            }
382
        }
371
        }
383
        
372
        
384
        
385
        public void endDocument() throws SAXException {
386
        }
387
        
388
        public void ignorableWhitespace(char[] values, int param, int param2) 
389
        throws SAXException {
390
        }
391
        
392
        public void endElement(String str, String str1, String str2) 
393
        throws SAXException {
394
        }
395
        
396
        public void skippedEntity(String str) throws SAXException {
397
        }
398
        
399
        public void processingInstruction(String str, String str1)
400
        throws SAXException {
401
        }
402
                
403
        public void endPrefixMapping(String str) throws SAXException {
404
        }
405
        
406
        public void startPrefixMapping(String str, String str1) throws SAXException {
407
        }
408
        
409
        public void characters(char[] values, int param, int param2) 
410
        throws SAXException {
411
        }
412
        
413
        public void setDocumentLocator(org.xml.sax.Locator locator) {
414
        }
415
        
416
        public void startDocument() throws SAXException {
417
        }
418
        
419
        /** Writes data from asociated tcRef to the xml representation */
373
        /** Writes data from asociated tcRef to the xml representation */
420
        void writeData (TCRefConfig tcRefCfg, InternalConfig ic) throws IOException {
374
        void writeData (TCRefConfig tcRefCfg, InternalConfig ic) throws IOException {
421
            final StringBuffer buff = fillBuffer(tcRefCfg, ic);
375
            final StringBuffer buff = fillBuffer(tcRefCfg, ic);
Lines 506-541 Link Here
506
            buff.append("\" />\n"); // NOI18N
460
            buff.append("\" />\n"); // NOI18N
507
        }
461
        }
508
462
509
        /** @return Newly created parser with set content handler, errror handler
510
         * and entity resolver
511
         */
512
        private XMLReader getXMLParser () throws SAXException {
513
            if (parser == null) {
514
                // get non validating, not namespace aware parser
515
                parser = XMLUtil.createXMLReader();
516
                parser.setContentHandler(this);
517
                parser.setErrorHandler(this);
518
                parser.setEntityResolver(this);
519
            }
520
            return parser;
521
        }
522
523
        /** Implementation of entity resolver. Points to the local DTD
524
         * for our public ID */
525
        public InputSource resolveEntity (String publicId, String systemId)
526
        throws SAXException {
527
            if (INSTANCE_DTD_ID_1_0.equals(publicId)
528
             || INSTANCE_DTD_ID_2_0.equals(publicId)
529
             || INSTANCE_DTD_ID_2_1.equals(publicId)) {
530
                InputStream is = new ByteArrayInputStream(new byte[0]);
531
                //getClass().getResourceAsStream(INSTANCE_DTD_LOCAL);
532
//                if (is == null) {
533
//                    throw new IllegalStateException ("Entity cannot be resolved."); // NOI18N
534
//                }
535
                return new InputSource(is);
536
            }
537
            return null; // i.e. follow advice of systemID
538
        }
539
    }
463
    }
540
    
464
    
541
}
465
}
(-)core/windows/src/org/netbeans/core/windows/persistence/WindowManagerParser.java (-77 / +5 lines)
Lines 40-52 Link Here
40
40
41
public class WindowManagerParser {
41
public class WindowManagerParser {
42
    
42
    
43
    private static final String INSTANCE_DTD_ID_1_0
43
    public static final String INSTANCE_DTD_ID_1_0
44
        = "-//NetBeans//DTD Window Manager Properties 1.0//EN"; // NOI18N
44
        = "-//NetBeans//DTD Window Manager Properties 1.0//EN"; // NOI18N
45
    private static final String INSTANCE_DTD_ID_1_1
45
    public static final String INSTANCE_DTD_ID_1_1
46
        = "-//NetBeans//DTD Window Manager Properties 1.1//EN"; // NOI18N
46
        = "-//NetBeans//DTD Window Manager Properties 1.1//EN"; // NOI18N
47
    private static final String INSTANCE_DTD_ID_2_0
47
    public static final String INSTANCE_DTD_ID_2_0
48
        = "-//NetBeans//DTD Window Manager Properties 2.0//EN"; // NOI18N
48
        = "-//NetBeans//DTD Window Manager Properties 2.0//EN"; // NOI18N
49
    private static final String INSTANCE_DTD_ID_2_1
49
    public static final String INSTANCE_DTD_ID_2_1
50
        = "-//NetBeans//DTD Window Manager Properties 2.1//EN"; // NOI18N
50
        = "-//NetBeans//DTD Window Manager Properties 2.1//EN"; // NOI18N
51
    
51
    
52
    private static final boolean DEBUG = Debug.isLoggable(WindowManagerParser.class);
52
    private static final boolean DEBUG = Debug.isLoggable(WindowManagerParser.class);
Lines 733-741 Link Here
733
        /** List to store parsed tc-ids */
733
        /** List to store parsed tc-ids */
734
        private List tcIdList = new ArrayList(10);
734
        private List tcIdList = new ArrayList(10);
735
        
735
        
736
        /** xml parser */
737
        private XMLReader parser;
738
        
739
        /** Lock to prevent mixing readData and writeData */
736
        /** Lock to prevent mixing readData and writeData */
740
        private final Object RW_LOCK = new Object();
737
        private final Object RW_LOCK = new Object();
741
        
738
        
Lines 820-826 Link Here
820
                    if (DEBUG) Debug.log(WindowManagerParser.class, s);*/
817
                    if (DEBUG) Debug.log(WindowManagerParser.class, s);*/
821
                    //DUMP END
818
                    //DUMP END
822
//                    long time = System.currentTimeMillis();
819
//                    long time = System.currentTimeMillis();
823
                    getXMLParser().parse(new InputSource(cfgFOInput.getInputStream()));
820
                    PersistenceManager.getDefault().getXMLParser(this).parse(new InputSource(cfgFOInput.getInputStream()));
824
//                    System.out.println("WindowManagerParser.readData "+(System.currentTimeMillis()-time));
821
//                    System.out.println("WindowManagerParser.readData "+(System.currentTimeMillis()-time));
825
                }
822
                }
826
            } catch (SAXException exc) {
823
            } catch (SAXException exc) {
Lines 887-900 Link Here
887
            throw ex;
884
            throw ex;
888
        }
885
        }
889
886
890
        public void fatalError(SAXParseException ex) throws SAXException {
891
            throw ex;
892
        }
893
894
        public void warning(SAXParseException ex) throws SAXException {
895
            // ignore
896
        }
897
        
898
        /** Reads element "windowmanager" */
887
        /** Reads element "windowmanager" */
899
        private void handleWindowManager (Attributes attrs) {
888
        private void handleWindowManager (Attributes attrs) {
900
            String version = attrs.getValue("version"); // NOI18N
889
            String version = attrs.getValue("version"); // NOI18N
Lines 1709-1744 Link Here
1709
            }
1698
            }
1710
        }
1699
        }
1711
        
1700
        
1712
        public void endDocument() throws org.xml.sax.SAXException {
1713
        }
1714
        
1715
        public void ignorableWhitespace(char[] values, int param, int param2) throws org.xml.sax.SAXException {
1716
        }
1717
        
1718
        public void endElement(java.lang.String str, java.lang.String str1, java.lang.String str2) throws org.xml.sax.SAXException {
1719
        }
1720
        
1721
        public void skippedEntity(java.lang.String str) throws org.xml.sax.SAXException {
1722
        }
1723
        
1724
        public void processingInstruction(java.lang.String str, java.lang.String str1) throws org.xml.sax.SAXException {
1725
        }
1726
                
1727
        public void endPrefixMapping(java.lang.String str) throws org.xml.sax.SAXException {
1728
        }
1729
        
1730
        public void startPrefixMapping(java.lang.String str, java.lang.String str1) throws org.xml.sax.SAXException {
1731
        }
1732
        
1733
        public void characters(char[] values, int param, int param2) throws org.xml.sax.SAXException {
1734
        }
1735
        
1736
        public void setDocumentLocator(org.xml.sax.Locator locator) {
1737
        }
1738
        
1739
        public void startDocument() throws SAXException {
1740
        }
1741
        
1742
        /** Writes data from asociated window manager to the xml representation */
1701
        /** Writes data from asociated window manager to the xml representation */
1743
        void writeData (WindowManagerConfig wmc) throws IOException {
1702
        void writeData (WindowManagerConfig wmc) throws IOException {
1744
            final StringBuffer buff = fillBuffer(wmc);
1703
            final StringBuffer buff = fillBuffer(wmc);
Lines 1893-1929 Link Here
1893
            buff.append("    </tc-list>\n"); // NOI18N
1852
            buff.append("    </tc-list>\n"); // NOI18N
1894
        }
1853
        }
1895
        
1854
        
1896
        /** @return Newly created parser with set content handler, errror handler
1897
         * and entity resolver
1898
         */
1899
        private XMLReader getXMLParser () throws SAXException {
1900
            if (parser == null) {
1901
                // get non validating, not namespace aware parser
1902
                parser = XMLUtil.createXMLReader();
1903
                parser.setContentHandler(this);
1904
                parser.setErrorHandler(this);
1905
                parser.setEntityResolver(this);
1906
            }
1907
            return parser;
1908
        }
1909
1910
        /** Implementation of entity resolver. Points to the local DTD
1911
         * for our public ID */
1912
        public InputSource resolveEntity (String publicId, String systemId)
1913
        throws SAXException {
1914
            if (INSTANCE_DTD_ID_1_0.equals(publicId)
1915
             || INSTANCE_DTD_ID_1_1.equals(publicId)
1916
             || INSTANCE_DTD_ID_2_0.equals(publicId)
1917
             || INSTANCE_DTD_ID_2_1.equals(publicId)) {
1918
                InputStream is = new ByteArrayInputStream(new byte[0]);
1919
                //getClass().getResourceAsStream(INSTANCE_DTD_LOCAL);
1920
//                if (is == null) {
1921
//                    throw new IllegalStateException ("Entity cannot be resolved."); // NOI18N
1922
//                }
1923
                return new InputSource(is);
1924
            }
1925
            return null; // i.e. follow advice of systemID
1926
        }
1927
    }
1855
    }
1928
    
1856
    
1929
    /** Float.parseFloat() shows up as a startup hotspot (classloading?), so this uses a 
1857
    /** Float.parseFloat() shows up as a startup hotspot (classloading?), so this uses a 

Return to bug 51453