Example usage for javax.swing JLabel equals

List of usage examples for javax.swing JLabel equals

Introduction

In this page you can find the example usage for javax.swing JLabel equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:com.josue.tileset.editor.Editor.java

private void mountButtons(List<Tile> tiles, int cols, int rows) {

    imagePanel.removeAll();/*from  w w  w  . jav  a  2s  . c o  m*/
    if (animatedPerformer != null) {
        animatedPerformer.stop();
        animatedPerformer = null;
    }

    imagePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    Dimension dimension = new Dimension(cols * TILE_SIZE, rows * TILE_SIZE);

    for (Tile tile : tiles) {
        final JLabel tileLabel = new JLabel();

        tileLabel.setIcon(new ImageIcon(tile.getImage()));
        Dimension labelDimension = new Dimension(TILE_SIZE, TILE_SIZE);
        tileLabel.setMinimumSize(labelDimension);
        tileLabel.setMaximumSize(labelDimension);
        tileLabel.setPreferredSize(labelDimension);
        tileLabel.setSize(labelDimension);
        tileLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            @Override
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                if (SwingUtilities.isRightMouseButton(evt)) {//select animated sequence

                    if (animatedAction.isSelected()) {
                        addAnimatedTile(tile);
                    } else {
                        addLightSourceTile(tile);
                    }

                } else {

                    if (animatedPerformer != null) {
                        animatedPerformer.stop();
                    }
                    Iterator<JLabel> iterator = tileLabels.values().iterator();
                    while (iterator.hasNext()) {
                        JLabel next = iterator.next();
                        next.revalidate();
                    }
                    imagePanel.repaint();
                    for (Map.Entry<Tile, JLabel> entry : tileLabels.entrySet()) {
                        Tile key = entry.getKey();
                        JLabel value = entry.getValue();
                        value.setBorder(null); //clear borders
                    }

                    selectedTile = tile;//this isolate for the next operations
                    tileLabel.setBorder(new LineBorder(Color.RED, 2));

                    previewLabel.setIcon(new ImageIcon(tile.getImage()));
                    animatedTb.setSelected(selectedTile.isAnimated());
                    lightTb.setSelected(selectedTile.isLight());
                    solidTb.setSelected(selectedTile.isSolid());

                    if (tile.isAnimated()) {

                        for (Integer animatesTileOffset : selectedTile.getAnimation().getAnimatedSequence()) { //display animated borders
                            for (Map.Entry<Tile, JLabel> entry : tileLabels.entrySet()) {
                                Tile key = entry.getKey();
                                JLabel value = entry.getValue();
                                if (key.getId() == selectedTile.getId() + animatesTileOffset) {
                                    value.setBorder(new LineBorder(Color.BLUE, 2));
                                }
                            }

                        }

                        animatedPerformer = new Timer(
                                (int) (selectedTile.getAnimation().getAnimationInterval()),
                                new TileAnimator(selectedTile, previewLabel, loadedTiles));
                        animatedPerformer.start();
                    }
                    if (selectedTile.isLight()) {//light color has preference
                        for (Tile tile : tiles) {
                            if (tile.getId() == selectedTile.getLightTileId()) {
                                JLabel found = tileLabels.get(tile);
                                found.setBorder(new LineBorder(Color.YELLOW, 2));
                                break;
                            }
                        }

                    }
                }
            }

            @Override
            public void mouseExited(MouseEvent e) {
                if (selectedTile != null && selectedTile.getAnimation() != null && selectedTile.getAnimation()
                        .getAnimatedSequence().contains(tile.getId() - selectedTile.getId())) {
                    tileLabel.setBorder(new LineBorder(Color.BLUE, 2));
                } else if (selectedTile != null && selectedTile.isLight()
                        && selectedTile.getLightTileId() == tile.getId()) {
                    tileLabel.setBorder(new LineBorder(Color.YELLOW, 2));
                } else if (selectedTile != null) {
                    JLabel get = tileLabels.get(selectedTile);
                    if (!get.equals(tileLabel)) { //keep the red border if is the selected
                        tileLabel.setBorder(null);
                    }
                } else {
                    tileLabel.setBorder(null);
                }
            }

            @Override
            public void mouseEntered(MouseEvent e) {
                if (selectedTile != null && selectedTile.getAnimation() != null
                        && !selectedTile.getAnimation().getAnimatedSequence()
                                .contains(tile.getId() - selectedTile.getId())
                        && tile.getLight() != null && tile.getLight().getLightTileOffset() != 0) {
                    tileLabel.setBorder(new LineBorder(Color.RED, 2));
                } else if (selectedTile == null) {
                    tileLabel.setBorder(new LineBorder(Color.RED, 2));
                }
            }
        });
        tileLabels.put(tile, tileLabel);
        imagePanel.add(tileLabel);
    }

    imagePanel.setMaximumSize(dimension);
    imagePanel.setMinimumSize(dimension);
    imagePanel.setPreferredSize(dimension);
    imagePanel.revalidate();
    imagePanel.repaint();
    this.pack();
}

