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 void main(IWContext iwc) throws Exception {
    parseAction(iwc);
    IWResourceBundle resourceBundle = getResourceBundle(iwc);

    // uploading
    Text uploadingText =
        new Text(
            resourceBundle.getLocalizedString(
                "query_uploader_upload_query_headline", "Upload Query"));
    uploadingText.setBold();
    add(uploadingText);
    Form form = new Form();
    addMaintainParametersToForm(form);
    Table table = new Table(2, 4);
    int row = 1;
    String queryInfo =
        resourceBundle.getLocalizedString("query_uploader_replace_query", "Replace query");
    table.add(queryInfo, 1, row);
    PresentationObject queryList = getDropDownOfQueriesForReplacing(resourceBundle, iwc);
    table.add(queryList, 2, row);
    row++;
    String defaultName =
        resourceBundle.getLocalizedString("query_uploader_default_queryname", "My query");
    TextInput textInput = new TextInput(KEY_QUERY_NAME, defaultName);
    Text info =
        new Text(resourceBundle.getLocalizedString("query_uploader_query_name", "set query name"));
    table.add(info, 1, row);
    table.add(textInput, 2, row);
    row++;
    table.add(getPrivatePublicRadioButtons(resourceBundle), 2, row);
    SimpleFileChooser uploader = new SimpleFileChooser(form, KEY_QUERY_FILE_ID);
    row++;
    table.add(uploader, 2, row);

    form.add(table);
    form.addParameter(KEY_QUERY_UPLOAD_IS_SUBMITTED, KEY_QUERY_UPLOAD_IS_SUBMITTED);
    add(form);

    // downloading
    add(Text.getBreak());
    Text downloadingText =
        new Text(
            resourceBundle.getLocalizedString(
                "query_uploader_download_query_headline", "Download Query"));
    downloadingText.setBold();
    add(downloadingText);
    Form downloadForm = new Form();
    row = 1;
    addMaintainParametersToForm(downloadForm);
    Table downloadTable = new Table(2, 3);
    PresentationObject downloadQueryList = getDropDownOfQueriesForDownloading(iwc);
    downloadTable.add(downloadQueryList, 1, row);
    downloadTable.add(getDownloadButton(resourceBundle), 2, row++);
    if (this.downloadUrl != null) {
      String downloadText =
          resourceBundle.getLocalizedString("query_uploader_download_query", "Download");
      downloadTable.add(new Link(downloadText, this.downloadUrl), 1, row++);
    }
    downloadTable.add(getGoBackButton(resourceBundle), 1, row);
    downloadForm.add(downloadTable);
    add(downloadForm);
  }
 private void addMaintainParametersToForm(Form form) {
   form.addParameter(ReportQueryBuilder.PARAM_LAYOUT_FOLDER_ID, this.layoutFolderId);
 }
  /**
   * this method creates the form for creating new categories as well as editing the properties of
   * existing ones, plus it allows to see all the applications within this category and change their
   * display ordering
   *
   * @throws RemoteException
   */
  private void getCategoryCreationForm(
      IWContext iwc, ApplicationCategory cat, List<ICLocale> locales) throws RemoteException {
    if (cat != null) {
      getApplicationBusiness(iwc).checkApplicationPriorityConstraint(cat);
    }

    Form form = new Form();
    form.setID("applicationCategoryCreator");
    form.setStyleClass("adminForm");

    TextInput tName = new TextInput("name");
    TextArea tDesc = new TextArea("desc");

    if (cat != null) {
      tName.setContent(cat.getName());
      tDesc.setContent(cat.getDescription());
      form.addParameter("id", cat.getPrimaryKey().toString());
    }

    Layer layer = new Layer(Layer.DIV);
    layer.setStyleClass("formSection");
    form.add(layer);

    Layer formItem = new Layer(Layer.DIV);
    formItem.setStyleClass("formItem");
    Label label = new Label(this.iwrb.getLocalizedString("default_name", "Default name"), tName);
    formItem.add(label);
    formItem.add(tName);
    layer.add(formItem);

    formItem = new Layer(Layer.DIV);
    formItem.setStyleClass("formItem");
    label =
        new Label(
            this.iwrb.getLocalizedString("default_description", "Default description"), tDesc);
    formItem.add(label);
    formItem.add(tDesc);
    layer.add(formItem);

    for (Iterator<ICLocale> it = locales.iterator(); it.hasNext(); ) {
      ICLocale locale = it.next();
      Locale javaLocale = ICLocaleBusiness.getLocaleFromLocaleString(locale.getLocale());

      TextInput locInput = new TextInput(locale.getName() + "_locale");
      if (cat != null) {
        LocalizedText text = cat.getLocalizedText(locale.getLocaleID());
        locInput.setValue(text == null ? "" : text.getBody());
      }
      formItem = new Layer(Layer.DIV);
      formItem.setStyleClass("formItem");
      label = new Label(javaLocale.getDisplayLanguage(), locInput);
      formItem.add(label);
      formItem.add(locInput);
      layer.add(formItem);
    }

    List apps = null;
    if (cat != null) {
      try {
        apps =
            new ArrayList(
                getApplicationBusiness(iwc)
                    .getApplicationHome()
                    .findAllByCategoryOrderedByPriority(cat));
      } catch (FinderException f) {
        f.printStackTrace();
      }
    }

    if (apps != null && !apps.isEmpty()) {
      Table2 table = new Table2();
      table.setWidth("100%");
      table.setCellpadding(0);
      table.setCellspacing(0);
      table.setStyleClass("ruler");
      table.setStyleClass("adminTable");

      TableRowGroup group = table.createHeaderRowGroup();
      TableRow row = group.createRow();
      TableCell2 cell = row.createHeaderCell();
      cell.setStyleClass("firstColumn");
      cell.setStyleClass("application");
      cell.add(new Text(this.iwrb.getLocalizedString("application", "Application")));

      cell = row.createHeaderCell();
      cell.setStyleClass("description");
      cell.add(new Text(this.iwrb.getLocalizedString("priority", "Priority")));

      group = table.createBodyRowGroup();
      int iRow = 1;

      Iterator iter = apps.iterator();

      while (iter.hasNext()) {
        Application app = (Application) iter.next();

        row = table.createRow();

        if (iRow % 2 == 0) {
          row.setStyleClass("evenRow");
        } else {
          row.setStyleClass("oddRow");
        }

        cell = row.createCell();
        cell.setStyleClass("firstColumn");
        cell.setStyleClass("application");
        cell.add(new Text(app.getName()));

        cell = row.createCell();
        cell.setStyleClass("description");
        cell.setStyleClass("lastColumn");

        Link up =
            new Link(
                this.iwb.getImage("previous.png", this.iwrb.getLocalizedString("previous", "Up")));
        up.addParameter(PARAMETER_ACTION, ACTION_APP_UP);
        up.addParameter("app_id", app.getPrimaryKey().toString());
        up.addParameter("id", cat.getPrimaryKey().toString());
        up.setStyleClass("flippedImageLink");
        cell.add(up);

        if (iRow <= 1) {
          up.setStyleAttribute("visibility", "hidden");
        }

        Link down =
            new Link(this.iwb.getImage("next.png", this.iwrb.getLocalizedString("next", "Down")));
        down.addParameter(PARAMETER_ACTION, ACTION_APP_DOWN);
        down.addParameter("app_id", app.getPrimaryKey().toString());
        down.addParameter("id", cat.getPrimaryKey().toString());
        down.setStyleClass("flippedImageLink");
        cell.add(down);

        if (iRow >= apps.size()) {
          down.setStyleAttribute("visibility", "hidden");
        }

        iRow++;
      }

      Layer clearLayer = new Layer(Layer.DIV);
      clearLayer.setStyleClass("Clear");
      layer.add(clearLayer);

      form.add(table);
    }

    Layer buttonLayer = new Layer(Layer.DIV);
    buttonLayer.setStyleClass("buttonLayer");
    form.add(buttonLayer);

    SubmitButton back =
        new SubmitButton(this.iwrb.getLocalizedString("back", "Back"), PARAMETER_ACTION, "list");
    buttonLayer.add(back);

    SubmitButton save =
        new SubmitButton(this.iwrb.getLocalizedString("save", "Save"), PARAMETER_ACTION, "save");
    buttonLayer.add(save);

    add(form);
  }
 /* (non-Javadoc)
  * @see com.idega.presentation.ui.AbstractChooser#addParametersToForm(com.idega.presentation.ui.Form)
  */
 @Override
 protected void addParametersToForm(Form form) {
   if (this.submitForm) {
     form.addParameter(GroupChooserWindow.SUBMIT_PARENT_FORM_AFTER_CHANGE, "true");
   }
 }