Create New Tabbed Pane

    This script creates a new tabbed pane in a form view.

    Defaults for this script are set for the Pubchem demo data tree in the sample project included in IJC.

    
    import com.chemaxon.ijc.form.api.*
    import com.chemaxon.ijc.form.api.renderers.*
    import com.chemaxon.ijc.commons.datarequest.api.FieldReference
     
    ety = dataTree.rootVertex.entity
     
    // Main script body
    form = new Form()
    tabbedPane = createTabbedPaneWidget()
    label = createLabelWidget("TabbedPane demo")
     
    firstTab = tabbedPane.getTabAt(0)
    firstTab.addWidget(label)
    firstTab.addWidget(createTableWidget())
    firstTab.addWidget(createTextBoxWidget())
     
    secondTab = tabbedPane.getTabAt(1)
    secondTab.addWidget(label)
    secondTab.addWidget(createMolWidget())
    secondTab.addWidget(createSheetWidget())
    secondTab.setBackgroundColor("/display/docs/create-new-tabbed-pane.md#FFFFFF")
     
    form.addWidget(tabbedPane)
    DFViews.create(dataTree, form, "TabbedPane form")
     
     
    // widgets creation methods
    def createTabbedPaneWidget() {
        tabbedPane = new TabbedPaneWidget("First tab")
        tabbedPane.setSize(410, 630)
        tabbedPane.addTab(new PanelWidget("Second tab"))
        return tabbedPane
    }
     
    def createLabelWidget(label) {
        widget = new LabelWidget(label)
        widget.setSize(160, 50)
        widget.setFont(new Font("Arial", Font.Style.BOLD, 16))
        return widget
    }
     
    def createTableWidget() {
        table = new TableWidget()
        table.setPosition(0, 50)
        table.setSize(400, 500)
        table.setRowHeight(60)
     
        table.addColumn(newFieldReference("CdId"), new IntegerRenderer())
        structureColumn = table.addColumn(newFieldReference("Structure"), new StructureRenderer())
        structureColumn.setColumnWidth(150)
        table.addColumn(newFieldReference("Formula"), new TextRenderer())
        table.addColumn(newFieldReference("Donors"), new IntegerRenderer())
     
        return table
    }
     
    def createTextBoxWidget() {
        widget = new TextBoxWidget()
        widget.setPosition(0, 550)
        widget.setSize(400, 50)
     
        widget.setField(newFieldReference("IUPAC name"))
        widget.setRenderer(new TextRenderer())
        return widget
    }
     
    def createMolWidget() {
        widget = new MolWidget()
        widget.setPosition(0, 50)
        widget.setSize(300, 300)
     
        widget.setField(newFieldReference("Structure"))
        widget.setRenderer(new StructureRenderer())
        return widget
    }
     
    def createSheetWidget() {
        sheet = new SheetWidget()
        sheet.setPosition(0, 350)
        sheet.setSize(300, 250)
     
        sheet.addRow(newFieldReference("CdId"), new IntegerRenderer())
        sheet.addRow(newFieldReference("Structure"), new StructureRenderer())
        sheet.addRow(newFieldReference("Formula"), new TextRenderer())
        sheet.addRow(newFieldReference("Donors"), new IntegerRenderer())
     
        return sheet
    }
     
    def newFieldReference(name) {
      field = ety.fields.items.find { it.name == name }
      new FieldReference(ety.id, field.id)
    }