FileDocCategorySizeDatePackage
RoleMapElementEditor.javaAPI DocGlassfish v2 API7996Fri May 04 22:34:56 BST 2007com.sun.enterprise.tools.common.properties

RoleMapElementEditor

public class RoleMapElementEditor extends PropertyEditorSupport
author
vkraemer
version

Fields Summary
private RoleMapElement
roleMap
private JTable
table
private JTextField
desc
private static ResourceBundle
bundle
static final ResourceBundle
helpBundle
TableCellEditor
c023cell
TableCellEditor
c1cell
Constructors Summary
public RoleMapElementEditor()
Creates new RoleMapElementEditor

 // NOI18N
    
        
      
    
Methods Summary
public java.lang.StringgetAsText()
The String is not editable in the sheet.

        return null;
    
public java.awt.ComponentgetCustomEditor()
return the UI components to edit this object

        table = new JTable(new RoleMapElementTableModel(roleMap));
        table.setDefaultEditor(Object.class, c023cell);
        if (table.getModel().getRowCount() > 0)
            table.editCellAt(0,0);
        javax.swing.table.TableColumnModel tcm = table.getColumnModel();
        //
        // make the password field editor 'secret'...
        //
        javax.swing.table.TableColumn tc = tcm.getColumn(1);
        //PasswordRenderEdit pre1 = new PasswordRenderEdit();
        PasswordRender pre2 = new PasswordRender();
        tc.setCellEditor(c1cell);
        tc.setCellRenderer(pre2);
        
        //set principal editor
        javax.swing.table.TableColumn principalColumn = tcm.getColumn(3);
        principalColumn.setCellEditor(new PrincipalsEditor(null));
        principalColumn.setCellRenderer(new PrincipalsRenderer());
        JScrollPane sp = new JScrollPane(table);
        
        JPanel pane = new JPanel();
        GridBagLayout gridbag = new GridBagLayout();
        pane.setLayout(gridbag);
        GridBagConstraints  c = new GridBagConstraints();
        c.weightx = 0.5;
        c.weighty = 0.5;
        c.gridx = 0;
        c.gridy = 0;
        c.gridwidth = 1;
        c.gridheight = 1;
        c.insets = new Insets(5, 5, 5, 5);
        c.fill = GridBagConstraints.BOTH;
        pane.add(sp, c);

        c.weightx = 0.5;
        c.weighty = 0.5;
        c.gridx = 0;
        c.gridy = 1;
        c.gridwidth = 1;
        c.gridheight = 1;
        c.insets = new Insets(5, 5, 5, 5);
        c.fill = GridBagConstraints.BOTH;
        JLabel descLabel = new JLabel(bundle.getString("LBL_DESCRIPTION"));   //NOI18N
/*        pane.add(descLabel, c);

        c.weightx = 0.5;
        c.weighty = 0.5;
        c.gridx = 0;
        c.gridy = 2;
        c.gridwidth = 1;
        c.gridheight = 1;
        c.insets = new Insets(5, 5, 5, 5);
        c.fill = GridBagConstraints.BOTH;
 */
        desc = new JTextField(68);
        desc.setText(roleMap.getRoleMapDescription());
        JPanel descPane = new JPanel();
        descLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        descPane.add(descLabel);
        descPane.add(desc);
        pane.add(descPane, c);
        org.openide.util.HelpCtx.setHelpIDString(pane, helpBundle.getString("role_map_editor")); //NOI18N
        return pane;
    
public java.lang.ObjectgetValue()

        if (roleMap != null && desc != null)
            roleMap.setRoleMapDescription(desc.getText());
        return new RoleMapElement(roleMap);
    
public booleanisPaintable()
Does this editor use painting to illuminate the property state in the property sheet

        return true;
    
public voidpaintValue(java.awt.Graphics gfx, java.awt.Rectangle box)

        int num = roleMap.getLength();
        String s = "" + num + " "; //NOI18N
        
        String format = null; //bundle.getString
        if(num == 1)
            format = bundle.getString("PROP_TEXT_ONE_MAP_ELEMNT");//NOI18N
        else
            format = bundle.getString("PROP_TEXT_N_MAP_ELEMNT");//NOI18N

        s = java.text.MessageFormat.format(format, new Object[]  { s });
        
        java.awt.FontMetrics fm = gfx.getFontMetrics();
        
        //PropertySheetSettings pss = (PropertySheetSettings)	PropertySheetSettings.findObject(PropertySheetSettings.class, true);
        //gfx.setColor(pss.getValueColor());
        gfx.drawString(s, 4, (box.height - fm.getHeight()) / 2 + 1 + fm.getMaxAscent());
    
public voidsetAsText(java.lang.String text)

        throw new IllegalArgumentException(bundle.getString("ERR_SET_AS_TEXT_ILLEGAL")); //NOI18N
    
public voidsetValue(java.lang.Object value)

    
        
        Reporter.info("");  //NOI18N
        if (table != null) {
            TableCellEditor cell = table.getCellEditor();
            if (null != cell) {
                Reporter.info("There is a cell: " + cell);//NOI18N
                Reporter.info("  this is the value of the cell: " + cell.getCellEditorValue());//NOI18N
                int r = table.getEditingRow();
                int c = table.getEditingColumn();
                if (r > -1 && c > -1) {
                    table.setValueAt(cell.getCellEditorValue(), r, c);
                }
            }
        }
        if (value instanceof RoleMapElement) {
            roleMap = (RoleMapElement) value; //new RoleMapElement((RoleMapElement) value);
        }
    
public booleansupportsCustomEditor()

        return true;