public static void positionInputLabelPairBelow(
      Control control, Label label, Control widgetAbove, int topMarginHint) {

    int topMargin = DEFAULT_LABEL_INPUT_MARGIN;
    if (topMarginHint >= 0) {
      topMargin = topMarginHint;
    }

    FormData fd = new FormData();
    if (control.getLayoutData() != null && control.getLayoutData() instanceof FormData) {
      fd = (FormData) control.getLayoutData();
    }

    fd.left = new FormAttachment(0, 0);
    if (widgetAbove == null) {
      fd.top = new FormAttachment(0, topMargin);
    } else {
      fd.top = new FormAttachment(widgetAbove, topMargin);
    }
    control.setLayoutData(fd);

    FormData fdl = new FormData();
    if (label.getLayoutData() != null && label.getLayoutData() instanceof FormData) {
      fdl = (FormData) label.getLayoutData();
    }

    fdl.left = new FormAttachment(control, 5, SWT.TOP);
    if (widgetAbove == null) {
      fdl.top = new FormAttachment(0, topMargin);
    } else {
      fdl.top = new FormAttachment(widgetAbove, topMargin);
    }
    label.setLayoutData(fdl);
  }
  public static void positionControlBelow(
      Control control, Control widgetAbove, int topMarginHint, int leftMarginHint) {

    int topMargin = DEFAULT_LABEL_INPUT_MARGIN;
    if (topMarginHint >= 0) {
      topMargin = topMarginHint;
    }

    int leftMargin = LEFT_MARGIN_OFFSET;
    if (leftMarginHint >= 0) {
      leftMargin = leftMarginHint;
    }

    FormData fd = new FormData();
    if (control.getLayoutData() != null && control.getLayoutData() instanceof FormData) {
      fd = (FormData) control.getLayoutData();
    }

    fd.left = new FormAttachment(0, leftMargin);
    if (widgetAbove != null) {
      fd.top = new FormAttachment(widgetAbove, topMargin);
    } else {
      fd.top = new FormAttachment(0);
    }
    control.setLayoutData(fd);
  }
  protected void makeStartCommandControlsVisible(StartCommandType typeToMakeVisible) {
    StartCommandPart part = startCommandAreas.get(typeToMakeVisible);
    Control areaToMakeVisible = part != null ? part.getComposite() : null;

    if (areaToMakeVisible != null && !areaToMakeVisible.isDisposed()) {

      GridData data = (GridData) areaToMakeVisible.getLayoutData();
      GridDataFactory.createFrom(data).exclude(false).applyTo(areaToMakeVisible);
      areaToMakeVisible.setVisible(true);

      // Hide the other sections
      // If hiding, exclude from layout as to not take up space when it is
      // made invisible
      for (StartCommandType otherTypes : startCommandAreas.keySet()) {
        if (!otherTypes.equals(typeToMakeVisible)) {
          StartCommandPart otherArea = startCommandAreas.get(otherTypes);

          if (otherArea != null) {
            Control otherAreaComposite = otherArea.getComposite();

            if (!otherAreaComposite.isDisposed()) {
              data = (GridData) otherAreaComposite.getLayoutData();
              GridDataFactory.createFrom(data).exclude(true).applyTo(otherAreaComposite);

              otherAreaComposite.setVisible(false);
            }
          }
        }
      }

      // Recalculate layout
      areaToMakeVisible.getParent().layout(true, true);
    }
  }
Example #4
0
  @Override
  protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    POPUP_LAYOUT_FACTORY.applyTo(composite);

    // LAYOUTDATA_GRAB_BOTH.applyTo(composite);
    GridData gd = LAYOUTDATA_GRAB_BOTH.create();

    composite.setLayoutData(gd);
    if (hasTitleArea()) {
      createTitleMenuArea(composite);
      createHorizontalSeparator(composite);
    }
    dialogArea = createDialogArea(composite);
    if (dialogArea.getLayoutData() == null) LAYOUTDATA_GRAB_BOTH.applyTo(composite);

    gd = LAYOUTDATA_GRAB_BOTH.create();
    dialogArea.pack();
    gd.widthHint = dialogArea.getSize().x;
    gd.heightHint = dialogArea.getSize().y;
    dialogArea.setLayoutData(gd);

    if (hasInfoArea()) {
      createHorizontalSeparator(composite);
      createInfoTextArea(composite);
    }
    return composite;
  }
