[ /**
* Default constructor.
* @param manager the mananger containing contacts
* Initialize all non FXML attributes
/
public Controller()
{
/
* Can’t get parent logger now, so standalone logger.
* Parent logger will be set in Main.
*/
logger = LoggerFactory.getParentLogger(getClass(), null, Level.INFO);
/*
* TODO complete Controller(): Load Data file instead
*/
manager = new ContactManager();
PersonalContact p1 = new PersonalContact("Pierre", "Durand", null, null, null, null, null, null);
manager.add(p1);
PersonalContact p2 = new PersonalContact("Sophie", "Durand", null, null, null, null, null, null);
manager.add(p2);
PersonalContact p3 = new PersonalContact("Paul", "Dupont", null, null, null, null, null, null);
manager.add(p3);
CorporateContact ensiie = new CorporateContact("ENSIIE", null, null, null, null, null);
ensiie.add(p1);
ensiie.add(p2);
manager.add(ensiie);
contactsList = manager.getFilteredContacts();
/*
* Setup edition property
*/
edition = new SimpleBooleanProperty();
/*
* Setup Contact view in GridPane
*/
Font.getDefault();
Font font = Font.font(24);
firstName = new EditableLabel("[first]Name", font);
lastName = new EditableLabel("lastName", font);
}
/**
* Controller initialization to initialize FXML related attributes.
* @param location The location used to resolve relative paths for the root
* object, or null if the location is not known.
* @param resources Resource Bundle containing translations resources for
* the UI (or null)
*/
@Override
public void initialize(URL location, ResourceBundle resources)
{
// --------------------------------------------------------------------
// Initialize FXML related attributes
// --------------------------------------------------------------------
/*
* Create #styleableButtons so they can be style-updated in
* - #onDisplayButtonsWithGraphicsOnlyAction
* - #onDisplayButtonsWithTextOnlyAction
* - #onDisplayButtonsWithTextAndGraphicsAction
*/
styleableButtons = new ArrayList<Labeled>();
styleableButtons.add(addButton);
// TODO initialize(URL location, ResourceBundle resources): Add buttons to styleableButtons ...
onDisplayButtonsWithGraphicsOnlyAction(null);
styleableButtons = new ArrayList<Labeled>();
/*
* Share edition on/off property with bidirectional bindings between
* - edition
* - editButton
* - editMenuItem
* - editContextMenuItem
*/
edition.bindBidirectional(editButton.selectedProperty());
// TODO initialize(URL location, ResourceBundle resources): bind edition property bidirectionnaly
/*
* Bind to edition property
* - submitButton and cancelButton visible property
* - firstName & lastName editatble property
* - Contacts details buttons
*/
submitButton.visibleProperty().bind(edition);
cancelButton.visibleProperty().bind(edition);
firstName.editableProperty().bind(edition);
lastName.editableProperty().bind(edition);
// TODO initialize(URL location, ResourceBundle resources): bind various elts to edition property
/*
* TODO initialize(URL location, ResourceBundle resources): Setup ListView's
* - content with setItems
* - and selection mode (SINGLE)
*/
/*
* Set GridPane constraints on #firtName and #lastName
* and addAll to #contactGridPane
*/
GridPane.setConstraints(firstName, 1, 0);
GridPane.setConstraints(lastName, 2, 0);
contactGridPane.getChildren().addAll(firstName, lastName);
/*
* TODO initialize(URL location, ResourceBundle resources): Setup #typeComboBox's
* - content by creating an observable list from Contact.Type.all() : See FXCollections class
* - selected item on selection model to Contact.Type.ALL
*/
/*
* TODO initialize(URL location, ResourceBundle resources): Bind manager properties
* - manager's typeFiltering property to typeComboBox's value property
* - manager's searched property to SearchField's text property
*/
// manager.typeFilteringProperty().bind(...)
// manager.searchedProperty().bind(...);
}
]
New contributor
ALI DAOUDI is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.