mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Revert projectFileManager
This commit is contained in:
@@ -4188,7 +4188,7 @@
|
|||||||
<changes>
|
<changes>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Added Project Explorer pane in the right-hand side for quick access to components</description>
|
<description>Added 'Project Explorer' pane in the right-hand side for quick access to components</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
|||||||
@@ -31,8 +31,6 @@ import java.io.OutputStreamWriter;
|
|||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -263,28 +261,25 @@ public class ProjectFileManager {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
warnings.add("Could not read file version number, the file may be corrupted.");
|
warnings.add("Could not read file version number, the file may be corrupted.");
|
||||||
}
|
}
|
||||||
|
FileInputStream fis = new FileInputStream(fileName);
|
||||||
String xml = new String(Files.readAllBytes(Paths.get(fileName)));
|
|
||||||
missingFields.clear();
|
missingFields.clear();
|
||||||
try {
|
try {
|
||||||
xml = cleanupV3XML(xml);
|
Reader reader = new InputStreamReader(fis, "UTF-8");
|
||||||
project = (Project) xStream.fromXML(xml);
|
project = (Project) xStream.fromXML(reader);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.warn("Could not open with the new xStream, trying the old one", e);
|
LOG.warn("Could not open with the new xStream, trying the old one", e);
|
||||||
project = (Project) xStreamOld.fromXML(xml);
|
fis.close();
|
||||||
|
fis = new FileInputStream(fileName);
|
||||||
|
project = (Project) xStreamOld.fromXML(fis);
|
||||||
}
|
}
|
||||||
if (!missingFields.isEmpty()) {
|
if (!missingFields.isEmpty()) {
|
||||||
LOG.warn("The opened file is missing the following properties: " + String.join(", ", missingFields));
|
LOG.warn("The opened file is missing the following properties: " + String.join(", ", missingFields));
|
||||||
warnings.add("The project references unknown component properties, most likely because it was created with a newer version of DIYLC.");
|
warnings.add("The project references unknown component properties, most likely because it was created with a newer version of DIYLC.");
|
||||||
}
|
}
|
||||||
|
fis.close();
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String cleanupV3XML(String xml) {
|
|
||||||
xml = xml.replaceAll("<name defined-in=\"diylc.AbstractComponent\"></name>", "");
|
|
||||||
return xml;
|
|
||||||
}
|
|
||||||
|
|
||||||
private VersionNumber readV3Version(String fileName) throws Exception {
|
private VersionNumber readV3Version(String fileName) throws Exception {
|
||||||
File fXmlFile = new File(fileName);
|
File fXmlFile = new File(fileName);
|
||||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||||
|
|||||||
Reference in New Issue
Block a user