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 |
|