Announcement Announcement Module
Collapse
No announcement yet.
Default layouts in TableFormBuilder (TableLayoutBuilder) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Please post an example of where you need to specify these values.

    Thanks

    Comment


    • #3
      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 Im not seeing it (I must say that Im not yet very comfortable in the RCP).
      Please give me some guidelines here.

      Thanks
      Best regards

      rps

      Comment


      • #4
        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

        Comment

        Working...
        X