Example usage for javax.swing JScrollPane setHorizontalScrollBarPolicy

List of usage examples for javax.swing JScrollPane setHorizontalScrollBarPolicy

Introduction

In this page you can find the example usage for javax.swing JScrollPane setHorizontalScrollBarPolicy.

Prototype

@BeanProperty(preferred = true, enumerationValues = { "ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED",
        "ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER",
        "ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS" }, description = "The scrollpane scrollbar policy")
public void setHorizontalScrollBarPolicy(int policy) 

Source Link

Document

Determines when the horizontal scrollbar appears in the scrollpane.

Usage

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  . jav  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;
}

From source file:com.mirth.connect.client.ui.Frame.java

/**
 * Builds the content panel with a title bar and settings.
 *//*from ww w  .j  a v  a 2  s. c o m*/
private void buildContentPanel(JXTitledPanel container, JScrollPane component, boolean opaque) {
    container.getContentContainer().setLayout(new BorderLayout());
    container.setBorder(null);
    container.setTitleFont(new Font("Tahoma", Font.BOLD, 18));
    container.setTitleForeground(UIConstants.HEADER_TITLE_TEXT_COLOR);
    JLabel mirthConnectImage = new JLabel();
    mirthConnectImage.setIcon(UIConstants.MIRTHCONNECT_LOGO_GRAY);
    mirthConnectImage.setText(" ");
    mirthConnectImage.setToolTipText(UIConstants.MIRTHCONNECT_TOOLTIP);
    mirthConnectImage.setCursor(new Cursor(Cursor.HAND_CURSOR));

    mirthConnectImage.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent evt) {
            BareBonesBrowserLaunch.openURL(UIConstants.MIRTHCONNECT_URL);
        }
    });

    ((JPanel) container.getComponent(0)).add(mirthConnectImage);

    component.setBorder(new LineBorder(Color.GRAY, 1));
    component.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    component.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);

    container.getContentContainer().add(component);
}

From source file:net.sourceforge.pmd.util.designer.Designer.java

private JPanel createXPathQueryPanel() {
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    xpathQueryArea.setBorder(BorderFactory.createLineBorder(Color.black));
    makeTextComponentUndoable(xpathQueryArea);
    JScrollPane scrollPane = new JScrollPane(xpathQueryArea);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    final JButton b = createGoButton();

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());
    topPanel.add(new JLabel("XPath Query (if any):"), BorderLayout.WEST);
    topPanel.add(createXPathVersionPanel(), BorderLayout.EAST);

    p.add(topPanel, BorderLayout.NORTH);
    p.add(scrollPane, BorderLayout.CENTER);
    p.add(b, BorderLayout.SOUTH);

    return p;//w w w. j a  v a2  s.c  o  m
}

From source file:nz.govt.natlib.ndha.manualdeposit.metadata.MetaDataConfigurator.java