Example #5
0
 /**
  * excludes a control from the Layout calculation
  *
  * @param that
  * @param hideit
  */
 private void hideObject(final Control that, final boolean hideit) {
   GridData GData = (GridData) that.getLayoutData();
   GData.exclude = true && hideit;
   that.setVisible(true && !hideit);
   Control[] myArray = {that};
   layout(myArray);
 }
Example #6
0
  /**
   * @return the total GridData.horizontalSpan of all controls, except excluded controls and the
   *     control we are about lay out.
   */
  private int getTotalHorizontalSpan(Composite composite) {

    Control[] children = composite.getChildren();

    int totalHorizontalSpan = 0;

    for (int loop = 0, length = children.length - 1; loop < length; loop++) {

      Control child = children[loop];
      GridData gridData = (GridData) child.getLayoutData();

      // Manually added controls, that have not been laid out yet, will have no GridData

      if (gridData == null) {
        continue;
      }

      // Stubs will be excluded

      if (gridData.exclude) {
        continue;
      }

      totalHorizontalSpan += gridData.horizontalSpan;
    }

    return totalHorizontalSpan;
  }
 @Override
 protected void adjustForNumColumns(int numColumns) {
   Control control = getLabelControl();
   if (control != null) {
     ((GridData) control.getLayoutData()).horizontalSpan = numColumns;
   }
   ((GridData) fCombo.getLayoutData()).horizontalSpan = numColumns;
 }
 private static void showControl(boolean show, Control control) {
   Object data = control.getLayoutData();
   if (data instanceof GridData) {
     GridData gridData = (GridData) data;
     gridData.exclude = !show;
   }
   control.setVisible(show);
 }
Example #9
0
 /*
  * Overridden to adjust the span of the title label. Reachy, reachy.... (non-Javadoc)
  * @see org.eclipse.jface.dialogs.PopupDialog#createTitleControl(org.eclipse.swt.widgets.Composite)
  */
 protected Control createTitleControl(Composite parent) {
   Control control = super.createTitleControl(parent);
   Object data = control.getLayoutData();
   if (data instanceof GridData) {
     ((GridData) data).horizontalSpan = 1;
   }
   return control;
 }
Example #10
0
 /**
  * Get the column span for a particular child. This is obtained from the layout data's GridData
  * object.
  *
  * @param child the child control.
  * @return -1 if nothing was found or the value of the horizontal span.
  */
 private int getColumnSpan(Control child) {
   int horizontalSpan = -1;
   final GridData gridData = ((GridData) child.getLayoutData());
   if (gridData != null) {
     horizontalSpan = gridData.horizontalSpan;
   }
   return horizontalSpan;
 }
 private void hideControl(Control control, boolean hide, boolean autoLayout) {
   control.setVisible(!hide);
   GridData layoutData = (GridData) control.getLayoutData();
   layoutData.exclude = hide;
   if (autoLayout) {
     control.getParent().layout();
   }
 }
Example #12
0
  /**
   * Sets the visibility of a control. Includes setting of the include property of the layoutData
   * (if available)
   *
   * @param visible
   */
  public static void setVisiblity(Control control, boolean visible) {
    if (control == null) {
      return;
    }

    control.setVisible(visible);
    Object layoutData = control.getLayoutData();
    if (layoutData instanceof GridData) {
      ((GridData) layoutData).exclude = !visible;
    }
  }
  /* (non-Javadoc)
   * @see org.eclipse.jface.dialogs.Dialog#createButtonBar(org.eclipse.swt.widgets.Composite)
   */
  @Override
  protected Control createButtonBar(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.horizontalSpacing = 0;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    composite.setFont(parent.getFont());

    // create the localization button
    Control localizationControl = createLocalizationControl(composite);
    ((GridData) localizationControl.getLayoutData()).horizontalIndent =
        convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);

    Control buttonSection = super.createButtonBar(composite);
    ((GridData) buttonSection.getLayoutData()).grabExcessHorizontalSpace = true;
    return composite;
  }
