private void LineUpElements(IWContext iwc) {

      Form form = new Form();

      Table frameTable = new Table(3, 3);
      frameTable.setWidth("100%");
      frameTable.setHeight("100%");
      // frameTable.setBorder(1);

      SelectionDoubleBox sdb =
          new SelectionDoubleBox(GroupGroupSetter.FIELDNAME_SELECTION_DOUBLE_BOX, "Not in", "In");

      SelectionBox left = sdb.getLeftBox();
      left.setHeight(8);
      left.selectAllOnSubmit();

      SelectionBox right = sdb.getRightBox();
      right.setHeight(8);
      right.selectAllOnSubmit();

      String stringGroupId = iwc.getParameter(GroupGroupSetter.PARAMETER_GROUP_ID);
      int groupId = Integer.parseInt(stringGroupId);
      form.addParameter(GroupGroupSetter.PARAMETER_GROUP_ID, stringGroupId);

      List directGroups = UserGroupBusiness.getGroupsContainingDirectlyRelated(groupId);

      Iterator iter = null;
      if (directGroups != null) {
        iter = directGroups.iterator();
        while (iter.hasNext()) {
          Object item = iter.next();
          right.addElement(
              Integer.toString(((GenericGroup) item).getID()), ((GenericGroup) item).getName());
        }
      }
      List notDirectGroups = UserGroupBusiness.getRegisteredGroupsNotDirectlyRelated(groupId, iwc);
      if (notDirectGroups != null) {
        iter = notDirectGroups.iterator();
        while (iter.hasNext()) {
          Object item = iter.next();
          left.addElement(
              Integer.toString(((GenericGroup) item).getID()), ((GenericGroup) item).getName());
        }
      }

      // left.addSeparator();
      // right.addSeparator();

      frameTable.setAlignment(2, 2, "center");
      frameTable.add("GroupId: " + groupId, 2, 1);
      frameTable.add(sdb, 2, 2);
      frameTable.add(new SubmitButton("  Save  ", "save", "true"), 2, 3);
      frameTable.add(new CloseButton("  Cancel  "), 2, 3);
      frameTable.setAlignment(2, 3, "right");
      form.add(frameTable);
      this.add(form);
    }
  public Table getNavigationTable(IWContext iwc) {

    int usersSize = 0;
    if (this.users != null) {
      usersSize = this.users.size();
    }

    int maxPage = (int) Math.ceil(usersSize / this.USERS_PER_PAGE);

    Table navigationTable = new Table(3, 1);
    navigationTable.setCellpadding(2);
    navigationTable.setCellspacing(0);
    navigationTable.setWidth(Table.HUNDRED_PERCENT);
    navigationTable.setBorder(0);
    navigationTable.setWidth(1, "33%");
    navigationTable.setWidth(2, "33%");
    navigationTable.setWidth(3, "33%");
    navigationTable.setAlignment(2, 1, Table.HORIZONTAL_ALIGN_CENTER);
    navigationTable.setAlignment(3, 1, Table.HORIZONTAL_ALIGN_RIGHT);

    Text prev = getSmallText(localize("previous", "Previous"));
    Text next = getSmallText(localize("next", "Next"));
    Text info =
        getSmallText(
            localize("page", "Page")
                + " "
                + (this.currentPage + 1)
                + " "
                + localize("of", "of")
                + " "
                + (maxPage + 1));
    if (this.currentPage > 0) {
      Link lPrev = getLink(getSmallText(localize("previous", "Previous")), iwc);
      lPrev.addParameter(this.PARAMETER_CURRENT_PAGE, Integer.toString(this.currentPage - 1));
      lPrev.addParameter(this.PARAMETER_SEARCH, iwc.getParameter(this.PARAMETER_SEARCH));
      if (this.showAll) {
        lPrev.addParameter(this.PARAMETER_VIEW_ALL, "true");
      }
      navigationTable.add(lPrev, 1, 1);
    } else {
      navigationTable.add(prev, 1, 1);
    }
    navigationTable.add(info, 2, 1);

    if (this.currentPage < maxPage) {
      Link lNext = getLink(getSmallText(localize("next", "Next")), iwc);
      lNext.addParameter(this.PARAMETER_CURRENT_PAGE, Integer.toString(this.currentPage + 1));
      lNext.addParameter(this.PARAMETER_SEARCH, iwc.getParameter(this.PARAMETER_SEARCH));
      if (this.showAll) {
        lNext.addParameter(this.PARAMETER_VIEW_ALL, "true");
      }
      navigationTable.add(lNext, 3, 1);
    } else {
      navigationTable.add(next, 3, 1);
    }
    return navigationTable;
  }
  private void addForm(IWContext iwc) {
    Form form = new Form();
    form.maintainParameter(PARAMETER_GROUP_ID);

    Table mainTable = new Table();
    mainTable.setWidth(660);
    mainTable.setHeight(200);
    mainTable.setCellpadding(0);
    mainTable.setCellspacing(0);
    form.add(mainTable);

    Table topTable = new Table(1, 1);
    topTable.setStyleClass(MAIN_STYLECLASS);
    topTable.setWidth(Table.HUNDRED_PERCENT);
    topTable.setHeight(160);

    topTable.add(
        this.iwrb.getLocalizedString(
            UPDATE_INFO, "Press Update to update all clubs linked to this league."),
        1,
        1);

    CloseButton close =
        new CloseButton(
            this.iwrb.getLocalizedImageButton("updateclubdivisiontemplate.close", "Close"));
    SubmitButton start =
        new SubmitButton(
            this.iwrb.getLocalizedImageButton("updateclubdivisiontemplate.update", "Update"),
            ACTION,
            ACTION_UPDATE);
    start.setSubmitConfirm(
        this.iwrb.getLocalizedString(
            "updateclubdivisiontemplate.confirm_message",
            "Are you sure you want to start the update process? The process will start in the background and once it is running you can not stop it nor start a new one."));
    Help help = getHelp(HELP_TEXT_KEY);

    Table bottomTable = new Table();
    bottomTable.setCellpadding(0);
    bottomTable.setCellspacing(5);
    bottomTable.setWidth(Table.HUNDRED_PERCENT);
    bottomTable.setHeight(39);
    bottomTable.setStyleClass(MAIN_STYLECLASS);
    bottomTable.add(help, 1, 1);
    bottomTable.setAlignment(2, 1, Table.HORIZONTAL_ALIGN_RIGHT);
    bottomTable.add(start, 2, 1);
    bottomTable.add(Text.getNonBrakingSpace(), 2, 1);
    bottomTable.add(close, 2, 1);

    mainTable.setVerticalAlignment(1, 1, Table.VERTICAL_ALIGN_TOP);
    mainTable.setVerticalAlignment(1, 3, Table.VERTICAL_ALIGN_TOP);
    mainTable.add(topTable, 1, 1);
    mainTable.add(bottomTable, 1, 3);

    add(form, iwc);
  }
  private void addInfo(IWContext iwc) {
    Form form = new Form();
    form.maintainParameter(PARAMETER_GROUP_ID);

    Table mainTable = new Table();
    mainTable.setWidth(660);
    mainTable.setHeight(200);
    mainTable.setCellpadding(0);
    mainTable.setCellspacing(0);
    form.add(mainTable);

    Table topTable = new Table(1, 1);
    topTable.setStyleClass(MAIN_STYLECLASS);
    topTable.setWidth(Table.HUNDRED_PERCENT);
    topTable.setHeight(160);

    topTable.add(
        this.iwrb.getLocalizedString(
            UPDATE_RUNNING,
            "The update process is now running in the background. You cannot start another one while this one is running."),
        1,
        1);

    CloseButton close =
        new CloseButton(
            this.iwrb.getLocalizedImageButton("updateclubdivisiontemplate.close", "Close"));
    Help help = getHelp(HELP_TEXT_KEY);

    Table bottomTable = new Table();
    bottomTable.setCellpadding(0);
    bottomTable.setCellspacing(5);
    bottomTable.setWidth(Table.HUNDRED_PERCENT);
    bottomTable.setHeight(39);
    bottomTable.setStyleClass(MAIN_STYLECLASS);
    bottomTable.add(help, 1, 1);
    bottomTable.setAlignment(2, 1, Table.HORIZONTAL_ALIGN_RIGHT);
    bottomTable.add(close, 2, 1);

    mainTable.setVerticalAlignment(1, 1, Table.VERTICAL_ALIGN_TOP);
    mainTable.setVerticalAlignment(1, 3, Table.VERTICAL_ALIGN_TOP);
    mainTable.add(topTable, 1, 1);
    mainTable.add(bottomTable, 1, 3);

    add(form, iwc);
  }
 public void main(IWContext iwc) throws Exception {
   // debugParameters(iwc);
   LoginEditor BE = new LoginEditor();
   if (iwc.isParameterSet(PARAM_MESSAGE)) {
     BE.setMessage(iwc.getParameter(PARAM_MESSAGE));
   }
   if (iwc.isParameterSet(PARAM_CHANGE)) {
     BE.setChangeLoginNextTime(true);
   }
   Table T = new Table(1, 1);
   T.setAlignment(1, 1, "center");
   T.setStyleClass(MAIN_STYLECLASS);
   T.add(BE, 1, 1);
   add(T, iwc);
   addTitle(
       getResourceBundle(iwc).getLocalizedString("login_editor", "Login Editor"),
       TITLE_STYLECLASS);
   // setTitle("Login Editor");
   // addTitle("Login Editor");
 }
  // public PresentationObject getVisitForm(IWContext iwc, User userVK) throws
  // java.rmi.RemoteException {
  public UIComponent getDoctorForm() {
    IWResourceBundle iwrb = this.getResourceBundle(_iwc);
    Form myForm = new Form();
    myForm.setName(prmForm);

    Table table = new Table(3, 3);
    table.setCellpadding(0);
    table.setCellspacing(0);
    table.setBorder(0);
    table.setVerticalAlignment(1, 1, Table.VERTICAL_ALIGN_TOP);
    table.setVerticalAlignment(3, 1, Table.VERTICAL_ALIGN_TOP);
    table.setVerticalAlignment(1, 2, Table.VERTICAL_ALIGN_BOTTOM);
    table.setVerticalAlignment(1, 3, Table.VERTICAL_ALIGN_BOTTOM);

    table.setWidth(400);
    table.setWidth(2, 1, 15);
    table.setWidth(1, 1, 73);

    myForm.add(table);

    Age age = null;
    String doctorInfo = null;

    if (user != null && user.getDateOfBirth() != null) age = new Age(user.getDateOfBirth());
    else if (user != null && user.getPersonalID() != null)
      age = new Age(PIDChecker.getInstance().getDateFromPersonalID(user.getPersonalID()));

    int userIDDr = 45;

    if (age != null && age.getYears() >= 70) {
      userIDDr = 46; // 45   41047
    }

    PresentationObject picture = null;
    User doctor = null;

    int userImageID = -1;
    try {
      doctor =
          ((UserBusiness) IBOLookup.getServiceInstance(_iwc, UserBusiness.class)).getUser(userIDDr);
    } catch (Exception fe) {
      log(fe);
    }

    if (doctor != null) userImageID = doctor.getSystemImageID();

    if (userImageID == -1) {
      Table fakeImageTable = new Table(1, 1);
      fakeImageTable.setAlignment(1, 1, Table.HORIZONTAL_ALIGN_CENTER);
      fakeImageTable.setBorder(4);
      fakeImageTable.setHeight(140);
      fakeImageTable.setWidth(100);
      String fakeImageColor = "#CCCCCC";
      Text photoText = new Text(iwrb.getLocalizedString("managerview.photo_text", "Photo"));
      photoText.setBold();
      photoText.setFontColor(fakeImageColor);
      photoText.setFontSize(Text.FONT_SIZE_12_STYLE_TAG);
      fakeImageTable.add(photoText, 1, 1);
      fakeImageTable.setBorderColor(fakeImageColor);
      picture = fakeImageTable;
    } else {
      Image image = new Image();
      image.setImageID(userImageID);
      image.setWidth(73);

      picture = image;
    }
    table.add(picture, 1, 1);

    if (age != null && age.getYears() >= 70) {
      doctorInfo =
          "<b>Dr. Inga Pren</b><br>Allmänläkare<br>Telefon:<br>018-987624<br>Telefontid: Mån-ons, kl 08:30-10.00<br>Webbsida: <a href='http://www.flogsta.se' target='_new'>www.flogsta.se</a>";
    } else {
      doctorInfo =
          "<b>Dr. Magne Syhl</b><br>Allmänläkare<br>Telefon:<br>018-987654<br>Telefontid: Mån-ons, kl 08-10.00<br>Webbsida: <a href='http://www.gimovc.se' target='_new'>www.gimovc.se</a>";
    }

    table.add(doctorInfo, 3, 1);
    GenericButton message =
        getButton(new GenericButton("send_message", localize(prmSendMessage, "Send message")));
    if (_messagePage != null) message.setPageToOpen(_messagePage);

    table.add(message, 3, 2);
    table.setHeight(3, 2, "25");

    GenericButton visitbooking =
        getButton(new GenericButton("visit", localize(prmVisitBooking, "Book an appointment")));
    if (_appointmentPage != null) visitbooking.setPageToOpen(_appointmentPage);

    SubmitButton smb = new SubmitButton();
    smb.setStyleClass("ehealth_InterfaceButton");
    smb.setValue("Skicka meddelande >");
    smb.setPageToOpen(132);

    table.add(visitbooking, 3, 3);

    return myForm;
  }
  private void drawForm(IWContext iwc) {
    Form form = new Form();
    Table T = new Table();
    T.setCellpadding(2);
    T.setCellspacing(2);
    T.setBorder(0);
    form.add(T);

    Table table = new Table();
    //		table.setWidth(getWidth());
    table.setCellpadding(2);
    table.setCellspacing(2);
    table.setBorder(0);
    T.add(table, 1, 1);
    T.setWidth(2, 1, "20");

    T.setVerticalAlignment(1, 1, Table.VERTICAL_ALIGN_BOTTOM);
    T.setVerticalAlignment(3, 1, Table.VERTICAL_ALIGN_BOTTOM);

    int row = 1;

    String personalID =
        PersonalIDFormatter.format(
            user.getPersonalID(), iwc.getIWMainApplication().getSettings().getApplicationLocale());

    table.add(new Break(2), 1, row);
    table.add(getSmallHeader(localize(KEY_PID, DEFAULT_PID)), 1, row);

    if (user.getPersonalID() != null) {
      table.add(getSmallText(personalID), 2, row);
      table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_BOTTOM);
      table.setVerticalAlignment(2, row, Table.VERTICAL_ALIGN_BOTTOM);
    }
    row++;
    table.add(getSmallHeader(localize(KEY_LOGIN, DEFAULT_LOGIN)), 1, row);
    LoginTable loginTable =
        LoginDBHandler.getUserLogin(((Integer) user.getPrimaryKey()).intValue());
    if (loginTable != null) {
      table.add(new HiddenInput(PARAMETER_OLD_LOGIN, loginTable.getUserLogin()), 2, row);
      table.add(getSmallText(loginTable.getUserLogin()), 2, row);
      table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_BOTTOM);
      table.setVerticalAlignment(2, row, Table.VERTICAL_ALIGN_BOTTOM);
    }

    String valueCurrentPassword =
        iwc.getParameter(PARAMETER_CURRENT_PASSWORD) != null
            ? iwc.getParameter(PARAMETER_CURRENT_PASSWORD)
            : "";
    String valueNewPassword =
        iwc.getParameter(PARAMETER_NEW_PASSWORD) != null
            ? iwc.getParameter(PARAMETER_NEW_PASSWORD)
            : "";
    String valueNewPasswordRepeated =
        iwc.getParameter(PARAMETER_NEW_PASSWORD_REPEATED) != null
            ? iwc.getParameter(PARAMETER_NEW_PASSWORD_REPEATED)
            : "";

    // Text tLogin = getSmallHeader(localize(KEY_LOGIN, DEFAULT_LOGIN));
    Text tCurrentPassword =
        getSmallHeader(localize(KEY_CURRENT_PASSWORD, DEFAULT_CURRENT_PASSWORD));
    Text tNewPassword = getSmallHeader(localize(KEY_NEW_PASSWORD, DEFAULT_NEW_PASSWORD));
    Text tNewPasswordRepeated =
        getSmallHeader(localize(KEY_NEW_PASSWORD_REPEATED, DEFAULT_NEW_PASSWORD_REPEATED));

    PasswordInput tiCurrentPassword =
        (PasswordInput) getStyledInterface(new PasswordInput(PARAMETER_CURRENT_PASSWORD));
    if (valueCurrentPassword != null) {
      tiCurrentPassword.setValue(valueCurrentPassword);
    }
    PasswordInput tiNewPassword =
        (PasswordInput) getStyledInterface(new PasswordInput(PARAMETER_NEW_PASSWORD));
    if (valueNewPassword != null) {
      tiNewPassword.setValue(valueNewPassword);
    }
    PasswordInput tiNewPasswordRepeated =
        (PasswordInput) getStyledInterface(new PasswordInput(PARAMETER_NEW_PASSWORD_REPEATED));
    if (valueNewPasswordRepeated != null) {
      tiNewPasswordRepeated.setValue(valueNewPasswordRepeated);
    }

    SubmitButton sbUpdate =
        (SubmitButton)
            getStyledInterface(
                new SubmitButton(
                    localize(KEY_UPDATE, DEFAULT_UPDATE), PARAMETER_FORM_SUBMIT, "true"));

    row++;
    table.setHeight(row, 12);

    if (requirePasswordVerification) {
      row++;
      table.add(tCurrentPassword, 1, row);
      table.add(tiCurrentPassword, 2, row);
    }

    row++;
    table.add(tNewPassword, 1, row);
    table.add(tiNewPassword, 2, row);

    row++;
    table.add(tNewPasswordRepeated, 1, row);
    table.add(tiNewPasswordRepeated, 2, row);

    row++;
    table.setHeight(row, 12);

    row++;
    table.mergeCells(1, row, 2, row);
    table.setAlignment(1, row, Table.HORIZONTAL_ALIGN_RIGHT);

    table.add(Text.NON_BREAKING_SPACE, 1, row);
    table.add(sbUpdate, 1, row);

    add(form);
  }
  public void main(IWContext iwc) throws Exception {

    String providerId = iwc.getParameter(CCConstants.PROVIDER_ID);
    String appId = iwc.getParameter(CCConstants.APPID);
    School school = getChildCareBusiness(iwc).getSchoolBusiness().getSchool(providerId);

    ChildCarePrognosis prognosis =
        getChildCareBusiness(iwc).getPrognosis(Integer.parseInt(providerId));

    String prognosisText =
        prognosis == null
            ? this.style.localize("ccpqw_no_prognosis", "No prognosis available")
            : this.style.localize("ccpqw_three_months", "Three months:")
                + " "
                + prognosis.getThreeMonthsPrognosis()
                + "  "
                + this.style.localize("ccpqw_one_year", "One year:")
                + " "
                + prognosis.getOneYearPrognosis()
                + "  "
                + this.style.localize("ccpqw_updated_date", "Updated date:")
                + " "
                + prognosis.getUpdatedDate();

    Table appTbl = new Table();

    //		add(new Text("ProviderId: " + providerId));
    if (providerId != null) {
      Collection applications =
          getChildCareBusiness(iwc)
              .getOpenAndGrantedApplicationsByProvider(new Integer(providerId).intValue());

      Iterator i = applications.iterator();

      appTbl.add(this.HEADER_ORDER, 1, 1);
      appTbl.add(this.HEADER_QUEUE_DATE, 2, 1);
      appTbl.add(this.HEADER_FROM_DATE, 3, 1);
      appTbl.setRowColor(1, this.style.getHeaderColor());

      int row = 2;

      while (i.hasNext()) {
        ChildCareApplication app = (ChildCareApplication) i.next();

        Text
            queueOrder =
                this.style.getSmallText("" + getChildCareBusiness(iwc).getNumberInQueue(app)),
            queueDate = this.style.getSmallText(app.getQueueDate().toString()),
            fromDate = this.style.getSmallText(app.getFromDate().toString());
        //					currentAppId = style.getSmallText(""+app.getNodeID());   //debug only

        appTbl.add(queueOrder, 1, row);
        appTbl.add(queueDate, 2, row);
        appTbl.add(fromDate, 3, row);
        //				appTbl.add(currentAppId, 4, row);  //debug only

        if (app.getNodeID() == new Integer(appId).intValue()) {
          emphasizeText(queueOrder);
          emphasizeText(queueDate);
          emphasizeText(fromDate);
        }

        if (row % 2 == 0) {
          appTbl.setRowColor(row, this.style.getZebraColor1());
        } else {
          appTbl.setRowColor(row, this.style.getZebraColor2());
        }

        row++;
      }
    }

    Table layoutTbl = new Table();
    layoutTbl.add(this.PROVIDER, 1, 1);
    layoutTbl.add(this.style.getSmallText(school.getName()), 2, 1);

    layoutTbl.setRowHeight(2, "20px");

    layoutTbl.add(this.PROGNOSIS, 1, 3);
    layoutTbl.add(this.style.getSmallText(prognosisText), 2, 3);

    layoutTbl.setRowHeight(4, "20px");

    layoutTbl.add(appTbl, 1, 5);
    layoutTbl.mergeCells(1, 5, 2, 5);

    CloseButton closeBtn = (CloseButton) this.style.getStyledInterface(new CloseButton(this.CLOSE));
    layoutTbl.add(closeBtn, 2, 6);
    layoutTbl.setAlignment(2, 6, "right");

    add(layoutTbl);
  }
  private Table getPlacementTable(IWContext iwc) throws RemoteException {
    Table table = new Table();
    // table.setColor("#DDDDDD");
    table.setBorder(0);
    table.setWidth(Table.HUNDRED_PERCENT);
    table.setCellpadding(1);
    table.setCellspacing(2);
    int col = 1;
    int row = 1;

    // *** HEADING Placements ***
    Text pupilTxt = new Text(localize(KEY_PLACEMENTS_HEADING, "Placements"));
    pupilTxt.setFontStyle(STYLE_UNDERLINED_SMALL_HEADER);
    table.add(pupilTxt, col++, row);
    table.setRowHeight(row, "40");
    table.setRowVerticalAlignment(row, Table.VERTICAL_ALIGN_BOTTOM);
    table.mergeCells(col, row, table.getColumns(), row);
    col = 1;
    row++;

    // empty space row
    table.add(this.transGIF, col, row);
    table.setRowHeight(row, "10");
    col = 1;
    row++;

    //  *** Column headings ***
    table.add(getLocalizedSmallHeader(KEY_NUMBER, "No."), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_SCHOOL_TYPE, "School type"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_PROVIDER, "Provider"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_SCHOOL_YEAR, "School year"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_STUDY_PATH, "Study path"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_SCHOOL_GROUP, "School group"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_START_DATE, "Start date"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_END_DATE, "End date"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_REGISTRATOR, "Registrator"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_REGISTRATION_CREATED_DATE, "Created date"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_PLACEMENT_PARAGRAPH_SHORT, "Par"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_NOTES, "Notes"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(Text.getNonBrakingSpace(), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(Text.getNonBrakingSpace(), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);

    table.setRowColor(row, getHeaderColor());

    table.setRowHeight(row, "18");
    row++;

    // Loop placements
    Collection placements = null;
    try {
      if (this.pupil != null) {
        placements =
            getSchoolBusiness(iwc)
                .getSchoolClassMemberHome()
                .findAllOrderedByRegisterDate(this.pupil);
      }
    } catch (FinderException e) {
    }

    if (placements != null && placements.size() > 0) {
      int zebra = 0;
      int rowNum = 0;
      table.add(new HiddenInput(PARAM_REMOVE_PLACEMENT, "-1"), 1, 1);
      for (Iterator iter = placements.iterator(); iter.hasNext(); ) {
        rowNum++;
        SchoolClassMember plc = (SchoolClassMember) iter.next();
        col = 1;

        // Row number
        table.add(getSmallText(String.valueOf(rowNum)), col++, row);
        // School type
        try {
          table.add(getSmallText(plc.getSchoolType().getName()), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Provider
        try {
          table.add(getSmallText(plc.getSchoolClass().getSchool().getName()), col++, row);
        } catch (Exception e) {
          col++;
        }
        // School year
        try {
          table.add(getSmallText(plc.getSchoolYear().getName()), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Study path
        try {
          if (plc.getStudyPathId() != -1) {
            SchoolStudyPathHome home =
                (SchoolStudyPathHome) IDOLookup.getHome(SchoolStudyPath.class);
            SchoolStudyPath sp = home.findByPrimaryKey(new Integer(plc.getStudyPathId()));
            table.add(getSmallText(sp.getCode()), col, row);
          }
        } catch (Exception e) {
        }
        col++;
        // School type
        try {
          table.add(getSmallText(plc.getSchoolClass().getSchoolClassName()), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Start date
        try {
          String dateStr =
              getCentralPlacementBusiness(iwc).getDateString(plc.getRegisterDate(), "yyyy-MM-dd");
          table.add(getSmallText(dateStr), col++, row);
        } catch (Exception e) {
          col++;
        }
        // End date
        try {
          String dateStr =
              getCentralPlacementBusiness(iwc).getDateString(plc.getRemovedDate(), "yyyy-MM-dd");
          table.add(getSmallText(dateStr), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Registrator
        try {
          int registratorID = plc.getRegistratorId();
          User registrator = getUserBusiness(iwc).getUser(registratorID);
          if (registrator != null) {
            Name name =
                new Name(
                    registrator.getFirstName(),
                    registrator.getMiddleName(),
                    registrator.getLastName());
            table.add(
                getSmallText(name.getName(iwc.getApplicationSettings().getDefaultLocale(), false)),
                col++,
                row);
          }
        } catch (Exception e) {
          col++;
        }
        // Created date
        try {
          String dateStr =
              getCentralPlacementBusiness(iwc)
                  .getDateString(plc.getRegistrationCreatedDate(), "yyyy-MM-dd");
          table.add(getSmallText(dateStr), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Placement paragraph
        try {
          if (plc.getPlacementParagraph() != null) {
            table.add(getSmallText(plc.getPlacementParagraph()), col++, row);
          } else {
            col++;
          }
        } catch (Exception e) {
          col++;
        }
        // Notes
        try {
          if (plc.getNotes() != null) {
            table.add(getSmallText(plc.getNotes()), col++, row);
          } else {
            col++;
          }
        } catch (Exception e) {
          col++;
        }
        // Pupil overview button
        try {
          // Get Pupil overview button
          String plcId = ((Integer) plc.getPrimaryKey()).toString();
          String schClassId = String.valueOf(plc.getSchoolClassId());

          Link editButt =
              new Link(this.getEditIcon(localize(KEY_TOOLTIP_PUPIL_OVERVIEW, "Pupil overview")));
          editButt.setWindowToOpen(PlacementHistoryEditPlacement.class);
          editButt.setParameter(
              SchoolAdminOverview.PARAMETER_METHOD,
              String.valueOf(SchoolAdminOverview.METHOD_OVERVIEW));
          editButt.addParameter(
              SchoolAdminOverview.PARAMETER_METHOD,
              String.valueOf(SchoolAdminOverview.METHOD_OVERVIEW));
          editButt.addParameter(SchoolAdminOverview.PARAMETER_SHOW_ONLY_OVERVIEW, "true");
          editButt.addParameter(SchoolAdminOverview.PARAMETER_SHOW_NO_CHOICES, "true");
          editButt.addParameter(SchoolAdminOverview.PARAMETER_PAGE_ID, getParentPage().getPageID());
          editButt.addParameter(
              SchoolAdminOverview.PARAMETER_USER_ID, String.valueOf(plc.getClassMemberId()));
          editButt.addParameter(SchoolAdminOverview.PARAMETER_SCHOOL_CLASS_ID, schClassId);
          editButt.addParameter(SchoolAdminOverview.PARAMETER_SCHOOL_CLASS_MEMBER_ID, plcId);
          editButt.addParameter(
              SchoolAdminOverview.PARAMETER_RESOURCE_PERMISSION,
              SchoolAdminOverview.PARAMETER_RESOURCE_PERM_VALUE_CENTRAL_ADMIN);
          editButt.addParameter(
              SchoolAdminOverview.PARAMETER_FROM_CENTRAL_PLACEMENT_EDITOR, "true");
          if (plc.getRemovedDate() != null) {
            editButt.addParameter(
                SchoolAdminOverview.PARAMETER_SCHOOL_CLASS_MEMBER_REMOVED_DATE,
                plc.getRemovedDate().toString());
          }

          table.add(editButt, col, row);
          table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
        } catch (Exception e) {
          col++;
        }
        // Remove button
        try {
          // Get remove button
          Image delImg = getDeleteIcon(localize(KEY_TOOLTIP_REMOVE_PLC, "Delete placement"));
          int plcID = ((Integer) plc.getPrimaryKey()).intValue();

          SubmitButton delButt = new SubmitButton(delImg);
          delButt.setValueOnClick(PARAM_REMOVE_PLACEMENT, String.valueOf(plcID));
          delButt.setSubmitConfirm(
              localize(
                  KEY_CONFIRM_REMOVE_PLC_MSG,
                  "Do you really want to erase this school placement and its resource placements?"));
          delButt.setToolTip(localize(KEY_TOOLTIP_REMOVE_PLC, "Delete school placement"));
          table.add(delButt, col, row);
          table.setAlignment(col, row, Table.HORIZONTAL_ALIGN_CENTER);
        } catch (Exception e) {
        }

        String zebraColor = zebra % 2 == 0 ? getZebraColor2() : getZebraColor1();
        table.setRowColor(row, zebraColor);
        col = 2;
        row++;

        // Resources
        String rscStr = getResourceBusiness(iwc).getResourcesStringXtraInfo(plc);
        if (!("".equals(rscStr))) {
          table.add(
              getSmallText("<i>" + localize(KEY_RESOURCES, "Resources") + ":</i> "), col, row);
          table.add(getSmallText("<i>" + rscStr + "</i>"), col, row);
          table.setRowColor(row, zebraColor);
          table.mergeCells(col, row, table.getColumns(), row);
          row++;
        }

        zebra++;
      }
    }

    col = 1;

    // empty space row
    table.add(this.transGIF, col, row);
    table.setRowHeight(row, "20");

    return table;
  }
  /*
   * (non-Javadoc)
   *
   * @see is.idega.idegaweb.member.presentation.UserEditor#presentateUserRelations(com.idega.presentation.IWContext)
   */
  protected void presentUserRelations(IWContext iwc) throws RemoteException {
    Table relationsTable = new Table();
    relationsTable.setCellspacing(4);
    relationsTable.setWidth(Table.HUNDRED_PERCENT);
    int row = 1;

    if (user != null) {
      addSeperator(iwrb.getLocalizedString("mbe.user_relations", "User relations"));
      CommuneFamilyService familyService = getFamilyService(iwc);

      // parent handling
      relationsTable.add(getHeader(iwrb.getLocalizedString("mbe.parents", "Parents")), 1, row++);
      Collection parents = null;
      try {
        parents = familyService.getParentsFor(user);
        if (parents != null && !parents.isEmpty()) {
          for (Iterator iter = parents.iterator(); iter.hasNext(); ) {
            User parent = (User) iter.next();
            relationsTable.add(getRelatedUserLink(parent), 1, row);
            relationsTable.add(
                PersonalIDFormatter.format(parent.getPersonalID(), iwc.getCurrentLocale()),
                2,
                row++);
          }
        }
      } catch (Exception e1) {
      }
      row++;

      // partner handling
      relationsTable.add(getHeader(iwrb.getLocalizedString("mbe.spouse", "Spouse")), 1, row++);
      User partner = null;
      try {
        partner = familyService.getSpouseFor(this.user);
      } catch (NoSpouseFound e) {
      } catch (Exception e) {
      }
      if (partner != null) {
        relationsTable.add(getRelatedUserLink(partner), 1, row);
        relationsTable.add(
            PersonalIDFormatter.format(partner.getPersonalID(), iwc.getCurrentLocale()), 2, row++);
      }
      row++;

      // cohabitant handling
      relationsTable.add(
          getHeader(iwrb.getLocalizedString("mbe.cohabitant", "Cohabitant")), 1, row++);
      User cohabitant = null;
      try {
        cohabitant = familyService.getCohabitantFor(this.user);
      } catch (NoCohabitantFound e) {
      }
      if (cohabitant != null) {
        relationsTable.add(getRelatedUserLink(cohabitant), 1, row);
        relationsTable.add(
            PersonalIDFormatter.format(cohabitant.getPersonalID(), iwc.getCurrentLocale()),
            2,
            row++);
      }
      row++;

      // biological children handling
      relationsTable.add(
          getHeader(iwrb.getLocalizedString("mbe.parential_children", "Parential children")),
          1,
          row++);
      Collection children = null;
      Collection custodianChildren = null;
      Text star = new Text(" *");
      star.setStyleClass(STYLENAME_HEADER);
      try {
        children = familyService.getChildrenFor(user);
        custodianChildren = familyService.getChildrenInCustodyOf(user);
        if (custodianChildren != null && !custodianChildren.isEmpty()) {
          for (Iterator iter = custodianChildren.iterator(); iter.hasNext(); ) {
            User child = (User) iter.next();
            relationsTable.add(getRelatedUserLink(child), 1, row);
            if (children != null && !children.contains(child)) {
              relationsTable.add(star, 1, row);
            }
            relationsTable.add(
                PersonalIDFormatter.format(child.getPersonalID(), iwc.getCurrentLocale()),
                2,
                row++);
            row++;
          }
        }
      } catch (Exception e2) {
      }
    }
    relationsTable.setWidth(1, "300");
    row++;

    Text infoText =
        new Text(
            iwrb.getLocalizedString(
                "person_is_only_custodian", "* Not child, person is only custodian"));
    infoText.setStyleClass(STYLENAME_TEXT);
    relationsTable.add(infoText, 1, row++);
    row++;

    relationsTable.setAlignment(2, row, Table.HORIZONTAL_ALIGN_RIGHT);
    relationsTable.add(getEditButton(iwc, ACTION_EDIT_RELATIONS), 2, row);

    addToMainPart(relationsTable);
  }
  /*
   * (non-Javadoc)
   *
   * @see is.idega.idegaweb.member.presentation.UserEditor#presentateUserRelations(com.idega.presentation.IWContext)
   */
  protected void editUserRelations(IWContext iwc) throws RemoteException {
    Table relationsTable = new Table();
    relationsTable.setWidth(Table.HUNDRED_PERCENT);
    relationsTable.setCellspacing(4);
    int row = 1;

    if (user != null) {
      addSeperator(iwrb.getLocalizedString("mbe.user_relations", "User relations"));
      CommuneFamilyService familyService = getFamilyService(iwc);
      // partner handling
      relationsTable.add(getHeader(iwrb.getLocalizedString("mbe.spouse", "Spouse")), 1, row);
      User partner = null;
      try {
        partner = familyService.getSpouseFor(this.user);
      } catch (NoSpouseFound e) {
      } catch (Exception e) {
      }
      if (partner != null) {
        relationsTable.add(getRelatedUserLink(partner), 2, row);
        relationsTable.add(
            getDisconnectorLink(
                familyService.getSpouseRelationType(),
                null,
                (Integer) user.getPrimaryKey(),
                (Integer) partner.getPrimaryKey(),
                getDeleteIcon(
                    iwrb.getLocalizedString(
                        "mbe.remove_spouse_relation", "Remove spouse relationship"))),
            3,
            row);
      }

      // cohabitant handling
      relationsTable.add(
          getHeader(iwrb.getLocalizedString("mbe.cohabitant", "Cohabitant")), 5, row);
      User cohabitant = null;
      try {
        cohabitant = familyService.getCohabitantFor(this.user);
      } catch (NoCohabitantFound e) {
      }
      if (cohabitant != null) {
        relationsTable.add(getRelatedUserLink(cohabitant), 6, row);
        relationsTable.add(
            getDisconnectorLink(
                familyService.getCohabitantRelationType(),
                null,
                (Integer) user.getPrimaryKey(),
                (Integer) cohabitant.getPrimaryKey(),
                getDeleteIcon(
                    iwrb.getLocalizedString(
                        "mbe.remove_cohabitant_relation", "Remove cohabitant relationship"))),
            7,
            row);
      }
      row++;

      // parent handling
      int parentStartRow = row, custodianStartRow = row;
      relationsTable.add(getHeader(iwrb.getLocalizedString("mbe.parents", "Parents")), 1, row);
      Collection parents = null;
      try {
        parents = familyService.getParentsFor(user);
        if (parents != null && !parents.isEmpty()) {
          for (Iterator iter = parents.iterator(); iter.hasNext(); ) {
            User parent = (User) iter.next();
            relationsTable.add(getRelatedUserLink(parent), 2, parentStartRow);
            String relationType = familyService.getParentRelationType();
            relationsTable.add(
                getDisconnectorLink(
                    null,
                    relationType,
                    (Integer) user.getPrimaryKey(),
                    (Integer) parent.getPrimaryKey(),
                    getDeleteIcon(
                        iwrb.getLocalizedString(
                            "mbe.remove_parent_relation", "Remove parent relationship"))),
                3,
                parentStartRow);
            parentStartRow++;
          }
        }
      } catch (Exception e1) {
      }

      // custodians handling
      relationsTable.add(
          getHeader(iwrb.getLocalizedString("mbe.custodians", "Custodians")), 5, custodianStartRow);
      Collection custodians = null;
      try {
        custodians = familyService.getCustodiansFor(user, false);
        if (custodians != null && !custodians.isEmpty()) {
          for (Iterator iter = custodians.iterator(); iter.hasNext(); ) {
            User custodian = (User) iter.next();
            relationsTable.add(getRelatedUserLink(custodian), 6, custodianStartRow);
            String relationType = familyService.getCustodianRelationType();
            relationsTable.add(
                getDisconnectorLink(
                    null,
                    relationType,
                    (Integer) user.getPrimaryKey(),
                    (Integer) custodian.getPrimaryKey(),
                    getDeleteIcon(
                        iwrb.getLocalizedString(
                            "mbe.remove_custodian_relation", "Remove custodian relationship"))),
                7,
                custodianStartRow);
            custodianStartRow++;
          }
        }
      } catch (Exception e1) {
      }
      row = Math.max(custodianStartRow, parentStartRow) + 1;

      // biological children handling
      relationsTable.add(
          getHeader(iwrb.getLocalizedString("mbe.parential_children", "Parential children")),
          1,
          row);
      Collection children = null;
      int childrowstart = row;
      try {
        children = familyService.getChildrenFor(user);
        if (children != null && !children.isEmpty()) {
          for (Iterator iter = children.iterator(); iter.hasNext(); ) {
            User child = (User) iter.next();
            relationsTable.add(getRelatedUserLink(child), 2, row);
            relationsTable.add(
                getDisconnectorLink(
                    familyService.getParentRelationType(),
                    null,
                    (Integer) user.getPrimaryKey(),
                    (Integer) child.getPrimaryKey(),
                    getDeleteIcon(
                        iwrb.getLocalizedString(
                            "mbe.remove_child_relation", "Remove child relationship"))),
                3,
                row);
            row++;
          }
        }
      } catch (Exception e2) {
      }
      // custody children handling
      row = childrowstart;
      relationsTable.add(
          getHeader(iwrb.getLocalizedString("mbe.custody_children", "Custody children")), 5, row);
      try {
        children = familyService.getChildrenInCustodyOf(user);
        if (children != null && !children.isEmpty()) {
          for (Iterator iter = children.iterator(); iter.hasNext(); ) {
            User child = (User) iter.next();
            relationsTable.add(getRelatedUserLink(child), 6, row);
            relationsTable.add(
                getDisconnectorLink(
                    familyService.getCustodianRelationType(),
                    null,
                    (Integer) user.getPrimaryKey(),
                    (Integer) child.getPrimaryKey(),
                    getDeleteIcon(
                        iwrb.getLocalizedString(
                            "mbe.remove_child_relation", "Remove child relationship"))),
                7,
                row);
            row++;
          }
        }
      } catch (NoChildrenFound e3) {
        // e3.printStackTrace();
      } catch (RemoteException e3) {
        e3.printStackTrace();
      } catch (EJBException e3) {
        e3.printStackTrace();
      }
    }
    relationsTable.setWidth(2, "150");
    relationsTable.setWidth(6, "150");

    row++;
    relationsTable.mergeCells(1, row, relationsTable.getColumns(), row);
    relationsTable.setAlignment(1, row, Table.HORIZONTAL_ALIGN_RIGHT);
    relationsTable.add(getCancelButton(iwc), 1, row);

    addToMainPart(relationsTable);

    presentButtons(iwc);
    presentButtonRegister(iwc);
  }