private void initComponents() {

    tabMain = new javax.swing.JTabbedPane();
    pnlApplicationData = new javax.swing.JPanel();
    pnlUsers = new javax.swing.JPanel();
    pnlUserGroupData = new javax.swing.JPanel();
    pnlMetaData = new javax.swing.JPanel();
    pnlSipStatusData = new javax.swing.JPanel();

    setTitle("Indigo MetaData Configurator");
    setDefaultCloseOperation(3);/*from  w ww . jav  a 2 s. c  o  m*/
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowOpened(java.awt.event.WindowEvent evt) {
            formWindowOpened(evt);
        }

        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }
    });

    javax.swing.GroupLayout pnlApplicationDataLayout = new javax.swing.GroupLayout(pnlApplicationData);
    pnlApplicationData.setLayout(pnlApplicationDataLayout);
    pnlApplicationDataLayout.setHorizontalGroup(pnlApplicationDataLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 884, Short.MAX_VALUE));
    pnlApplicationDataLayout.setVerticalGroup(pnlApplicationDataLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 429, Short.MAX_VALUE));

    tabMain.addTab("Maintain Application Data", pnlApplicationData);

    javax.swing.GroupLayout pnlUsersLayout = new javax.swing.GroupLayout(pnlUsers);
    pnlUsers.setLayout(pnlUsersLayout);
    pnlUsersLayout.setHorizontalGroup(pnlUsersLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 884, Short.MAX_VALUE));
    pnlUsersLayout.setVerticalGroup(pnlUsersLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 429, Short.MAX_VALUE));

    tabMain.addTab("Maintain Users", pnlUsers);

    javax.swing.GroupLayout pnlUserGroupDataLayout = new javax.swing.GroupLayout(pnlUserGroupData);
    pnlUserGroupData.setLayout(pnlUserGroupDataLayout);
    pnlUserGroupDataLayout.setHorizontalGroup(pnlUserGroupDataLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 884, Short.MAX_VALUE));
    pnlUserGroupDataLayout.setVerticalGroup(pnlUserGroupDataLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 429, Short.MAX_VALUE));

    tabMain.addTab("User Group Data", pnlUserGroupData);

    javax.swing.GroupLayout pnlMetaDataLayout = new javax.swing.GroupLayout(pnlMetaData);
    pnlMetaData.setLayout(pnlMetaDataLayout);
    pnlMetaDataLayout.setHorizontalGroup(pnlMetaDataLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 884, Short.MAX_VALUE));
    pnlMetaDataLayout.setVerticalGroup(pnlMetaDataLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 429, Short.MAX_VALUE));

    tabMain.addTab("Maintain Meta Data", pnlMetaData);

    javax.swing.GroupLayout pnlSipStatusDataLayout = new javax.swing.GroupLayout(pnlSipStatusData);
    pnlSipStatusData.setLayout(pnlSipStatusDataLayout);
    pnlSipStatusDataLayout.setHorizontalGroup(pnlSipStatusDataLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 884, Short.MAX_VALUE));
    pnlSipStatusDataLayout.setVerticalGroup(pnlSipStatusDataLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 429, Short.MAX_VALUE));

    tabMain.addTab("Maintain SIP status definitions", pnlSipStatusData);

    // Added by Ben - 6.12.2013
    // Surround main content in a scroll pane - to handle display on smaller screen resolutions.
    tabMain.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    javax.swing.JScrollPane scrollFrame = new JScrollPane(tabMain);
    tabMain.setAutoscrolls(true);
    scrollFrame.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollFrame.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(scrollFrame, javax.swing.GroupLayout.DEFAULT_SIZE, 889, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(scrollFrame, javax.swing.GroupLayout.DEFAULT_SIZE, 454, Short.MAX_VALUE));

    pack();
}

From source file:org.dishevelled.brainstorm.BrainStorm.java

/**
 * Layout components./*from www.  j ava2s.  co  m*/
 */
private void layoutComponents() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setBorder(null);
    scrollPane.setOpaque(true);
    scrollPane.setBackground(backgroundColor);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
    add(placeholder);

    JPanel flow = new JPanel();
    flow.setLayout(new FlowLayout());
    flow.setOpaque(false);
    flow.add(scrollPane);

    add(flow);
    add(Box.createVerticalGlue());
    add(Box.createVerticalGlue());
}

From source file:org.docx4all.swing.ExternalHyperlinkDialog.java

private void fillRow5(JPanel host, GridBagConstraints c) {
    c.gridx = 0;/*  w ww  . j  av  a  2s  . c  o m*/
    c.gridy = 4;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.insets = gridCellInsets;
    c.ipadx = 0;
    c.ipady = 0;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.fill = GridBagConstraints.NONE;

    JPanel directoryPathPanel = new JPanel();
    directoryPathPanel.setBorder(BorderFactory.createEtchedBorder());

    this.directoryPathField = new JTextArea();
    this.directoryPathField.setEditable(false);
    this.directoryPathField.setEnabled(false);
    this.directoryPathField.setLineWrap(true);

    JScrollPane sp = new JScrollPane(this.directoryPathField);
    sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    sp.setMinimumSize(new Dimension(350, 100));
    sp.setPreferredSize(new Dimension(350, 100));
    directoryPathPanel.add(sp);
    host.add(directoryPathPanel, c);

    c.gridx = 2;
    c.gridy = 4;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.insets = gridCellInsets;
    c.ipadx = 0;
    c.ipady = 0;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.fill = GridBagConstraints.NONE;

    this.selectButton = new JButton("Select...");
    this.selectButton.addActionListener(new SelectButtonActionListener());
    this.selectButton.setSize(100, 50);
    host.add(this.selectButton, c);
}

