FileDocCategorySizeDatePackage
ClusterDetailsPanel.javaAPI DocGlassfish v2 API17373Fri May 04 22:35:06 BST 2007com.sun.enterprise.tools.upgrade.gui

ClusterDetailsPanel

public class ClusterDetailsPanel extends JPanel
author
prakash

Fields Summary
private com.sun.enterprise.util.i18n.StringManager
stringManager
private ClusterFilesTableModel
clusterFilesTableModel
private JTable
clusterFilesTable
private JScrollPane
clusterFilesTableScrollPane
private JPanel
clusterFilesPanel
private JPanel
addRemoveEditHomeInterfacePanel
private JButton
addClusterFileButton
private JButton
removeClusterFileButton
private JFileChooser
fileChooser
private Vector
dialogListeners
Constructors Summary
public ClusterDetailsPanel()
Creates a new instance of ClusterDetailsPanel


           
      
        this.initComponents();
    
Methods Summary
public voidaddClusterFileAction()

        int returnedValue = getfileChooser().showOpenDialog(this);
        if(returnedValue == javax.swing.JFileChooser.APPROVE_OPTION){
            getClusterFilesTableModel().addClusterFile(String.valueOf(getfileChooser().getSelectedFile()));	            
        }	
    
public voidaddDialogListener(DialogListener listener)

        this.dialogListeners.addElement(listener);
    
public voidenableDisableRemoveButton(javax.swing.JTable table, javax.swing.JButton removeButton)

	if (table.getSelectionModel().isSelectionEmpty()) {
	    //no rows are selected
	    // Need to remove disable remove and edit buttons.
	    removeButton.setEnabled(false);
		
	} else {
	    //int selectedRow = lsm.getMinSelectionIndex();
	    if (table.getSelectedRowCount() > 1) {
		//editButton.setEnabled(false);
	    } else {
		removeButton.setEnabled(true);
		//editButton.setEnabled(true);
	    }

	    //selectedRow is selected
	}
    
private javax.swing.JPanelgetClusterFilesPanel()

	if (clusterFilesPanel == null) {
            clusterFilesPanel = new javax.swing.JPanel();
            clusterFilesPanel.setName("clusterFilesPanel");
            clusterFilesPanel.setLayout(new java.awt.GridBagLayout());
                        
            JLabel tableTitleLabel = new JLabel();
            tableTitleLabel.setText(stringManager.getString("upgrade.gui.clusterPanel.tableTitleName"));
            java.awt.GridBagConstraints labelConstraints = new java.awt.GridBagConstraints();
            labelConstraints.gridx = 0; labelConstraints.gridy = 0;
            labelConstraints.gridwidth = 3;
            labelConstraints.fill = java.awt.GridBagConstraints.NONE;
            labelConstraints.insets = new java.awt.Insets(10, 10, 5, 0);
            clusterFilesPanel.add(tableTitleLabel, labelConstraints);
            
            java.awt.GridBagConstraints constraintsClusterScrollPane1 = new java.awt.GridBagConstraints();
            constraintsClusterScrollPane1.gridx = 0; constraintsClusterScrollPane1.gridy = 1;
            constraintsClusterScrollPane1.gridwidth = 2;
            constraintsClusterScrollPane1.fill = java.awt.GridBagConstraints.BOTH;
            constraintsClusterScrollPane1.weightx = 1.0;
            constraintsClusterScrollPane1.weighty = 1.0;
            constraintsClusterScrollPane1.insets = new java.awt.Insets(5, 10, 5, 0);
            clusterFilesPanel.add(getClusterFilesTableScrollPane(), constraintsClusterScrollPane1);
            
            java.awt.GridBagConstraints constraintsaddRemoveEditHomeInterfacePanel1 = new java.awt.GridBagConstraints();
            constraintsaddRemoveEditHomeInterfacePanel1.gridx = 2; constraintsaddRemoveEditHomeInterfacePanel1.gridy = 1;
            constraintsaddRemoveEditHomeInterfacePanel1.fill = java.awt.GridBagConstraints.VERTICAL;
            constraintsaddRemoveEditHomeInterfacePanel1.weighty = 1.0;
            constraintsaddRemoveEditHomeInterfacePanel1.insets = new java.awt.Insets(5, 0, 5, 0);
            clusterFilesPanel.add(getaddRemoveEditHomeInterfacePanel(), constraintsaddRemoveEditHomeInterfacePanel1);
        }
	return clusterFilesPanel;
    
