directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbenn...@apache.org
Subject svn commit: r486187 [32/49] - in /directory/trunks/triplesec: ./ admin-api/ admin-api/src/ admin-api/src/main/ admin-api/src/main/java/ admin-api/src/main/java/org/ admin-api/src/main/java/org/safehaus/ admin-api/src/main/java/org/safehaus/triplesec/ a...
Date Tue, 12 Dec 2006 15:24:14 GMT
Added: directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/RoleDependentsPanel.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/RoleDependentsPanel.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/RoleDependentsPanel.java (added)
+++ directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/RoleDependentsPanel.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,321 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.safehaus.triplesec.admin.swing;
+
+
+import javax.swing.JPanel;
+import java.awt.BorderLayout;
+import javax.swing.JButton;
+import java.awt.GridBagLayout;
+
+import javax.swing.JOptionPane;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import java.awt.GridBagConstraints;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.swing.table.AbstractTableModel;
+import javax.swing.tree.DefaultMutableTreeNode;
+
+import org.safehaus.triplesec.admin.DataAccessException;
+import org.safehaus.triplesec.admin.Profile;
+import org.safehaus.triplesec.admin.Role;
+
+
+public class RoleDependentsPanel extends JPanel
+{
+    private static final long serialVersionUID = -5711894948847093836L;
+    private JPanel centerPanel = null;
+    private JPanel southPanel = null;
+    private JButton removeButton = null;
+    private JScrollPane jScrollPane = null;
+    private JTable dependentsTable = null;
+    private List dependents = new ArrayList();
+    private Role role;
+    private DependencyModel dependencyModel = null;
+    
+
+    /**
+     * This is the default constructor
+     */
+    public RoleDependentsPanel()
+    {
+        super();
+        initialize();
+    }
+
+
+    public void setSelectedNode( DefaultMutableTreeNode node )
+    {
+        this.role = ( Role ) node.getUserObject();
+        this.dependents.clear();
+        
+        if ( node == null || node.getParent() == null || node.getParent().getParent() == null )
+        {
+            return;
+        }
+
+        // -------------------------------------------------------------------
+        // Find the application, and subordinate "Profiles" node
+        // -------------------------------------------------------------------
+
+        DefaultMutableTreeNode applicationNode = ( DefaultMutableTreeNode ) node.getParent().getParent();
+        DefaultMutableTreeNode profilesNode = null;
+        for ( Enumeration ii = applicationNode.children(); ii.hasMoreElements(); /**/ )
+        {
+            DefaultMutableTreeNode child = ( DefaultMutableTreeNode ) ii.nextElement();
+            if ( "Profiles".equals( child.getUserObject() ) )
+            {
+                profilesNode = child;
+                break;
+            }
+        }
+        
+        // -------------------------------------------------------------------
+        // Find the profile dependents
+        // -------------------------------------------------------------------
+        
+        for ( Enumeration ii = profilesNode.children(); ii.hasMoreElements(); /**/ )
+        {
+            DefaultMutableTreeNode child = ( DefaultMutableTreeNode ) ii.nextElement();
+            Profile profile = ( Profile ) ( child ).getUserObject();
+            if ( profile.getRoles().contains( role.getName() ) )
+            {
+                dependents.add( child );
+            }
+        }
+        
+        dependencyModel.fireTableDataChanged();
+    }
+    
+    
+    /**
+     * This method initializes this
+     * 
+     * @return void
+     */
+    private void initialize()
+    {
+        this.setLayout(new BorderLayout());
+        this.setSize(590, 289);
+        this.add(getCenterPanel(), java.awt.BorderLayout.CENTER);
+        this.add(getSouthPanel(), java.awt.BorderLayout.SOUTH);
+    }
+
+
+    /**
+     * This method initializes jPanel	
+     * 	
+     * @return javax.swing.JPanel	
+     */
+    private JPanel getCenterPanel()
+    {
+        if ( centerPanel == null )
+        {
+            GridBagConstraints gridBagConstraints = new GridBagConstraints();
+            gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+            gridBagConstraints.gridy = 0;
+            gridBagConstraints.weightx = 1.0;
+            gridBagConstraints.weighty = 1.0;
+            gridBagConstraints.insets = new java.awt.Insets(10,10,10,10);
+            gridBagConstraints.gridx = 0;
+            centerPanel = new JPanel();
+            centerPanel.setLayout(new GridBagLayout());
+            centerPanel.add(getJScrollPane(), gridBagConstraints);
+        }
+        return centerPanel;
+    }
+
+
+    /**
+     * This method initializes jPanel1	
+     * 	
+     * @return javax.swing.JPanel	
+     */
+    private JPanel getSouthPanel()
+    {
+        if ( southPanel == null )
+        {
+            southPanel = new JPanel();
+            southPanel.add(getRemoveButton(), null);
+        }
+        return southPanel;
+    }
+
+
+    /**
+     * This method initializes jButton	
+     * 	
+     * @return javax.swing.JButton	
+     */
+    private JButton getRemoveButton()
+    {
+        if ( removeButton == null )
+        {
+            removeButton = new JButton();
+            removeButton.setText("Remove");
+            removeButton.setToolTipText("Remove the link to the dependent object");
+            removeButton.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed( java.awt.event.ActionEvent e )
+                {
+                    String msg = UiUtils.wrap( "Removing dependency relationships will effect " +
+                            "entities other than this role.  You cannot automatically revert from operation.  " +
+                            "Would you like to continue?", 79 );
+                    int response = JOptionPane.showOptionDialog( RoleDependentsPanel.this, msg, 
+                        "Irreverable operation!", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, 
+                        null, null, null );
+                    if ( response == JOptionPane.NO_OPTION )
+                    {
+                        return;
+                    }
+                    
+                    int[] selectedRows = dependentsTable.getSelectedRows();
+                    Set removed = new HashSet();
+                    for ( int ii = 0; ii < selectedRows.length; ii++ )
+                    {
+                        DefaultMutableTreeNode dependentNode = 
+                            ( DefaultMutableTreeNode ) dependents.get( selectedRows[ii] ); 
+                        Profile profile = ( Profile ) dependentNode.getUserObject();
+                        try
+                        {
+                            dependentNode.setUserObject( profile.modifier().removeRole( role.getName() ).modify() );
+                            removed.add( dependentNode );
+                        }
+                        catch ( DataAccessException dae )
+                        {
+                            msg = UiUtils.wrap( "Failed to remove all dependency relationships for role: "
+                                + dae.getMessage(), 79 );
+                            JOptionPane.showMessageDialog( RoleDependentsPanel.this, msg, 
+                                "Dependency removal failure!", JOptionPane.ERROR_MESSAGE );
+                        }
+                    }
+                    
+                    for ( Iterator ii = removed.iterator(); ii.hasNext(); /**/ )
+                    {
+                        dependents.remove( ii.next() );
+                    }
+                    
+                    if ( removed.size() > 0 )
+                    {
+                        dependencyModel.fireTableDataChanged();
+                    }
+                }
+            } );
+        }
+        return removeButton;
+    }
+
+
+    /**
+     * This method initializes jScrollPane	
+     * 	
+     * @return javax.swing.JScrollPane	
+     */
+    private JScrollPane getJScrollPane()
+    {
+        if ( jScrollPane == null )
+        {
+            jScrollPane = new JScrollPane();
+            jScrollPane.setViewportView(getDependentsTable());
+        }
+        return jScrollPane;
+    }
+
+
+    /**
+     * This method initializes jTable	
+     * 	
+     * @return javax.swing.JTable	
+     */
+    private JTable getDependentsTable()
+    {
+        if ( dependentsTable == null )
+        {
+            dependentsTable = new JTable();
+            dependentsTable.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+            dependentsTable.setToolTipText("Role dependents");
+            dependencyModel = new DependencyModel();
+            dependentsTable.setModel( dependencyModel );
+            dependentsTable.setShowGrid(true);
+        }
+        return dependentsTable;
+    }
+
+    
+    class DependencyModel extends AbstractTableModel
+    {
+        private static final long serialVersionUID = 5348529870374118604L;
+        private final String[] COLNAMES = new String[] { "Profile Id" };
+
+
+        public String getColumnName( int columnIndex )
+        {
+            return COLNAMES[columnIndex];
+        }
+        
+        public int getRowCount()
+        {
+            return dependents.size();
+        }
+
+        public int getColumnCount()
+        {
+            return 1;
+        }
+
+        public Object getValueAt( int rowIndex, int columnIndex )
+        {
+            Object dependent = ( ( DefaultMutableTreeNode ) dependents.get( rowIndex ) ).getUserObject();
+            if ( dependent instanceof Role )
+            {
+                switch( columnIndex )
+                {
+                    case ( 0 ):
+                        return dependent;
+                    default:
+                        throw new IndexOutOfBoundsException( "Only 1 column present so columnIndex is invalid: "
+                            + columnIndex );
+                }
+            }
+            else if ( dependent instanceof Profile )
+            {
+                switch( columnIndex )
+                {
+                    case ( 0 ):
+                        return dependent;
+                    default:
+                        throw new IndexOutOfBoundsException( "Only 1 columns present so columnIndex is invalid: "
+                            + columnIndex );
+                }
+            }
+            else
+            {
+                throw new IllegalStateException( "Only expecting Profile dependents for Permissions not " 
+                    + dependent.getClass() );
+            }
+        }
+    }
+}  //  @jve:decl-index=0:visual-constraint="10,10"