From source file:org.genedb.jogra.plugins.TermRationaliser.java

/**
 * Return a new JFrame which is the main interface to the Rationaliser.
 *///from  w  w  w  .  j ava  2s  .c  om
public JFrame getMainPanel() {

    /* JFRAME */
    frame.setTitle(WINDOW_TITLE);
    frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
    frame.setLayout(new BorderLayout());

    /* MENU */
    JMenuBar menuBar = new JMenuBar();

    JMenu actions_menu = new JMenu("Actions");
    JMenuItem actions_mitem_1 = new JMenuItem("Refresh lists");
    actions_mitem_1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            initModels();
        }
    });
    actions_menu.add(actions_mitem_1);

    JMenu about_menu = new JMenu("About");
    JMenuItem about_mitem_1 = new JMenuItem("About");
    about_mitem_1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            JOptionPane.showMessageDialog(null,
                    "Term Rationaliser \n" + "Wellcome Trust Sanger Institute, UK \n" + "2009",
                    "Term Rationaliser", JOptionPane.PLAIN_MESSAGE);
        }
    });
    about_menu.add(about_mitem_1);

    menuBar.add(about_menu);
    menuBar.add(actions_menu);
    frame.add(menuBar, BorderLayout.NORTH);

    /* MAIN BOX */
    Box center = Box.createHorizontalBox(); //A box that displays contents from left to right
    center.add(Box.createHorizontalStrut(5)); //Invisible fixed-width component

    /* FROM LIST AND PANEL */
    fromList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); //Allow multiple products to be selected 
    fromList.addKeyListener(new KeyListener() {
        @Override
        public void keyPressed(KeyEvent arg0) {
            if (arg0.getKeyCode() == KeyEvent.VK_RIGHT) {
                synchroniseLists(fromList, toList); //synchronise from left to right
            }
        }

        @Override
        public void keyReleased(KeyEvent arg0) {
        }

        @Override
        public void keyTyped(KeyEvent arg0) {
        }
    });

    Box fromPanel = this.createRationaliserPanel(FROM_LIST_NAME, fromList); //Box on left hand side
    fromPanel.add(Box.createVerticalStrut(55)); //Add some space
    center.add(fromPanel); //Add to main box
    center.add(Box.createHorizontalStrut(3)); //Add some space

    /* MIDDLE PANE */
    Box middlePane = Box.createVerticalBox();

    ClassLoader classLoader = this.getClass().getClassLoader(); //Needed to access the images later on
    ImageIcon leftButtonIcon = new ImageIcon(classLoader.getResource("left_arrow.gif"));
    ImageIcon rightButtonIcon = new ImageIcon(classLoader.getResource("right_arrow.gif"));

    leftButtonIcon = new ImageIcon(leftButtonIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH)); //TODO: Investigate simpler way to resize an icon!
    rightButtonIcon = new ImageIcon(rightButtonIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH)); //TODO: Investigate simpler way to resize an icon!

    JButton rightSynch = new JButton(rightButtonIcon);
    rightSynch.setToolTipText("Synchronise TO list. \n Shortcut: Right-arrow key");

    rightSynch.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            synchroniseLists(fromList, toList);
        }
    });

    JButton leftSynch = new JButton(leftButtonIcon);
    leftSynch.setToolTipText("Synchronise FROM list. \n Shortcut: Left-arrow key");

    leftSynch.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            synchroniseLists(toList, fromList);
        }
    });

    middlePane.add(rightSynch);
    middlePane.add(leftSynch);

    center.add(middlePane); //Add middle pane to main box
    center.add(Box.createHorizontalStrut(3));

    /* TO LIST AND PANEL */
    toList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); //Single product selection in TO list
    toList.addKeyListener(new KeyListener() {
        @Override
        public void keyPressed(KeyEvent arg0) {
            if (arg0.getKeyCode() == KeyEvent.VK_LEFT) {
                synchroniseLists(toList, fromList); //synchronise from right to left
            }
        }

        @Override
        public void keyReleased(KeyEvent arg0) {
        }

        @Override
        public void keyTyped(KeyEvent arg0) {
        }
    });

    Box toPanel = this.createRationaliserPanel(TO_LIST_NAME, toList);

    Box newTerm = Box.createVerticalBox();

    textField = new JTextArea(1, 1); //textfield to let the user edit the name of an existing term
    textField.setMaximumSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().height, 10));

    textField.setForeground(Color.BLUE);
    JScrollPane jsp = new JScrollPane(textField); //scroll pane so that there is a horizontal scrollbar
    jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    newTerm.add(jsp);
    TitledBorder editBorder = BorderFactory.createTitledBorder("Edit term name");
    editBorder.setTitleColor(Color.DARK_GRAY);
    newTerm.setBorder(editBorder);
    toPanel.add(newTerm); //add textfield to panel

    center.add(toPanel); //add panel to main box
    center.add(Box.createHorizontalStrut(5));

    frame.add(center); //add the main panel to the frame

    initModels(); //load the lists with data

    /* BOTTOM HALF OF FRAME */
    Box main = Box.createVerticalBox();
    TitledBorder border = BorderFactory.createTitledBorder("Information");
    border.setTitleColor(Color.DARK_GRAY);

    /* INFORMATION BOX */
    Box info = Box.createVerticalBox();

    Box scope = Box.createHorizontalBox();
    scope.add(Box.createHorizontalStrut(5));
    scope.add(scopeLabel); //label showing the scope of the terms
    scope.add(Box.createHorizontalGlue());

    Box productCount = Box.createHorizontalBox();
    productCount.add(Box.createHorizontalStrut(5));
    productCount.add(productCountLabel); //display the label showing the number of terms
    productCount.add(Box.createHorizontalGlue());

    info.add(scope);
    info.add(productCount);
    info.setBorder(border);

    /* ACTION BUTTONS */
    Box actionButtons = Box.createHorizontalBox();
    actionButtons.add(Box.createHorizontalGlue());
    actionButtons.add(Box.createHorizontalStrut(10));

    JButton findFix = new JButton(new FindClosestMatchAction());
    actionButtons.add(findFix);
    actionButtons.add(Box.createHorizontalStrut(10));

    RationaliserAction ra = new RationaliserAction();
    // RationaliserAction2 ra2 = new RationaliserAction2();
    JButton go = new JButton(ra);
    actionButtons.add(go);
    actionButtons.add(Box.createHorizontalGlue());

    /* MORE INFORMATION TOGGLE */
    Box buttonBox = Box.createHorizontalBox();
    final JButton toggle = new JButton("Hide information <<");

    buttonBox.add(Box.createHorizontalStrut(5));
    buttonBox.add(toggle);
    buttonBox.add(Box.createHorizontalGlue());

    Box textBox = Box.createHorizontalBox();

    final JScrollPane scrollPane = new JScrollPane(information);
    scrollPane.setPreferredSize(new Dimension(frame.getWidth(), 100));
    scrollPane.setVisible(true);
    textBox.add(Box.createHorizontalStrut(5));
    textBox.add(scrollPane);

    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            if (toggle.getText().equals("Show information >>")) {
                scrollPane.setVisible(true);
                toggle.setText("Hide information <<");
                frame.setPreferredSize(new Dimension(frame.getWidth(), frame.getHeight() + 100));
                frame.pack();
            } else if (toggle.getText().equals("Hide information <<")) {
                scrollPane.setVisible(false);
                toggle.setText("Show information >>");
                frame.setPreferredSize(new Dimension(frame.getWidth(), frame.getHeight() - 100));
                frame.pack();
            }
        }
    };
    toggle.addActionListener(actionListener);

    main.add(Box.createVerticalStrut(5));
    main.add(info);
    main.add(Box.createVerticalStrut(5));
    main.add(Box.createVerticalStrut(5));
    main.add(actionButtons);
    main.add(Box.createVerticalStrut(10));
    main.add(buttonBox);
    main.add(textBox);

    frame.add(main, BorderLayout.SOUTH);
    frame.pack();
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    frame.setVisible(true);
    //initModels();

    return frame;
}