private javax.swing.JTablegetClusterFilesTable()

        if (clusterFilesTable == null) {
            clusterFilesTable = new javax.swing.JTable();
            clusterFilesTable.setName("clusterFilesTable");
            getClusterFilesTableScrollPane().setColumnHeaderView(clusterFilesTable.getTableHeader());
            getClusterFilesTableScrollPane().getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE);
            clusterFilesTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
            clusterFilesTable.setAutoCreateColumnsFromModel(true);
            clusterFilesTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
            clusterFilesTable.setAutoCreateColumnsFromModel(true);
            
            ListSelectionModel rowSM = clusterFilesTable.getSelectionModel();
            rowSM.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
                public void valueChanged(javax.swing.event.ListSelectionEvent e) {
                    //Ignore extra messages.
                    if (e.getValueIsAdjusting()) return;
                    
                    ListSelectionModel lsm = (ListSelectionModel)e.getSource();
                    enableDisableRemoveButton(clusterFilesTable,getremoveClusterFileButton());
                }
            });
            final DefaultCellEditor editor = (DefaultCellEditor)clusterFilesTable.getDefaultEditor(String.class);
            editor.getComponent().addKeyListener(new java.awt.event.KeyAdapter(){
                public void keyReleased(java.awt.event.KeyEvent ke){
                    try{
                        getClusterFilesTableModel().setValueAt(((JTextField)editor.getComponent()).getText().trim(),clusterFilesTable.getEditingRow(),0);
                    }catch(Exception e){
                    }
                }
                
            });
            
        }
        return clusterFilesTable;
    
public com.sun.enterprise.tools.upgrade.gui.ClusterDetailsPanel$ClusterFilesTableModelgetClusterFilesTableModel()

	if(this.clusterFilesTableModel == null){
	    clusterFilesTableModel = new ClusterFilesTableModel(this);
	}
	return clusterFilesTableModel;
    
private javax.swing.JScrollPanegetClusterFilesTableScrollPane()

        if (clusterFilesTableScrollPane == null) {
            clusterFilesTableScrollPane = new javax.swing.JScrollPane();
            clusterFilesTableScrollPane.setName("getClusterFilesTable");
            clusterFilesTableScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            clusterFilesTableScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
            clusterFilesTableScrollPane.setMaximumSize(new java.awt.Dimension(21, 20));
            clusterFilesTableScrollPane.setPreferredSize(new java.awt.Dimension(21, 20));
            clusterFilesTableScrollPane.setMinimumSize(new java.awt.Dimension(21, 20));
            clusterFilesTableScrollPane.setViewportView(getClusterFilesTable());
        }
        return clusterFilesTableScrollPane;
    
private javax.swing.JButtongetaddClusterFileButton()

        if (addClusterFileButton == null) {
            addClusterFileButton = new javax.swing.JButton();
            addClusterFileButton.setName("addClusterFileButton");
            addClusterFileButton.setText(stringManager.getString("upgrade.gui.clusterPanel.addButtonText"));
            addClusterFileButton.addActionListener(new java.awt.event.ActionListener(){
                public void actionPerformed(java.awt.event.ActionEvent e) {
                    addClusterFileAction();
                }
            });
        }
        return addClusterFileButton;
    
