Results 1 to 4 of 4

Thread: Default layouts in TableFormBuilder (TableLayoutBuilder)

  1. #1
    Join Date
    Sep 2005
    Location
    Lisbon
    Posts
    2

    Default Default layouts in TableFormBuilder (TableLayoutBuilder)

    I'm using TableFormBuilder and I need a way to set layout defaults to the rows and cols (has FormLayout in JGoodies) because we have many forms to build (hundreds) and some off them and complex and I don't want to specify colspecs and rowspecs item per item.

    Is there a way to do this using the RCP classes? I thought in overwriting the TableLayoutBuilder class but i will only do that in last case.

    Best regards

    rps

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    335

    Default

    Please post an example of where you need to specify these values.

    Thanks

  3. #3
    Join Date
    Sep 2005
    Location
    Lisbon
    Posts
    2

    Default

    Oliver, sorry for the delay, but here is an example

    Code:
    	JComboBox classe = new JComboBox();
    	JComboBox type = new JComboBox();
    	JTextField number = new JTextField(10);
    JTextField internalCode = new JTextField(15);
    	    JComboBox nameTitle = new JComboBox();
    	    JTextField name = new JTextField(40);
    	    JTextField shortName = new JTextField(15);
    	    JComboBox juridic = new JComboBox();
    	    JTextField email = new JTextField(20);
    	    JTextField webPage = new JTextField(20);
    	    JComboBox place = new JComboBox();
    	    JComboBox responsable = new JComboBox();
    	    JTextField cont = new JTextField(20);
    	    JButton lookupButton = new JButton("...");
    	    JSeparator sep1 = new JSeparator();
    	    JComboBox doc = new JComboBox();
    	    JComboBox docType = new JComboBox();
    	    JTextField docNumber = new JTextField(10);
    	    JSeparator sep2 = new JSeparator();
    	    JComboBox phoneType = new JComboBox();
    	    JTextField phoneNumber = new JTextField(10);
    	    JCheckBox cli = new JCheckBox("Cliente");
    	    JCheckBox forn = new JCheckBox("Fornecedor");
    	    JButton contData = new JButton("Dados Contabilisticos");
    	    JLabel dummy = new JLabel();
    	    JTabbedPane jTab = new JTabbedPane();
    	
    	    FormLayout layout =
    	    	new FormLayout("l:p, 4dlu, fill:max(50dlu;p), 4dlu, " +
    	    				   "l:p, 4dlu, fill:max(50dlu;p), 4dlu, " +
    	    				   "l:p, 4dlu, fill:max(50dlu;p), fill:max(50dlu;p), 4dlu, " +
    	    				   "l:p, l:p, l:p, 4dlu, p, 4dlu, " +
    	    				   "p, p, p", "");
    	    //DefaultFormBuilder builder = new DefaultFormBuilder(layout,  new FormDebugPanel());
    	    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    	    builder.setDefaultDialogBorder();
    	
    	    builder.append("&Classe", classe);
    	    builder.append("&Tipo", type);
    	    builder.append("&Numero", number, 2);
    	    builder.append("&InternalCode", internalCode);
    	    builder.append(cli);
    	    builder.nextLine();
    	    builder.append("&Nome", nameTitle);
    	    builder.append(name, 7);
    	    builder.append(dummy, 4);
    	    builder.append(forn);
    	    builder.nextLine();
    	    builder.append("&Abreviatura", shortName, 5);
    	    builder.append("&Forma Juridica", juridic);
    	    builder.append(dummy, 4);
    	    builder.append(contData);
    	    builder.nextLine();
    	    builder.append("&Email", email, 5);
    	    builder.append("&Pagina", webPage, 4);
    	    builder.nextLine();
    	    builder.append("&Local", place);
    	    builder.append("&Responsavel", responsable);
    	    builder.append("&Contencioso", cont, 4);
    	    builder.append(lookupButton);
    	    builder.nextLine();
    	    
    	    FormLayout subLayout1 = new FormLayout("2dlu, 2dlu, l:p, 4dlu, fill:max(50dlu;p), 4dlu, " +
    	    									   "l:p, 4dlu, fill:max(50dlu;p), 4dlu, " +
    	    									   "l:p, 4dlu, p", "");
    	    DefaultFormBuilder subBuilder1 = new DefaultFormBuilder(subLayout1);
    	    subBuilder1.append(dummy);
    	    subBuilder1.append("&Documento", doc);
    	    subBuilder1.append("&Tipo Doc.", docType);
    	    subBuilder1.append("&Nº Doc.", docNumber);
    	    subBuilder1.appendUnrelatedComponentsGapRow();
    	    JPanel j1 = subBuilder1.getPanel();
    	    j1.setBorder(javax.swing.BorderFactory.
    	    				createTitledBorder(null, "Documento principal", javax.swing.border.TitledBorder.LEFT,
    	    										javax.swing.border.TitledBorder.DEFAULT_POSITION));
    	    builder.append(j1, 16);
    	    builder.nextLine();
    	    
    	    FormLayout subLayout2 = new FormLayout("2dlu, 2dlu, l:p, 4dlu, fill:max(50dlu;p), 4dlu, " +
    				   							   "l:p, 4dlu, fill:max(50dlu;p), 4dlu, ", "");
    	    
    	    DefaultFormBuilder subBuilder2 = new DefaultFormBuilder(subLayout2);
    	    subBuilder2.append(dummy);
    	    subBuilder2.append("&Tipo Telf.", phoneType);
    	    subBuilder2.append("&Nº Telf.", phoneNumber);
    	    subBuilder2.appendUnrelatedComponentsGapRow();
    	    JPanel j2 = subBuilder2.getPanel();
    	    j2.setBorder(javax.swing.BorderFactory.
    	    				createTitledBorder(null, "Telefone principal", javax.swing.border.TitledBorder.LEFT,
    	    										javax.swing.border.TitledBorder.DEFAULT_POSITION));
    	    builder.append(j2, 16);
    	    builder.nextLine();
    	    
    	    return builder.getPanel();
    I'm trying to do this in the RCP using TableFormBuilder, but not being able to define column defaults is making my task difficult for me.
    Perhaps there is a easy way to do it but I’m not seeing it (I must say that I’m not yet very comfortable in the RCP).
    Please give me some guidelines here.

    Thanks
    Best regards

    rps

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    335

    Default

    If you want to specify the colspec defaults before you layout the form this is not possible - with TableFormBuilder and TableLayoutBuilder you specify the colspec as you go but you only have to do this once for each column.

    Following is an attempt at laying out a similar form to yours but since I've not seen your form I'm really guessing:

    [code]SwingBindingFactory bindingFactory = getBindingFactory();
    TableFormBuilder builder = new TableFormBuilder (bindingFactory );

    builder.add("classe", "colspec=fill:max(50dlu;p)");
    builder.add("type", "colspec=fill:max(50dlu;p)");
    builder.add("number", "colspec=fill:max(50dlu;p)");
    builder.add("internalCode", "colspan=2");

    builder.row();
    builder.add("nameTitle");
    builder.getLayoutBuilder().cell(bindingFactory.cre ateBinding("name").getControl(), "colspan=2");
    builder.getLayoutBuilder().cell(bindingFactory.cre ateBinding("forn").getControl(), "colspan=2");

    builder.row();
    builder.add("shortName", "colspan=3");
    builder.add("juridic");
    builder.getLayoutBuilder().cell("colspan=2");
    builder.add("contData");

    ...[code]

    Note that the colspec is only specified once and also note that colspans do NOT have to take into account gaps.

    Another option you should consider if you already have these forms coded up using JGoodies is to continue using you existing layout code but replace the labels and the controls with ones you are getting out of a binding factory.

    HTH

    Ollie

Similar Threads

  1. default button for view, eg ENTER in login
    By amcauley in forum Swing
    Replies: 3
    Last Post: Aug 3rd, 2006, 08:49 AM
  2. Replies: 7
    Last Post: Aug 1st, 2005, 01:38 AM
  3. Odd behaviour when injecting TransactionTemplate
    By damon311 in forum Container
    Replies: 3
    Last Post: Jul 23rd, 2005, 11:21 AM
  4. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM
  5. Default values
    By Edward Kenworthy in forum Data
    Replies: 5
    Last Post: Sep 17th, 2004, 03:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •