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

(-)a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/NativeProjectProvider.java (-2 / +5 lines)
Lines 92-99 Link Here
92
92
93
    public void runOnCodeModelReadiness(Runnable task) {
93
    public void runOnCodeModelReadiness(Runnable task) {
94
        if (getMakeConfigurationDescriptor() != null) {
94
        if (getMakeConfigurationDescriptor() != null) {
95
            DevelopmentHostConfiguration host = ((MakeConfiguration)getMakeConfigurationDescriptor().getConfs().getActive()).getDevelopmentHost();
95
            MakeConfiguration active = (MakeConfiguration)getMakeConfigurationDescriptor().getConfs().getActive();
96
            CompilerSetManagerEvents.get(host.getName()).runOnCodeModelReadiness(task);
96
            if (active != null) {
97
                DevelopmentHostConfiguration host = active.getDevelopmentHost();
98
                CompilerSetManagerEvents.get(host.getName()).runOnCodeModelReadiness(task);
99
            }
97
        }
100
        }
98
    }
101
    }
99
102
(-)a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/ConfigurationDescriptor.java (-2 / +2 lines)
Lines 44-50 Link Here
44
import javax.swing.Icon;
44
import javax.swing.Icon;
45
45
46
public abstract class ConfigurationDescriptor {
46
public abstract class ConfigurationDescriptor {
47
    private Configurations confs;
47
    private Configurations confs = new Configurations();
48
    int version = -1;
48
    int version = -1;
49
49
50
    public ConfigurationDescriptor() {
50
    public ConfigurationDescriptor() {
Lines 104-107 Link Here
104
    public abstract boolean getModified();
104
    public abstract boolean getModified();
105
    public abstract void setModified();
105
    public abstract void setModified();
106
    public abstract void closed();
106
    public abstract void closed();
107
            }
107
}
(-)a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/ConfigurationDescriptorProvider.java (-10 / +3 lines)
Lines 110-125 Link Here
110
                            }
110
                            }
111
                        }
111
                        }
112
                        ConfigurationXMLReader reader = new ConfigurationXMLReader(projectDirectory);
112
                        ConfigurationXMLReader reader = new ConfigurationXMLReader(projectDirectory);
113
                        ConfigurationDescriptor newDescriptor = null;
114
113
115
                        if (SwingUtilities.isEventDispatchThread()) {
116
                            new Exception("Not allowed to use EDT for reading XML descriptor of project!").printStackTrace(System.err); // NOI18N
117
                            // PLEASE DO NOT ADD HACKS like Task.waitFinished()
118
                            // CHANGE YOUR LOGIC INSTEAD
119
120
                            // FIXUP for IZ#146696: cannot open projects: Not allowed to use EDT...
121
                            // return null;
122
                        }
123
                        try {
114
                        try {
124
                            projectDescriptor = reader.read(relativeOffset);
115
                            projectDescriptor = reader.read(relativeOffset);
125
                        } catch (java.io.IOException x) {
116
                        } catch (java.io.IOException x) {
Lines 127-133 Link Here
127
                        }
118
                        }
128
                        
119
                        
129
                        hasTried = true;
120
                        hasTried = true;
130
                        recordMetrics(USG_PROJECT_OPEN_CND, projectDescriptor);
131
                    }
121
                    }
132
                }
122
                }
133
            }
123
            }
Lines 163-168 Link Here
163
        Logger logger = Logger.getLogger("org.netbeans.ui.metrics.cnd"); // NOI18N
153
        Logger logger = Logger.getLogger("org.netbeans.ui.metrics.cnd"); // NOI18N