Example #14
0
 private static void recirsivelySetExclude(Control widget, boolean hide) {
   Object data = widget.getLayoutData();
   if (data instanceof GridData) {
     ((GridData) data).exclude = hide;
   }
   if (widget instanceof Composite) {
     Control[] controls = ((Composite) widget).getChildren();
     for (Control control : controls) {
       recirsivelySetExclude(control, hide);
     }
   }
 }
 private void showControlGroup(String group, boolean show) {
   List<Control> controlList = propGroupMap.get(group);
   if (controlList != null) {
     for (Control control : controlList) {
       GridData gd = (GridData) control.getLayoutData();
       if (gd == null) {
         gd = new GridData(GridData.BEGINNING);
         control.setLayoutData(gd);
       }
       gd.exclude = !show;
       control.setVisible(show);
     }
   }
 }
  /**
   * @inheritDoc このクラスではパネルを正方形に使います。
   * @see IgoOutlinePanel#setSizeHint(Point)
   */
  public void setSizeHint(Point boardSize) {
    ArgumentChecker.throwIfNull(boardSize);

    GridData gridData;
    gridData = (GridData) frame_.getLayoutData();
    gridData.widthHint = boardSize.x;

    int margin = ((GridLayout) frame_.getLayout()).marginWidth;
    gridData = (GridData) boardControl_.getLayoutData();
    gridData.widthHint = boardSize.x - frame_.getBorderWidth() * 2 - margin * 2;
    gridData.heightHint = boardSize.y - frame_.getBorderWidth() * 2 - margin * 2;

    gridData = (GridData) annotationLabel_.getLayoutData();
    gridData.widthHint = boardSize.x - frame_.getBorderWidth() * 2 - margin * 2;
  }
