*/
public static Build copyDefaultBuildModelAndLoad(String destination) throws IOException, JAXBException {
InputStream source = RtMetaPlugin.class.getResourceAsStream("resources" + File.separator + IModelConstants.FILE_NAME_BUILD_META_XML);
- return copyDefaultModelAndLoad(Build.class, source, destination);
+ Build model = copyDefaultModelAndLoad(Build.class, source, destination);
+ if (source != null) {
+ source.close();
+ }
+ return model;
}
/**
*/
public static Flash copyDefaultFlashModelAndLoad(String destination) throws IOException, JAXBException {
InputStream source = RtMetaPlugin.class.getResourceAsStream("resources" + File.separator + IModelConstants.FILE_NAME_FLASH_META_XML);
- return copyDefaultModelAndLoad(Flash.class, source, destination);
+ Flash model = copyDefaultModelAndLoad(Flash.class, source, destination);
+ if (source != null) {
+ source.close();
+ }
+ return model;
}
/**
*/
public static Debugs copyDefaultDebugModelAndLoad(String destination) throws IOException, JAXBException {
InputStream source = RtMetaPlugin.class.getResourceAsStream("resources" + File.separator + IModelConstants.FILE_NAME_DEBUG_META_XML);
- return copyDefaultModelAndLoad(Debugs.class, source, destination);
+ Debugs model = copyDefaultModelAndLoad(Debugs.class, source, destination);
+ if (source != null) {
+ source.close();
+ }
+ return model;
}
private static <T> T copyDefaultModelAndLoad(Class<T> clazz, InputStream source, String destination) throws JAXBException, IOException {
throws FileNotFoundException, ParserConfigurationException, SAXException, IOException {
InputStream xsdFileStream = RtMetaPlugin.class.getResourceAsStream("resources/buildSpec.xsd"); //$NON-NLS-1$
validate(xmlFileStream, xsdFileStream);
+ if (xsdFileStream != null) {
+ xsdFileStream.close();
+ }
}
public static void validateFlashFile(InputStream xmlFileStream)
throws FileNotFoundException, ParserConfigurationException, SAXException, IOException {
InputStream xsdFileStream = RtMetaPlugin.class.getResourceAsStream("resources/flashSpec.xsd"); //$NON-NLS-1$
validate(xmlFileStream, xsdFileStream);
+ if (xsdFileStream != null) {
+ xsdFileStream.close();
+ }
}
public static void validateDebugFile(InputStream xmlFileStream)
throws FileNotFoundException, ParserConfigurationException, SAXException, IOException {
InputStream xsdFileStream = RtMetaPlugin.class.getResourceAsStream("resources/debugSpec.xsd"); //$NON-NLS-1$
validate(xmlFileStream, xsdFileStream);
+ if (xsdFileStream != null) {
+ xsdFileStream.close();
+ }
}
}
private String openFileDialog() {
TabFolderManager manager = (TabFolderManager) view.getAdapter(TabFolderManager.class);
CTabItem item = manager.getActiveTabItem();
- Assert.isTrue(!item.isDisposed());
+ Assert.isTrue(item != null && !item.isDisposed());
String DefaultPath = null;
// IProject project = ResourceUtil.getCurrentProject();
}
String result = openFileDialog(DefaultPath, getLogFileName(item.getText()));
// check if dialog cancel
- if (result == null) {
- getSaveLogHandler().setCancelDialog(true);
- } else {
- getSaveLogHandler().setCancelDialog(false);
+ ToggleSaveLogHandler handler = getSaveLogHandler();
+ if (handler != null) {
+ if (result == null) {
+ handler.setCancelDialog(true);
+ } else {
+ handler.setCancelDialog(false);
+ }
}
return result;
}