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

PrincipalsEditor

public class PrincipalsEditor extends Object implements TableCellEditor
author
shirleyc
version

Fields Summary
private Vector
model
private transient Vector
listeners
private transient Vector
originalValue
private JTable
principalsTable
private JButton
button
private JDialog
d
private JFrame
frame
private static ResourceBundle
bundle
static final ResourceBundle
helpBundle
Constructors Summary
public PrincipalsEditor(JFrame f)

 // NOI18N
    
       
        listeners = new Vector();
        this.frame = f;
        
	// Create button that brings up the editor
	button = new JButton();
	button.setBackground(Color.white);
	button.setBorderPainted(false);
	button.setMargin(new Insets(0,0,0,0));
        // Set up the dialog that the button brings up
	// This will be called when OK button is selected on resulting Dialog
	button.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    if (d == null)
                        createDialog();
                    d.setVisible(true);
                }
        });        
    
Methods Summary
public voidaddCellEditorListener(javax.swing.event.CellEditorListener cellEditorListener)

        listeners.addElement(cellEditorListener);
    
public voidcancelCellEditing()

        fireEditingCanceled();
    
public voidcreateDialog()

        JPanel pane = new JPanel();
        principalsTable = new JTable();        
        JScrollPane sp = new JScrollPane(principalsTable);        
        d = new JDialog(this.frame, bundle.getString("PRIN_TITLE"), true);    //NOI18N
        d.setSize(500, 300);
        d.getContentPane().setLayout(new BorderLayout());
        pane.setLayout(new BorderLayout());
//        d.getContentPane().add(sp, BorderLayout.CENTER);
        pane.add(sp, BorderLayout.CENTER);
        JButton okButton = new JButton(bundle.getString("OK_BUTTON_LABEL"));   //NOI18N
        JButton cancelButton = new JButton(bundle.getString("CANCEL_BUTTON_LABEL"));   //NOI18N
        okButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ev) {
                stopCellEditing();
                d.setVisible(false);
                d.dispose();
            }
        });
        cancelButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ev) {
                cancelCellEditing();
                d.setVisible(false);
                d.dispose();
            }
        });
        JPanel buttonsPane = new JPanel();
        buttonsPane.add(okButton);
        buttonsPane.add(cancelButton);
        org.openide.util.HelpCtx.setHelpIDString(pane, helpBundle.getString("role_map_principal_editor")); //NOI18N
 //       d.getContentPane().add(buttonsPane, BorderLayout.SOUTH);
        pane.add(buttonsPane, BorderLayout.SOUTH);
        d.getContentPane().add(pane, BorderLayout.CENTER);
 //       d.setLocationRelativeTo(this.frame);
    
private voidfireEditingCanceled()

        ChangeEvent ce = new ChangeEvent(this);
        for (int i = listeners.size() - 1; i >= 0; i--) {
            ((CellEditorListener)listeners.elementAt(i)).editingCanceled(ce);
        }
    
private voidfireEditingStopped()

        ChangeEvent ce = new ChangeEvent(this);
        for (int i = listeners.size() - 1; i >= 0; i--) {
            ((CellEditorListener)listeners.elementAt(i)).editingStopped(ce);
        }
    
public java.lang.ObjectgetCellEditorValue()

        return model;
    
public java.awt.ComponentgetTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)

        if (value == null)
            model = new Vector();
        else if (value instanceof String && ((String)value).length() == 0)
            model = new Vector();
        else if (value instanceof Vector)
            model = (Vector)value;
        else
            Reporter.error(value);
        if (principalsTable == null)
            createDialog();
        principalsTable.setModel(new PrincipalTableModel(model));
        originalValue = model;
     
        table.setRowSelectionInterval(row, row);
        table.setColumnSelectionInterval(column, column);
//        return sp;   
        return button;
    
public booleanisCellEditable(java.util.EventObject eventObject)

        return true;
    
public voidremoveCellEditorListener(javax.swing.event.CellEditorListener cellEditorListener)

        listeners.removeElement(cellEditorListener);
    
public booleanshouldSelectCell(java.util.EventObject eventObject)

        return true;
    
public booleanstopCellEditing()

        if (principalsTable != null) {
            TableCellEditor cell = principalsTable.getCellEditor();
            if (cell != null)
                cell.stopCellEditing();
        }
 
        model = ((PrincipalTableModel)principalsTable.getModel()).getPrincipals();
        fireEditingStopped();
        return true;