private void update() {
   User user = null;
   try {
     user = getUser();
     setEnabled(object != null && (isAdmin() || user.equals(object)));
   } catch (RaplaException ex) {
     setEnabled(false);
     return;
   }
 }
Esempio n. 2
0
 public void testNewUser() throws RaplaException {
   User newUser = facade.newUser();
   newUser.setUsername("newUser");
   try {
     facade.getPreferences(newUser);
     fail("getPreferences should throw an Exception for non existant user");
   } catch (EntityNotFoundException ex) {
   }
   facade.store(newUser);
   Preferences prefs = facade.edit(facade.getPreferences(newUser));
   facade.store(prefs);
 }
 /**
  * add organizer to properties
  *
  * @param appointment
  * @param properties
  */
 private void addOrganizer(
     Appointment appointment, PropertyList properties, boolean doExportAsMeeting) {
   // means we do not export attendees so we do not have a meeting
   if (!doExportAsMeeting) return;
   final User owner = appointment.getReservation().getOwner();
   try {
     Organizer organizer = null;
     if (owner.getEmail() != null && owner.getEmail().trim().length() > 0) {
       try {
         final URI uri = new URI("MAILTO:" + owner.getEmail().trim());
         organizer = new Organizer(uri);
       } catch (URISyntaxException e) {
       }
     }
     if (organizer == null) {
       organizer = new Organizer("MAILTO:" + URLEncoder.encode(owner.getUsername(), "UTF-8"));
     }
     if (!"".equals(owner.getName())) organizer.getParameters().add(new Cn(owner.getName()));
     properties.add(organizer);
   } catch (URISyntaxException e) {
     throw new IllegalArgumentException(e);
   } catch (UnsupportedEncodingException e) {
     throw new IllegalArgumentException(e);
   }
 }
Esempio n. 4
0
 public void actionPerformed(ActionEvent e) {
   try {
     String newMail = emailField.getText();
     getUserModule().changeEmail(newMail);
     emailLabel.setText(user.getEmail());
     dlg.close();
   } catch (RaplaException e1) {
     e1.printStackTrace();
   }
 }
Esempio n. 5
0
  public List<Row> getAttributes(
      Allocatable allocatable, LinkController controller, boolean excludeAdditionalInfos) {
    ArrayList<Row> att = new ArrayList<Row>();
    att.addAll(super.getClassificationAttributes(allocatable, excludeAdditionalInfos, controller));
    final Locale locale = getLocale();
    User owner = allocatable.getOwner();
    User lastChangeBy = allocatable.getLastChangedBy();
    if (owner != null) {
      final String ownerName = owner.getName(locale);
      String ownerText = encode(ownerName);
      if (controller != null) ownerText = controller.createLink(owner, ownerName);

      att.add(new Row(getString("resource.owner"), ownerText));
    }
    if (lastChangeBy != null && (owner == null || !lastChangeBy.equals(owner))) {
      final String lastChangedName = lastChangeBy.getName(locale);
      String lastChangeByText = encode(lastChangedName);
      if (controller != null)
        lastChangeByText = controller.createLink(lastChangeBy, lastChangedName);
      att.add(new Row(getString("last_changed_by"), lastChangeByText));
    }

    return att;
  }
Esempio n. 6
0
  public List<Row> getAttributes(
      Reservation reservation,
      LinkController controller,
      User user,
      boolean excludeAdditionalInfos) {
    ArrayList<Row> att = new ArrayList<Row>();
    att.addAll(getClassificationAttributes(reservation, excludeAdditionalInfos, controller));
    User owner = reservation.getOwner();
    final Locale locale = getLocale();
    if (owner != null) {
      final String ownerName = owner.getName(locale);
      String ownerText = encode(ownerName);
      if (controller != null) ownerText = controller.createLink(owner, ownerName);
      att.add(new Row(getString("reservation.owner"), ownerText));
    }
    User lastChangeBy = reservation.getLastChangedBy();
    if (lastChangeBy != null && (owner == null || !lastChangeBy.equals(owner))) {
      final String lastChangedName = lastChangeBy.getName(locale);
      String lastChangeByText = encode(lastChangedName);
      if (controller != null)
        lastChangeByText = controller.createLink(lastChangeBy, lastChangedName);
      att.add(new Row(getString("last_changed_by"), lastChangeByText));
    }

    Allocatable[] resources = reservation.getResources();
    String resourceList = allocatableList(reservation, resources, user, controller);
    if (resourceList.length() > 0) {
      att.add(new Row(getString("resources"), resourceList));
    }
    Allocatable[] persons = reservation.getPersons();
    String personList = allocatableList(reservation, persons, user, controller);
    if (personList.length() > 0) {
      att.add(new Row(getString("persons"), personList));
    }
    return att;
  }
Esempio n. 7
0
      public void actionPerformed(ActionEvent arg0) {
        try {
          User user = getUserModule().getUser();
          boolean correct;
          try {
            int wert = Integer.parseInt(codeField.getText());
            correct = wert == (Math.abs(user.getEmail().hashCode()));
          } catch (NumberFormatException er) {
            correct = false;
          }
          if (correct) {
            dlg.getButton(0).setEnabled(true);
          } else {
            JOptionPane.showMessageDialog(
                getMainComponent(),
                getString("code_error1"),
                getString("error"),
                JOptionPane.ERROR_MESSAGE);
          }

        } catch (RaplaException ex) {
          showException(ex, getMainComponent());
        }
      }
