示例#1
0
 /** @param b */
 private void setRendererMode(boolean b) {
   rendererMode = b;
   b &= getHelpText() != null;
   renderer.setVisible(b);
   editor.setVisible(!b);
   revalidate();
 }
示例#2
0
 public JPanelPassword(String texte, String passwordInitial, int largeur) {
   password = passwordInitial;
   JLabel jLabel;
   setLayout(new GridLayout(1, 2, 4, 4));
   setPreferredSize(new Dimension(largeur - 20, 20));
   jLabel = new JLabel(texte);
   jLabel.setVisible(true);
   add(jLabel);
   jPasswordField = new JPasswordField(passwordInitial);
   jPasswordField.setVisible(true);
   jPasswordField.addCaretListener(new ActionPasswordGestionnaire());
   add(jPasswordField);
   setVisible(true);
 }
示例#3
0
 private void checkVisibilityOfSmtpAuth() {
   boolean val = cb_smtp_auth.isSelected();
   lb_smtpUser.setVisible(val);
   tf_smtpUser.setVisible(val);
   lb_smtpPW.setVisible(val);
   pf_smtpPW.setVisible(val);
   cb_pwSave.setVisible(val);
   if (!val) {
     tf_smtpUser.setText("");
     pf_smtpPW.setText("");
     cb_pwSave.setSelected(false);
   }
   repaint();
 }
示例#4
0
  public PasswordDialog(LaunchFrame instance, boolean modal) {
    super(instance, modal);

    setIconImage(
        Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/image/logo_ftb.png")));
    setTitle(I18N.getLocaleString("PASSWORD_TITLE"));
    setBounds(300, 300, 300, 120);
    setResizable(false);

    getRootPane().setDefaultButton(submitButton);

    panel.setBounds(0, 0, 300, 100);
    setContentPane(panel);
    panel.setLayout(null);

    passLabel.setBounds(10, 10, 80, 30);
    passLabel.setVisible(true);
    panel.add(passLabel);

    password.setBounds(100, 10, 170, 30);
    password.setVisible(true);
    panel.add(password);

    submitButton.setBounds(105, 50, 90, 25);
    submitButton.setVisible(true);
    submitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            if (!new String(password.getPassword()).isEmpty()) {
              LaunchFrame.tempPass = new String(password.getPassword());
              setVisible(false);
            }
          }
        });
    panel.add(submitButton);
  }
