/** * Updates the view of ModifyProfilePopUpView * * @param obj * @param str */ @Override public void update(Observable obj, String str) { System.out.println("----- ModifyProfilePopUpView.update() -> " + str); User ourProfile = WindowComponent.getInstance().getApiProfile().getCurrentUser(); this.lastNameField.setText(ourProfile.getLastName()); this.firstNameField.setText(ourProfile.getFirstName()); // SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); // String strdate = sdf.format(ourProfile.getBirthDate().getTime()); // this.birthField.setText(strdate); this.avatarField.setText(ourProfile.getAvatarPath()); WindowComponent.getInstance() .getMyProfileComponent() .getModel() .notifyObservers("Profile update"); }
/** Initializes the view of ModifyProfilePopUp */ @Override public void initPanel() { System.out.println("--- ModifyProfilePopUpView.initPanel()"); // Remplissage avec les valeurs déjà enregistrées User ourProfile = WindowComponent.getInstance().getApiProfile().getCurrentUser(); this.lastNameField.setText(ourProfile.getLastName()); this.firstNameField.setText(ourProfile.getFirstName()); // SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); // String strdate = sdf.format(ourProfile.getBirthDate().getTime()); // this.birthField.setText(strdate); this.avatarField.setText(ourProfile.getAvatarPath()); this.avatarBrowseButton.addActionListener(this.getController().new AvatarBrowseListener()); this.cancelButton.addActionListener(this.getController().new CancelListener()); this.submitButton.addActionListener(this.getController().new ModifyMyProfileListener()); this.avatarField.setEditable(false); GroupLayout layout = new GroupLayout(this.getPanel()); this.getPanel().setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addContainerGap() .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) // .addComponent(birthLabel) .addComponent(avatarLabel) .addComponent(lastNameLabel) .addComponent(firstNameLabel)) .addGap(18, 18, 18) .addGroup( layout .createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING, false) // .addComponent(birthField, // javax.swing.GroupLayout.Alignment.LEADING, // javax.swing.GroupLayout.PREFERRED_SIZE, 100, // javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( lastNameField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( firstNameField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( avatarField, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup( layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(avatarBrowseButton) // .addComponent(birthFormatLabel) )) .addGroup( javax.swing.GroupLayout.Alignment.LEADING, layout .createSequentialGroup() .addComponent( cancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .UNRELATED) .addComponent(submitButton))) .addComponent( myProfileLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(11, Short.MAX_VALUE))); layout.setVerticalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addContainerGap() .addComponent( myProfileLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(firstNameLabel) .addComponent( firstNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lastNameLabel) .addComponent( lastNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) /*.addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(birthLabel) .addComponent(birthField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(birthFormatLabel) )*/ .addGap(18, 18, 18) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(avatarLabel) .addComponent( avatarField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(avatarBrowseButton)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cancelButton) .addComponent(submitButton)) .addContainerGap())); }