Esempio n. 8
0
  private void create() throws RaplaException {
    superPanel.removeAll();
    TableLayout tableLayout =
        new TableLayout(
            new double[][] {
              {
                TableLayout.PREFERRED,
                5,
                TableLayout.PREFERRED,
                5,
                TableLayout.PREFERRED,
                5,
                TableLayout.PREFERRED
              },
              {
                TableLayout.PREFERRED,
                5,
                TableLayout.PREFERRED,
                5,
                TableLayout.PREFERRED,
                5,
                TableLayout.PREFERRED,
                5,
                TableLayout.PREFERRED,
                5,
                TableLayout.PREFERRED,
                5,
                TableLayout.PREFERRED
              }
            });
    languageChooser = new LanguageChooser(getLogger(), getI18n(), getRaplaLocale());
    RaplaButton changeNameButton = new RaplaButton();
    RaplaButton changeEmailButton = new RaplaButton();
    RaplaButton changePasswordButton = new RaplaButton();

    superPanel.setLayout(tableLayout);
    superPanel.add(new JLabel(getString("language") + ": "), "0,0");
    superPanel.add(languageChooser.getComponent(), "2,0");
    superPanel.add(new JLabel(getString("username") + ": "), "0,2");
    superPanel.add(usernameLabel, "2,2");
    superPanel.add(new JLabel(), "4,2");
    superPanel.add(new JLabel(getString("name") + ": "), "0,4");
    superPanel.add(nameLabel, "2,4");
    superPanel.add(changeNameButton, "4,4");
    superPanel.add(new JLabel(getString("email") + ": "), "0,6");
    superPanel.add(emailLabel, "2,6");
    superPanel.add(changeEmailButton, "4,6");
    changeNameButton.setText(getString("change"));
    changeNameButton.addActionListener(new MyActionListener());
    nameLabel.setText(this.getClientFacade().getUser().getName());
    emailLabel.setText(this.getClientFacade().getUser().getEmail());
    changeEmailButton.setText(getString("change"));
    changeEmailButton.addActionListener(new MyActionListener2());
    superPanel.add(new JLabel(getString("password") + ":"), "0,8");
    superPanel.add(new JLabel("****"), "2,8");
    superPanel.add(changePasswordButton, "4,8");
    PasswordChangeAction passwordChangeAction =
        new PasswordChangeAction(getContext(), createPopupContext(getComponent(), null));
    User user = getUser();
    passwordChangeAction.changeObject(user);
    changePasswordButton.setAction(new ActionWrapper(passwordChangeAction));
    changePasswordButton.setText(getString("change"));
    usernameLabel.setText(user.getUsername());
  }
Esempio n. 9
0
    public void actionPerformed(ActionEvent arg0) {
      try {
        JPanel test = new JPanel();
        test.setLayout(new BorderLayout());
        JPanel content = new JPanel();
        GridLayout layout = new GridLayout();
        layout.setColumns(2);
        layout.setHgap(5);
        layout.setVgap(5);

        // content.setLayout(new TableLayout(new
        // double[][]{{TableLayout.PREFERRED,5,TableLayout.PREFERRED},{TableLayout.PREFERRED,5,TableLayout.PREFERRED,5,TableLayout.PREFERRED, 5, TableLayout.PREFERRED}}));
        content.setLayout(layout);
        test.add(new JLabel(getString("enter_name")), BorderLayout.NORTH);
        test.add(content, BorderLayout.CENTER);
        User user = getUserModule().getUser();

        Allocatable person = user.getPerson();
        JTextField inputSurname = new JTextField();
        addCopyPaste(inputSurname);
        JTextField inputFirstname = new JTextField();
        addCopyPaste(inputFirstname);
        JTextField inputTitle = new JTextField();
        addCopyPaste(inputTitle);
        // Person connected?
        if (person != null) {
          Classification classification = person.getClassification();
          DynamicType type = classification.getType();
          Map<String, JTextField> map = new LinkedHashMap<String, JTextField>();
          map.put("title", inputTitle);
          map.put("firstname", inputFirstname);
          map.put("forename", inputFirstname);
          map.put("surname", inputSurname);
          map.put("lastname", inputSurname);
          int rows = 0;
          for (Map.Entry<String, JTextField> entry : map.entrySet()) {
            String fieldName = entry.getKey();
            Attribute attribute = type.getAttribute(fieldName);
            JTextField value = entry.getValue();
            if (attribute != null && !content.isAncestorOf(value)) {
              Locale locale = getLocale();
              content.add(new JLabel(attribute.getName(locale)));
              content.add(value);
              Object value2 = classification.getValue(attribute);
              rows++;
              if (value2 != null) {
                value.setText(value2.toString());
              }
            }
          }
          layout.setRows(rows);
        } else {
          content.add(new JLabel(getString("name")));
          content.add(inputSurname);
          inputSurname.setText(user.getName());
          layout.setRows(1);
        }
        DialogUI dlg =
            DialogUI.create(
                getContext(),
                getComponent(),
                true,
                test,
                new String[] {getString("save"), getString("abort")});
        dlg.start();
        if (dlg.getSelectedIndex() == 0) {
          String title = inputTitle.getText();
          String firstname = inputFirstname.getText();
          String surname = inputSurname.getText();
          getUserModule().changeName(title, firstname, surname);

          nameLabel.setText(user.getName());
        }
      } catch (RaplaException ex) {
        showException(ex, getMainComponent());
      }
    }