Example #17
0
 protected void getControls(Composite composite) {
   // Iterate through all the controls, setting
   // the member data according to the BorderData.
   // Note that we overwrite any previously set data.
   // Note also that we default to CENTER
   Control[] children = composite.getChildren();
   for (int i = 0, n = children.length; i < n; i++) {
     Control child = children[i];
     Integer borderData = (Integer) child.getLayoutData();
     if (borderData == NORTH) north = child;
     else if (borderData == SOUTH) south = child;
     else if (borderData == EAST) east = child;
     else if (borderData == WEST) west = child;
     else center = child;
   }
 }
 private void createTextValueComposite(int span) {
   if (!(value instanceof Text)) {
     Composite parent = value.getParent();
     if (value != null) {
       value.dispose();
     }
     value = new Text(parent, SWT.BORDER | SWT.LEAD | SWT.DROP_DOWN);
     ((Text) value).addModifyListener(modifyListener);
     GridData vgd = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL);
     vgd.horizontalSpan = span;
     value.setLayoutData(vgd);
   } else {
     ((GridData) value.getLayoutData()).horizontalSpan = span;
     ((Text) value).setText(""); // $NON-NLS-1$
   }
   value.getParent().layout();
 }
 /**
  * Create the sash with right control on the right. Note that this method assumes GridData for the
  * layout data of the rightControl.
  *
  * @param composite
  * @param rightControl
  * @return Sash
  * @since 3.1
  */
 protected Sash createSash(final Composite composite, final Control rightControl) {
   final Sash sash = new Sash(composite, SWT.VERTICAL);
   sash.setLayoutData(new GridData(GridData.FILL_VERTICAL));
   sash.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
   // the following listener resizes the tree control based on sash deltas.
   // If necessary, it will also grow/shrink the dialog.
   sash.addListener(
       SWT.Selection,
       event -> {
         if (event.detail == SWT.DRAG) {
           return;
         }
         int shift = event.x - sash.getBounds().x;
         GridData data = (GridData) rightControl.getLayoutData();
         int newWidthHint = data.widthHint + shift;
         if (newWidthHint < 20) {
           return;
         }
         Point computedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
         Point currentSize = getShell().getSize();
         // if the dialog wasn't of a custom size we know we can shrink
         // it if necessary based on sash movement.
         boolean customSize = !computedSize.equals(currentSize);
         data.widthHint = newWidthHint;
         setLastTreeWidth(newWidthHint);
         composite.layout(true);
         // recompute based on new widget size
         computedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
         // if the dialog was of a custom size then increase it only if
         // necessary.
         if (customSize) {
           computedSize.x = Math.max(computedSize.x, currentSize.x);
         }
         computedSize.y = Math.max(computedSize.y, currentSize.y);
         if (computedSize.equals(currentSize)) {
           return;
         }
         setShellSize(computedSize.x, computedSize.y);
         lastShellSize = getShell().getSize();
       });
   return sash;
 }
  /**
   * Synchronizes this Composite's layout with the given GridLayoutRule's data. Ensures that, at the
   * end of the method execution, all children of the Composite have a layout's data either null or
   * of type GridData.
   */
  public static void platformSpecificRefresh(Object containerView, GridLayoutRule rule) {
    assert rule != null;
    if (!(containerView instanceof SWTContainerView)) return;
    final Composite context = (Composite) ((SWTContainerView) containerView).getContentPane();
    if (context == null || context.isDisposed()) return;

    final Layout previousLayout = context.getLayout();
    context.setLayout(convertIntoSWTGridLayout(rule));

    // we check if we changed the type of the layout
    if (previousLayout == null && context.getLayout() == null) return;
    if (previousLayout != null
        && context.getLayout() != null
        && previousLayout.getClass().equals(context.getLayout().getClass())) return;

    for (Control child : context.getChildren())
      if (!(child.getLayoutData() instanceof GridData)) {
        Object data = child.getData(SWTWidgetView.WAZAABI_HOST_KEY);
        if (data instanceof AbstractComponentEditPart)
          child.setLayoutData(
              GridDataStyleRuleManager.getFirstGridData((AbstractComponentEditPart) data));
      }
  }
Example #21
0
  /**
   * @return the last control in the composite, except excluded controls and the control we are
   *     about lay out.
   */
  private Control getLastNonExcludedControl(Composite composite) {

    Control[] children = composite.getChildren();

    for (int loop = children.length - 2; loop > 0; loop--) {

      Control child = children[loop];
      GridData gridData = (GridData) child.getLayoutData();

      // Manually added controls, that have not been laid out yet, will have no GridData

      if (gridData == null) {
        continue;
      }

      // Stubs will be excluded

      if (!gridData.exclude) {
        return child;
      }
    }

    return null;
  }
Example #22
0
  /**
   * Evaluates each of the controls and determines the largest width. Then sets each control with
   * the largest width. Each control must have a GridData as its layout data
   *
   * @param controls
   */
  public static void resizeControlWidthInGrid(Collection<Control> controls) {
    int largestWidth = SWT.DEFAULT;
    List<GridData> gridDatas = new ArrayList<GridData>();
    for (Control control : controls) {
      Object layoutData = control.getLayoutData();
      if (layoutData instanceof GridData) {
        GridData gridData = (GridData) layoutData;
        gridDatas.add(gridData);

        if (gridData.widthHint > largestWidth) {
          largestWidth = gridData.widthHint;
        } else {
          int preferredX = control.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
          if (preferredX > largestWidth) {
            largestWidth = preferredX;
          }
        }
      }
    }

    for (GridData gridData : gridDatas) {
      gridData.widthHint = largestWidth;
    }
  }
