}
};
if (controller.isPropertyEditable(FurnitureLibraryUserPreferencesController.Property.DEFAULT_CREATOR)) {
// Create default author label and its text field bound to DEFAULT_CREATOR controller property
this.defaultCreatorLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences, FurnitureLibraryUserPreferencesPanel.class, "defaultCreatorLabel.text"));
this.defaultCreatorTextField = new JTextField(controller.getDefaultCreator(), 10);
if (!OperatingSystem.isMacOSXLeopardOrSuperior()) {
SwingTools.addAutoSelectionOnFocusGain(this.defaultCreatorTextField);
}
final PropertyChangeListener creatorChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
defaultCreatorTextField.setText(controller.getDefaultCreator());
}
};
controller.addPropertyChangeListener(FurnitureLibraryUserPreferencesController.Property.DEFAULT_CREATOR, creatorChangeListener);
this.defaultCreatorTextField.getDocument().addDocumentListener(new DocumentChangeListener() {
public void changedUpdate(DocumentEvent ev) {
controller.removePropertyChangeListener(FurnitureLibraryUserPreferencesController.Property.DEFAULT_CREATOR, creatorChangeListener);
String defaultCreator = defaultCreatorTextField.getText();
if (defaultCreator == null || defaultCreator.trim().length() == 0) {
controller.setDefaultCreator(null);
} else {
controller.setDefaultCreator(defaultCreator);
}
controller.addPropertyChangeListener(FurnitureLibraryUserPreferencesController.Property.DEFAULT_CREATOR, creatorChangeListener);
}
});
}
if (controller.isPropertyEditable(FurnitureLibraryUserPreferencesController.Property.OFFLINE_FURNITURE_LIBRARY)) {
// Create offline label and check box bound to controller OFFLINE_FURNITURE_LIBRARY property
this.offlineFurnitureLibraryLabel = new JLabel(preferences.getLocalizedString(
FurnitureLibraryUserPreferencesPanel.class, "offlineFurnitureLibraryLabel.text"));
this.offlineFurnitureLibraryCheckBox = new JCheckBox(SwingTools.getLocalizedLabelText(preferences,
FurnitureLibraryUserPreferencesPanel.class, "offlineFurnitureLibraryCheckBox.text"), controller.isFurnitureLibraryOffline());
this.offlineFurnitureLibraryCheckBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent ev) {
controller.setFurnitureLibraryOffline(offlineFurnitureLibraryCheckBox.isSelected());
}
});
controller.addPropertyChangeListener(FurnitureLibraryUserPreferencesController.Property.OFFLINE_FURNITURE_LIBRARY,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
boolean furnitureLibraryOffline = controller.isFurnitureLibraryOffline();
offlineFurnitureLibraryCheckBox.setSelected(furnitureLibraryOffline);
if (furnitureResourcesLocalDirectoryTextField != null) {
furnitureResourcesLocalDirectoryTextField.setEnabled(!furnitureLibraryOffline);
}
if (furnitureResourcesRemoteUrlBaseTextField != null) {
furnitureResourcesRemoteUrlBaseTextField.setEnabled(!furnitureLibraryOffline);
}
}
});
}
if (controller.isPropertyEditable(FurnitureLibraryUserPreferencesController.Property.FURNITURE_RESOURCES_LOCAL_DIRECTORY)) {
// Create local directory label and its text field bound to FURNITURE_RESOURCES_LOCAL_DIRECTORY controller property
this.furnitureResourcesLocalDirectoryLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences, FurnitureLibraryUserPreferencesPanel.class, "furnitureResourcesLocalDirectoryLabel.text"));
this.furnitureResourcesLocalDirectoryTextField = new JTextField(controller.getFurnitureResourcesLocalDirectory(), 20);
this.furnitureResourcesLocalDirectoryTextField.setEnabled(!controller.isFurnitureLibraryOffline());
if (!OperatingSystem.isMacOSXLeopardOrSuperior()) {
SwingTools.addAutoSelectionOnFocusGain(this.furnitureResourcesLocalDirectoryTextField);
}
final PropertyChangeListener localDirectoryChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
furnitureResourcesLocalDirectoryTextField.setText(controller.getFurnitureResourcesLocalDirectory());
}
};
controller.addPropertyChangeListener(FurnitureLibraryUserPreferencesController.Property.FURNITURE_RESOURCES_LOCAL_DIRECTORY, localDirectoryChangeListener);
this.furnitureResourcesLocalDirectoryTextField.getDocument().addDocumentListener(new DocumentChangeListener() {
public void changedUpdate(DocumentEvent ev) {
controller.removePropertyChangeListener(FurnitureLibraryUserPreferencesController.Property.FURNITURE_RESOURCES_LOCAL_DIRECTORY, localDirectoryChangeListener);
String furnitureResourcesLocalDirectory = furnitureResourcesLocalDirectoryTextField.getText();
if (furnitureResourcesLocalDirectory == null || furnitureResourcesLocalDirectory.trim().length() == 0) {
controller.setFurnitureResourcesLocalDirectory(null);
} else {
controller.setFurnitureResourcesLocalDirectory(furnitureResourcesLocalDirectory);
}
controller.addPropertyChangeListener(FurnitureLibraryUserPreferencesController.Property.FURNITURE_RESOURCES_LOCAL_DIRECTORY, localDirectoryChangeListener);
}
});
}
if (controller.isPropertyEditable(FurnitureLibraryUserPreferencesController.Property.FURNITURE_RESOURCES_REMOTE_URL_BASE)) {
// Create URL base label and its text field bound to FURNITURE_RESOURCES_REMOTE_URL_BASE controller property
this.furnitureResourcesRemoteUrlBaseLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences, FurnitureLibraryUserPreferencesPanel.class, "furnitureResourcesRemoteUrlBaseLabel.text"));
this.furnitureResourcesRemoteUrlBaseTextField = new JTextField(controller.getFurnitureResourcesRemoteURLBase(), 20);
this.furnitureResourcesRemoteUrlBaseTextField.setEnabled(!controller.isFurnitureLibraryOffline());
if (!OperatingSystem.isMacOSXLeopardOrSuperior()) {
SwingTools.addAutoSelectionOnFocusGain(this.furnitureResourcesRemoteUrlBaseTextField);
}