/** * Builds the panel hosting the user's details. * * @return See above. */ private JPanel buildContentPanel() { ExperimenterData user = (ExperimenterData) model.getRefObject(); boolean editable = model.isUserOwner(user); if (!editable) editable = model.isGroupLeader() || MetadataViewerAgent.isAdministrator(); details = EditorUtil.convertExperimenter(user); JPanel content = new JPanel(); content.setBorder(BorderFactory.createTitledBorder("Profile")); content.setBackground(UIUtilities.BACKGROUND_COLOR); Entry entry; Iterator i = details.entrySet().iterator(); JComponent label; JTextField area; String key, value; content.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(0, 2, 2, 0); // Add log in name but cannot edit. c.gridx = 0; c.gridy = 0; c.gridwidth = GridBagConstraints.REMAINDER; // end row c.fill = GridBagConstraints.HORIZONTAL; content.add(userPicture, c); c.gridy++; c.gridx = 0; label = EditorUtil.getLabel(EditorUtil.DISPLAY_NAME, true); label.setBackground(UIUtilities.BACKGROUND_COLOR); c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last c.fill = GridBagConstraints.NONE; // reset to default c.weightx = 0.0; content.add(label, c); c.gridx++; content.add(Box.createHorizontalStrut(5), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; // end row c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; loginArea.setText(user.getUserName()); loginArea.getDocument().addDocumentListener(this); content.add(loginArea, c); while (i.hasNext()) { ++c.gridy; c.gridx = 0; entry = (Entry) i.next(); key = (String) entry.getKey(); value = (String) entry.getValue(); label = EditorUtil.getLabel(key, false); area = new JTextField(value); area.setBackground(UIUtilities.BACKGROUND_COLOR); area.setEditable(editable); area.setEnabled(editable); if (editable) area.getDocument().addDocumentListener(this); items.put(key, area); label.setBackground(UIUtilities.BACKGROUND_COLOR); c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last c.fill = GridBagConstraints.NONE; // reset to default c.weightx = 0.0; content.add(label, c); c.gridx++; content.add(Box.createHorizontalStrut(5), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; // end row c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; content.add(area, c); } c.gridx = 0; c.gridy++; label = EditorUtil.getLabel(EditorUtil.DEFAULT_GROUP, false); c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last c.fill = GridBagConstraints.NONE; // reset to default c.weightx = 0.0; content.add(label, c); c.gridx++; content.add(Box.createHorizontalStrut(5), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; // end row c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; content.add(groupLabel, c); c.gridy++; content.add(permissionsPane, c); // content.add(groups, c); c.gridx = 0; c.gridy++; label = EditorUtil.getLabel(EditorUtil.GROUP_OWNER, false); c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last c.fill = GridBagConstraints.NONE; // reset to default c.weightx = 0.0; content.add(label, c); c.gridx++; content.add(Box.createHorizontalStrut(5), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; // end row c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; content.add(ownerBox, c); if (activeBox.isVisible()) { c.gridx = 0; c.gridy++; label = EditorUtil.getLabel(EditorUtil.ACTIVE, false); c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last c.fill = GridBagConstraints.NONE; // reset to default c.weightx = 0.0; content.add(label, c); c.gridx++; content.add(Box.createHorizontalStrut(5), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; // end row c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; content.add(activeBox, c); } if (adminBox.isVisible()) { c.gridx = 0; c.gridy++; label = EditorUtil.getLabel(EditorUtil.ADMINISTRATOR, false); c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last c.fill = GridBagConstraints.NONE; // reset to default c.weightx = 0.0; content.add(label, c); c.gridx++; content.add(Box.createHorizontalStrut(5), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; // end row c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; content.add(adminBox, c); } c.gridx = 0; c.gridy++; content.add(Box.createHorizontalStrut(10), c); c.gridy++; label = UIUtilities.setTextFont(EditorUtil.MANDATORY_DESCRIPTION, Font.ITALIC); label.setForeground(UIUtilities.REQUIRED_FIELDS_COLOR); c.weightx = 0.0; content.add(label, c); return content; }