From source file:org.genedb.jogra.plugins.TermRationaliser.java

private Box createRationaliserPanel(final String name, final RationaliserJList rjlist) {

    int preferredHeight = 500; //change accordingly
    int preferredWidth = 500;

    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension size = tk.getScreenSize();
    int textboxHeight = 10; //change accordingly
    int textboxWidth = size.width;

    Box box = Box.createVerticalBox();
    box.add(new JLabel(name));

    JTextField searchField = new JTextField(20); //Search field on top
    /* We don't want this textfield's height to expand when
     * the Rationaliser is dragged to exapnd. So we set it's
     * height to what we want and the width to the width of
     * the screen  /*from   w ww.jav  a 2s.  c  om*/
     */
    searchField.setMaximumSize(new Dimension(textboxWidth, textboxHeight));
    rjlist.installJTextField(searchField);
    box.add(searchField);

    JScrollPane scrollPane = new JScrollPane(); //scroll pane
    scrollPane.setViewportView(rjlist);
    scrollPane.setPreferredSize(new Dimension(preferredWidth, preferredHeight));
    box.add(scrollPane);

    TitledBorder sysidBorder = BorderFactory.createTitledBorder("Systematic IDs"); //systematic ID box
    sysidBorder.setTitleColor(Color.DARK_GRAY);

    final JTextArea idField = new JTextArea(1, 1);
    idField.setMaximumSize(new Dimension(textboxWidth, textboxHeight));
    idField.setEditable(false);
    idField.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
    idField.setForeground(Color.DARK_GRAY);
    JScrollPane scroll = new JScrollPane(idField);
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    Box sysidBox = Box.createVerticalBox();
    sysidBox.add(scroll /*idField*/);
    sysidBox.setBorder(sysidBorder);
    box.add(sysidBox);

    rjlist.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            Term highlightedTerm = (Term) rjlist.getSelectedValue();
            if (highlightedTerm != null) {
                /* For each list, call the relevant methods
                 * to get the systematic IDs. Then for the
                 * right list, add the term name in the
                 * text box below
                 */
                if (name.equals(FROM_LIST_NAME)) {
                    idField.setText(StringUtils.collectionToCommaDelimitedString(
                            termService.getSystematicIDs(highlightedTerm, selectedTaxons)));
                } else if (name.equals(TO_LIST_NAME)) {
                    idField.setText(StringUtils.collectionToCommaDelimitedString(
                            termService.getSystematicIDs(highlightedTerm, null)));
                    /* We allow the user to edit the term name */
                    textField.setText(highlightedTerm.getName());
                }

            }
        }
    });

    return box;

}