Added: directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/RoleGrantsPanel.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/RoleGrantsPanel.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/RoleGrantsPanel.java (added)
+++ directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/RoleGrantsPanel.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,383 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.safehaus.triplesec.admin.swing;
+
+
+import java.awt.BorderLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.swing.DefaultListModel;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.tree.DefaultMutableTreeNode;
+
+import org.safehaus.triplesec.admin.Permission;
+
+
+public class RoleGrantsPanel extends JPanel
+{
+    private static final long serialVersionUID = 7392344377397200180L;
+    private JPanel jPanel5 = null;
+    private JPanel jPanel6 = null;
+    private JPanel jPanel7 = null;
+    private JList applicationPermissions = null;
+    private JList roleGrants = null;
+    private JButton addPermissionButton = null;
+    private JButton removePermissionButton = null;
+    private DefaultListModel applicationPermissionsModel = null; // @jve:decl-index=0:visual-constraint=""
+    private DefaultListModel grantsModel = null; // @jve:decl-index=0:visual-constraint=""
+    private JScrollPane jScrollPane = null;
+    private JScrollPane jScrollPane1 = null;
+
+
+    /**
+     * This is the default constructor
+     */
+    public RoleGrantsPanel()
+    {
+        super();
+        initialize();
+    }
+    
+    
+    public void populateLists( DefaultMutableTreeNode applicationNode, Set grants )
+    {
+        applicationPermissionsModel.clear();
+        grantsModel.clear();
+        
+        // -------------------------------------------------------------------
+        // find the permissions container node under the application
+        // -------------------------------------------------------------------
+
+        DefaultMutableTreeNode permissionsNode = null;
+        for ( Enumeration ii = applicationNode.children(); ii.hasMoreElements(); /**/ )
+        {
+            DefaultMutableTreeNode child = ( DefaultMutableTreeNode ) ii.nextElement();
+            if ( "Permissions".equals( child.getUserObject() ) )
+            {
+                permissionsNode = child;
+                break;
+            }
+        }
+        
+        // -------------------------------------------------------------------
+        // Iterate through children underneath Permssions container adding 
+        // them to the available permssions model if they are not included
+        // in the set of grants of the role
+        // -------------------------------------------------------------------
+
+        for ( Enumeration ii = permissionsNode.children(); ii.hasMoreElements(); /**/ )
+        {
+            Permission permission = ( Permission ) ( ( DefaultMutableTreeNode ) ii.nextElement() ).getUserObject();
+            if ( ! grants.contains( permission.getName() ) )
+            {
+                applicationPermissionsModel.addElement( permission.getName() );
+            }
+        }
+        
+        // -------------------------------------------------------------------
+        // Now add all the grants to the grants model for the grants list
+        // -------------------------------------------------------------------
+        
+        for ( Iterator ii = grants.iterator(); ii.hasNext(); /**/ )
+        {
+            grantsModel.addElement( ii.next() );
+        }
+        
+        jScrollPane.repaint();
+        jScrollPane1.repaint();
+    }
+
+    
+    public DefaultListModel getRoleGrantsModel()
+    {
+        return grantsModel;
+    }
+
+
+    public DefaultListModel getAvailablePermssionsModel()
+    {
+        return applicationPermissionsModel;
+    }
+    
+    
+    /**
+     * This method initializes this
+     * 
+     * @return void
+     */
+    private void initialize()
+    {
+        this.setSize(528, 234);
+        setLayout( new BorderLayout() );
+        add( getJPanel5(), java.awt.BorderLayout.WEST );
+        add( getJPanel6(), java.awt.BorderLayout.CENTER );
+        add( getJPanel7(), java.awt.BorderLayout.EAST );
+
+    }
+
+
+    /**
+     * This method initializes jPanel5
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getJPanel5()
+    {
+        if ( jPanel5 == null )
+        {
+            jPanel5 = new JPanel();
+            jPanel5.setLayout( new BorderLayout() );
+            jPanel5.setBorder( javax.swing.BorderFactory.createTitledBorder( null, "Available Grants",
+                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
+                javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null ) );
+            jPanel5.setPreferredSize( new java.awt.Dimension( 200, 35 ) );
+            jPanel5.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
+        }
+        return jPanel5;
+    }
+
+
+    /**
+     * This method initializes jPanel6
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getJPanel6()
+    {
+        if ( jPanel6 == null )
+        {
+            GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
+            gridBagConstraints14.gridx = 0;
+            gridBagConstraints14.insets = new java.awt.Insets( 10, 0, 0, 0 );
+            gridBagConstraints14.gridy = 1;
+            GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
+            gridBagConstraints5.gridx = 0;
+            gridBagConstraints5.gridy = 0;
+            jPanel6 = new JPanel();
+            jPanel6.setLayout( new GridBagLayout() );
+            jPanel6.add( getAddPermissionButton(), gridBagConstraints5 );
+            jPanel6.add( getRemovePermissionButton(), gridBagConstraints14 );
+        }
+        return jPanel6;
+    }
+
+
+    /**
+     * This method initializes jPanel7
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getJPanel7()
+    {
+        if ( jPanel7 == null )
+        {
+            jPanel7 = new JPanel();
+            jPanel7.setLayout( new BorderLayout() );
+            jPanel7.setPreferredSize( new java.awt.Dimension( 200, 10 ) );
+            jPanel7.setBorder( javax.swing.BorderFactory.createTitledBorder( null, "Role Grants",
+                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
+                javax.swing.border.TitledBorder.DEFAULT_POSITION,
+                new java.awt.Font( "Dialog", java.awt.Font.BOLD, 12 ), new java.awt.Color( 51, 51, 51 ) ) );
+            jPanel7.add(getJScrollPane1(), java.awt.BorderLayout.CENTER);
+        }
+        return jPanel7;
+    }
+
+
+    /**
+     * This method initializes jList
+     * 
+     * @return javax.swing.JList
+     */
+    private JList getApplicationPermissions()
+    {
+        if ( applicationPermissions == null )
+        {
+            applicationPermissions = new JList();
+            applicationPermissions.setPreferredSize( new java.awt.Dimension( 0, 0 ) );
+            applicationPermissions.setToolTipText( "Application permissions assignable to role grants" );
+            applicationPermissions.setModel( getDefaultListModel() );
+        }
+        return applicationPermissions;
+    }
+
+
+    /**
+     * This method initializes jList1
+     * 
+     * @return javax.swing.JList
+     */
+    private JList getRoleGrants()
+    {
+        if ( roleGrants == null )
+        {
+            roleGrants = new JList();
+            roleGrants.setToolTipText( "Permissions already assigned to role grants" );
+            roleGrants.setModel( getDefaultListModel1() );
+        }
+        return roleGrants;
+    }
+
+
+    /**
+     * This method initializes jButton
+     * 
+     * @return javax.swing.JButton
+     */
+    private JButton getAddPermissionButton()
+    {
+        if ( addPermissionButton == null )
+        {
+            addPermissionButton = new JButton();
+            addPermissionButton.setToolTipText( "Add selected permissions to role grants" );
+            addPermissionButton.setIcon( new ImageIcon( getClass().getResource(
+                "/org/safehaus/triplesec/admin/swing/rightarrow_16x16.png" ) ) );
+            addPermissionButton.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed( java.awt.event.ActionEvent e )
+                {
+                    Object[] selectedValues = applicationPermissions.getSelectedValues();
+                    if ( selectedValues == null || selectedValues.length == 0 )
+                    {
+                        return;
+                    }
+
+                    for ( int ii = 0; ii < selectedValues.length; ii++ )
+                    {
+                        applicationPermissionsModel.removeElement( selectedValues[ii] );
+                        grantsModel.add( 0, selectedValues[ii] );
+                    }
+                }
+            } );
+        }
+        return addPermissionButton;
+    }
+
+
+    /**
+     * This method initializes jButton1
+     * 
+     * @return javax.swing.JButton
+     */
+    private JButton getRemovePermissionButton()
+    {
+        if ( removePermissionButton == null )
+        {
+            removePermissionButton = new JButton();
+            removePermissionButton.setToolTipText( "Remove selected permissions from role grants" );
+            removePermissionButton.setIcon( new ImageIcon( getClass().getResource(
+                "/org/safehaus/triplesec/admin/swing/leftarrow_16x16.png" ) ) );
+            removePermissionButton.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed( java.awt.event.ActionEvent e )
+                {
+                    Object[] selectedValues = roleGrants.getSelectedValues();
+                    if ( selectedValues == null || selectedValues.length == 0 )
+                    {
+                        return;
+                    }
+
+                    for ( int ii = 0; ii < selectedValues.length; ii++ )
+                    {
+                        grantsModel.removeElement( selectedValues[ii] );
+                        applicationPermissionsModel.add( 0, selectedValues[ii] );
+                    }
+                }
+            } );
+        }
+        return removePermissionButton;
+    }
+
+
+    /**
+     * This method initializes defaultListModel
+     * 
+     * @return javax.swing.DefaultListModel
+     */
+    private DefaultListModel getDefaultListModel()
+    {
+        if ( applicationPermissionsModel == null )
+        {
+            applicationPermissionsModel = new DefaultListModel();
+        }
+        return applicationPermissionsModel;
+    }
+
+
+    /**
+     * This method initializes defaultListModel1
+     * 
+     * @return javax.swing.DefaultListModel
+     */
+    private DefaultListModel getDefaultListModel1()
+    {
+        if ( grantsModel == null )
+        {
+            grantsModel = new DefaultListModel();
+        }
+        return grantsModel;
+    }
+
+
+
+
+    /**
+     * This method initializes jScrollPane  
+     *  
+     * @return javax.swing.JScrollPane  
+     */
+    private JScrollPane getJScrollPane()
+    {
+        if ( jScrollPane == null )
+        {
+            jScrollPane = new JScrollPane();
+            jScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+            jScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
+            jScrollPane.setViewportView(getApplicationPermissions());
+        }
+        return jScrollPane;
+    }
+
+
+    /**
+     * This method initializes jScrollPane1 
+     *  
+     * @return javax.swing.JScrollPane  
+     */
+    private JScrollPane getJScrollPane1()
+    {
+        if ( jScrollPane1 == null )
+        {
+            jScrollPane1 = new JScrollPane();
+            jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+            jScrollPane1.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
+            jScrollPane1.setViewportView(getRoleGrants());
+        }
+        return jScrollPane1;
+    }
+}  //  @jve:decl-index=0:visual-constraint="10,10"

