Index: modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/Permission.java
===================================================================
--- modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/Permission.java (revision 681611)
+++ modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/Permission.java (working copy)
@@ -20,7 +20,7 @@
/**
* Represents a principal for the grant entries.
*/
-public class Permission {
+public class Permission implements Cloneable {
/** Name of the class of the permission. */
private String className;
@@ -95,4 +95,15 @@
this.signedBy = signedBy;
}
+ @Override
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch ( final CloneNotSupportedException cnse ) {
+ // This never gonna happen.
+ cnse.printStackTrace();
+ return null;
+ }
+ }
+
}
Index: modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/Principal.java
===================================================================
--- modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/Principal.java (revision 681611)
+++ modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/Principal.java (working copy)
@@ -20,7 +20,7 @@
/**
* Represents a principal for the grant entries.
*/
-public class Principal {
+public class Principal implements Cloneable {
/** Type of the principal. */
private String type;
@@ -64,4 +64,15 @@
return "Principal " + type + " \"" + name + '"';
}
+ @Override
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch ( final CloneNotSupportedException cnse ) {
+ // This never gonna happen.
+ cnse.printStackTrace();
+ return null;
+ }
+ }
+
}
Index: modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/BaseFormDialog.java
===================================================================
--- modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/BaseFormDialog.java (revision 681611)
+++ modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/BaseFormDialog.java (working copy)
@@ -148,7 +148,16 @@
* Finishes a successful edit action.
*/
protected void finishSuccessfulEdit() {
- ownerEditorPanel.setHasDirty( true );
+ finishSuccessfulEdit( true );
+ }
+
+ /**
+ * Finishes a successful edit action.
+ * @param setDirtyFlag tells whether dirty flag has to be set (to true)
+ */
+ protected void finishSuccessfulEdit( final boolean setDirtyFlag ) {
+ if ( setDirtyFlag )
+ ownerEditorPanel.setHasDirty( true );
dispose();
}
Index: modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/GraphicalEditorPanel.java
===================================================================
--- modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/GraphicalEditorPanel.java (revision 681611)
+++ modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/GraphicalEditorPanel.java (working copy)
@@ -32,11 +32,13 @@
public class GraphicalEditorPanel extends EditorPanel {
/** Holds the invalid policy text or null if the loaded policy text is valid. */
- private String invalidPolicyText;
+ private String invalidPolicyText;
/** The list of the policy text's entries or null if invalid policy text was loaded. */
- private List< PolicyEntry > policyEntryList = new ArrayList< PolicyEntry >();
+ private List< PolicyEntry > policyEntryList = new ArrayList< PolicyEntry >();
+ /** ListAndEditPanel for handling the grant entries. */
+ private ListAndEditPanel< PolicyEntry > grantEntryLAEPanel;
/**
* Creates a new GraphicalEditorPanel.
* Sets a BorderLayout as the layout manager.
@@ -45,8 +47,18 @@
public GraphicalEditorPanel( final MainFrame mainFrame ) {
super( mainFrame, "Graphical editing", new BorderLayout(), true );
- // buildGUI:
- add( new ListAndEditPanel< PolicyEntry >( "Policy entries:", "Policy Entry", policyEntryList,
+ buildGUI();
+ }
+
+ /**
+ * Builds the graphical user interface.
+ * Creates and adds a new LAE panel to this editor panel which will be responsible to handle the grant entries.
+ */
+ private void buildGUI() {
+ if ( grantEntryLAEPanel != null )
+ remove( grantEntryLAEPanel );
+
+ grantEntryLAEPanel = new ListAndEditPanel< PolicyEntry >( "Policy entries:", "Policy Entry", policyEntryList,
new ListAndEditPanel.Filter< PolicyEntry > () {
public boolean includeEntity( final PolicyEntry entity ) {
return entity instanceof GrantEntry;
@@ -57,7 +69,9 @@
return new GrantEntryEditFormDialog( mainFrame, GraphicalEditorPanel.this, (GrantEntry) selectedEntity, policyEntryList );
}
}
- ), BorderLayout.CENTER );
+ );
+
+ add( grantEntryLAEPanel, BorderLayout.CENTER );
}
@Override
@@ -66,6 +80,9 @@
policyEntryList = new ArrayList< PolicyEntry >();
+ //TODO: uncomment when loadPolicyText() is implemented
+ //buildGUI();
+
return true;
}
Index: modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/PrincipalEditFormDialog.java
===================================================================
--- modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/PrincipalEditFormDialog.java (revision 681611)
+++ modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/PrincipalEditFormDialog.java (working copy)
@@ -94,11 +94,11 @@
if ( initialPrincipal.getType() != null )
for ( int i = 0; i < DEFAULT_PRINCIPAL_TYPE_CLASS_NAMES.length; i++ )
if ( DEFAULT_PRINCIPAL_TYPE_CLASS_NAMES[ i ] != null && DEFAULT_PRINCIPAL_TYPE_CLASS_NAMES[ i ].equals( initialPrincipal.getType() ) ) {
- principalTypeComboBox .setSelectedIndex( i );
+ principalTypeComboBox.setSelectedIndex( i );
break;
}
- principalTypeTextField.setText( initialPrincipal.getType() );
- principalNameTextField.setText( initialPrincipal.getName() );
+ principalTypeTextField.setText( initialPrincipal.getType() );
+ principalNameTextField.setText( initialPrincipal.getName() );
}
final JPanel flowPanel = new JPanel();
@@ -121,7 +121,7 @@
} else
refreshVisualizationList();
- finishSuccessfulEdit();
+ finishSuccessfulEdit( false );
}
}
Index: modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/GrantEntryEditFormDialog.java
===================================================================
--- modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/GrantEntryEditFormDialog.java (revision 681611)
+++ modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/GrantEntryEditFormDialog.java (working copy)
@@ -20,6 +20,7 @@
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
+import java.util.ArrayList;
import java.util.List;
import javax.swing.Box;
@@ -41,10 +42,21 @@
private final GrantEntry initialGrantEntry;
/** List of policy entries where to store if new entry is to be created. */
private final List< PolicyEntry > policyEntryList;
-
+
/** Holds the reference to the new granty entry in case of we are creating a new one. */
private final GrantEntry newGrantEntry;
+ /** A deep clone of the edited grant entry's principal list.
+ * This is necessary because we have to be able to restore the original principal list
+ * (which are edited by another instance of LAEFormDialog)
+ * if cancel action is performed here on the grant entry's LAEFormDialog. */
+ private final List< Principal > tempPrincipalList;
+ /** A deep clone of the edited grant entry's permission list.
+ * This is necessary because we have to be able to restore the original permission list
+ * (which are edited by another instance of LAEFormDialog)
+ * if cancel action is performed here on the grant entry's LAEFormDialog. */
+ private final List< Permission > tempPermissionList;
+
/** Text field to view and edit the value of code base. */
private final JTextField codeBaseTextField = new JTextField();
/** Text field to view and edit the value of signed by. */
@@ -64,6 +76,8 @@
this.policyEntryList = policyEntryList;
newGrantEntry = initialGrantEntry == null ? new GrantEntry() : null;
+ tempPrincipalList = deepclonePrincipalList ( ( initialGrantEntry == null ? newGrantEntry : initialGrantEntry ).getPrincipalList () );
+ tempPermissionList = deepclonePermissionList( ( initialGrantEntry == null ? newGrantEntry : initialGrantEntry ).getPermissionList() );
prepareForDisplay();
}
@@ -68,6 +82,38 @@
prepareForDisplay();
}
+ /**
+ * Deepclones a principal list and returns it.
+ * This method uses the Object.clone() clone the elements.
+ *
+ * @param principalList principal list to be deepcloned
+ * @return a deepcloned principal list
+ */
+ private static List< Principal > deepclonePrincipalList( final List< Principal > principalList ) {
+ final List< Principal > deepclonedPrincipalList = new ArrayList< Principal >( principalList.size() );
+
+ for ( final Principal principal : principalList )
+ deepclonedPrincipalList.add( (Principal) principal.clone() );
+
+ return deepclonedPrincipalList;
+ }
+
+ /**
+ * Deepclones a permission list and returns it.
+ * This method uses the Object.clone() clone the elements.
+ *
+ * @param permissionList permission list to be deepcloned
+ * @return a deepcloned permission list
+ */
+ private static List< Permission > deepclonePermissionList( final List< Permission > permissionList ) {
+ final List< Permission > deepclonedPermissionList = new ArrayList< Permission >( permissionList.size() );
+
+ for ( final Permission permission : permissionList )
+ deepclonedPermissionList.add( (Permission) permission.clone() );
+
+ return deepclonedPermissionList;
+ }
+
@Override
protected void buildGUI() {
final JPanel panel = new JPanel( new BorderLayout( 2,15 ) );
@@ -100,10 +146,10 @@
panel.add( verticalBox, BorderLayout.NORTH );
// ListAndEdit component for Principals
- panel.add( new ListAndEditPanel< Principal >( "Principals:", "Principal", ( initialGrantEntry == null ? newGrantEntry : initialGrantEntry ).getPrincipalList(),
+ panel.add( new ListAndEditPanel< Principal >( "Principals:", "Principal", tempPrincipalList,
new ListAndEditPanel.LAEFormDialogFactory< Principal > () {
public LAEFormDialog createFactoryForAddOrEdit( final Principal selectedEntity ) {
- return new PrincipalEditFormDialog( GrantEntryEditFormDialog.this, ownerEditorPanel, selectedEntity, ( initialGrantEntry == null ? newGrantEntry : initialGrantEntry ).getPrincipalList() );
+ return new PrincipalEditFormDialog( GrantEntryEditFormDialog.this, ownerEditorPanel, selectedEntity, tempPrincipalList );
}
}
), BorderLayout.CENTER );
@@ -114,10 +160,10 @@
// ListAndEdit component for Permissions
final ListAndEditPanel< Permission > permissionsLAE =
- new ListAndEditPanel< Permission >( "Permissions:", "Permission", ( initialGrantEntry == null ? newGrantEntry : initialGrantEntry ).getPermissionList(),
+ new ListAndEditPanel< Permission >( "Permissions:", "Permission", tempPermissionList,
new ListAndEditPanel.LAEFormDialogFactory< Permission > () {
public LAEFormDialog createFactoryForAddOrEdit( final Permission selectedEntity ) {
- return null;
+ return new PermissionEditFormDialog( GrantEntryEditFormDialog.this, ownerEditorPanel, selectedEntity, tempPermissionList );
}
}
);
@@ -131,8 +177,10 @@
final GrantEntry grantEntry = initialGrantEntry == null ? newGrantEntry : initialGrantEntry;
- grantEntry.setCodeBase( codeBaseTextField.getText() );
- grantEntry.setSignedBy( signedByTextField.getText() );
+ grantEntry.setCodeBase ( codeBaseTextField.getText() );
+ grantEntry.setSignedBy ( signedByTextField.getText() );
+ grantEntry.setPrincipalList ( tempPrincipalList );
+ grantEntry.setPermissionList( tempPermissionList );
if ( initialGrantEntry == null ) {
policyEntryList.add( grantEntry );
Index: modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/ListAndEditPanel.java
===================================================================
--- modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/ListAndEditPanel.java (revision 681611)
+++ modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/ListAndEditPanel.java (working copy)
@@ -31,7 +31,7 @@
/**
* The abstraction of a panel which can list entities and provide GUI components to offer and handle certain actions on the entities.
- * The entities are listed in a listbox,
+ * The entities are listed in a listbox.
* @param type of the entities listed on and edited by this panel
*/
public class ListAndEditPanel< EntityType > extends JPanel implements ActionListener {
Index: modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/PermissionEditFormDialog.java
===================================================================
--- modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/PermissionEditFormDialog.java (revision 0)
+++ modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/PermissionEditFormDialog.java (revision 0)
@@ -0,0 +1,203 @@
+/*
+ * 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.apache.harmony.tools.policytool.view;
+
+import java.awt.BorderLayout;
+import java.awt.Dialog;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import org.apache.harmony.tools.policytool.model.Permission;
+
+/**
+ * Form dialog to view and edit the permissions of a grant entry.
+ */
+public class PermissionEditFormDialog extends LAEFormDialog {
+
+ /** Names of the permission types. */
+ private static final String[] DEFAULT_PERMISSION_TYPE_NAMES =
+ new String[] { "Permission:", "AllPermission" , "AudioPermission" , "AuthPermission" , "AWTPermission" , "DelegationPermission" , "FilePermission" , "LoggingPermission" , "ManagementPermission" , "MBeanPermission" , "MBeanServerPermission" , "MBeanTrustPermission" , "NetPermission" , "PrivateCredentialPermission" , "PropertyPermission" , "ReflectPermission" , "RuntimePermission" , "SecurityPermission" , "SerializablePermission" , "ServicePermission" , "SocketPermission" , "SQLPermission" , "SSLPermission" , "SubjectDelegationPermission" };
+ /** Default names of the permission type classes to be set when chosen. Null value means not to change it. */
+ private static final String[] DEFAULT_PERMISSION_TYPE_CLASS_NAMES =
+ new String[] { null , "java.security.AllPermission", "javax.sound.sampled.AudioPermission", "javax.security.auth.AuthPermission", "java.awt.AWTPermission", "javax.security.auth.kerberos.DelegationPermission", "java.io.FilePermission", "java.util.logging.LoggingPermission", "java.lang.management.ManagementPermission", "javax.management.MBeanPermission", "javax.management.MBeanServerPermission", "javax.management.MBeanTrustPermission", "java.net.NetPermission", "javax.security.auth.PrivateCredentialPermission", "java.util.PropertyPermission", "java.lang.reflect.ReflectPermission", "java.lang.RuntimePermission", "java.security.SecurityPermission", "java.io.SerializablePermission", "javax.security.auth.kerberos.ServicePermission", "java.net.SocketPermission", "java.sql.SQLPermission", "javax.net.ssl.SSLPermission", "javax.management.remote.SubjectDelegationPermission" };
+
+ /** Maps the permission type names to their possible target names and actions.
+ * The key is the permission type name, the value is a 2-length string array of string arrays, of which:
+ *
+ * - element is the array of possible target names (if null, target name text field has to be disabled)
+ *
- element is the array of possible actions (if null, actions text field has to be disabled)
+ *
*/
+ private static final Map< String, String[][] > permissionTypeTargetNamesActionsMap = new HashMap< String, String[][] >();
+ static {
+ permissionTypeTargetNamesActionsMap.put( "AllPermission" , new String[][] { null, null } );
+ permissionTypeTargetNamesActionsMap.put( "AudioPermission" , new String[][] { new String[] { "play", "record" }, null } );
+ permissionTypeTargetNamesActionsMap.put( "AuthPermission" , new String[][] { new String[] { "doAs", "doAsPrivileged", "getSubject", "getSubjectFromDomainCombiner", "setReadOnly", "modifyPrincipals", "modifyPublicCredentials", "modifyPrivateCredentials", "refreshCredentials", "destroyCredentials", "createLoginContext.", "getLoginConfiguration", "setLoginConfiguration", "createLoginConfiguration.", "refreshLoginConfiguration" }, null } );
+ permissionTypeTargetNamesActionsMap.put( "AWTPermission" , new String[][] { new String[] { "accessClipboard", "accessEventQueue" , "accessSystemTray" , "createRobot" , "fullScreenExclusive" , "listenToAllAWTEvents" , "readDisplayPixels" , "replaceKeyboardFocusManager" , "setAppletStub" , "setWindowAlwaysOnTop" , "showWindowWithoutWarningBanner" , "toolkitModality" , "watchMousePointer" }, null } );
+ permissionTypeTargetNamesActionsMap.put( "DelegationPermission" , new String[][] { new String[] {}, null } );
+ permissionTypeTargetNamesActionsMap.put( "FilePermission" , new String[][] { new String[] { "<>" }, new String[] { "read", "write", "delete", "execute" } } );
+ permissionTypeTargetNamesActionsMap.put( "LoggingPermission" , new String[][] { new String[] { "control" }, null } );
+ permissionTypeTargetNamesActionsMap.put( "ManagementPermission" , new String[][] { new String[] { "control", "monitor" }, null } );
+ permissionTypeTargetNamesActionsMap.put( "MBeanPermission" , new String[][] { new String[] {}, new String[] { "addNotificationListener", "getAttribute", "getClassLoader", "getClassLoaderFor", "getClassLoaderRepository", "getDomains", "getMBeanInfo", "getObjectInstance", "instantiate", "invoke", "isInstanceOf", "queryMBeans", "queryNames", "registerMBean", "removeNotificationListener", "setAttribute", "unregisterMBean" } } );
+ permissionTypeTargetNamesActionsMap.put( "MBeanServerPermission" , new String[][] { new String[] { "createMBeanServer", "findMBeanServer", "newMBeanServer", "releaseMBeanServer" }, null } );
+ permissionTypeTargetNamesActionsMap.put( "MBeanTrustPermission" , new String[][] { new String[] { "register" }, null } );
+ permissionTypeTargetNamesActionsMap.put( "NetPermission" , new String[][] { new String[] { "setDefaultAuthenticator", "requestPasswordAuthentication" , "specifyStreamHandler" , "setProxySelector" , "getProxySelector" , "setCookieHandler" , "getCookieHandler" , "setResponseCache" , "getResponseCache" }, null } );
+ permissionTypeTargetNamesActionsMap.put( "PrivateCredentialPermission", new String[][] { new String[] {}, new String[] { "read" } } );
+ permissionTypeTargetNamesActionsMap.put( "PropertyPermission" , new String[][] { new String[] {}, new String[] { "read", "write" } } );
+ permissionTypeTargetNamesActionsMap.put( "ReflectPermission" , new String[][] { new String[] { "suppressAccessChecks" }, null } );
+ permissionTypeTargetNamesActionsMap.put( "RuntimePermission" , new String[][] { new String[] { "createClassLoader", "getClassLoader", "setContextClassLoader", "enableContextClassLoaderOverride", "setSecurityManage", "createSecurityManager", "getenv.", "exitVM", "shutdownHooks", "setFactory", "setIO", "modifyThread", "stopThread", "modifyThreadGroup", "getProtectionDomain", "readFileDescriptor", "writeFileDescriptor", "loadLibrary.", "accessClassInPackage.", "defineClassInPackage.", "accessDeclaredMembers", "queuePrintJob", "getStackTrace", "setDefaultUncaughtExceptionHandler", "preferences", "usePolicy" }, null } );
+ permissionTypeTargetNamesActionsMap.put( "SecurityPermission" , new String[][] { new String[] { "createAccessControlContext", "getDomainCombiner", "getPolicy", "setPolicy", "createPolicy.", "getProperty.", "setProperty.", "insertProvider.", "removeProvider.", "clearProviderProperties.", "putProviderProperty.", "removeProviderProperty." }, null } );
+ permissionTypeTargetNamesActionsMap.put( "SerializablePermission" , new String[][] { new String[] { "enableSubclassImplementation", "enableSubstitution" }, null } );
+ permissionTypeTargetNamesActionsMap.put( "ServicePermission" , new String[][] { new String[] {}, new String[] { "initiate", "accept" } } );
+ permissionTypeTargetNamesActionsMap.put( "SocketPermission" , new String[][] { new String[] {}, new String[] { "accept", "connect", "listen", "resolve" } } );
+ permissionTypeTargetNamesActionsMap.put( "SQLPermission" , new String[][] { new String[] { "setLog" }, null } );
+ permissionTypeTargetNamesActionsMap.put( "SSLPermission" , new String[][] { new String[] { "setHostnameVerifier", "getSSLSessionContext" }, null } );
+ permissionTypeTargetNamesActionsMap.put( "SubjectDelegationPermission", new String[][] { new String[] {}, null } );
+ }
+
+ /** Default item for the target name combo box. */
+ private static final String DEFAULT_TARGET_NAME_COMBO_BOX_ITEM = "Target Name:";
+ /** Default item for the actions combo box. */
+ private static final String DEFAULT_ACTIONS_COMBO_BOX_ITEM = "Actions:";
+
+ /** Reference to the initial editable permission or null, if we are creating a new one. */
+ private final Permission initialPermission;
+ /** List of permissions where to store if new permission is to be created. */
+ private final List< Permission > permissionList;
+
+ /** Model for the target name combo box. */
+ private final DefaultComboBoxModel targetNameComboBoxModel = new DefaultComboBoxModel( new Object[] { DEFAULT_TARGET_NAME_COMBO_BOX_ITEM } );
+ /** Model for the actions combo box. */
+ private final DefaultComboBoxModel actionsComboBoxModel = new DefaultComboBoxModel( new Object[] { DEFAULT_ACTIONS_COMBO_BOX_ITEM } );
+
+ /** Combo box to view and choose the permission type. */
+ private final JComboBox permissionTypeComboBox = new JComboBox( DEFAULT_PERMISSION_TYPE_NAMES );
+ /** Text field to view and edit the permission type (class name). */
+ private final JTextField permissionTypeTextField = new JTextField( 28 );
+ /** Combo box to view and choose the target name. */
+ private final JComboBox targetNameComboBox = new JComboBox( targetNameComboBoxModel );
+ /** Text field to view and edit the target name. */
+ private final JTextField targetNameTextField = new JTextField( 28 );
+ /** Combo box to view and choose the actions. */
+ private final JComboBox actionsComboBox = new JComboBox( actionsComboBoxModel );
+ /** Text field to view and edit the actions. */
+ private final JTextField actionsTextField = new JTextField( 28 );
+ /** Text field to view and edit the signed by. */
+ private final JTextField signedByTextField = new JTextField( 28 );
+
+ /**
+ * Creates a new PermissionEditFormDialog.
+ * @param ownerDialog reference to the owner dialog
+ * @param ownerEditorPanel reference to the owner editor panel
+ * @param permission reference to the editable permission or null, if we are creating a new one
+ * @param permissionList list of permissions where to store if new permission is to be created
+ */
+ public PermissionEditFormDialog( final Dialog ownerDialog, final EditorPanel ownerEditorPanel, final Permission permission, final List< Permission > permissionList ) {
+ super( ownerDialog, "Permission", ownerEditorPanel );
+
+ this.initialPermission = permission;
+ this.permissionList = permissionList;
+
+ prepareForDisplay();
+ }
+
+ @Override
+ protected void buildGUI() {
+ final JPanel panel = new JPanel( new GridLayout( 4, 2, 5, 10 ) );
+
+ permissionTypeComboBox.addActionListener( new ActionListener() {
+ public void actionPerformed( final ActionEvent ae ) {
+ final String classNameForSelectedType = DEFAULT_PERMISSION_TYPE_CLASS_NAMES[ permissionTypeComboBox.getSelectedIndex() ];
+ if ( classNameForSelectedType != null ) {
+ permissionTypeTextField.setText( classNameForSelectedType );
+
+ targetNameTextField.setText( null );
+ targetNameComboBoxModel.removeAllElements();
+ targetNameComboBoxModel.addElement( DEFAULT_TARGET_NAME_COMBO_BOX_ITEM );
+
+ actionsTextField.setText( null );
+ actionsComboBoxModel.removeAllElements();
+ actionsComboBoxModel.addElement( DEFAULT_ACTIONS_COMBO_BOX_ITEM );
+
+ final String[][] targetNameActions = permissionTypeTargetNamesActionsMap.get( DEFAULT_PERMISSION_TYPE_NAMES[ permissionTypeComboBox.getSelectedIndex() ] );
+ if ( targetNameActions[ 0 ] == null )
+ targetNameTextField.setEnabled( false );
+ else {
+ targetNameTextField.setEnabled( true );
+ for ( final String targetName : targetNameActions[ 0 ] )
+ targetNameComboBoxModel.addElement( targetName );
+ }
+ if ( targetNameActions[ 1 ] == null )
+ actionsTextField.setEnabled( false );
+ else {
+ actionsTextField.setEnabled( true );
+ for ( final String actions : targetNameActions[ 1 ] )
+ actionsComboBoxModel.addElement( actions );
+ }
+ }
+ }
+ } );
+ panel.add( permissionTypeComboBox );
+ panel.add( permissionTypeTextField );
+
+ targetNameComboBox.addActionListener( new ActionListener() {
+ public void actionPerformed( final ActionEvent ae ) {
+ if ( targetNameComboBox.getSelectedIndex() > 0 )
+ targetNameTextField.setText( targetNameComboBox.getSelectedItem().toString() );
+ }
+ } );
+ panel.add( targetNameComboBox );
+ panel.add( targetNameTextField );
+
+ actionsComboBox.addActionListener( new ActionListener() {
+ public void actionPerformed( final ActionEvent ae ) {
+ if ( actionsComboBox.getSelectedIndex() > 0 )
+ actionsTextField.setText( actionsTextField.getText() + ( actionsTextField.getText().length() > 0 ? ", " : "" ) + actionsComboBox.getSelectedItem().toString() );
+ }
+ } );
+ panel.add( actionsComboBox );
+ panel.add( actionsTextField );
+
+ panel.add( new JLabel( "Signed By:" ) );
+ panel.add( signedByTextField );
+
+
+
+ final JPanel flowPanel = new JPanel();
+ flowPanel.add( panel );
+ add( new JScrollPane( flowPanel ), BorderLayout.CENTER );
+ }
+
+ @Override
+ public void onOkButtonPressed() {
+ // TODO: validation
+ // TODO Auto-generated method stub
+
+ }
+
+}
Index: modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/KeystoreEntryEditFormDialog.java
===================================================================
--- modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/KeystoreEntryEditFormDialog.java (revision 681611)
+++ modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/KeystoreEntryEditFormDialog.java (working copy)
@@ -94,7 +94,7 @@
}
if ( initialKeystorePasswordURLEntry != null ) {
- keystorePasswordURLTextField.setText( initialKeystorePasswordURLEntry.getUrl() );
+ keystorePasswordURLTextField.setText( initialKeystorePasswordURLEntry.getUrl() );
}
final JPanel flowPanel = new JPanel();
Index: modules/tools/src/main/java/org/apache/harmony/tools/policytool/control/Controller.java
===================================================================
--- modules/tools/src/main/java/org/apache/harmony/tools/policytool/control/Controller.java (revision 681611)
+++ modules/tools/src/main/java/org/apache/harmony/tools/policytool/control/Controller.java (working copy)
@@ -104,7 +104,7 @@
* This method checks whether there are unsaved changes, and if so, ask confirmation on what to do with them.
* Finally returns true, if the dirty data can be thrown away or has been saved successfully.
* Returns false, if the effect of the operation (throwing away unsaved changes) is unwanted and therefore the operation is disallowed.
- *
+ *
* @param operationName name of the operation which will be included in the confirmation messages
* @return true, if the operation now can be performed safely; false otherwise
*/
@@ -163,7 +163,7 @@
*/
public void stateChanged( final ChangeEvent ce ) {
final EditorPanel newActiveEditorPanel = (EditorPanel) ( (JTabbedPane) ce.getSource() ).getSelectedComponent();
-
+
newActiveEditorPanel.loadPolicyText( activeEditorPanel.getPolicyText() );
newActiveEditorPanel.setHasDirty ( activeEditorPanel.getHasDirty () );
activeEditorPanel = newActiveEditorPanel;