if (xmlString != null && xmlString.length() != 0) {
reader = new StringReader(xmlString);
}
// Restore the layout state.
XMLMemento memento = XMLMemento.createReadRoot(reader);
PerspectiveDescriptor newPersp = new PerspectiveDescriptor(
null, null, null);
newPersp.restoreState(memento);
String id = newPersp.getId();
IPerspectiveDescriptor oldPersp = findPerspectiveWithId(id);
if (oldPersp == null) {
add(newPersp);
}
reader.close();
} catch (IOException e) {
unableToLoadPerspective(null);
} catch (WorkbenchException e) {
unableToLoadPerspective(e.getStatus());
}
}
// Get the entries from files, if any
// if -data @noDefault specified the state location may not be
// initialized
IPath path = WorkbenchPlugin.getDefault().getDataLocation();
if (path == null) {
return;
}
File folder = path.toFile();
if (folder.isDirectory()) {
File[] fileList = folder.listFiles();
int nSize = fileList.length;
for (int nX = 0; nX < nSize; nX++) {
File file = fileList[nX];
if (file.getName().endsWith(EXT)) {
// get the memento
InputStream stream = null;
try {
stream = new FileInputStream(file);
reader = new BufferedReader(new InputStreamReader(
stream, "utf-8")); //$NON-NLS-1$
// Restore the layout state.
XMLMemento memento = XMLMemento.createReadRoot(reader);
PerspectiveDescriptor newPersp = new PerspectiveDescriptor(
null, null, null);
newPersp.restoreState(memento);
IPerspectiveDescriptor oldPersp = findPerspectiveWithId(newPersp
.getId());