Added: directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/RolePanel.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/RolePanel.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/RolePanel.java (added)
+++ directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/RolePanel.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,642 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.safehaus.triplesec.admin.swing;
+
+
+import javax.swing.JPanel;
+import java.awt.BorderLayout;
+
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JButton;
+import javax.swing.JTree;
+
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+import java.util.Enumeration;
+
+import javax.swing.JTextField;
+import javax.swing.JTextArea;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreePath;
+
+import org.safehaus.triplesec.admin.DataAccessException;
+import org.safehaus.triplesec.admin.Role;
+import org.safehaus.triplesec.admin.RoleModifier;
+
+
+public class RolePanel extends JPanel
+{
+    private static final long serialVersionUID = 1L;
+    private JPanel mainPanel = null;
+    private JPanel buttonPanel = null;
+    private JButton revertButton = null;
+    private JButton saveButton = null;
+    private JPanel aboveButtonPanel = null;
+    private JPanel northPanel = null;
+    private JTabbedPane centerTabbedPane = null;
+    private JPanel southPanel = null;
+    private GeneralPanel generalPanel = null;
+    private JLabel iconLabel = null;
+    private JPanel jPanel = null;
+    private JTextArea descriptionTextArea = null;
+    private JPanel jPanel4 = null;
+    private RoleGrantsPanel roleGrantsPanel;
+    private JTree tree = null;
+    private Role role = null;
+    private DefaultMutableTreeNode node = null;
+    private JLabel jLabel = null;
+    private JLabel jLabel1 = null;
+    private JLabel jLabel2 = null;
+    private JTextField statusTextField = null;
+    private JTextField applicationNameTextField = null;
+    private JTextField roleNameTextField = null;
+    private JButton deleteButton = null;
+    private RoleDependentsPanel roleDependentsPanel;
+
+
+    /**
+     * This is the default constructor
+     */
+    public RolePanel()
+    {
+        super();
+        initialize();
+    }
+
+
+    /**
+     * This method initializes this
+     * 
+     * @return void
+     */
+    private void initialize()
+    {
+        GridBagConstraints gridBagConstraints = new GridBagConstraints();
+        gridBagConstraints.gridx = 0;
+        gridBagConstraints.weightx = 1.0D;
+        gridBagConstraints.weighty = 1.0D;
+        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+        gridBagConstraints.insets = new java.awt.Insets( 10, 10, 10, 10 );
+        gridBagConstraints.gridy = 0;
+        this.setLayout( new GridBagLayout() );
+        this.setSize( 550, 417 );
+        this.setBorder( javax.swing.BorderFactory.createTitledBorder( null, "Existing Role",
+            javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION,
+            null, null ) );
+        this.add( getMainPanel(), gridBagConstraints );
+    }
+
+
+    /**
+     * This method initializes jPanel
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getMainPanel()
+    {
+        if ( mainPanel == null )
+        {
+            mainPanel = new JPanel();
+            mainPanel.setLayout( new BorderLayout() );
+            mainPanel.add( getButtonPanel(), java.awt.BorderLayout.SOUTH );
+            mainPanel.add( getAboveButtonPanel(), java.awt.BorderLayout.CENTER );
+        }
+        return mainPanel;
+    }
+
+
+    /**
+     * This method initializes jPanel
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getButtonPanel()
+    {
+        if ( buttonPanel == null )
+        {
+            buttonPanel = new JPanel();
+            buttonPanel.setBorder( javax.swing.BorderFactory.createEmptyBorder( 0, 0, 0, 0 ) );
+            buttonPanel.add(getDeleteButton(), null);
+            buttonPanel.add( getRevertButton(), null );
+            buttonPanel.add( getSaveButton(), null );
+        }
+        return buttonPanel;
+    }
+
+
+    /**
+     * This method initializes jButton
+     * 
+     * @return javax.swing.JButton
+     */
+    private JButton getRevertButton()
+    {
+        if ( revertButton == null )
+        {
+            revertButton = new JButton();
+            revertButton.setText( "Revert" );
+            revertButton.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed( java.awt.event.ActionEvent e )
+                {
+                    try
+                    {
+                        setRoleFields();
+                    }
+                    catch ( DataAccessException e1 )
+                    {
+                        JOptionPane.showMessageDialog( RolePanel.this,
+                            "Failed to access application permissions for role: " + role.getName() + "\n\n"
+                                + e1.getMessage(), "Data access error", JOptionPane.ERROR_MESSAGE );
+                    }
+                }
+            } );
+        }
+        return revertButton;
+    }
+
+
+    /**
+     * This method initializes jButton
+     * 
+     * @return javax.swing.JButton
+     */
+    private JButton getSaveButton()
+    {
+        if ( saveButton == null )
+        {
+            saveButton = new JButton();
+            saveButton.setText( "Save" );
+            saveButton.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed( java.awt.event.ActionEvent e )
+                {
+                    saveAction();
+                }
+            } );
+        }
+        return saveButton;
+    }
+
+
+    /**
+     * This method initializes jPanel
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getAboveButtonPanel()
+    {
+        if ( aboveButtonPanel == null )
+        {
+            aboveButtonPanel = new JPanel();
+            aboveButtonPanel.setLayout( new BorderLayout() );
+            aboveButtonPanel.add( getNorthPanel(), java.awt.BorderLayout.NORTH );
+            aboveButtonPanel.add( getCenterTabbedPane(), java.awt.BorderLayout.CENTER );
+            aboveButtonPanel.add( getSouthPanel(), java.awt.BorderLayout.SOUTH );
+        }
+        return aboveButtonPanel;
+    }
+
+
+    /**
+     * This method initializes jPanel
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getNorthPanel()
+    {
+        if ( northPanel == null )
+        {
+            GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
+            gridBagConstraints1.gridx = 1;
+            gridBagConstraints1.weightx = 1.0D;
+            gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
+            gridBagConstraints1.gridheight = 3;
+            gridBagConstraints1.insets = new java.awt.Insets( 0, 10, 0, 10 );
+            gridBagConstraints1.weighty = 1.0D;
+            gridBagConstraints1.gridy = 0;
+            northPanel = new JPanel();
+            northPanel.setLayout( new GridBagLayout() );
+            northPanel.setPreferredSize( new java.awt.Dimension( 179, 68 ) );
+            northPanel.add( getJPanel4(), new GridBagConstraints() );
+            northPanel.add( getJPanel(), gridBagConstraints1 );
+        }
+        return northPanel;
+    }
+
+
+    /**
+     * This method initializes jTabbedPane
+     * 
+     * @return javax.swing.JTabbedPane
+     */
+    private JTabbedPane getCenterTabbedPane()
+    {
+        if ( centerTabbedPane == null )
+        {
+            centerTabbedPane = new JTabbedPane();
+            centerTabbedPane.addTab( "General", null, getGeneralPanelTab(), null );
+            centerTabbedPane.addTab( "Grants", null, getRoleGrantsPanel(), null );
+            centerTabbedPane.addTab( "Dependent Profiles",  null, getRoleDependentsPanel(), null );
+        }
+        return centerTabbedPane;
+    }
+
+
+    private RoleDependentsPanel getRoleDependentsPanel()
+    {
+        if ( roleDependentsPanel == null )
+        {
+            roleDependentsPanel = new RoleDependentsPanel();
+        }
+        return roleDependentsPanel;
+    }
+
+
+    private RoleGrantsPanel getRoleGrantsPanel()
+    {
+        if ( roleGrantsPanel == null )
+        {
+            roleGrantsPanel = new RoleGrantsPanel();
+        }
+        return roleGrantsPanel;
+    }
+    
+    
+    /**
+     * This method initializes jPanel
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getSouthPanel()
+    {
+        if ( southPanel == null )
+        {
+            southPanel = new JPanel();
+            southPanel.setLayout( new BorderLayout() );
+            southPanel.setBorder( javax.swing.BorderFactory.createTitledBorder( null, "Description",
+                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
+                javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null ) );
+            southPanel.add( getDescriptionTextArea(), java.awt.BorderLayout.NORTH );
+        }
+        return southPanel;
+    }
+
+
+    /**
+     * This method initializes jPanel
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getGeneralPanelTab()
+    {
+        if ( generalPanel == null )
+        {
+            generalPanel = new GeneralPanel();
+        }
+        return generalPanel;
+    }
+
+
+    /**
+     * This method initializes iconLabel
+     * 
+     * @return javax.swing.JLabel
+     */
+    private JLabel getIconLabel()
+    {
+        if ( iconLabel == null )
+        {
+            iconLabel = new JLabel();
+            iconLabel.setIcon( new ImageIcon( getClass().getResource(
+                "/org/safehaus/triplesec/admin/swing/role_48x48.png" ) ) );
+            iconLabel.setPreferredSize( new java.awt.Dimension( 48, 48 ) );
+            iconLabel.setText( "" );
+            iconLabel.setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM );
+            iconLabel.setVerticalAlignment( javax.swing.SwingConstants.BOTTOM );
+            iconLabel.setEnabled( true );
+        }
+        return iconLabel;
+    }
+
+
+    /**
+     * This method initializes jPanel
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getJPanel()
+    {
+        if ( jPanel == null )
+        {
+            GridBagConstraints gridBagConstraints17 = new GridBagConstraints();
+            gridBagConstraints17.fill = java.awt.GridBagConstraints.HORIZONTAL;
+            gridBagConstraints17.gridy = 2;
+            gridBagConstraints17.weightx = 1.0;
+            gridBagConstraints17.gridx = 1;
+            GridBagConstraints gridBagConstraints16 = new GridBagConstraints();
+            gridBagConstraints16.fill = java.awt.GridBagConstraints.HORIZONTAL;
+            gridBagConstraints16.gridy = 1;
+            gridBagConstraints16.weightx = 1.0;
+            gridBagConstraints16.insets = new java.awt.Insets( 0, 0, 5, 0 );
+            gridBagConstraints16.gridx = 1;
+            GridBagConstraints gridBagConstraints15 = new GridBagConstraints();
+            gridBagConstraints15.fill = java.awt.GridBagConstraints.HORIZONTAL;
+            gridBagConstraints15.gridy = 0;
+            gridBagConstraints15.weightx = 1.0;
+            gridBagConstraints15.insets = new java.awt.Insets( 0, 0, 5, 0 );
+            gridBagConstraints15.gridx = 1;
+            GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
+            gridBagConstraints4.gridx = 0;
+            gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL;
+            gridBagConstraints4.insets = new java.awt.Insets( 0, 0, 0, 5 );
+            gridBagConstraints4.gridy = 2;
+            jLabel2 = new JLabel();
+            jLabel2.setText( "Role Name:" );
+            jLabel2.setHorizontalAlignment( javax.swing.SwingConstants.RIGHT );
+            GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
+            gridBagConstraints3.gridx = 0;
+            gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL;
+            gridBagConstraints3.insets = new java.awt.Insets( 0, 0, 5, 5 );
+            gridBagConstraints3.gridy = 1;
+            jLabel1 = new JLabel();
+            jLabel1.setText( "Application Name:" );
+            jLabel1.setHorizontalAlignment( javax.swing.SwingConstants.RIGHT );
+            GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
+            gridBagConstraints2.gridx = 0;
+            gridBagConstraints2.insets = new java.awt.Insets( 0, 0, 5, 5 );
+            gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
+            gridBagConstraints2.gridy = 0;
+            jLabel = new JLabel();
+            jLabel.setText( "Status:" );
+            jLabel.setHorizontalAlignment( javax.swing.SwingConstants.RIGHT );
+            jPanel = new JPanel();
+            jPanel.setLayout( new GridBagLayout() );
+            jPanel.setPreferredSize( new java.awt.Dimension( 131, 88 ) );
+            jPanel.add( jLabel, gridBagConstraints2 );
+            jPanel.add( jLabel1, gridBagConstraints3 );
+            jPanel.add( jLabel2, gridBagConstraints4 );
+            jPanel.add( getStatusTextField(), gridBagConstraints15 );
+            jPanel.add( getApplicationNameTextField(), gridBagConstraints16 );
+            jPanel.add( getRoleNameTextField(), gridBagConstraints17 );
+        }
+        return jPanel;
+    }
+
+
+    /**
+     * This method initializes jTextArea
+     * 
+     * @return javax.swing.JTextArea
+     */
+    private JTextArea getDescriptionTextArea()
+    {
+        if ( descriptionTextArea == null )
+        {
+            descriptionTextArea = new JTextArea();
+            descriptionTextArea.setRows( 3 );
+        }
+        return descriptionTextArea;
+    }
+
+
+    /**
+     * This method initializes jPanel4
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getJPanel4()
+    {
+        if ( jPanel4 == null )
+        {
+            jPanel4 = new JPanel();
+            jPanel4.setBorder( javax.swing.BorderFactory.createEtchedBorder( javax.swing.border.EtchedBorder.RAISED ) );
+            jPanel4.add( getIconLabel(), null );
+        }
+        return jPanel4;
+    }
+
+
+    private void setRoleFields() throws DataAccessException
+    {
+        if ( role == null || node == null || node.getParent() == null )
+        {
+            return;
+        }
+        generalPanel.setFields( role );
+        applicationNameTextField.setText( role.getApplicationName() );
+        roleNameTextField.setText( role.getName() );
+        descriptionTextArea.setText( role.getDescription() );
+        roleGrantsPanel.populateLists( ( DefaultMutableTreeNode ) node.getParent().getParent(), role.getGrants() );
+    }
+
+
+    public void setTree( JTree tree )
+    {
+        this.tree = tree;
+    }
+
+
+    public void setTreeNode( DefaultMutableTreeNode node )
+    {
+        if ( node == null )
+        {
+            return;
+        }
+        this.node = node;
+        this.role = ( Role ) node.getUserObject();
+
+        try
+        {
+            setRoleFields();
+        }
+        catch ( DataAccessException e )
+        {
+            JOptionPane.showMessageDialog( RolePanel.this, "Failed to access application permissions for role: "
+                + role.getName() + "\n\n" + e.getMessage(), "Data access error", JOptionPane.ERROR_MESSAGE );
+        }
+        roleDependentsPanel.setSelectedNode( node );
+    }
+
+
+    public String noNull( Object obj )
+    {
+        if ( obj == null )
+        {
+            return "";
+        }
+        return obj.toString();
+    }
+
+
+    public DefaultMutableTreeNode getTreeNode()
+    {
+        return node;
+    }
+
+
+    public void saveAction()
+    {
+        if ( role == null )
+        {
+            return;
+        }
+
+        // change the description and add remove values from list views then see if anything changed
+        RoleModifier modifier = role.modifier().setDescription( descriptionTextArea.getText() );
+        for ( Enumeration ii = roleGrantsPanel.getAvailablePermssionsModel().elements(); ii.hasMoreElements(); /**/)
+        {
+            modifier.removeGrant( ( String ) ii.nextElement() );
+        }
+        for ( Enumeration ii = roleGrantsPanel.getRoleGrantsModel().elements(); ii.hasMoreElements(); /**/)
+        {
+            modifier.addGrant( ( String ) ii.nextElement() );
+        }
+
+        if ( modifier.isUpdateNeeded() )
+        {
+            try
+            {
+                role = modifier.modify();
+            }
+            catch ( DataAccessException e )
+            {
+                JOptionPane.showMessageDialog( this, UiUtils.wrap( "Failed to modify role:\n" + e.getMessage(), 79 ),
+                    "Role modification failure!", JOptionPane.ERROR_MESSAGE );
+                return;
+            }
+            node.setUserObject( role );
+        }
+
+        if ( !role.getName().equals( roleNameTextField.getText() ) )
+        {
+            try
+            {
+                role = role.modifier().rename( roleNameTextField.getText() );
+                ( ( DefaultTreeModel ) tree.getModel() ).valueForPathChanged( new TreePath( node.getPath() ), role );
+            }
+            catch ( DataAccessException e )
+            {
+                JOptionPane.showMessageDialog( this, UiUtils.wrap( "Failed to rename role:\n" + e.getMessage(), 79 ),
+                    "Role rename failure!", JOptionPane.ERROR_MESSAGE );
+                return;
+            }
+        }
+
+        node.setUserObject( role );
+        try
+        {
+            setRoleFields();
+        }
+        catch ( DataAccessException e )
+        {
+            JOptionPane.showMessageDialog( RolePanel.this, "Failed to access application permissions for role: "
+                + role.getName() + "\n\n" + e.getMessage(), "Data access error", JOptionPane.ERROR_MESSAGE );
+        }
+    }
+
+
+    /**
+     * This method initializes jTextField	
+     * 	
+     * @return javax.swing.JTextField	
+     */
+    private JTextField getStatusTextField()
+    {
+        if ( statusTextField == null )
+        {
+            statusTextField = new JTextField();
+            statusTextField.setEditable( false );
+        }
+        return statusTextField;
+    }
+
+
+    /**
+     * This method initializes jTextField1	
+     * 	
+     * @return javax.swing.JTextField	
+     */
+    private JTextField getApplicationNameTextField()
+    {
+        if ( applicationNameTextField == null )
+        {
+            applicationNameTextField = new JTextField();
+            applicationNameTextField.setEditable( false );
+        }
+        return applicationNameTextField;
+    }
+
+
+    /**
+     * This method initializes jTextField2	
+     * 	
+     * @return javax.swing.JTextField	
+     */
+    private JTextField getRoleNameTextField()
+    {
+        if ( roleNameTextField == null )
+        {
+            roleNameTextField = new JTextField();
+        }
+        return roleNameTextField;
+    }
+
+
+    /**
+     * This method initializes jButton	
+     * 	
+     * @return javax.swing.JButton	
+     */
+    private JButton getDeleteButton()
+    {
+        if ( deleteButton == null )
+        {
+            deleteButton = new JButton();
+            deleteButton.setText("Delete");
+            deleteButton.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed( java.awt.event.ActionEvent e )
+                {
+                    try
+                    {
+                        role.modifier().delete();
+                        DefaultMutableTreeNode parentNode = ( DefaultMutableTreeNode ) node.getParent();
+                        DefaultTreeModel treeModel = ( DefaultTreeModel ) tree.getModel();
+                        treeModel.removeNodeFromParent( node );
+                        TreePath path = new TreePath( parentNode.getPath() );
+                        tree.setSelectionPaths( new TreePath[] { path } );
+                    }
+                    catch ( DataAccessException e1 )
+                    {
+                        JOptionPane.showMessageDialog( RolePanel.this, 
+                            "Failed to delete role: " + e1.getMessage(), "Delete Failed", 
+                            JOptionPane.ERROR_MESSAGE );
+                    }
+                }
+            } );
+        }
+        return deleteButton;
+    }
+} // @jve:decl-index=0:visual-constraint="10,10"

