/** * 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; }
/** * Builds the UI component hosting the UI component used to modify the password. * * @return See above. */ private JPanel buildPasswordPanel() { JPanel content = new JPanel(); content.setBackground(UIUtilities.BACKGROUND_COLOR); Registry reg = MetadataViewerAgent.getRegistry(); String ldap = (String) reg.lookup(LookupNames.USER_AUTHENTICATION); if (ldap != null && ldap.length() > 0) { content.setBorder(BorderFactory.createTitledBorder("LDAP Authentication")); content.setLayout(new FlowLayout(FlowLayout.LEFT)); content.add(new JLabel(ldap)); return content; } content.setBorder(BorderFactory.createTitledBorder("Change Password")); content.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(0, 2, 2, 0); c.gridx = 0; c.gridy = 0; c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last c.fill = GridBagConstraints.NONE; // reset to default c.weightx = 0.0; if (MetadataViewerAgent.isAdministrator()) { content.add(UIUtilities.setTextFont(PASSWORD_NEW), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; // end row c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; content.add(passwordNew, c); } else { content.add(UIUtilities.setTextFont(PASSWORD_OLD), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; // end row c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; content.add(oldPassword, c); c.gridy++; c.gridx = 0; c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last c.fill = GridBagConstraints.NONE; // reset to default c.weightx = 0.0; content.add(UIUtilities.setTextFont(PASSWORD_NEW), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; // end row c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; content.add(passwordNew, c); c.gridy++; c.gridx = 0; c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last c.fill = GridBagConstraints.NONE; // reset to default c.weightx = 0.0; content.add(UIUtilities.setTextFont(PASSWORD_CONFIRMATION), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; // end row c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; content.add(passwordConfirm, c); c.gridy++; c.gridx = 0; } JPanel p = new JPanel(); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.add(content); JPanel buttonPanel = UIUtilities.buildComponentPanel(passwordButton); buttonPanel.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(buttonPanel); return p; }
/** Builds and lays out the UI. */ private void buildGUI() { removeAll(); JLabel l = new JLabel(); Font f = l.getFont(); int size = f.getSize() - 1; content.removeAll(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); // layout button. // filters JPanel p = UIUtilities.buildComponentPanel(createBar(filterButton, null), 0, 0); p.setBackground(UIUtilities.BACKGROUND_COLOR); content.add(p); // rating p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(UIUtilities.setTextFont("rate", Font.BOLD, size)); p.add(createBar(unrateButton, null)); p.add(Box.createHorizontalStrut(2)); p.add(rating); // p.add(Box.createHorizontalStrut(2)); // p.add(otherRating); content.add(p); // tags and attachments. p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(UIUtilities.setTextFont("tag", Font.BOLD, size)); p.add(createBar(addTagsButton, removeTagsButton)); JPanel panel = new JPanel(new GridBagLayout()); panel.setBorder(null); panel.setBackground(UIUtilities.BACKGROUND_COLOR); GridBagConstraints c = new GridBagConstraints(); // c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last c.fill = GridBagConstraints.NONE; // reset to default c.insets = new Insets(0, 2, 2, 0); c.gridy = 0; c.gridx = 0; panel.add(p, c); p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(UIUtilities.setTextFont("attachment", Font.BOLD, size)); p.add(createBar(addDocsButton, removeDocsButton)); c.gridy = 3; panel.add(p, c); c.gridy = 0; c.gridx++; // c.ipady = 2; c.gridheight = 2; panel.add(tagsPane, c); c.gridy = 3; panel.add(docRef, c); content.add(panel); // analysis results List results = model.getAnalysisResults(); if (results != null && results.size() > 0) { // panel = new JPanel(new GridBagLayout()); // panel.setBorder(null); // panel.setBackground(UIUtilities.BACKGROUND_COLOR); // c = new GridBagConstraints(); // c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last c.fill = GridBagConstraints.NONE; // reset to default c.insets = new Insets(0, 2, 2, 0); c.gridy = 4; c.gridx = 0; p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.setBorder(null); l = UIUtilities.setTextFont("analysis", Font.BOLD, size); l.setToolTipText("Displays the results of analysis run."); p.add(l); panel.add(p, c); Iterator i = results.iterator(); AnalysisResultsItem item; JPanel list = new JPanel(); list.setLayout(new BoxLayout(list, BoxLayout.Y_AXIS)); list.setBackground(UIUtilities.BACKGROUND_COLOR); int n = 0; JPanel row = null; while (i.hasNext()) { item = (AnalysisResultsItem) i.next(); item.addPropertyChangeListener(controller); if (n == 0) { row = initRow(); row.add(item); n++; } else if (n == 1) { row.add(item); list.add(row); n = 0; } } if (row != null) list.add(row); c.gridx++; c.gridheight = 2; panel.add(UIUtilities.buildComponentPanel(list, 0, 0), c); } setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); setBackground(UIUtilities.BACKGROUND); setBorder(new SeparatorOneLineBorder()); add(content); }