示例#5
0
  /** Initializes the components composing this display. */
  private void initComponents() {
    admin = false;
    active = false;
    groupOwner = false;

    userPicture = new UserProfileCanvas();
    userPicture.setBackground(UIUtilities.BACKGROUND_COLOR);
    userPicture.setToolTipText("Click to upload your picture.");
    IconManager icons = IconManager.getInstance();
    userPicture.setImage(icons.getImageIcon(IconManager.USER_PHOTO_32).getImage());
    loginArea = new JTextField();
    boolean a = MetadataViewerAgent.isAdministrator();
    loginArea.setEnabled(a);
    loginArea.setEditable(a);
    adminBox = new JCheckBox();
    adminBox.setVisible(false);
    adminBox.setBackground(UIUtilities.BACKGROUND_COLOR);
    ownerBox = new JCheckBox();
    ownerBox.setBackground(UIUtilities.BACKGROUND_COLOR);
    activeBox = new JCheckBox();
    activeBox.setBackground(UIUtilities.BACKGROUND_COLOR);
    activeBox.setVisible(false);
    passwordButton = new JButton("Change password");
    passwordButton.setEnabled(false);
    passwordButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    passwordButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            changePassword();
          }
        });
    manageButton = new JButton("Group");
    manageButton.setEnabled(false);
    manageButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    manageButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            manageGroup();
          }
        });
    passwordNew = new JPasswordField();
    passwordNew.setBackground(UIUtilities.BACKGROUND_COLOR);
    passwordConfirm = new JPasswordField();
    passwordConfirm.setBackground(UIUtilities.BACKGROUND_COLOR);
    oldPassword = new JPasswordField();
    oldPassword.setBackground(UIUtilities.BACKGROUND_COLOR);
    items = new HashMap<String, JTextField>();
    ExperimenterData user = (ExperimenterData) model.getRefObject();
    GroupData defaultGroup = user.getDefaultGroup();

    permissionsPane =
        new PermissionsPane(defaultGroup.getPermissions(), UIUtilities.BACKGROUND_COLOR);
    permissionsPane.disablePermissions();
    groupLabel = new JLabel(defaultGroup.getName());
    groupLabel.setBackground(UIUtilities.BACKGROUND_COLOR);

    long groupID = defaultGroup.getId();
    boolean owner = false;
    /*
    if (defaultGroup.getLeaders() != null)
    	owner = setGroupOwner(defaultGroup);
    else {
    	GroupData g = model.loadGroup(groupID);
    	if (g != null)
    		owner = setGroupOwner(g);
    }
    */
    Object parentRootObject = model.getParentRootObject();
    if (parentRootObject instanceof GroupData) {
      owner = setGroupOwner((GroupData) parentRootObject);
    }
    // Build the array for box.
    /*
    Iterator i = userGroups.iterator();
    GroupData g;

    List<GroupData> validGroups = new ArrayList<GroupData>();
    while (i.hasNext()) {
    	g = (GroupData) i.next();
    	if (model.isValidGroup(g))
    		validGroups.add(g);
    }
    groupData = new GroupData[validGroups.size()];
    admin = false;
    active = false;
    int selectedIndex = 0;
    int index = 0;
    i = validGroups.iterator();
    boolean owner = false;
    while (i.hasNext()) {
    	g = (GroupData) i.next();
    	groupData[index] = g;
    	if (g.getId() == groupID) {
    		if (g.getLeaders() != null) {
    			owner = setGroupOwner(g);
    			originalIndex = index;
    		}
    	}
    	index++;
    }
    selectedIndex = originalIndex;
    groups = EditorUtil.createComboBox(groupData, 0);
    groups.setEnabled(false);
    groups.setRenderer(new GroupsRenderer());
    if (groupData.length != 0)
    	groups.setSelectedIndex(selectedIndex);
    */

    if (MetadataViewerAgent.isAdministrator()) {
      // Check that the user is not the one currently logged.
      oldPassword.setVisible(false);
      owner = true;
      adminBox.setVisible(true);
      activeBox.setVisible(true);
      adminBox.addChangeListener(this);
      active = user.isActive();
      activeBox.setSelected(active);
      activeBox.setEnabled(!model.isSelf());
      activeBox.addChangeListener(this);
      // indicate if the user is an administrator.a
      admin = isUserAdministrator();
      adminBox.setSelected(admin);
      ownerBox.addChangeListener(this);
      // admin = false;
      // Now check if the user is the last administrator
    } else {
      ownerBox.setEnabled(false);
      passwordConfirm
          .getDocument()
          .addDocumentListener(
              new DocumentListener() {

                /**
                 * Allows the user to interact with the password controls depending on the value
                 * entered.
                 *
                 * @see DocumentListener#removeUpdate(DocumentEvent)
                 */
                public void removeUpdate(DocumentEvent e) {
                  handlePasswordEntered();
                }

                /**
                 * Allows the user to interact with the password controls depending on the value
                 * entered.
                 *
                 * @see DocumentListener#insertUpdate(DocumentEvent)
                 */
                public void insertUpdate(DocumentEvent e) {
                  handlePasswordEntered();
                }

                /**
                 * Required by the {@link DocumentListener} I/F but no-operation implementation in
                 * our case.
                 *
                 * @see DocumentListener#changedUpdate(DocumentEvent)
                 */
                public void changedUpdate(DocumentEvent e) {}
              });
    }
    passwordNew
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {

              /**
               * Allows the user to interact with the password controls depending on the value
               * entered.
               *
               * @see DocumentListener#removeUpdate(DocumentEvent)
               */
              public void removeUpdate(DocumentEvent e) {
                handlePasswordEntered();
              }

              /**
               * Allows the user to interact with the password controls depending on the value
               * entered.
               *
               * @see DocumentListener#insertUpdate(DocumentEvent)
               */
              public void insertUpdate(DocumentEvent e) {
                handlePasswordEntered();
              }

              /**
               * Required by the {@link DocumentListener} I/F but no-operation implementation in our
               * case.
               *
               * @see DocumentListener#changedUpdate(DocumentEvent)
               */
              public void changedUpdate(DocumentEvent e) {}
            });
    ExperimenterData logUser = MetadataViewerAgent.getUserDetails();
    if (user.getId() == logUser.getId()) {
      userPicture.addMouseListener(
          new MouseAdapter() {

            /** Brings up a chooser to load the user image. */
            public void mouseReleased(MouseEvent e) {
              uploadPicture();
            }
          });
    }
  }