Added: directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/SecretDialog.java
URL: http://svn.apache.org/viewvc/directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/SecretDialog.java?view=auto&rev=486187
==============================================================================
--- directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/SecretDialog.java (added)
+++ directory/trunks/triplesec/swing-admin/src/main/java/org/safehaus/triplesec/admin/swing/SecretDialog.java Tue Dec 12 07:23:31 2006
@@ -0,0 +1,193 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.safehaus.triplesec.admin.swing;
+
+
+import java.awt.BorderLayout;
+import javax.swing.JPanel;
+import javax.swing.JDialog;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPasswordField;
+
+import java.awt.Frame;
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+
+
+public class SecretDialog extends JDialog
+{
+    private static final long serialVersionUID = 1L;
+    private JPanel jContentPane = null;
+    private JPanel jPanel1 = null;
+    private JPanel jPanel2 = null;
+    private JButton jButton = null;
+    private JLabel jLabel = null;
+    private JPasswordField jPasswordField = null;
+    
+    
+    /**
+     * This is the default constructor
+     */
+    public SecretDialog( Frame parent )
+    {
+        super( parent );
+        setModal( true );
+        initialize();
+    }
+
+    
+    public void setMessage( String message )
+    {
+        jLabel.setText( UiUtils.wrap( message, 79 ) );
+    }
+
+    
+    public String getPassword()
+    {
+        return new String( jPasswordField.getPassword() );
+    }
+    
+    
+    /**
+     * This method initializes this
+     * 
+     * @return void
+     */
+    private void initialize()
+    {
+        this.setSize(622, 169);
+        this.setContentPane( getJContentPane() );
+        this.addWindowListener( new java.awt.event.WindowAdapter()
+        {
+            public void windowClosing( java.awt.event.WindowEvent e )
+            {
+                SecretDialog.this.setVisible( false );
+                SecretDialog.this.dispose();
+            }
+        } );
+    }
+
+
+    /**
+     * This method initializes jContentPane
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getJContentPane()
+    {
+        if ( jContentPane == null )
+        {
+            jContentPane = new JPanel();
+            jContentPane.setLayout( new BorderLayout() );
+            jContentPane.add(getJPanel1(), java.awt.BorderLayout.CENTER);
+            jContentPane.add(getJPanel2(), java.awt.BorderLayout.SOUTH);
+        }
+        return jContentPane;
+    }
+
+
+    /**
+     * This method initializes jPanel1	
+     * 	
+     * @return javax.swing.JPanel	
+     */
+    private JPanel getJPanel1()
+    {
+        if ( jPanel1 == null )
+        {
+            GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
+            gridBagConstraints1.fill = java.awt.GridBagConstraints.NONE;
+            gridBagConstraints1.gridy = 1;
+            gridBagConstraints1.weightx = 1.0;
+            gridBagConstraints1.gridx = 0;
+            GridBagConstraints gridBagConstraints = new GridBagConstraints();
+            gridBagConstraints.gridx = 0;
+            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+            gridBagConstraints.weightx = 1.0D;
+            gridBagConstraints.insets = new java.awt.Insets(10,15,10,15);
+            gridBagConstraints.gridy = 0;
+            jLabel = new JLabel();
+            jLabel.setText("JLabel");
+            jPanel1 = new JPanel();
+            jPanel1.setLayout(new GridBagLayout());
+            jPanel1.add(jLabel, gridBagConstraints);
+            jPanel1.add(getJPasswordField(), gridBagConstraints1);
+        }
+        return jPanel1;
+    }
+
+
+    /**
+     * This method initializes jPanel2	
+     * 	
+     * @return javax.swing.JPanel	
+     */
+    private JPanel getJPanel2()
+    {
+        if ( jPanel2 == null )
+        {
+            jPanel2 = new JPanel();
+            jPanel2.add(getJButton(), null);
+        }
+        return jPanel2;
+    }
+
+
+    /**
+     * This method initializes jButton	
+     * 	
+     * @return javax.swing.JButton	
+     */
+    private JButton getJButton()
+    {
+        if ( jButton == null )
+        {
+            jButton = new JButton();
+            jButton.setText("Ok");
+            jButton.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed( java.awt.event.ActionEvent e )
+                {
+                     SecretDialog.this.setVisible( false );
+                     SecretDialog.this.dispose();
+                }
+            } );
+        }
+        return jButton;
+    }
+
+
+    /**
+     * This method initializes jPasswordField	
+     * 	
+     * @return javax.swing.JPasswordField	
+     */
+    private JPasswordField getJPasswordField()
+    {
+        if ( jPasswordField == null )
+        {
+            jPasswordField = new JPasswordField();
+            jPasswordField.setColumns(18);
+        }
+        return jPasswordField;
+    }
+
+}  //  @jve:decl-index=0:visual-constraint="10,10"



Mime
View raw message