/**
  * 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);
   }
 }
Exemplo n.º 2
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;
  }
Exemplo n.º 3
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;
  }
Exemplo n.º 4
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());
      }
    }