private javax.swing.JPanelgetaddRemoveEditHomeInterfacePanel()

        if (addRemoveEditHomeInterfacePanel == null) {
            addRemoveEditHomeInterfacePanel = new javax.swing.JPanel();
            addRemoveEditHomeInterfacePanel.setName("addRemoveEditHomeInterfacePanel");
            addRemoveEditHomeInterfacePanel.setLayout(new java.awt.GridBagLayout());
            
            java.awt.GridBagConstraints constraintsaddClusterFileButton = new java.awt.GridBagConstraints();
            constraintsaddClusterFileButton.gridx = 0; constraintsaddClusterFileButton.gridy = 0;
            constraintsaddClusterFileButton.insets = new java.awt.Insets(10, 5, 5, 5);
            addRemoveEditHomeInterfacePanel.add(getaddClusterFileButton(), constraintsaddClusterFileButton);
            
            java.awt.GridBagConstraints constraintsremoveClusterFileButton = new java.awt.GridBagConstraints();
            constraintsremoveClusterFileButton.gridx = 0; constraintsremoveClusterFileButton.gridy = 1;
            constraintsremoveClusterFileButton.insets = new java.awt.Insets(5, 5, 5, 5);
            addRemoveEditHomeInterfacePanel.add(getremoveClusterFileButton(), constraintsremoveClusterFileButton);
        }
        return addRemoveEditHomeInterfacePanel;
    
private javax.swing.JFileChoosergetfileChooser()

        if (fileChooser == null) {
            fileChooser = new javax.swing.JFileChooser();
            fileChooser.setName("fileChooser");
            fileChooser.setBounds(668, 49, 500, 300);
            fileChooser.setDialogTitle(stringManager.getString("upgrade.gui.certpanel.chooseFile"));            
        }
        return fileChooser;
    
private javax.swing.JButtongetremoveClusterFileButton()

        if (removeClusterFileButton == null) {
            removeClusterFileButton = new javax.swing.JButton();
            removeClusterFileButton.setName("removeClusterFileButton");
            removeClusterFileButton.setText(stringManager.getString("upgrade.gui.clusterPanel.deleteButtonText"));
            removeClusterFileButton.addActionListener(new java.awt.event.ActionListener(){
                public void actionPerformed(java.awt.event.ActionEvent e) {
                    removeClusterFileAction();
                }
            });
        }
        return removeClusterFileButton;
    
private voidinitComponents()

        this.setLayout(new java.awt.GridBagLayout());
        
        java.awt.GridBagConstraints constraints = new java.awt.GridBagConstraints();
        constraints.gridx = 0; constraints.gridy = 0;
        constraints.gridwidth = 1;
        constraints.fill = java.awt.GridBagConstraints.BOTH;
        constraints.weightx = 1.0;
        constraints.weighty = 1.0;
        constraints.insets = new java.awt.Insets(0, 0, 0, 0);
        this.add(getClusterFilesPanel(), constraints);
        
        getClusterFilesTableScrollPane().setViewportView(getClusterFilesTable());
        
        getClusterFilesTable().setModel(this.getClusterFilesTableModel());
        getClusterFilesTable().createDefaultColumnsFromModel();
        
    
private voidprocessDialogEvent()

        DialogEvent de = new DialogEvent(this, DialogEvent.CHANGE_ACTION);
        for(int i=0 ; i<this.dialogListeners.size(); i++){
            ((DialogListener)dialogListeners.elementAt(i)).dialogProcessed(de);
        }
    
public voidremoveClusterFileAction()

	
	int rows[] = getClusterFilesTable().getSelectedRows();
	String[] rowPropNames = new String[rows.length];
	int option = 
	    javax.swing.JOptionPane.showConfirmDialog(
						      this, 
						      stringManager.getString("upgrade.gui.clusterPanel.removeConfirmMsg"),
                                                      stringManager.getString("upgrade.gui.clusterPanel.removeConfirmTitle"),
						      javax.swing.JOptionPane.YES_NO_OPTION, 
						      javax.swing.JOptionPane.QUESTION_MESSAGE); 
	if (option == javax.swing.JOptionPane.NO_OPTION) {
	    return;
	}

	for (int i = 0; i < rows.length; i++) {
	    rowPropNames[i] = 
		(String)getClusterFilesTableModel().getClusterFile(rows[i]); 
	}
	for (int i = 0; i < rows.length; i++) {
	    getClusterFilesTableModel().removeClusterFile(rowPropNames[i]);
	}
	// Un select items rows in table.
	getClusterFilesTable().clearSelection();
	enableDisableRemoveButton(getClusterFilesTable(), getremoveClusterFileButton()); 	
    
public voidremoveDialogListener(DialogListener listener)

        this.dialogListeners.removeElement(listener);