Example #23
0
  public ViewerToolBar(IViewerBinding viewer, int style) {
    myViewer = viewer;
    myStyle = style;

    // TODO: Check style

    myViewer.registerService(this);

    final IManager manager = IManager.Factory.getManager();
    myToolkit = manager.getFormToolkit();

    final IServiceLocator serviceLocator = getViewer().getContext().getServiceLocator();
    myCommandService = (ICommandService) serviceLocator.getService(ICommandService.class);
    myHandlerService = (IHandlerService) serviceLocator.getService(IHandlerService.class);
    myCommandImageService =
        (ICommandImageService) serviceLocator.getService(ICommandImageService.class);

    /*
     * Find the control of the viewer (a Table or Tree).
     *
     * Find the parent Composite.
     *
     * Add a new Composite (with a GridLayout) and reparent the control
     *
     * Then add the toolbar itself on the correct side of the control
     */
    final Control control = myViewer.getControl();
    final Composite parent = control.getParent();

    myComposite = myToolkit.createComposite(parent);
    myComposite.setLayoutData(control.getLayoutData());
    final GridLayout compLayout = new GridLayout(1, false);
    myComposite.setLayout(compLayout);

    control.setParent(myComposite);
    control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    myToolBar = new ToolBar(myComposite, SWT.FLAT | (style & (VERTICAL | HORIZONTAL)));
    if ((style & VERTICAL) != 0) {
      myToolBar.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, false, false));
      compLayout.numColumns = 2;
    } else {
      myToolBar.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false));
    }
    /*
     * Inlined from FormToolkit.adapt(Composite composite). Do not set focus though.
     */
    myToolBar.setBackground(myComposite.getBackground());
    myToolBar.setMenu(myComposite.getMenu());

    myViewer.registerWidget(myToolBar);

    /*
     * Add standard items
     */
    if ((style & ADD) != 0) {
      // TODO addItem(ADD, "");
    }
    if ((style & DELETE) != 0) {
      addItem(
          DELETE,
          IManager.Factory.getManager()
              .getCommandIDs()
              .get(IWorkbenchCommandConstants.EDIT_DELETE));
    }
    if ((style & UP) != 0) {
      addItem(UP, "com.rcpcompany.uibindings.commands.moveItemUp");
    }
    if ((style & DOWN) != 0) {
      addItem(DOWN, "com.rcpcompany.uibindings.commands.moveItemDown");
    }

    myComposite.layout(true);
  }
Example #24
0
  public void layoutWidget(
      Control control,
      String elementName,
      Map<String, String> attributes,
      Composite composite,
      SwtMetawidget metawidget) {

    // Do not layout space for empty stubs

    if (control instanceof Stub && ((Stub) control).getChildren().length == 0) {
      GridData stubData = new GridData();
      stubData.exclude = true;
      control.setLayoutData(stubData);
      return;
    }

    // Special support for large controls (make the previous control span all and kick us to the
    // next row)

    boolean spanAllColumns = willFillHorizontally(control, attributes);

    if (spanAllColumns) {
      int totalHorizontalSpan = getTotalHorizontalSpan(composite);
      int numberColumnsRemainingOnRow =
          totalHorizontalSpan % (mNumberOfColumns * LABEL_AND_CONTROL);

      if (numberColumnsRemainingOnRow != 0) {
        Control lastControl = getLastNonExcludedControl(composite);
        ((GridData) lastControl.getLayoutData()).horizontalSpan = numberColumnsRemainingOnRow + 1;
      }
    }

    // Layout a label...

    String labelText = null;

    if (attributes != null) {
      labelText = metawidget.getLabelString(attributes);
    }

    layoutBeforeChild(control, labelText, elementName, attributes, composite, metawidget);

    // ...and layout the control

    GridData controlLayoutData = new GridData();
    controlLayoutData.grabExcessHorizontalSpace = true;

    if (!(control instanceof Button)) {
      controlLayoutData.horizontalAlignment = SWT.FILL;
      controlLayoutData.verticalAlignment = SWT.FILL;
    }

    if (spanAllColumns) {
      controlLayoutData.horizontalSpan = mNumberOfColumns * LABEL_AND_CONTROL;

      if (SimpleLayoutUtils.needsLabel(labelText, elementName)) {
        controlLayoutData.horizontalSpan--;
      }
    } else if (!SimpleLayoutUtils.needsLabel(labelText, elementName)) {
      controlLayoutData.horizontalSpan = LABEL_AND_CONTROL;
    }

    if (willFillVertically(control, attributes)) {
      controlLayoutData.grabExcessVerticalSpace = true;
    }

    // Add it

    control.setLayoutData(controlLayoutData);
  }
 protected void adjustForNumColumns(int numColumns) {
   Control control = getLabelComposite();
   ((GridData) control.getLayoutData()).horizontalSpan = numColumns;
   ((GridData) list.getLayoutData()).horizontalSpan = numColumns - 1;
 }
 private void setControlVisible(Control control, boolean visible) {
   GridData data = (GridData) control.getLayoutData();
   data.exclude = !visible;
   control.setVisible(visible);
 }
