You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by sj...@apache.org on 2008/07/17 14:30:50 UTC
svn commit: r677567 - in
/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool:
./ control/ model/ view/
Author: sjanuary
Date: Thu Jul 17 05:30:49 2008
New Revision: 677567
URL: http://svn.apache.org/viewvc?rev=677567&view=rev
Log:
Apply patch for HARMONY-5912 (Progress on policytool)
Added:
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/GrantEntryEditFormDialog.java (with props)
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/LAEFormDialog.java (with props)
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/PrincipalEditFormDialog.java (with props)
Modified:
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/Consts.java
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/Main.java
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/control/Controller.java
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/control/PolicyFileHandler.java
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/CommentEntry.java
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/GrantEntry.java
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/KeystoreEntry.java
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/KeystorePasswordURLEntry.java
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/Permission.java
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/PolicyEntry.java
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/Principal.java
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/BaseFormDialog.java
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/DirectTextEditorPanel.java
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/EditorPanel.java
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/GraphicalEditorPanel.java
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/KeystoreEntryEditFormDialog.java
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/ListAndEditPanel.java
harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/MainFrame.java
Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/Consts.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/Consts.java?rev=677567&r1=677566&r2=677567&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/Consts.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/Consts.java Thu Jul 17 05:30:49 2008
@@ -5,9 +5,9 @@
* 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.
@@ -29,6 +29,10 @@
public static final int MAIN_FRAME_START_POS_X = 200;
/** Y coordinate of the main frame on startup. */
public static final int MAIN_FRAME_START_POS_Y = 100;
+ /** Width of the main frame. */
+ public static final int MAIN_FRAME_WIDTH = 600;
+ /** Height of the main frame. */
+ public static final int MAIN_FRAME_HEIGHT = 600;
/** Font size in the direct editing panel. */
public static final int DIRECT_EDITING_FONT_SIZE = 13;
Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/Main.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/Main.java?rev=677567&r1=677566&r2=677567&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/Main.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/Main.java Thu Jul 17 05:30:49 2008
@@ -5,9 +5,9 @@
* 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.
@@ -21,7 +21,7 @@
/**
* The main class that parses command line parameters, and starts the GUI if everything everything is ok.
- *
+ *
*/
public class Main {
@@ -30,7 +30,7 @@
/**
* Entry point of the program.
- *
+ *
* @param arguments used to take arguments from the running environment
*/
public static void main( final String[] arguments ) {
@@ -49,7 +49,7 @@
* Currently only one option is supported:
* <pre><code> [-file file]</code></pre>
* for specifying the name of a policy file to be loaded initially.
- *
+ *
* @param arguments arguments taken from the running environment
* @return true if arguments were processed successfully and launching the GUI is allowed;<br>
* false if there were missing or invalid arguments, or no GUI launch is needed
Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/control/Controller.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/control/Controller.java?rev=677567&r1=677566&r2=677567&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/control/Controller.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/control/Controller.java Thu Jul 17 05:30:49 2008
@@ -5,9 +5,9 @@
* 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.
@@ -104,7 +104,7 @@
* This method checks whether there are unsaved changes, and if so, ask confirmation on what to do with them.<br>
* 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;
Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/control/PolicyFileHandler.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/control/PolicyFileHandler.java?rev=677567&r1=677566&r2=677567&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/control/PolicyFileHandler.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/control/PolicyFileHandler.java Thu Jul 17 05:30:49 2008
@@ -5,9 +5,9 @@
* 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.
@@ -32,7 +32,7 @@
/**
* This class is responsible to read policy text from and write policy text to policy files.<br>
- * We're aware of the UTF-8 policy file encoding.
+ * We're aware of the UTF-8 policy file encoding.
*/
public class PolicyFileHandler {
Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/CommentEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/CommentEntry.java?rev=677567&r1=677566&r2=677567&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/CommentEntry.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/CommentEntry.java Thu Jul 17 05:30:49 2008
@@ -5,9 +5,9 @@
* 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.
@@ -23,7 +23,7 @@
* <ul>
* <li>separate, tag the policy text
* <li>hold informations, comments for the author or the user of the policy text
- * </ul>
+ * </ul>
*/
public class CommentEntry extends PolicyEntry {
Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/GrantEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/GrantEntry.java?rev=677567&r1=677566&r2=677567&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/GrantEntry.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/GrantEntry.java Thu Jul 17 05:30:49 2008
@@ -5,9 +5,9 @@
* 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.
@@ -113,4 +113,19 @@
// TODO Auto-generated method stub
}
+ @Override
+ public String toString() {
+ final StringBuilder stringBuilder = new StringBuilder();
+
+ if ( codeBase != null )
+ stringBuilder.append( "CodeBase \"" ).append( codeBase ).append( '"');
+ if ( signedBy != null )
+ stringBuilder.append( stringBuilder.length() > 0 ? ", " : "" ).append( "SignedBy \"" ).append( signedBy ).append( '"' );
+
+ for ( final Principal principal : principalList )
+ stringBuilder.append( stringBuilder.length() > 0 ? ", " : "" ).append( principal );
+
+ return stringBuilder.toString();
+ }
+
}
Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/KeystoreEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/KeystoreEntry.java?rev=677567&r1=677566&r2=677567&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/KeystoreEntry.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/KeystoreEntry.java Thu Jul 17 05:30:49 2008
@@ -5,9 +5,9 @@
* 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.
Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/KeystorePasswordURLEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/KeystorePasswordURLEntry.java?rev=677567&r1=677566&r2=677567&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/KeystorePasswordURLEntry.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/KeystorePasswordURLEntry.java Thu Jul 17 05:30:49 2008
@@ -5,9 +5,9 @@
* 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.
Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/Permission.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/Permission.java?rev=677567&r1=677566&r2=677567&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/Permission.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/Permission.java Thu Jul 17 05:30:49 2008
@@ -5,9 +5,9 @@
* 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.
Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/PolicyEntry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/PolicyEntry.java?rev=677567&r1=677566&r2=677567&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/PolicyEntry.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/PolicyEntry.java Thu Jul 17 05:30:49 2008
@@ -5,9 +5,9 @@
* 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.
Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/Principal.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/Principal.java?rev=677567&r1=677566&r2=677567&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/Principal.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/model/Principal.java Thu Jul 17 05:30:49 2008
@@ -5,9 +5,9 @@
* 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.
@@ -59,4 +59,9 @@
this.name = name;
}
+ @Override
+ public String toString() {
+ return "Principal " + type + " \"" + name + '"';
+ }
+
}
Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/BaseFormDialog.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/BaseFormDialog.java?rev=677567&r1=677566&r2=677567&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/BaseFormDialog.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/BaseFormDialog.java Thu Jul 17 05:30:49 2008
@@ -5,9 +5,9 @@
* 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.
@@ -18,7 +18,9 @@
package org.apache.harmony.tools.policytool.view;
import java.awt.BorderLayout;
+import java.awt.Dialog;
import java.awt.Frame;
+import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -31,13 +33,13 @@
*/
public abstract class BaseFormDialog extends JDialog implements ActionListener {
- /** Reference to the owner frame. */
- private final Frame ownerFrame;
+ /** Reference to the owner window. */
+ protected final Window ownerWindow;
/** Ok button of the form dialog. */
- private final JButton okButton = new JButton( "OK" );
+ private final JButton okButton = new JButton( "OK" );
/** Cancel button of the form dialog. */
- private final JButton cancelButton = new JButton( "Cancel" );
+ private final JButton cancelButton = new JButton( "Cancel" );
/** Reference to the owner editor panel. This reference can (will) be used to indicate new data/dirty state. */
protected final EditorPanel ownerEditorPanel;
@@ -51,11 +53,38 @@
public BaseFormDialog( final Frame ownerFrame, final String title, final EditorPanel ownerEditorPanel ) {
super( ownerFrame, title, true );
- this.ownerFrame = ownerFrame;
+ this.ownerWindow = ownerFrame;
this.ownerEditorPanel = ownerEditorPanel;
- buildBaseGUI();
+ initialize();
+ }
+
+ /**
+ * Creates a new BaseFormDialog.
+ * @param ownerDialog owner dialog of the dialog
+ * @param title title of the dialog
+ * @param ownerEditorPanel reference to the owner editor panel
+ */
+ public BaseFormDialog( final Dialog ownerDialog, final String title, final EditorPanel ownerEditorPanel ) {
+ super( ownerDialog, title, true );
+
+ this.ownerWindow = ownerDialog;
+ this.ownerEditorPanel = ownerEditorPanel;
+
+ initialize();
+ }
+
+ /**
+ * Initializes the dialog.<br>
+ * Part of the constructor.
+ */
+ private void initialize() {
setDefaultCloseOperation( DISPOSE_ON_CLOSE );
+
+ buildBaseGUI();
+
+ // We cannot call or perform the prepareForDisplay() operation here,
+ // because the actual GUI might require fields initialized after this constructor.
}
/**
@@ -77,11 +106,27 @@
}
/**
+ * Builds the GUI of the dialog.
+ */
+ protected abstract void buildGUI();
+
+ /**
+ * Prepares the dialog for displaying.<br>
+ * This includes finishing building the gui and sizing and positioning it.
+ */
+ protected void prepareForDisplay() {
+ buildGUI();
+
+ pack();
+ center();
+ }
+
+ /**
* Centers the dialog to its owner frame.
*/
public void center() {
- setLocation( ownerFrame.getX() + ownerFrame.getWidth () / 2 - getWidth () / 2,
- ownerFrame.getY() + ownerFrame.getHeight() / 2 - getHeight() / 2 );
+ setLocation( ownerWindow.getX() + ownerWindow.getWidth () / 2 - getWidth () / 2,
+ ownerWindow.getY() + ownerWindow.getHeight() / 2 - getHeight() / 2 );
}
/**
@@ -100,6 +145,14 @@
public abstract void onOkButtonPressed();
/**
+ * Finishes a successful edit action.
+ */
+ protected void finishSuccessfulEdit() {
+ ownerEditorPanel.setHasDirty( true );
+ dispose();
+ }
+
+ /**
* Called when the cancel button of the dialog is pressed.<br>
* Simply disposes the dialog.
*/
Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/DirectTextEditorPanel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/DirectTextEditorPanel.java?rev=677567&r1=677566&r2=677567&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/DirectTextEditorPanel.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/DirectTextEditorPanel.java Thu Jul 17 05:30:49 2008
@@ -5,9 +5,9 @@
* 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.
Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/EditorPanel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/EditorPanel.java?rev=677567&r1=677566&r2=677567&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/EditorPanel.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/EditorPanel.java Thu Jul 17 05:30:49 2008
@@ -5,9 +5,9 @@
* 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.
Added: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/GrantEntryEditFormDialog.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/GrantEntryEditFormDialog.java?rev=677567&view=auto
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/GrantEntryEditFormDialog.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/GrantEntryEditFormDialog.java Thu Jul 17 05:30:49 2008
@@ -0,0 +1,146 @@
+/*
+ * 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.Dimension;
+import java.awt.Frame;
+import java.util.List;
+
+import javax.swing.Box;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.apache.harmony.tools.policytool.model.GrantEntry;
+import org.apache.harmony.tools.policytool.model.Permission;
+import org.apache.harmony.tools.policytool.model.PolicyEntry;
+import org.apache.harmony.tools.policytool.model.Principal;
+
+/**
+ * Form dialog to view and edit the grant entries.
+ */
+public class GrantEntryEditFormDialog extends LAEFormDialog {
+
+ /** Reference to the initial editable grant entry or null, if we are creating a new one. */
+ 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;
+
+ /** 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. */
+ private final JTextField signedByTextField = new JTextField();
+
+ /**
+ * Creates a new GrantEntryEditFormDialog.
+ * @param ownerFrame reference to the owner frame
+ * @param ownerEditorPanel reference to the owner editor panel
+ * @param grantEntry reference to the editable grant entry or null, if we are creating a new one
+ * @param policyEntryList list of policy entries where to store if new entry is to be created
+ */
+ public GrantEntryEditFormDialog( final Frame ownerFrame, final EditorPanel ownerEditorPanel, final GrantEntry grantEntry, final List< PolicyEntry > policyEntryList ) {
+ super( ownerFrame, "Policy Entry", ownerEditorPanel );
+
+ this.initialGrantEntry = grantEntry;
+ this.policyEntryList = policyEntryList;
+
+ newGrantEntry = initialGrantEntry == null ? new GrantEntry() : null;
+
+ prepareForDisplay();
+ }
+
+ @Override
+ protected void buildGUI() {
+ final JPanel panel = new JPanel( new BorderLayout( 2,15 ) );
+
+ final Box verticalBox = Box.createVerticalBox();
+
+ verticalBox.add( Box.createVerticalStrut( 10 ) );
+
+ Box hBox = Box.createHorizontalBox();
+ JLabel label = new JLabel( "CodeBase: ", JLabel.RIGHT );
+ label.setPreferredSize( new Dimension( 80, 20 ) );
+ hBox.add( label );
+ hBox.add( codeBaseTextField );
+ verticalBox.add( hBox );
+
+ verticalBox.add( Box.createVerticalStrut( 5 ) );
+
+ hBox = Box.createHorizontalBox();
+ label = new JLabel( "SignedBy: ", JLabel.RIGHT );
+ label.setPreferredSize( new Dimension( 80, 20 ) );
+ hBox.add( label );
+ hBox.add( signedByTextField );
+ verticalBox.add( hBox );
+
+ if ( initialGrantEntry != null ) {
+ codeBaseTextField.setText( initialGrantEntry.getCodeBase() );
+ signedByTextField.setText( initialGrantEntry.getSignedBy() );
+ }
+
+ panel.add( verticalBox, BorderLayout.NORTH );
+
+ // ListAndEdit component for Principals
+ panel.add( new ListAndEditPanel< Principal >( "Principals:", "Principal", ( initialGrantEntry == null ? newGrantEntry : initialGrantEntry ).getPrincipalList(),
+ new ListAndEditPanel.LAEFormDialogFactory< Principal > () {
+ public LAEFormDialog createFactoryForAddOrEdit( final Principal selectedEntity ) {
+ return new PrincipalEditFormDialog( GrantEntryEditFormDialog.this, ownerEditorPanel, selectedEntity, ( initialGrantEntry == null ? newGrantEntry : initialGrantEntry ).getPrincipalList() );
+ }
+ }
+ ), BorderLayout.CENTER );
+
+ panel.add( new JLabel(), BorderLayout.SOUTH ); // To make some space between the 2 ListAndEdit components (vertical gap of the BorderLayout of the panel will be used)
+
+ add( panel, BorderLayout.NORTH );
+
+ // ListAndEdit component for Permissions
+ final ListAndEditPanel< Permission > permissionsLAE =
+ new ListAndEditPanel< Permission >( "Permissions:", "Permission", ( initialGrantEntry == null ? newGrantEntry : initialGrantEntry ).getPermissionList(),
+ new ListAndEditPanel.LAEFormDialogFactory< Permission > () {
+ public LAEFormDialog createFactoryForAddOrEdit( final Permission selectedEntity ) {
+ return null;
+ }
+ }
+ );
+ permissionsLAE.overrideMnemonics( 'd', 't', 'v' );
+ add( permissionsLAE, BorderLayout.CENTER );
+ }
+
+ @Override
+ public void onOkButtonPressed() {
+ // TODO: validation
+
+ final GrantEntry grantEntry = initialGrantEntry == null ? newGrantEntry : initialGrantEntry;
+
+ grantEntry.setCodeBase( codeBaseTextField.getText() );
+ grantEntry.setSignedBy( signedByTextField.getText() );
+
+ if ( initialGrantEntry == null ) {
+ policyEntryList.add( grantEntry );
+ listModel.addElement( grantEntry );
+ } else
+ refreshVisualizationList();
+
+ finishSuccessfulEdit();
+ }
+
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/GrantEntryEditFormDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/GrantEntryEditFormDialog.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/GraphicalEditorPanel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/GraphicalEditorPanel.java?rev=677567&r1=677566&r2=677567&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/GraphicalEditorPanel.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/GraphicalEditorPanel.java Thu Jul 17 05:30:49 2008
@@ -5,9 +5,9 @@
* 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.
@@ -46,11 +46,18 @@
super( mainFrame, "Graphical editing", new BorderLayout(), true );
// buildGUI:
- add( new ListAndEditPanel< PolicyEntry >( "Policy Entry", policyEntryList, new ListAndEditPanel.Filter< PolicyEntry > () {
- public boolean includeEntity( final PolicyEntry entity ) {
- return entity instanceof GrantEntry;
+ add( new ListAndEditPanel< PolicyEntry >( "Policy entries:", "Policy Entry", policyEntryList,
+ new ListAndEditPanel.Filter< PolicyEntry > () {
+ public boolean includeEntity( final PolicyEntry entity ) {
+ return entity instanceof GrantEntry;
+ }
+ },
+ new ListAndEditPanel.LAEFormDialogFactory< PolicyEntry > () {
+ public LAEFormDialog createFactoryForAddOrEdit( final PolicyEntry selectedEntity ) {
+ return new GrantEntryEditFormDialog( mainFrame, GraphicalEditorPanel.this, (GrantEntry) selectedEntity, policyEntryList );
+ }
}
- } ), BorderLayout.CENTER );
+ ), BorderLayout.CENTER );
}
@Override
Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/KeystoreEntryEditFormDialog.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/KeystoreEntryEditFormDialog.java?rev=677567&r1=677566&r2=677567&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/KeystoreEntryEditFormDialog.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/KeystoreEntryEditFormDialog.java Thu Jul 17 05:30:49 2008
@@ -5,9 +5,9 @@
* 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.
@@ -37,27 +37,27 @@
*/
public class KeystoreEntryEditFormDialog extends BaseFormDialog {
- /** Reference to the initial editable keystore entry. */
+ /** Reference to the initial editable keystore entry or null, if we are creating a new one. */
private final KeystoreEntry initialKeystoreEntry;
- /** Reference to the initial editable keystore password URL entry. */
+ /** Reference to the initial editable keystore password URL entry. */
private final KeystorePasswordURLEntry initialKeystorePasswordURLEntry;
- /** List of policy entries where to store if new entries are to be created. */
+ /** List of policy entries where to store if new entry is to be created. */
private final List< PolicyEntry > policyEntryList;
- /** Text field to view and edit the value of keystore URL. */
- private final JTextField keystoreURLTextField = new JTextField( 10 );
- /** Text field to view and edit the value of keystore type. */
- private final JTextField keystoreTypeTextField = new JTextField( 10 );
- /** Text field to view and edit the value of keystore provider. */
- private final JTextField keystoreProviderTextField = new JTextField( 10 );
+ /** Text field to view and edit the value of keystore URL. */
+ private final JTextField keystoreURLTextField = new JTextField( 20 );
+ /** Text field to view and edit the value of keystore type. */
+ private final JTextField keystoreTypeTextField = new JTextField( 20 );
+ /** Text field to view and edit the value of keystore provider. */
+ private final JTextField keystoreProviderTextField = new JTextField( 20 );
/** Text field to view and edit the value of keystore password URL. */
- private final JTextField keystorePasswordURLTextField = new JTextField( 10 );
+ private final JTextField keystorePasswordURLTextField = new JTextField( 20 );
/**
* Creates a new KeystoreEntryEditFormDialog.
* @param ownerFrame reference to the owner frame
* @param ownerEditorPanel reference to the owner editor panel
- * @param keystoreEntry reference to the editable keystore entry
+ * @param keystoreEntry reference to the editable keystore entry or null, if we are creating a new one
* @param keystorePasswordURLEntry reference to the editable password URL entry
* @param policyEntryList list of policy entries where to store if new entries are to be created
*/
@@ -68,15 +68,11 @@
this.initialKeystorePasswordURLEntry = keystorePasswordURLEntry;
this.policyEntryList = policyEntryList;
- buildGUI();
- pack();
- center();
+ prepareForDisplay();
}
- /**
- * Builds the GUI of the dialog.
- */
- private void buildGUI() {
+ @Override
+ protected void buildGUI() {
final JPanel panel = new JPanel( new GridLayout( 4, 2, 5, 10 ) );
panel.add( new JLabel( "KeyStore URL:" ) );
@@ -92,13 +88,13 @@
panel.add( keystorePasswordURLTextField );
if ( initialKeystoreEntry != null ) {
- keystoreURLTextField .setText( initialKeystoreEntry.getUrl () );
- keystoreTypeTextField .setText( initialKeystoreEntry.getType () );
- keystoreProviderTextField.setText( initialKeystoreEntry.getProvider() );
+ keystoreURLTextField .setText( initialKeystoreEntry.getUrl () );
+ keystoreTypeTextField .setText( initialKeystoreEntry.getType () );
+ keystoreProviderTextField.setText( initialKeystoreEntry.getProvider() );
}
if ( initialKeystorePasswordURLEntry != null ) {
- keystorePasswordURLTextField.setText( initialKeystorePasswordURLEntry.getUrl() );
+ keystorePasswordURLTextField.setText( initialKeystorePasswordURLEntry.getUrl() );
}
final JPanel flowPanel = new JPanel();
@@ -153,9 +149,7 @@
}
}
- ownerEditorPanel.setHasDirty( true );
-
- dispose();
+ finishSuccessfulEdit();
}
}
Added: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/LAEFormDialog.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/LAEFormDialog.java?rev=677567&view=auto
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/LAEFormDialog.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/LAEFormDialog.java Thu Jul 17 05:30:49 2008
@@ -0,0 +1,76 @@
+/*
+ * 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.Dialog;
+import java.awt.Frame;
+
+import javax.swing.DefaultListModel;
+import javax.swing.JList;
+
+/**
+ * An extended form dialog which is tied to a ListAndEdit component.<br>
+ * The form is destined to view and edit the entities of a ListAndEdit component.
+ */
+public abstract class LAEFormDialog extends BaseFormDialog {
+
+ /** Reference to the visualization list component of the tied ListAndEdit component. */
+ protected JList visualizationJListforLAE;
+ /** Reference to the model of the visualization list as <code>DefaultListModel</code>. */
+ protected DefaultListModel listModel;
+
+ /**
+ * A delegator constructor toward the ancestor's constructor.
+ * @param ownerFrame reference to the owner frame
+ * @param title title of the dialog
+ * @param ownerEditorPanel reference to the owner editor panel
+ */
+ public LAEFormDialog( final Frame ownerFrame, final String title, final EditorPanel ownerEditorPanel ) {
+ super( ownerFrame, title, ownerEditorPanel );
+ }
+
+ /**
+ * A delegator constructor toward the ancestor's constructor.
+ * @param ownerDialog reference to the owner dialog
+ * @param title title of the dialog
+ * @param ownerEditorPanel reference to the owner editor panel
+ */
+ public LAEFormDialog( final Dialog ownerDialog, final String title, final EditorPanel ownerEditorPanel ) {
+ super( ownerDialog, title, ownerEditorPanel );
+ }
+
+ /**
+ * Sets the visualization list component and its list model of the tied ListAndEdit component.
+ * @param visualizationJListforLAE visualization list component of the tied ListAndEdit component
+ * @param listModel list model of the visualization list component
+ */
+ public void setVisualizationListForLAE( final JList visualizationJListforLAE, final DefaultListModel listModel ) {
+ this.visualizationJListforLAE = visualizationJListforLAE;
+ this.listModel = listModel;
+ }
+
+ /**
+ * Refreshes the visualization list.<br>
+ * Should be called if the entities of the list might have changed but the list model was not modified.
+ */
+ public void refreshVisualizationList() {
+ visualizationJListforLAE.revalidate();
+ visualizationJListforLAE.repaint();
+ }
+
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/LAEFormDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/LAEFormDialog.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/ListAndEditPanel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/ListAndEditPanel.java?rev=677567&r1=677566&r2=677567&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/ListAndEditPanel.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/ListAndEditPanel.java Thu Jul 17 05:30:49 2008
@@ -5,9 +5,9 @@
* 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.
@@ -22,6 +22,7 @@
import java.awt.event.ActionListener;
import java.util.List;
+import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JList;
@@ -30,26 +31,31 @@
/**
* The abstraction of a panel which can list entities and provide GUI components to offer and handle certain actions on the entities.<br>
- * The entities are listed in a listbox,
+ * The entities are listed in a listbox,
* @param <EntityType> type of the entities listed on and edited by this panel
*/
public class ListAndEditPanel< EntityType > extends JPanel implements ActionListener {
+ /** Model of the list component displaying the entities. */
+ private final DefaultListModel listModel = new DefaultListModel();
/** The component to list he entities. */
- private final JList entityListComponent = new JList();
+ private final JList entityListComponent = new JList( listModel );
/** Add new entity button. */
- private final JButton addButton = new JButton();
+ private final JButton addButton = new JButton();
/** Edit selected entity button. */
- private final JButton editButton = new JButton();
+ private final JButton editButton = new JButton();
/** Remove selected entity button. */
- private final JButton removeButton = new JButton();
+ private final JButton removeButton = new JButton();
/** Reference to the list whose elements are to be listed and edited, and where to put new entities. */
- private final List< ? > entityList;
+ private final List< ? > entityList;
+
+ /** Reference to the base form dialog factory. */
+ private final LAEFormDialogFactory< EntityType > baseFormDialogFactory;
/**
- * Can be used to filter the input entity list, hide elements from displaying.
+ * Can be used to filter the input entity list, hide elements from displaying.
* @param <EntityType> type of the entities filtered by this filter
*/
public interface Filter< EntityType > {
@@ -62,42 +68,59 @@
}
/**
+ * Factory instance to be used to acuire a base form dialog which will handle the add/edit action of the selected entity.
+ * @param <EntityType> type of the entities which is (listed and edited and) passed by by this ListAndEditPanel
+ */
+ public interface LAEFormDialogFactory< EntityType > {
+ /**
+ * Creates a <code>LAEFormDialog<code> which will handle the add/edit action of the passed selected entity.
+ * @param selectedEntity selected entity to be edited or null if a new one should be created and added
+ * @return a reference to the created BaseFormDialog
+ */
+ LAEFormDialog createFactoryForAddOrEdit( final EntityType selectedEntity );
+ }
+
+
+ /**
* Creates a new ListAndEditPanel.<br>
* Sets a BorderLayout for ourselves.
+ * @param panelTitle title of the list and edit panel
* @param entityName name of the listed and edited entity (this will be displayed on the buttons)
* @param entityList reference to the list whose elements are to be listed and edited, and where to put new entities
+ * @param baseFormDialogFactory reference to a base form dialog factory
*/
- public ListAndEditPanel( final String entityName, final List< EntityType > entityList ) {
- this( entityName, entityList, null );
+ public ListAndEditPanel( final String panelTitle, final String entityName, final List< EntityType > entityList, final LAEFormDialogFactory< EntityType > baseFormDialogFactory ) {
+ this( panelTitle, entityName, entityList, null, baseFormDialogFactory );
}
/**
* Creates a new ListAndEditPanel.<br>
* Sets a BorderLayout for ourselves.
+ * @param panelTitle title of the list and edit panel
* @param entityName name of the listed and edited entity (this will be displayed on the buttons)
* @param entityList reference to the list whose elements are to be listed and edited, and where to put new entities
* @param entityFilter filter to be used when listing the entities
+ * @param baseFormDialogFactory reference to a base form dialog factory
*/
- public ListAndEditPanel( final String entityName, final List< EntityType > entityList, final Filter< EntityType > entityFilter ) {
+ public ListAndEditPanel( final String panelTitle, final String entityName, final List< EntityType > entityList, final Filter< EntityType > entityFilter, final LAEFormDialogFactory< EntityType > baseFormDialogFactory ) {
super( new BorderLayout() );
- this.entityList = entityList;
+ this.entityList = entityList;
+ this.baseFormDialogFactory = baseFormDialogFactory;
- final DefaultListModel listModel = new DefaultListModel();
for ( final EntityType entity : entityList )
if ( entityFilter == null || entityFilter.includeEntity( entity ) )
listModel.addElement( entity );
- entityListComponent.setModel( listModel );
-
- buildGUI( entityName );
+ buildGUI( panelTitle, entityName );
}
/**
* Builds the graphical user interface of the panel.
+ * @param panelTitle title of the list and edit panel
* @param entityName name of the listed and edited entity (this will be displayed on the buttons)
*/
- private void buildGUI( final String entityName ) {
+ private void buildGUI( final String panelTitle, final String entityName ) {
final JPanel buttonsPanel = new JPanel();
addButton .setText ( "Add " + entityName );
@@ -118,13 +141,51 @@
add( buttonsPanel, BorderLayout.NORTH );
add( new JScrollPane( entityListComponent ), BorderLayout.CENTER );
+
+ setBorder( BorderFactory.createTitledBorder( panelTitle ) );
+ }
+
+ /**
+ * Overrides default mnemonic keys for the add, edit and remove buttons.<br>
+ * If null value is passed as a mnemonic, the mnemonic for that button will not be changed.
+ * @param addButtonMnemonic new mnemonic for the add button
+ * @param editButtonMnemonic new mnemonic for the edit button
+ * @param removeButtonMnemonic new mnemonic for the remove button
+ */
+ public void overrideMnemonics( final Character addButtonMnemonic, final Character editButtonMnemonic, final Character removeButtonMnemonic ) {
+ if ( addButtonMnemonic != null )
+ addButton .setMnemonic( addButtonMnemonic );
+
+ if ( editButtonMnemonic != null )
+ editButton .setMnemonic( editButtonMnemonic );
+
+ if ( removeButtonMnemonic != null )
+ removeButton.setMnemonic( removeButtonMnemonic );
}
/**
* Handles the action events of the buttons for adding new, editing and removing entities.
* @param ae details of the action event
*/
+ @SuppressWarnings("unchecked")
public void actionPerformed( final ActionEvent ae ) {
+ if ( ae.getSource() == addButton ) {
+ final LAEFormDialog laeFormDialog = baseFormDialogFactory.createFactoryForAddOrEdit( null );
+ laeFormDialog.setVisualizationListForLAE( entityListComponent, listModel );
+ laeFormDialog.setVisible( true );
+ } else if ( ae.getSource() == editButton ) {
+ final EntityType selectedEntity = (EntityType) entityListComponent.getSelectedValue();
+ if ( selectedEntity != null ) {
+ final LAEFormDialog laeFormDialog = baseFormDialogFactory.createFactoryForAddOrEdit( selectedEntity );
+ laeFormDialog.setVisualizationListForLAE( entityListComponent, listModel );
+ laeFormDialog.setVisible( true );
+ }
+ } else if ( ae.getSource() == removeButton ) {
+ for ( final Object selectedEntityObject : entityListComponent.getSelectedValues() ) {
+ listModel .removeElement( selectedEntityObject );
+ entityList.remove ( selectedEntityObject );
+ }
+ }
}
}
Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/MainFrame.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/MainFrame.java?rev=677567&r1=677566&r2=677567&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/MainFrame.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/MainFrame.java Thu Jul 17 05:30:49 2008
@@ -5,9 +5,9 @@
* 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.
@@ -63,7 +63,7 @@
buildGUI( controller );
setLocation( Consts.MAIN_FRAME_START_POS_X, Consts.MAIN_FRAME_START_POS_X );
- setSize( 500, 500 );
+ setSize( Consts.MAIN_FRAME_WIDTH, Consts.MAIN_FRAME_HEIGHT );
setDefaultCloseOperation( DO_NOTHING_ON_CLOSE );
addWindowListener( new WindowAdapter() {
public void windowClosing( final WindowEvent we ) {
@@ -161,7 +161,7 @@
/**
* Builds the menus and the menu bar.
- * @param controller reference to the controller
+ * @param controller reference to the controller
*/
private void buildMenusAndMenuBar( final Controller controller ) {
final JMenuBar menuBar = new JMenuBar();
@@ -188,7 +188,7 @@
/**
* Builds the tabbed pane containing the editor panels.
- * @param controller reference to the controller
+ * @param controller reference to the controller
*/
private void buildTabbedPane( final Controller controller ) {
final JTabbedPane tabbedPane = new JTabbedPane();
Added: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/PrincipalEditFormDialog.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/PrincipalEditFormDialog.java?rev=677567&view=auto
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/PrincipalEditFormDialog.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/PrincipalEditFormDialog.java Thu Jul 17 05:30:49 2008
@@ -0,0 +1,127 @@
+/*
+ * 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.List;
+
+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.Principal;
+
+/**
+ * Form dialog to view and edit the principals of a grant entry.
+ */
+public class PrincipalEditFormDialog extends LAEFormDialog {
+
+ /** Names of the principal types. */
+ private static final String[] DEFAULT_PRINCIPAL_TYPE_NAMES =
+ new String[] { "Principal Type:", "KerberosPrincipal" , "X500Principal" };
+ /** Default names of the principal type classes to be set when chosen. Null value means not to change it. */
+ private static final String[] DEFAULT_PRINCIPAL_TYPE_CLASS_NAMES =
+ new String[] { null , "javax.security.auth.kerberos.KerberosPrincipal", "javax.security.auth.x500.X500Principal" };
+
+ /** Reference to the initial editable principal or null, if we are creating a new one. */
+ private final Principal initialPrincipal;
+ /** List of principals where to store if new principal is to be created. */
+ private final List< Principal > principalList;
+
+ /** Combo box to view and choose the principal type. */
+ private final JComboBox principalTypeComboBox = new JComboBox( DEFAULT_PRINCIPAL_TYPE_NAMES );
+ /** Text field to view and edit the principal type (the class name). */
+ private final JTextField principalTypeTextField = new JTextField( 20 );
+ /** Text field to view and edit the principal name. */
+ private final JTextField principalNameTextField = new JTextField( 20 );
+
+ /**
+ * Creates a new PrincipalEditFormDialog.
+ * @param ownerDialog reference to the owner dialog
+ * @param ownerEditorPanel reference to the owner editor panel
+ * @param principal reference to the editable principal or null, if we are creating a new one
+ * @param principalList list of principals where to store if new principal is to be created
+ */
+ public PrincipalEditFormDialog( final Dialog ownerDialog, final EditorPanel ownerEditorPanel, final Principal principal, final List< Principal > principalList ) {
+ super( ownerDialog, "Principal", ownerEditorPanel );
+
+ this.initialPrincipal = principal;
+ this.principalList = principalList;
+
+ prepareForDisplay();
+ }
+
+ @Override
+ protected void buildGUI() {
+ final JPanel panel = new JPanel( new GridLayout( 2, 2, 5, 10 ) );
+
+ principalTypeComboBox.addActionListener( new ActionListener() {
+ public void actionPerformed( final ActionEvent ae ) {
+ final String classNameForSelectedType = DEFAULT_PRINCIPAL_TYPE_CLASS_NAMES[ principalTypeComboBox.getSelectedIndex() ];
+ if ( classNameForSelectedType != null )
+ principalTypeTextField.setText( classNameForSelectedType );
+ }
+ } );
+ panel.add( principalTypeComboBox );
+ panel.add( principalTypeTextField );
+
+ panel.add( new JLabel( "Principal Name:" ) );
+ panel.add( principalNameTextField );
+
+ if ( initialPrincipal != null ) {
+ // Should we choose anything in the principal type combo box?
+ 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 );
+ break;
+ }
+ principalTypeTextField.setText( initialPrincipal.getType() );
+ principalNameTextField.setText( initialPrincipal.getName() );
+ }
+
+ final JPanel flowPanel = new JPanel();
+ flowPanel.add( panel );
+ add( new JScrollPane( flowPanel ), BorderLayout.CENTER );
+ }
+
+ @Override
+ public void onOkButtonPressed() {
+ // TODO: validation
+
+ final Principal principal = initialPrincipal == null ? new Principal() : initialPrincipal;
+
+ principal.setType( principalTypeTextField.getText() );
+ principal.setName( principalNameTextField.getText() );
+
+ if ( initialPrincipal == null ) {
+ principalList.add( principal );
+ listModel.addElement( principal );
+ } else
+ refreshVisualizationList();
+
+ finishSuccessfulEdit();
+ }
+
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/PrincipalEditFormDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/policytool/view/PrincipalEditFormDialog.java
------------------------------------------------------------------------------
svn:mime-type = text/plain