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.ConfigurationDescriptor.State; |
53 |
import org.netbeans.modules.cnd.makeproject.api.configurations.ConfigurationDescriptorProvider; |
52 |
import org.openide.DialogDisplayer; |
54 |
import org.openide.DialogDisplayer; |
53 |
import org.openide.NotifyDescriptor; |
55 |
import org.openide.NotifyDescriptor; |
54 |
import org.openide.filesystems.FileObject; |
56 |
import org.openide.filesystems.FileObject; |
55 |
import org.openide.filesystems.FileUtil; |
57 |
import org.openide.filesystems.FileUtil; |
56 |
import org.openide.util.NbBundle; |
58 |
import org.openide.util.NbBundle; |
|
|
59 |
import org.openide.util.RequestProcessor; |
60 |
import org.openide.util.RequestProcessor.Task; |
57 |
import org.xml.sax.Attributes; |
61 |
import org.xml.sax.Attributes; |
58 |
|
62 |
|
59 |
/** |
63 |
/** |
Lines 76-103
Link Here
|
76 |
* was: readFromDisk |
80 |
* was: readFromDisk |
77 |
*/ |
81 |
*/ |
78 |
|
82 |
|
79 |
public ConfigurationDescriptor read(String relativeOffset) throws IOException { |
83 |
public ConfigurationDescriptor read(final String relativeOffset) throws IOException { |
80 |
|
84 |
final String tag; |
81 |
String tag = null; |
85 |
final FileObject xml; |
82 |
|
|
|
83 |
// Try first new style file |
86 |
// Try first new style file |
84 |
tag = CommonConfigurationXMLCodec.CONFIGURATION_DESCRIPTOR_ELEMENT; |
87 |
FileObject fo = projectDirectory.getFileObject("nbproject/configurations.xml"); // NOI18N |
85 |
FileObject xml = projectDirectory.getFileObject("nbproject/configurations.xml"); // NOI18N |
88 |
if (fo == null){ |
86 |
if (xml == null) { |
|
|
87 |
// then try old style file.... |
89 |
// then try old style file.... |
88 |
tag = CommonConfigurationXMLCodec.PROJECT_DESCRIPTOR_ELEMENT; |
90 |
tag = CommonConfigurationXMLCodec.PROJECT_DESCRIPTOR_ELEMENT; |
89 |
xml = projectDirectory.getFileObject("nbproject/projectDescriptor.xml"); // NOI18N |
91 |
xml = projectDirectory.getFileObject("nbproject/projectDescriptor.xml"); // NOI18N |
|
|
92 |
} else { |
93 |
tag = CommonConfigurationXMLCodec.CONFIGURATION_DESCRIPTOR_ELEMENT; |
94 |
xml = fo; |
90 |
} |
95 |
} |
91 |
|
96 |
|
92 |
if (xml == null) { |
97 |
if (xml == null) { |
93 |
displayErrorDialog(); |
98 |
displayErrorDialog(); |
94 |
return null; |
99 |
return null; |
95 |
} |
100 |
} |
|
|
101 |
String path = FileUtil.toFile(projectDirectory).getPath(); |
102 |
final MakeConfigurationDescriptor configurationDescriptor = new MakeConfigurationDescriptor(path); |
103 |
Task task = RequestProcessor.getDefault().post(new Runnable() { |
104 |
public void run() { |
105 |
try { |
106 |
try { |
107 |
// To emulate long work |
108 |
Thread.sleep(10000); |
109 |
} catch (InterruptedException ex) { |
110 |
} |
111 |
if (_read(relativeOffset, tag, xml, configurationDescriptor) == null){ |
112 |
// TODO configurationDescriptor is broken |
113 |
configurationDescriptor.setState(State.BROKEN); |
114 |
} |
115 |
} catch (IOException ex) { |
116 |
configurationDescriptor.setState(State.BROKEN); |
117 |
} |
118 |
} |
119 |
}); |
120 |
configurationDescriptor.setInitTask(task); |
121 |
return configurationDescriptor; |
122 |
} |
123 |
|
124 |
public ConfigurationDescriptor _read(String relativeOffset, |
125 |
String tag, FileObject xml, final MakeConfigurationDescriptor configurationDescriptor) throws IOException { |
96 |
|
126 |
|
97 |
boolean success; |
127 |
boolean success; |
98 |
|
128 |
|
99 |
String path = FileUtil.toFile(projectDirectory).getPath(); |
|
|
100 |
final MakeConfigurationDescriptor configurationDescriptor = new MakeConfigurationDescriptor(path); |
101 |
XMLDecoder decoder = |
129 |
XMLDecoder decoder = |
102 |
new ConfigurationXMLCodec(tag, |
130 |
new ConfigurationXMLCodec(tag, |
103 |
projectDirectory, |
131 |
projectDirectory, |
Lines 133-139
Link Here
|
133 |
return configurationDescriptor; |
161 |
return configurationDescriptor; |
134 |
} |
162 |
} |
135 |
} |
163 |
} |
136 |
|
164 |
configurationDescriptor.setState(State.READY); |
|
|
165 |
|
137 |
// Some samples are generated without generated makefile. Don't mark these 'not modified'. Then |
166 |
// Some samples are generated without generated makefile. Don't mark these 'not modified'. Then |
138 |
// the makefiles will be generated before the project is being built |
167 |
// the makefiles will be generated before the project is being built |
139 |
FileObject makeImpl = projectDirectory.getFileObject("nbproject/Makefile-impl.mk"); // NOI18N |
168 |
FileObject makeImpl = projectDirectory.getFileObject("nbproject/Makefile-impl.mk"); // NOI18N |
Lines 162-168
Link Here
|
162 |
// Project is modified and will be saved with current version. This includes samples. |
191 |
// Project is modified and will be saved with current version. This includes samples. |
163 |
configurationDescriptor.setVersion(CommonConfigurationXMLCodec.CURRENT_VERSION); |
192 |
configurationDescriptor.setVersion(CommonConfigurationXMLCodec.CURRENT_VERSION); |
164 |
} |
193 |
} |
165 |
|
194 |
ConfigurationDescriptorProvider.recordMetrics(ConfigurationDescriptorProvider.USG_PROJECT_OPEN_CND, configurationDescriptor); |
166 |
return configurationDescriptor; |
195 |
return configurationDescriptor; |
167 |
} |
196 |
} |
168 |
|
197 |
|