in app/src/main/java/com/oracle/javafx/scenebuilder/app/preferences/PreferencesRecordDocument.java [486:607]
public void readFromJavaPreferences() {
assert documentPreferences == null;
final URL fxmlLocation = documentWindowController.getEditorController().getFxmlLocation();
if (fxmlLocation == null) {
// Document has not been saved yet => nothing to read
return;
}
// Check if there is some preferences for this document
try {
final File fxmlFile = new File(fxmlLocation.toURI());
final String filePath = fxmlFile.getPath();
final String[] childrenNames = documentsRootPreferences.childrenNames();
for (String child : childrenNames) {
final Preferences pref = documentsRootPreferences.node(child);
final String nodePath = pref.get(PATH, null);
assert nodePath != null && nodePath.isEmpty() == false; // Each document node defines a path
if (filePath.equals(nodePath)) {
documentPreferences = pref;
break;
}
}
} catch (BackingStoreException ex) {
Logger.getLogger(PreferencesRecordDocument.class.getName()).log(Level.SEVERE, null, ex);
return;
} catch (URISyntaxException ex) {
Logger.getLogger(PreferencesRecordDocument.class.getName()).log(Level.SEVERE, null, ex);
}
// There is no preferences for this document in the Java preferences DB
// => nothing to read
if (documentPreferences == null) {
return;
}
// Window position
double xpos = documentPreferences.getDouble(X_POS, DEFAULT_X_POS);
if (xpos < 0) {
xpos = DEFAULT_X_POS;
}
setXPos(xpos);
double ypos = documentPreferences.getDouble(Y_POS, DEFAULT_Y_POS);
if (ypos < 0) {
ypos = DEFAULT_Y_POS;
}
setYPos(ypos);
// Window size
double h = documentPreferences.getDouble(STAGE_HEIGHT, DEFAULT_STAGE_HEIGHT);
if (h < 0) {
h = DEFAULT_STAGE_HEIGHT;
}
setStageHeight(h);
double w = documentPreferences.getDouble(STAGE_WIDTH, DEFAULT_STAGE_WIDTH);
if (w < 0) {
w = DEFAULT_STAGE_WIDTH;
}
setStageWidth(w);
// Panel visibility
final boolean bv = documentPreferences.getBoolean(BOTTOM_VISIBLE,
DEFAULT_BOTTOM_VISIBLE);
setBottomVisible(bv);
final boolean lv = documentPreferences.getBoolean(LEFT_VISIBLE,
DEFAULT_LEFT_VISIBLE);
setLeftVisible(lv);
final boolean rv = documentPreferences.getBoolean(RIGHT_VISIBLE,
DEFAULT_RIGHT_VISIBLE);
setRightVisible(rv);
final boolean libv = documentPreferences.getBoolean(LIBRARY_VISIBLE,
DEFAULT_LIBRARY_VISIBLE);
// Since SB 2.0 b11, the visibility of Library and Document was handled
// independently from the Left visibility.
// Starting from SB 2.0 b12, the visibility of Library and Document is
// linked to the Left visibility.
// We need to handle new preferences as well as old ones :
// hence the value set for Library and Document visible property.
setLibraryVisible(lv && libv);
final boolean docv = documentPreferences.getBoolean(DOCUMENT_VISIBLE,
DEFAULT_DOCUMENT_VISIBLE);
setDocumentVisible(lv && docv);
// Inspector expanded TitledPane
final String sectionId = documentPreferences.get(INSPECTOR_SECTION_ID,
DEFAULT_INSPECTOR_SECTION_ID.name());
setInspectorSectionId(SectionId.valueOf(sectionId));
// Dividers position
final double ldhp = documentPreferences.getDouble(LEFT_DIVIDER_HPOS,
DEFAULT_LEFT_DIVIDER_HPOS);
setLeftDividerHPos(ldhp);
final double rdhp = documentPreferences.getDouble(RIGHT_DIVIDER_HPOS,
DEFAULT_RIGHT_DIVIDER_HPOS);
setRightDividerHPos(rdhp);
final double bdvp = documentPreferences.getDouble(BOTTOM_DIVIDER_VPOS,
DEFAULT_BOTTOM_DIVIDER_VPOS);
setBottomDividerVPos(bdvp);
final double ldvp = documentPreferences.getDouble(LEFT_DIVIDER_VPOS,
DEFAULT_LEFT_DIVIDER_VPOS);
setLeftDividerVPos(ldvp);
// Scene style sheets
final String items = documentPreferences.get(SCENE_STYLE_SHEETS, null);
if (items != null) {
final String[] itemsArray = items.split("\\" + File.pathSeparator); //NOI18N
sceneStyleSheets.addAll(Arrays.asList(itemsArray));
}
// I18NResource
final String resource = documentPreferences.get(I18N_RESOURCE, null); //NOI18N
setI18NResource(resource);
// Theme and Gluon Theme
final String theme = documentPreferences.get(THEME, null);
if (theme != null) {
setTheme(EditorPlatform.Theme.valueOf(theme));
} else {
setTheme(documentWindowController.getEditorController().getTheme());
}
}