From source file:org.jajuk.ui.views.ArtistView.java

@Override
public void shortCall(Object in) {
    removeAll();//from ww w  .ja  v  a 2  s  .co  m
    jspAlbums = getLastFMSuggestionsPanel(SuggestionType.OTHERS_ALBUMS, true);
    // Artist unknown from last.fm, leave
    if (artistInfo == null
            // If image url is void, last.fm doesn't provide enough data about this
            // artist, we reset the view
            || StringUtils.isBlank(artistInfo.getImageUrl())) {
        reset();
        return;
    }
    artistThumb = new LastFmArtistThumbnail(artistInfo);
    // No known icon next to artist thumb
    artistThumb.setArtistView(true);
    artistThumb.populate();
    jtaArtistDesc = new JTextArea(bio) {
        private static final long serialVersionUID = 9217998016482118852L;

        // We set the margin this way, setMargin() doesn't work due to
        // existing border
        @Override
        public Insets getInsets() {
            return new Insets(2, 4, 0, 4);
        }
    };
    jtaArtistDesc.setBorder(null);
    jtaArtistDesc.setEditable(false);
    jtaArtistDesc.setLineWrap(true);
    jtaArtistDesc.setWrapStyleWord(true);
    jtaArtistDesc.setOpaque(false);
    JScrollPane jspWiki = new JScrollPane(jtaArtistDesc);
    jspWiki.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    jspWiki.setBorder(null);
    jspWiki.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    // Add items, layout is different according wiki text availability
    if (StringUtils.isNotBlank(jtaArtistDesc.getText())) {
        setLayout(new MigLayout("ins 5,gapy 5", "[grow]", "[grow][20%!][grow]"));
        add(artistThumb, "center,wrap");
        // don't add the textarea if no wiki text available
        add(jspWiki, "growx,wrap");
        add(jspAlbums, "grow,wrap");
    } else {
        setLayout(new MigLayout("ins 5,gapy 5", "[grow]"));
        add(artistThumb, "center,wrap");
        // don't add the textarea if no wiki text available
        add(jspAlbums, "grow,wrap");
    }
    revalidate();
    repaint();
}