164
        if (logger.isLoggable(Level.INFO)) {
154
        if (logger.isLoggable(Level.INFO)) {
165
            LogRecord rec = new LogRecord(Level.INFO, msg);
155
            LogRecord rec = new LogRecord(Level.INFO, msg);
156
            if (descr.getConfs() == null || descr.getConfs().getActive() == null){
157
                return;
158
            }
166
                MakeConfiguration makeConfiguration = (MakeConfiguration) descr.getConfs().getActive();
159
                MakeConfiguration makeConfiguration = (MakeConfiguration) descr.getConfs().getActive();
167
                String type;
160
                String type;
168
                switch (makeConfiguration.getConfigurationType().getValue()) {
161
                switch (makeConfiguration.getConfigurationType().getValue()) {
(-)a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/Configurations.java (-4 / +4 lines)
Lines 55-61 Link Here
55
    public static final String PROP_ACTIVE_CONFIGURATION = "activeconfiguration"; // NOI18N
55
    public static final String PROP_ACTIVE_CONFIGURATION = "activeconfiguration"; // NOI18N
56
56
57
    private PropertyChangeSupport pcs;
57
    private PropertyChangeSupport pcs;
58
    private List<Configuration> configurations;
58
    private List<Configuration> configurations = new ArrayList();
59
59
60
    public Configurations() {
60
    public Configurations() {
61
        pcs = new PropertyChangeSupport(this);
61
        pcs = new PropertyChangeSupport(this);
Lines 100-106 Link Here
100
    }
100
    }
101
    */
101
    */
102
    public Configurations init(Configuration[] confs, int defaultConf) {
102
    public Configurations init(Configuration[] confs, int defaultConf) {
103
	configurations = new ArrayList();
103
	configurations.clear();
104
	for (int i = 0; i < confs.length; i ++)
104
	for (int i = 0; i < confs.length; i ++)
105
	    configurations.add(confs[i]);
105
	    configurations.add(confs[i]);
106
	if (defaultConf >= 0 && confs != null && confs.length > 0)
106
	if (defaultConf >= 0 && confs != null && confs.length > 0)
Lines 279-286 Link Here
279
     */
279
     */
280
    private void checkValidIndex(int index) {
280
    private void checkValidIndex(int index) {
281
	if (index < 0 || index >= size()) {
281
	if (index < 0 || index >= size()) {
282
	    ;// Error ???
282
	    // Error ???
283
	    ;// FIXUP ???
283
	    // FIXUP ???
284
	}
284
	}
285
    }
285
    }
286
286
(-)a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/configurations/ConfigurationXMLReader.java (-10 / +41 lines)
Lines 49-59 Link Here
49
import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfigurationDescriptor;
49
import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfigurationDescriptor;
50
import org.netbeans.modules.cnd.api.xml.XMLDecoder;
50
import org.netbeans.modules.cnd.api.xml.XMLDecoder;
51
import org.netbeans.modules.cnd.api.xml.XMLDocReader;
51
import org.netbeans.modules.cnd.api.xml.XMLDocReader;
52
import org.netbeans.modules.cnd.makeproject.api.configurations.ConfigurationDescriptorProvider;
52
import org.openide.DialogDisplayer;
53
import org.openide.DialogDisplayer;
53
import org.openide.NotifyDescriptor;
54
import org.openide.NotifyDescriptor;
54
import org.openide.filesystems.FileObject;
55
import org.openide.filesystems.FileObject;
55
import org.openide.filesystems.FileUtil;
56
import org.openide.filesystems.FileUtil;
56
import org.openide.util.NbBundle;
57
import org.openide.util.NbBundle;
58
import org.openide.util.RequestProcessor;
57
import org.xml.sax.Attributes;
59
import org.xml.sax.Attributes;
58
60
59
/**
61
/**
Lines 76-103 Link Here
76
     * was: readFromDisk
78
     * was: readFromDisk
77
     */
79
     */
78
    
80
    
79
    public ConfigurationDescriptor read(String relativeOffset) throws IOException {
81
    public ConfigurationDescriptor read(final String relativeOffset) throws IOException {
80
        
82
        final String tag;
81
        String tag = null;
83
        final FileObject xml;
82
        
83
        // Try first new style file
84
        // Try first new style file
84
        tag = CommonConfigurationXMLCodec.CONFIGURATION_DESCRIPTOR_ELEMENT;
85
        FileObject fo = projectDirectory.getFileObject("nbproject/configurations.xml"); // NOI18N
85
        FileObject xml = projectDirectory.getFileObject("nbproject/configurations.xml"); // NOI18N
86
        if (fo == null){
86
        if (xml == null) {
87
            // then try old style file....
87
            // then try old style file....
88
            tag = CommonConfigurationXMLCodec.PROJECT_DESCRIPTOR_ELEMENT;
88
            tag = CommonConfigurationXMLCodec.PROJECT_DESCRIPTOR_ELEMENT;
89
            xml = projectDirectory.getFileObject("nbproject/projectDescriptor.xml"); // NOI18N
89
            xml = projectDirectory.getFileObject("nbproject/projectDescriptor.xml"); // NOI18N
90
        } else {
91
            tag = CommonConfigurationXMLCodec.CONFIGURATION_DESCRIPTOR_ELEMENT;
92
            xml = fo;
90
        }
93
        }
91
        
94
        
92
        if (xml == null) {
95
        if (xml == null) {
93
            displayErrorDialog();
96
            displayErrorDialog();
94
            return null;
97
            return null;
95
        }
98
        }
99
        String path = FileUtil.toFile(projectDirectory).getPath();
100
        final MakeConfigurationDescriptor configurationDescriptor = new MakeConfigurationDescriptor(path);
101
        boolean pospone = SwingUtilities.isEventDispatchThread() && xml.getSize() > 8*1024;
102
        if (pospone){
103
              RequestProcessor.getDefault().post(new Runnable() {
104
                public void run() {
105
                    try {
106
                        //System.out.println("Read "+xml.getPath()+" in request processor thread");
107
                        //try {
108
                        //    // To emulate long work
109
                        //    Thread.sleep(10000);
110
                        //} catch (InterruptedException ex) {
111
                        //    Exceptions.printStackTrace(ex);
112
                        //}
113
                        if (_read(relativeOffset, tag, xml, configurationDescriptor) == null){
114
                            // TODO configurationDescriptor is broken
115
                        }
116
                    } catch (IOException ex) {
117
                        // TODO configurationDescriptor is broken
118
                    }
119
                }
120
            });
121
        } else {
122
            return _read(relativeOffset, tag, xml, configurationDescriptor);
123
        }
124
        return configurationDescriptor;
125
    }
126
    
127
    public ConfigurationDescriptor _read(String relativeOffset,
128
            String tag, FileObject xml, final MakeConfigurationDescriptor configurationDescriptor) throws IOException {
96
        
129
        
97
        boolean success;
130
        boolean success;
98
        
131
        
99
        String path = FileUtil.toFile(projectDirectory).getPath();
100
        final MakeConfigurationDescriptor configurationDescriptor = new MakeConfigurationDescriptor(path);
101
        XMLDecoder decoder =
132
        XMLDecoder decoder =
102
                new ConfigurationXMLCodec(tag,
133
                new ConfigurationXMLCodec(tag,
103
                projectDirectory,
134
                projectDirectory,
Lines 162-168 Link Here
162
            // Project is modified and will be saved with current version. This includes samples.
193
            // Project is modified and will be saved with current version. This includes samples.
163
            configurationDescriptor.setVersion(CommonConfigurationXMLCodec.CURRENT_VERSION);
194
            configurationDescriptor.setVersion(CommonConfigurationXMLCodec.CURRENT_VERSION);
164
        }
195
        }
165
        
196
        ConfigurationDescriptorProvider.recordMetrics(ConfigurationDescriptorProvider.USG_PROJECT_OPEN_CND, configurationDescriptor);
166
        return configurationDescriptor;
197
        return configurationDescriptor;
167
    }
198
    }
168
    
199
    

Return to bug 146696