[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform.swt] Re: TabItem and Table

Veronika,

 i've tried to change my code with your answer
 but i can't manage to do what i want

 I want my Tables to appears on the maximum possible size
 even if there's no data in (I load them on a button click)
 I also want them to display their scrollbars if it's needed
 and finally, I won't to fix a size for my TabFolder because
 my application have to be fully resizable
 I manage to do this with this code, but i apply a GridData
 on a FillLayout and it's wrong

 Could you explain me if it's possible and what i'm doing wrong?

thanks
 philippe.


 public Composite createMsgScreen(Composite _pere) {

  Composite composite = new Composite(_pere, SWT.NONE);
  composite.setLayout(new GridLayout(1,false));
  GridData gridData =
   new GridData(
    GridData.FILL_BOTH
     | GridData.GRAB_HORIZONTAL
     | GridData.GRAB_VERTICAL
     | GridData.HORIZONTAL_ALIGN_FILL
     | GridData.VERTICAL_ALIGN_FILL);
  composite.setLayoutData(gridData);

  // -- Selection field --
  Composite c0 = new Composite(composite, SWT.NONE);
  c0.setLayout(new GridLayout(2, false));
  c0.setLayoutData(
   new GridData(
    GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL |
GridData.GRAB_HORIZONTAL));
  lblJobSel = new Label(c0, SWT.NONE);
  lblJobSel.setText(SMGPlugID.getTexte("act_41"));
  tJobSelect = new Text(c0, SWT.BORDER);
  tJobSelect.setBackground(SMGPlugID.colorWhite);

  Composite cfolder=new Composite(composite,SWT.NONE);

  // -- When i do this, my Table appears without scrollbars --
//  cfolder.setLayout(new GridLayout(1,false));

  // -- And when i do that, my Table appears with scrollbars --
  cfolder.setLayout(new FillLayout());
  // -- Do you know where's my mistake??? --

  cfolder.setLayoutData(
   new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL |
GridData.GRAB_VERTICAL));

  // -- My TabFolder --
  tFolder = new TabFolder(cfolder, SWT.NONE);

  iFolderLogItem = new TabItem(tFolder, SWT.NONE);
  iFolderLogItem.setText("Log");
  iFolderErrItem = new TabItem(tFolder, SWT.NONE);
  iFolderErrItem.setText("Erreur");

  // -- Table des erreurs --
  tTableErr =
   new Table(tFolder, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI |
SWT.FULL_SELECTION);
  tTableErr.setHeaderVisible(false);
  tTableErr.addSelectionListener(this);

  // -- Table des logs --
  tTableMsg =
   new Table(tFolder, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI |
SWT.FULL_SELECTION);
  tTableMsg.setHeaderVisible(false);
  tTableMsg.addSelectionListener(this);

  iFolderLogItem.setControl(tTableMsg);
  iFolderErrItem.setControl(tTableErr);

  // -- Commmand field --
  // -- Boutons refresh et clear --
  c0 = new Composite(composite, SWT.NONE);
  RowLayout r0 = new RowLayout(SWT.HORIZONTAL);
  r0.pack = false;
  c0.setLayout(r0);
  // -- Bouton de rafraichissement --
  bRefresh = new Button(c0, SWT.PUSH);
  bRefresh.setText(SMGPlugID.getTexte("act_39"));
  bRefresh.setData(ITEM_ACTION, new Integer(ACT_HARD_REFRESH));
  bRefresh.addSelectionListener(this);
  // -- Bouton de Clear --
  bClear = new Button(c0, SWT.PUSH);
  bClear.setText(SMGPlugID.getTexte("act_40"));
  bClear.setData(ITEM_ACTION, new Integer(ACT_HARD_REFRESH));
  bClear.addSelectionListener(this);

  return composite;
 }

"Veronika Irvine" <veronika_irvine@xxxxxxx> a écrit dans le message de news:
baignu$g7q$3@xxxxxxxxxxxxxxxx
> Philippe,
>
> You do not need to set a FillLayout on the TabFolder, the TabFolder by
> default sets the size of its TabItem content to fill the client area of
the
> tab item.
>
> >   tTableErr.setLayoutData(
> >    new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL |
> > GridData.GRAB_VERTICAL));
>
> You are setting GridData on an item that is in a FillLayout - not good -
> since FillLayout does not have any associated LayoutData you get away with
> it in this case but in general it will cause a ClassCastException if you
set
> the wrong type of layout data in a control (I think this is just a remnant
> of the fact that you removed an intermediate Composite).
>
>