From source file:org.kepler.gui.ComponentLibraryPreferencesTab.java

/**
 * Initialize the source list table.//  ww w . j av a  2  s .co m
 */
private void initSourceList() {

    try {

        ComponentSourceTableModel cstm = new ComponentSourceTableModel();
        _sourceList = new JTable(cstm);
        _sourceList.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        _sourceList.setShowGrid(true);
        _sourceList.setShowHorizontalLines(true);
        _sourceList.setShowVerticalLines(true);
        _sourceList.setGridColor(Color.lightGray);
        _sourceList.setIntercellSpacing(new Dimension(5, 5));
        _sourceList.setRowHeight(_sourceList.getRowHeight() + 10);
        _sourceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        if (isDebugging) {
            log.debug("intercellspacing: " + _sourceList.getIntercellSpacing().toString());
            log.debug("getRowHeight(): " + _sourceList.getRowHeight());
        }

        // Search column
        TableColumn c0 = _sourceList.getColumnModel().getColumn(0);
        c0.setMinWidth(50);
        c0.setPreferredWidth(60);
        c0.setMaxWidth(100);
        c0.setResizable(true);

        // Save column
        TableColumn c1 = _sourceList.getColumnModel().getColumn(1);
        c1.setMinWidth(50);
        c1.setPreferredWidth(60);
        c1.setMaxWidth(100);
        c1.setResizable(true);

        // Type column
        TableColumn c2 = _sourceList.getColumnModel().getColumn(2);
        c2.setMinWidth(50);
        c2.setPreferredWidth(60);
        c2.setMaxWidth(100);
        c2.setResizable(true);

        // Name column
        TableColumn c3 = _sourceList.getColumnModel().getColumn(3);
        c3.setMinWidth(50);
        c3.setPreferredWidth(100);
        c3.setMaxWidth(200);
        c3.setResizable(true);

        // Source column
        TableColumn c4 = _sourceList.getColumnModel().getColumn(4);
        c4.setMinWidth(200);
        c4.setPreferredWidth(600);
        c4.setMaxWidth(2000);
        c4.setResizable(true);

        JScrollPane sourceListSP = new JScrollPane(_sourceList);
        sourceListSP.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        sourceListSP.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
        sourceListSP.setBackground(TabManager.BGCOLOR);
        add(sourceListSP);
    } catch (Exception e) {
        System.out.println(e.toString());
    }

}