Example #27
0
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite main = new Composite(parent, SWT.NONE);
    GridLayoutFactory.swtDefaults().applyTo(main);
    GridDataFactory.fillDefaults().indent(0, 0).grab(true, true).applyTo(main);
    Group fetchResultGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
    fetchResultGroup.setText(UIText.PullResultDialog_FetchResultGroupHeader);
    GridLayoutFactory.fillDefaults().applyTo(fetchResultGroup);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(fetchResultGroup);
    FetchResult fRes = result.getFetchResult();
    if (hasFetchResults()) {
      GridLayoutFactory.fillDefaults().applyTo(fetchResultGroup);
      FetchResultDialog dlg =
          new FetchResultDialog(getParentShell(), repo, fRes, result.getFetchedFrom());
      Control fresult = dlg.createFetchResultTable(fetchResultGroup);
      Object layoutData = fresult.getLayoutData();
      if (layoutData instanceof GridData)
        GridDataFactory.createFrom((GridData) layoutData).hint(SWT.DEFAULT, 130).applyTo(fresult);

    } else {
      GridLayoutFactory.swtDefaults().applyTo(fetchResultGroup);
      Label noResult = new Label(fetchResultGroup, SWT.NONE);
      if (result.getFetchedFrom().equals(".")) // $NON-NLS-1$
      noResult.setText(UIText.PullResultDialog_NothingToFetchFromLocal);
      else
        noResult.setText(
            NLS.bind(UIText.FetchResultDialog_labelEmptyResult, result.getFetchedFrom()));
    }
    Group mergeResultGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
    mergeResultGroup.setText(UIText.PullResultDialog_MergeResultGroupHeader);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(mergeResultGroup);
    if (hasMergeResults()) {
      GridLayoutFactory.fillDefaults().applyTo(mergeResultGroup);
      MergeResultDialog dlg =
          new MergeResultDialog(getParentShell(), repo, result.getMergeResult());
      dlg.createDialogArea(mergeResultGroup);
    } else if (hasRebaseResults()) {
      Status status = result.getRebaseResult().getStatus();
      GridLayoutFactory.fillDefaults().applyTo(mergeResultGroup);
      switch (status) {
        case OK:
          // fall through
        case FAST_FORWARD:
          // fall through
        case UP_TO_DATE:
          // fall through
        case FAILED:
          // fall through
        case ABORTED:
          break;
        case STOPPED:
          Label errorLabel = new Label(mergeResultGroup, SWT.NONE);
          errorLabel.setImage(
              PlatformUI.getWorkbench()
                  .getSharedImages()
                  .getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
          Text errorText = new Text(mergeResultGroup, SWT.READ_ONLY);
          errorText.setText(UIText.PullResultDialog_RebaseStoppedMessage);
          break;
      }
      Label statusLabel = new Label(mergeResultGroup, SWT.NONE);
      statusLabel.setText(UIText.PullResultDialog_RebaseStatusLabel);
      Text statusText = new Text(mergeResultGroup, SWT.READ_ONLY);
      statusText.setText(status.name());
    } else {
      GridLayoutFactory.swtDefaults().applyTo(mergeResultGroup);
      Label noResult = new Label(mergeResultGroup, SWT.NONE);
      noResult.setText(UIText.PullResultDialog_MergeAlreadyUpToDateMessage);
    }
    return main;
  }