From source file:edu.ku.brc.af.ui.forms.ViewFactory.java

protected boolean createItem(final DBTableInfo parentTableInfo, final DBTableChildIFace childInfo,
        final MultiView parent, final ViewDefIFace viewDef, final FormValidator validator,
        final ViewBuilderIFace viewBldObj, final AltViewIFace.CreationMode mode,
        final HashMap<String, JLabel> labelsForHash, final Object currDataObj, final FormCellIFace cell,
        final boolean isEditOnCreateOnly, final int rowInx, final BuildInfoStruct bi) {
    bi.compToAdd = null;//from  w  w  w  . j av a  2  s . co  m
    bi.compToReg = null;
    bi.doAddToValidator = true;
    bi.doRegControl = true;

    DBRelationshipInfo relInfo = childInfo instanceof DBRelationshipInfo ? (DBRelationshipInfo) childInfo
            : null;

    if (isEditOnCreateOnly) {
        EditViewCompSwitcherPanel evcsp = new EditViewCompSwitcherPanel(cell);
        bi.compToAdd = evcsp;
        bi.compToReg = evcsp;

        if (validator != null) {
            //DataChangeNotifier dcn = validator.createDataChangeNotifer(cell.getIdent(), evcsp, null);
            DataChangeNotifier dcn = validator.hookupComponent(evcsp, cell.getIdent(), UIValidator.Type.Changed,
                    null, false);
            evcsp.setDataChangeNotifier(dcn);
        }

    } else if (cell.getType() == FormCellIFace.CellType.label) {
        FormCellLabel cellLabel = (FormCellLabel) cell;

        String lblStr = cellLabel.getLabel();
        if (cellLabel.isRecordObj()) {
            JComponent riComp = viewBldObj.createRecordIndentifier(lblStr, cellLabel.getIcon());
            bi.compToAdd = riComp;

        } else {
            String lStr = "  ";
            int align = SwingConstants.RIGHT;
            boolean useColon = StringUtils.isNotEmpty(cellLabel.getLabelFor());

            if (lblStr.equals("##")) {
                //lStr = "  ";
                bi.isDerivedLabel = true;
                cellLabel.setDerived(true);

            } else {
                String alignProp = cellLabel.getProperty("align");
                if (StringUtils.isNotEmpty(alignProp)) {
                    if (alignProp.equals("left")) {
                        align = SwingConstants.LEFT;

                    } else if (alignProp.equals("center")) {
                        align = SwingConstants.CENTER;

                    } else {
                        align = SwingConstants.RIGHT;
                    }
                } else if (useColon) {
                    align = SwingConstants.RIGHT;
                } else {
                    align = SwingConstants.LEFT;
                }

                if (isNotEmpty(lblStr)) {
                    if (useColon) {
                        lStr = lblStr + ":";
                    } else {
                        lStr = lblStr;
                    }
                } else {
                    lStr = "  ";
                }
            }

            if (lStr.indexOf(LF) > -1) {
                lStr = "<html>" + StringUtils.replace(lStr, LF, "<br>") + "</html>";
            }
            JLabel lbl = createLabel(lStr, align);
            String colorStr = cellLabel.getProperty("fg");
            if (StringUtils.isNotEmpty(colorStr)) {
                lbl.setForeground(UIHelper.parseRGB(colorStr));
            }
            labelsForHash.put(cellLabel.getLabelFor(), lbl);
            bi.compToAdd = lbl;
            viewBldObj.addLabel(cellLabel, lbl);
        }

        bi.doAddToValidator = false;
        bi.doRegControl = false;

    } else if (cell.getType() == FormCellIFace.CellType.field) {
        FormCellField cellField = (FormCellField) cell;

        bi.isRequired = bi.isRequired || cellField.isRequired()
                || (childInfo != null && childInfo.isRequired());

        DBFieldInfo fieldInfo = childInfo instanceof DBFieldInfo ? (DBFieldInfo) childInfo : null;
        if (fieldInfo != null && fieldInfo.isHidden()) {
            FormDevHelper.appendLocalizedFormDevError("ViewFactory.FORM_FIELD_HIDDEN", cellField.getIdent(),
                    cellField.getName(), viewDef.getName());
        } else {

            if (fieldInfo != null && fieldInfo.isHidden()) {
                FormDevHelper.appendLocalizedFormDevError("ViewFactory.FORM_REL_HIDDEN", cellField.getIdent(),
                        cellField.getName(), viewDef.getName());
            }
        }

        FormCellField.FieldType uiType = cellField.getUiType();

        // Check to see if there is a PickList and get it if there is
        PickListDBAdapterIFace adapter = null;

        String pickListName = cellField.getPickListName();
        if (childInfo != null && StringUtils.isEmpty(pickListName) && fieldInfo != null) {
            pickListName = fieldInfo.getPickListName();
        }

        if (isNotEmpty(pickListName)) {
            adapter = PickListDBAdapterFactory.getInstance().create(pickListName, false);

            if (adapter == null || adapter.getPickList() == null) {
                FormDevHelper.appendFormDevError("PickList Adapter [" + pickListName + "] cannot be null!");
                return false;
            }
        }

        /*if (uiType == FormCellFieldIFace.FieldType.text)
        {
        String weblink = cellField.getProperty("weblink");
        if (StringUtils.isNotEmpty(weblink))
        {
            String name = cellField.getProperty("name");
            if (StringUtils.isNotEmpty(name) && name.equals("WebLink"))
            {
                uiType
            }
        }
        }*/

        // The Default Display for combox is dsptextfield, except when there is a TableBased PickList
        // At the time we set the display we don't want to go get the picklist to find out. So we do it
        // here after we have the picklist and actually set the change into the cellField
        // because it uses the value to determine whether to convert the value into a text string 
        // before setting it.
        if (mode == AltViewIFace.CreationMode.VIEW) {
            if (uiType == FormCellFieldIFace.FieldType.combobox
                    && cellField.getDspUIType() != FormCellFieldIFace.FieldType.textpl) {
                if (adapter != null)// && adapter.isTabledBased())
                {
                    uiType = FormCellFieldIFace.FieldType.textpl;
                    cellField.setDspUIType(uiType);

                } else {
                    uiType = cellField.getDspUIType();
                }
            } else {
                uiType = cellField.getDspUIType();
            }
        } else if (uiType == FormCellField.FieldType.querycbx) {
            if (AppContextMgr.isSecurityOn()) {
                DBTableInfo tblInfo = childInfo != null
                        ? DBTableIdMgr.getInstance()
                                .getByShortClassName(childInfo.getDataClass().getSimpleName())
                        : null;
                if (tblInfo != null) {
                    PermissionSettings perm = tblInfo.getPermissions();
                    if (perm != null) {
                        //PermissionSettings.dumpPermissions("QCBX: "+tblInfo.getShortClassName(), perm.getOptions());
                        if (perm.isViewOnly() || !perm.canView()) {
                            uiType = FormCellField.FieldType.textfieldinfo;
                        }
                    }
                }
            }
        }

        Class<?> fieldClass = childInfo != null ? childInfo.getDataClass() : null;
        String uiFormatName = cellField.getUIFieldFormatterName();

        if (mode == AltViewIFace.CreationMode.EDIT && uiType == FormCellField.FieldType.text
                && fieldClass != null) {
            if (fieldClass == String.class && fieldInfo != null) {
                // check whether there's a formatter defined for this field in the schema
                if (fieldInfo.getFormatter() != null) {
                    uiFormatName = fieldInfo.getFormatter().getName();
                    uiType = FormCellField.FieldType.formattedtext;
                }
            } else if (fieldClass == Integer.class || fieldClass == Long.class || fieldClass == Short.class
                    || fieldClass == Byte.class || fieldClass == Double.class || fieldClass == Float.class
                    || fieldClass == BigDecimal.class) {
                //log.debug(cellField.getName()+"  is being changed to NUMERIC");
                uiType = FormCellField.FieldType.formattedtext;
                uiFormatName = "Numeric" + fieldClass.getSimpleName();
            }
        }

        // Create the UI Component

        boolean isReq = cellField.isRequired() || (fieldInfo != null && fieldInfo.isRequired())
                || (relInfo != null && relInfo.isRequired());
        cellField.setRequired(isReq);

        switch (uiType) {
        case text:

            bi.compToAdd = createTextField(validator, cellField, fieldInfo, isReq, adapter);
            bi.doAddToValidator = validator == null; // might already added to validator
            break;

        case formattedtext: {
            Class<?> tableClass = null;
            try {
                tableClass = Class.forName(viewDef.getClassName());
            } catch (Exception ex) {
            }

            JComponent tfStart = createFormattedTextField(validator, cellField, tableClass,
                    fieldInfo != null ? fieldInfo.getLength() : 0, uiFormatName,
                    mode == AltViewIFace.CreationMode.VIEW, isReq,
                    cellField.getPropertyAsBoolean("alledit", false));
            bi.compToAdd = tfStart;
            if (cellField.getPropertyAsBoolean("series", false)) {
                JComponent tfEnd = createFormattedTextField(validator, cellField, tableClass,
                        fieldInfo != null ? fieldInfo.getLength() : 0, uiFormatName,
                        mode == AltViewIFace.CreationMode.VIEW, isReq,
                        cellField.getPropertyAsBoolean("alledit", false));

                // Make sure we register it like a plugin not a regular control
                SeriesProcCatNumPlugin plugin = new SeriesProcCatNumPlugin((ValFormattedTextFieldIFace) tfStart,
                        (ValFormattedTextFieldIFace) tfEnd);
                bi.compToAdd = plugin.getUIComponent();
                viewBldObj.registerPlugin(cell, plugin);
                bi.doRegControl = false;
            }
            bi.doAddToValidator = validator == null; // might already added to validator
            break;
        }
        case label:
            JLabel label = createLabel("", SwingConstants.LEFT);
            bi.compToAdd = label;
            break;

        case dsptextfield:
            if (StringUtils.isEmpty(cellField.getPickListName())) {
                JTextField text = UIHelper.createTextField(cellField.getTxtCols());
                changeTextFieldUIForDisplay(text, cellField.getPropertyAsBoolean("transparent", false));
                bi.compToAdd = text;
            } else {
                bi.compToAdd = createTextField(validator, cellField, fieldInfo, isReq, adapter);
                bi.doAddToValidator = validator == null; // might already added to validator
            }
            break;

        case textfieldinfo:
            bi.compToAdd = createTextFieldWithInfo(cellField, parent);
            break;

        case image:
            bi.compToAdd = createImageDisplay(cellField, mode, validator);
            bi.doAddToValidator = (validator != null);
            break;

        case url:
            BrowserLauncherBtn blb = new BrowserLauncherBtn(cellField.getProperty("title"));
            bi.compToAdd = blb;
            bi.doAddToValidator = false;

            break;

        case combobox:
            bi.compToAdd = createValComboBox(validator, cellField, adapter, isReq);
            bi.doAddToValidator = validator != null; // might already added to validator
            break;

        case checkbox: {
            String lblStr = cellField.getLabel();
            if (lblStr.equals("##")) {
                bi.isDerivedLabel = true;
                cellField.setDerived(true);
            }
            ValCheckBox checkbox = new ValCheckBox(lblStr, isReq,
                    cellField.isReadOnly() || mode == AltViewIFace.CreationMode.VIEW);
            if (validator != null) {
                DataChangeNotifier dcn = validator.createDataChangeNotifer(cellField.getIdent(), checkbox,
                        validator.createValidator(checkbox, UIValidator.Type.Changed));
                checkbox.addActionListener(dcn);
                checkbox.addItemListener(dcn);
            }
            bi.compToAdd = checkbox;
            break;
        }

        case tristate: {
            String lblStr = cellField.getLabel();
            if (lblStr.equals("##")) {
                bi.isDerivedLabel = true;
                cellField.setDerived(true);
            }
            ValTristateCheckBox tristateCB = new ValTristateCheckBox(lblStr, isReq,
                    cellField.isReadOnly() || mode == AltViewIFace.CreationMode.VIEW);
            if (validator != null) {
                DataChangeNotifier dcn = validator.createDataChangeNotifer(cellField.getIdent(), tristateCB,
                        null);
                tristateCB.addActionListener(dcn);
            }
            bi.compToAdd = tristateCB;
            break;
        }

        case spinner: {
            String minStr = cellField.getProperty("min");
            int min = StringUtils.isNotEmpty(minStr) ? Integer.parseInt(minStr) : 0;

            String maxStr = cellField.getProperty("max");
            int max = StringUtils.isNotEmpty(maxStr) ? Integer.parseInt(maxStr) : 0;

            ValSpinner spinner = new ValSpinner(min, max, isReq,
                    cellField.isReadOnly() || mode == AltViewIFace.CreationMode.VIEW);
            if (validator != null) {
                DataChangeNotifier dcn = validator.createDataChangeNotifer(cellField.getIdent(), spinner,
                        validator.createValidator(spinner, UIValidator.Type.Changed));
                spinner.addChangeListener(dcn);
            }
            bi.compToAdd = spinner;
            break;
        }

        case password:
            bi.compToAdd = createPasswordField(validator, cellField, isReq);
            bi.doAddToValidator = validator == null; // might already added to validator
            break;

        case dsptextarea:
            bi.compToAdd = createDisplayTextArea(cellField);
            break;

        case textarea: {
            JTextArea ta = createTextArea(validator, cellField, isReq, fieldInfo);
            JScrollPane scrollPane = new JScrollPane(ta);
            scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            scrollPane.setVerticalScrollBarPolicy(
                    UIHelper.isMacOS() ? ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
                            : ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
            ta.setLineWrap(true);
            ta.setWrapStyleWord(true);

            bi.doAddToValidator = validator == null; // might already added to validator
            bi.compToReg = ta;
            bi.compToAdd = scrollPane;
            break;
        }

        case textareabrief: {
            String title = "";
            DBTableInfo ti = DBTableIdMgr.getInstance().getByClassName(viewDef.getClassName());
            if (ti != null) {
                DBFieldInfo fi = ti.getFieldByName(cellField.getName());
                if (fi != null) {
                    title = fi.getTitle();
                }
            }

            ValTextAreaBrief txBrief = createTextAreaBrief(validator, cellField, isReq, fieldInfo);
            txBrief.setTitle(title);

            bi.doAddToValidator = validator == null; // might already added to validator
            bi.compToReg = txBrief;
            bi.compToAdd = txBrief.getUIComponent();
            break;
        }

        case browse: {
            JTextField textField = createTextField(validator, cellField, null, isReq, null);
            if (textField instanceof ValTextField) {
                ValBrowseBtnPanel bbp = new ValBrowseBtnPanel((ValTextField) textField,
                        cellField.getPropertyAsBoolean("dirsonly", false),
                        cellField.getPropertyAsBoolean("forinput", true));
                String fileFilter = cellField.getProperty("filefilter");
                String fileFilterDesc = cellField.getProperty("filefilterdesc");
                String defaultExtension = cellField.getProperty("defaultExtension");
                if (fileFilter != null && fileFilterDesc != null) {
                    bbp.setUseNativeFileDlg(false);
                    bbp.setFileFilter(new FileNameExtensionFilter(fileFilterDesc, fileFilter));
                    bbp.setDefaultExtension(defaultExtension);
                    //bbp.setNativeDlgFilter(new FileNameExtensionFilter(fileFilterDesc, fileFilter));
                }
                bi.compToAdd = bbp;

            } else {
                BrowseBtnPanel bbp = new BrowseBtnPanel(textField,
                        cellField.getPropertyAsBoolean("dirsonly", false),
                        cellField.getPropertyAsBoolean("forinput", true));
                bi.compToAdd = bbp;
            }
            break;
        }

        case querycbx: {
            ValComboBoxFromQuery cbx = createQueryComboBox(validator, cellField, isReq,
                    cellField.getPropertyAsBoolean("adjustquery", true));
            cbx.setMultiView(parent);
            cbx.setFrameTitle(cellField.getProperty("title"));

            bi.compToAdd = cbx;
            bi.doAddToValidator = validator == null; // might already added to validator
            break;
        }

        case list: {
            JList list = createList(validator, cellField, isReq);

            JScrollPane scrollPane = new JScrollPane(list);
            scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            scrollPane.setVerticalScrollBarPolicy(
                    UIHelper.isMacOS() ? ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
                            : ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

            bi.doAddToValidator = validator == null;
            bi.compToReg = list;
            bi.compToAdd = scrollPane;
            break;
        }

        case colorchooser: {
            ColorChooser colorChooser = new ColorChooser(Color.BLACK);
            if (validator != null) {
                DataChangeNotifier dcn = validator.createDataChangeNotifer(cellField.getName(), colorChooser,
                        null);
                colorChooser.addPropertyChangeListener("setValue", dcn);
            }
            //setControlSize(colorChooser);
            bi.compToAdd = colorChooser;

            break;
        }

        case button:
            JButton btn = createFormButton(cellField, cellField.getProperty("title"));
            bi.compToAdd = btn;
            break;

        case progress:
            bi.compToAdd = createProgressBar(0, 100);
            break;

        case plugin:
            UIPluginable uip = createPlugin(parent, validator, cellField,
                    mode == AltViewIFace.CreationMode.VIEW, isReq);
            if (uip != null) {
                bi.compToAdd = uip.getUIComponent();
                viewBldObj.registerPlugin(cell, uip);
            } else {
                bi.compToAdd = new JPanel();
                log.error("Couldn't create UIPlugin [" + cellField.getName() + "] ID:" + cellField.getIdent());
            }
            bi.doRegControl = false;
            break;

        case textpl:
            JTextField txt = new TextFieldFromPickListTable(adapter, cellField.getTxtCols());
            changeTextFieldUIForDisplay(txt, cellField.getPropertyAsBoolean("transparent", false));
            bi.compToAdd = txt;
            break;

        default:
            FormDevHelper.appendFormDevError("Don't recognize uitype=[" + uiType + "]");

        } // switch

    } else if (cell.getType() == FormCellIFace.CellType.separator) {
        // still have compToAdd = null;
        FormCellSeparatorIFace fcs = (FormCellSeparatorIFace) cell;
        String collapsableName = fcs.getCollapseCompName();

        String label = fcs.getLabel();
        if (StringUtils.isEmpty(label) || label.equals("##")) {
            String className = fcs.getProperty("forclass");
            if (StringUtils.isNotEmpty(className)) {
                DBTableInfo ti = DBTableIdMgr.getInstance().getByShortClassName(className);
                if (ti != null) {
                    label = ti.getTitle();
                }
            }
        }
        Component sep = viewBldObj.createSeparator(label);
        if (isNotEmpty(collapsableName)) {
            CollapsableSeparator collapseSep = new CollapsableSeparator(sep, false, null);
            if (bi.collapseSepHash == null) {
                bi.collapseSepHash = new HashMap<CollapsableSeparator, String>();
            }
            bi.collapseSepHash.put(collapseSep, collapsableName);
            sep = collapseSep;

        }
        bi.doRegControl = cell.getName().length() > 0;
        bi.compToAdd = (JComponent) sep;
        bi.doRegControl = StringUtils.isNotEmpty(cell.getIdent());
        bi.doAddToValidator = false;

    } else if (cell.getType() == FormCellIFace.CellType.command) {
        FormCellCommand cellCmd = (FormCellCommand) cell;
        JButton btn = createFormButton(cell, cellCmd.getLabel());
        if (cellCmd.getCommandType().length() > 0) {
            btn.addActionListener(new CommandActionWrapper(
                    new CommandAction(cellCmd.getCommandType(), cellCmd.getAction(), "")));
        }
        bi.doAddToValidator = false;
        bi.compToAdd = btn;

    } else if (cell.getType() == FormCellIFace.CellType.iconview) {
        FormCellSubView cellSubView = (FormCellSubView) cell;

        String subViewName = cellSubView.getViewName();

        ViewIFace subView = AppContextMgr.getInstance().getView(cellSubView.getViewSetName(), subViewName);
        if (subView != null) {
            if (parent != null) {
                int options = MultiView.VIEW_SWITCHER
                        | (MultiView.isOptionOn(parent.getCreateOptions(), MultiView.IS_NEW_OBJECT)
                                ? MultiView.IS_NEW_OBJECT
                                : MultiView.NO_OPTIONS);

                options |= cellSubView.getPropertyAsBoolean("nosep", false) ? MultiView.DONT_USE_EMBEDDED_SEP
                        : 0;
                options |= cellSubView.getPropertyAsBoolean("nosepmorebtn", false)
                        ? MultiView.NO_MORE_BTN_FOR_SEP
                        : 0;

                MultiView multiView = new MultiView(parent, cellSubView.getName(), subView,
                        parent.getCreateWithMode(), options, null);
                parent.addChildMV(multiView);
                multiView.setClassToCreate(getClassToCreate(parent, cell));

                log.debug("[" + cell.getType() + "] [" + cell.getName() + "] col: " + bi.colInx + " row: "
                        + rowInx + " colspan: " + cell.getColspan() + " rowspan: " + cell.getRowspan());
                viewBldObj.addSubView(cellSubView, multiView, bi.colInx, rowInx, cellSubView.getColspan(), 1);
                viewBldObj.closeSubView(cellSubView);
                bi.curMaxRow = rowInx;
                bi.colInx += cell.getColspan() + 1;
            } else {
                log.error("buildFormView - parent is NULL for subview [" + subViewName + "]");
            }

        } else {
            log.error("buildFormView - Could find subview's with ViewSet[" + cellSubView.getViewSetName()
                    + "] ViewName[" + subViewName + "]");
        }
        // still have compToAdd = null;
        bi.colInx += 2;

    } else if (cell.getType() == FormCellIFace.CellType.subview) {
        FormCellSubView cellSubView = (FormCellSubView) cell;
        String subViewName = cellSubView.getViewName();
        ViewIFace subView = AppContextMgr.getInstance().getView(cellSubView.getViewSetName(), subViewName);

        if (subView != null) {
            // Check to see this view should be "flatten" meaning we are creating a grid from a form
            if (!viewBldObj.shouldFlatten()) {
                if (parent != null) {
                    ViewIFace parentView = parent.getView();
                    Properties props = cellSubView.getProperties();

                    boolean isSingle = cellSubView.isSingleValueFromSet();
                    boolean isACollection = false;

                    try {
                        Class<?> cls = Class.forName(parentView.getClassName());
                        Field fld = getFieldFromDotNotation(cellSubView, cls);
                        if (fld != null) {
                            isACollection = Collection.class.isAssignableFrom(fld.getType());
                        } else {
                            log.error("Couldn't find field [" + cellSubView.getName() + "] in class ["
                                    + parentView.getClassName() + "]");
                        }
                    } catch (Exception ex) {
                        log.error("Couldn't find field [" + cellSubView.getName() + "] in class ["
                                + parentView.getClassName() + "]");
                        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ViewFactory.class, ex);
                    }

                    if (isSingle) {
                        isACollection = true;
                    }

                    boolean useNoScrollbars = UIHelper.getProperty(props, "noscrollbars", false);
                    //Assume RecsetController will always be handled correctly for one-to-one
                    boolean hideResultSetController = relInfo == null ? false
                            : relInfo.getType().equals(DBRelationshipInfo.RelationshipType.ZeroOrOne);
                    /*XXX bug #9497: boolean canEdit = true;
                    boolean addAddBtn = isEditOnCreateOnly && relInfo != null;
                    if (AppContextMgr.isSecurityOn()) {
                    DBTableInfo tblInfo = childInfo != null ? DBTableIdMgr.getInstance().getByShortClassName(childInfo.getDataClass().getSimpleName()) : null;
                    if (tblInfo != null) {
                        PermissionSettings perm = tblInfo.getPermissions();
                        if (perm != null) {
                            //XXX whoa. What about view perms???
                           //if (perm.isViewOnly() || !perm.canView()) {
                            if (!perm.canModify()) {
                               canEdit = false;
                            }
                        }
                    }
                    }*/

                    int options = (isACollection && !isSingle ? MultiView.RESULTSET_CONTROLLER
                            : MultiView.IS_SINGLE_OBJ)
                            | MultiView.VIEW_SWITCHER
                            | (MultiView.isOptionOn(parent.getCreateOptions(), MultiView.IS_NEW_OBJECT)
                                    ? MultiView.IS_NEW_OBJECT
                                    : MultiView.NO_OPTIONS)
                            |
                            /* XXX bug #9497:(mode == AltViewIFace.CreationMode.EDIT && canEdit ? MultiView.IS_EDITTING : MultiView.NO_OPTIONS) |
                            (useNoScrollbars ? MultiView.NO_SCROLLBARS : MultiView.NO_OPTIONS)
                            //| (addAddBtn ? MultiView.INCLUDE_ADD_BTN : MultiView.NO_OPTIONS)
                            ; */

                            (mode == AltViewIFace.CreationMode.EDIT ? MultiView.IS_EDITTING
                                    : MultiView.NO_OPTIONS)
                            | (useNoScrollbars ? MultiView.NO_SCROLLBARS : MultiView.NO_OPTIONS)
                            | (hideResultSetController ? MultiView.HIDE_RESULTSET_CONTROLLER
                                    : MultiView.NO_OPTIONS);
                    //MultiView.printCreateOptions("HERE", options);

                    options |= cellSubView.getPropertyAsBoolean("nosep", false)
                            ? MultiView.DONT_USE_EMBEDDED_SEP
                            : 0;
                    options |= cellSubView.getPropertyAsBoolean("nosepmorebtn", false)
                            ? MultiView.NO_MORE_BTN_FOR_SEP
                            : 0;
                    options |= cellSubView.getPropertyAsBoolean("collapse", false)
                            ? MultiView.COLLAPSE_SEPARATOR
                            : 0;

                    if (!(isACollection && !isSingle)) {
                        options &= ~MultiView.ADD_SEARCH_BTN;
                    } else {
                        options |= cellSubView.getPropertyAsBoolean("addsearch", false)
                                ? MultiView.ADD_SEARCH_BTN
                                : 0;
                    }

                    //MultiView.printCreateOptions("_______________________________", parent.getCreateOptions());
                    //MultiView.printCreateOptions("_______________________________", options);
                    boolean useBtn = UIHelper.getProperty(props, "btn", false);
                    if (useBtn) {
                        SubViewBtn.DATA_TYPE dataType;
                        if (isSingle) {
                            dataType = SubViewBtn.DATA_TYPE.IS_SINGLESET_ITEM;

                        } else if (isACollection) {
                            dataType = SubViewBtn.DATA_TYPE.IS_SET;
                        } else {
                            dataType = cellSubView.getName().equals("this") ? SubViewBtn.DATA_TYPE.IS_THIS
                                    : SubViewBtn.DATA_TYPE.IS_SET;
                        }

                        SubViewBtn subViewBtn = getInstance().createSubViewBtn(parent, cellSubView, subView,
                                dataType, options, props, getClassToCreate(parent, cell), mode);
                        subViewBtn.setHelpContext(props.getProperty("hc", null));

                        bi.doAddToValidator = false;
                        bi.compToAdd = subViewBtn;

                        String visProp = cell.getProperty("visible");
                        if (StringUtils.isNotEmpty(visProp) && visProp.equalsIgnoreCase("false")
                                && bi.compToAdd != null) {
                            bi.compToAdd.setVisible(false);
                        }

                        try {
                            addControl(validator, viewBldObj, rowInx, cell, bi);

                        } catch (java.lang.IndexOutOfBoundsException ex) {
                            String msg = "Error adding control type: `" + cell.getType() + "` id: `"
                                    + cell.getIdent() + "` name: `" + cell.getName() + "` on row: " + rowInx
                                    + " column: " + bi.colInx + "\n" + ex.getMessage();
                            UIRegistry.showError(msg);
                            return false;
                        }

                        bi.doRegControl = false;
                        bi.compToAdd = null;

                    } else {

                        Color bgColor = getBackgroundColor(props, parent.getBackground());

                        //log.debug(cellSubView.getName()+"  "+UIHelper.getProperty(props, "addsearch", false));
                        if (UIHelper.getProperty(props, "addsearch", false)) {
                            options |= MultiView.ADD_SEARCH_BTN;
                        }

                        if (UIHelper.getProperty(props, "addadd", false)) {
                            options |= MultiView.INCLUDE_ADD_BTN;
                        }

                        //MultiView.printCreateOptions("SUBVIEW", options);
                        MultiView multiView = new MultiView(parent, cellSubView.getName(), subView,
                                parent.getCreateWithMode(), cellSubView.getDefaultAltViewType(), options,
                                bgColor, cellSubView);
                        multiView.setClassToCreate(getClassToCreate(parent, cell));
                        setBorder(multiView, cellSubView.getProperties());

                        parent.addChildMV(multiView);

                        //log.debug("["+cell.getType()+"] ["+cell.getName()+"] col: "+bi.colInx+" row: "+rowInx+" colspan: "+cell.getColspan()+" rowspan: "+cell.getRowspan());
                        viewBldObj.addSubView(cellSubView, multiView, bi.colInx, rowInx,
                                cellSubView.getColspan(), 1);
                        viewBldObj.closeSubView(cellSubView);

                        Viewable viewable = multiView.getCurrentView();
                        if (viewable != null) {
                            if (viewable instanceof TableViewObj) {
                                ((TableViewObj) viewable).setVisibleRowCount(cellSubView.getTableRows());
                            }
                            if (viewable.getValidator() != null && childInfo != null) {
                                viewable.getValidator().setRequired(childInfo.isRequired());
                            }
                        }
                        bi.colInx += cell.getColspan() + 1;
                    }
                    bi.curMaxRow = rowInx;

                    //if (hasColor)
                    //{
                    //    setMVBackground(multiView, multiView.getBackground());
                    //}

                } else {
                    log.error("buildFormView - parent is NULL for subview [" + subViewName + "]");
                    bi.colInx += 2;
                }
            } else {
                //log.debug("["+cell.getType()+"] ["+cell.getName()+"] col: "+bi.colInx+" row: "+rowInx+" colspan: "+cell.getColspan()+" rowspan: "+cell.getRowspan());
                viewBldObj.addSubView(cellSubView, parent, bi.colInx, rowInx, cellSubView.getColspan(), 1);

                AltViewIFace altView = subView.getDefaultAltView();
                DBTableInfo sbTableInfo = DBTableIdMgr.getInstance().getByClassName(subView.getClassName());
                ViewDefIFace altsViewDef = (ViewDefIFace) altView.getViewDef();

                if (altsViewDef instanceof FormViewDefIFace) {
                    FormViewDefIFace fvd = (FormViewDefIFace) altsViewDef;
                    processRows(sbTableInfo, parent, viewDef, validator, viewBldObj, altView.getMode(),
                            labelsForHash, currDataObj, fvd.getRows());

                } else if (altsViewDef == null) {
                    // This error is bad enough to have it's own dialog
                    String msg = String.format("The Altview '%s' has a null ViewDef!", altView.getName());
                    FormDevHelper.appendFormDevError(msg);
                    UIRegistry.showError(msg);
                }

                viewBldObj.closeSubView(cellSubView);
                bi.colInx += cell.getColspan() + 1;
            }

        } else {
            log.error("buildFormView - Could find subview's with ViewSet[" + cellSubView.getViewSetName()
                    + "] ViewName[" + subViewName + "]");
        }
        // still have compToAdd = null;

    } else if (cell.getType() == FormCellIFace.CellType.statusbar) {
        bi.compToAdd = new JStatusBar();
        bi.doRegControl = true;
        bi.doAddToValidator = false;

    } else if (cell.getType() == FormCellIFace.CellType.panel) {
        bi.doRegControl = false;
        bi.doAddToValidator = false;

        cell.setIgnoreSetGet(true);

        FormCellPanel cellPanel = (FormCellPanel) cell;
        PanelViewable.PanelType panelType = PanelViewable.getType(cellPanel.getPanelType());

        if (panelType == PanelViewable.PanelType.Panel) {
            PanelViewable panelViewable = new PanelViewable(viewBldObj, cellPanel);

            processRows(parentTableInfo, parent, viewDef, validator, panelViewable, mode, labelsForHash,
                    currDataObj, cellPanel.getRows());

            panelViewable.setVisible(cellPanel.getPropertyAsBoolean("visible", true));

            setBorder(panelViewable, cellPanel.getProperties());
            if (parent != null) {
                Color bgColor = getBackgroundColor(cellPanel.getProperties(), parent.getBackground());
                if (bgColor != null && bgColor != parent.getBackground()) {
                    panelViewable.setOpaque(true);
                    panelViewable.setBackground(bgColor);
                }
            }

            bi.compToAdd = panelViewable;
            bi.doRegControl = true;
            bi.compToReg = panelViewable;

        } else if (panelType == PanelViewable.PanelType.ButtonBar) {
            bi.compToAdd = PanelViewable.buildButtonBar(processRows(viewBldObj, cellPanel.getRows()));

        } else {
            FormDevHelper.appendFormDevError("Panel Type is not implemented.");
            return false;
        }
    }

    String visProp = cell.getProperty("visible");
    if (StringUtils.isNotEmpty(visProp) && visProp.equalsIgnoreCase("false") && bi.compToAdd != null) {
        bi.compToAdd.setVisible(false);
    }

    return true;
}