/hg/icedtea-web: Added menuentry to PolicyEditor to allow quicky...
jvanek at icedtea.classpath.org
jvanek at icedtea.classpath.org
Wed Feb 18 17:49:38 UTC 2015
changeset a1b50e850558 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=a1b50e850558
author: Jiri Vanek <jvanek at redhat.com>
date: Wed Feb 18 18:47:18 2015 +0100
Added menuentry to PolicyEditor to allow quicky open default java.policy
* netx/net/sourceforge/jnlp/resources/Messages.properties: added keys of PEOpenDefaultMenuItem, PEOpenDefaultMenuItemMnemonic, PEOpenDefaultMenuItemAccelerator
* netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java: added openDefaultButtonAction to open PathsAndFiles.JAVA_POLICY. Added openDefaultItem menu entry calling openDefaultButtonAction.
diffstat:
ChangeLog | 10 ++++
netx/net/sourceforge/jnlp/InformationDesc.java | 18 ++++++-
netx/net/sourceforge/jnlp/JNLPFile.java | 11 ++++-
netx/net/sourceforge/jnlp/Parser.java | 2 +-
netx/net/sourceforge/jnlp/resources/Messages.properties | 3 +
netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java | 22 ++++++++-
tests/netx/unit/net/sourceforge/jnlp/InformationDescTest.java | 10 ++++-
tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPFileTest.java | 2 +-
8 files changed, 66 insertions(+), 12 deletions(-)
diffs (226 lines):
diff -r 62290d68e546 -r a1b50e850558 ChangeLog
--- a/ChangeLog Tue Feb 17 16:33:14 2015 -0500
+++ b/ChangeLog Wed Feb 18 18:47:18 2015 +0100
@@ -1,3 +1,13 @@
+2015-02-18 Jiri Vanek <jvanek at redhat.com>
+
+ Added menuentry to PolicyEditor to allow quicky open default java.policy
+ * netx/net/sourceforge/jnlp/resources/Messages.properties: added keys of
+ PEOpenDefaultMenuItem, PEOpenDefaultMenuItemMnemonic,
+ PEOpenDefaultMenuItemAccelerator
+ * netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java: added
+ openDefaultButtonAction to open PathsAndFiles.JAVA_POLICY. Added openDefaultItem
+ menu entry calling openDefaultButtonAction.
+
2015-02-17 Jie Kang <jkang at redhat.com>
Refactor initializeResources in ResourceDownloader.
diff -r 62290d68e546 -r a1b50e850558 netx/net/sourceforge/jnlp/InformationDesc.java
--- a/netx/net/sourceforge/jnlp/InformationDesc.java Tue Feb 17 16:33:14 2015 -0500
+++ b/netx/net/sourceforge/jnlp/InformationDesc.java Wed Feb 18 18:47:18 2015 +0100
@@ -47,19 +47,24 @@
public static final Object DEFAULT = "default";
/** the locales for the information */
- private Locale locales[];
+ final private Locale locales[];
/** the data as list of key,value pairs */
private List<Object> info;
-
+ final boolean strict;
/**
* Create an information element object.
*
* @param locales the locales the information is for
*/
- public InformationDesc(Locale locales[]) {
+ public InformationDesc(Locale locales[], boolean strict) {
this.locales = locales;
+ this.strict = strict;
+ }
+
+ InformationDesc(Locale locales[]) {
+ this(locales, false);
}
/**
@@ -186,7 +191,12 @@
* Returns whether offline execution allowed.
*/
public boolean isOfflineAllowed() {
- return null != getItem("offline-allowed");
+ if (strict) {
+ return null != getItem("offline-allowed");
+ } else {
+ // by deault itw ignore this switch. Most applications are missusing it
+ return true;
+ }
}
/**
diff -r 62290d68e546 -r a1b50e850558 netx/net/sourceforge/jnlp/JNLPFile.java
--- a/netx/net/sourceforge/jnlp/JNLPFile.java Tue Feb 17 16:33:14 2015 -0500
+++ b/netx/net/sourceforge/jnlp/JNLPFile.java Wed Feb 18 18:47:18 2015 +0100
@@ -426,7 +426,16 @@
* through the specified locale.
*/
public InformationDesc getInformation(final Locale locale) {
- return new InformationDesc(new Locale[] { locale }) {
+ boolean strict = false;
+ if (this.info != null) {
+ for (InformationDesc infoDesc : this.info) {
+ if (infoDesc.strict) {
+ strict = true;
+ break;
+ }
+ }
+ }
+ return new InformationDesc(new Locale[] { locale }, strict) {
@Override
protected List<Object> getItems(Object key) {
List<Object> result = new ArrayList<Object>();
diff -r 62290d68e546 -r a1b50e850558 netx/net/sourceforge/jnlp/Parser.java
--- a/netx/net/sourceforge/jnlp/Parser.java Tue Feb 17 16:33:14 2015 -0500
+++ b/netx/net/sourceforge/jnlp/Parser.java Wed Feb 18 18:47:18 2015 +0100
@@ -495,7 +495,7 @@
Locale locales[] = getLocales(node);
// create information
- InformationDesc info = new InformationDesc(locales);
+ InformationDesc info = new InformationDesc(locales, strict);
// step through the elements
Node child = node.getFirstChild();
diff -r 62290d68e546 -r a1b50e850558 netx/net/sourceforge/jnlp/resources/Messages.properties
--- a/netx/net/sourceforge/jnlp/resources/Messages.properties Tue Feb 17 16:33:14 2015 -0500
+++ b/netx/net/sourceforge/jnlp/resources/Messages.properties Wed Feb 18 18:47:18 2015 +0100
@@ -709,6 +709,7 @@
PEFileMenu=File
PENewMenuItem=New
PEOpenMenuItem=Open...
+PEOpenDefaultMenuItem=Open default policy file
PESaveMenuItem=Save
PESaveAsMenuItem=Save As...
PEExitMenuItem=Exit
@@ -784,6 +785,7 @@
PERemoveCodebaseItemMnemonic=R
PENewMenuItemMnemonic=N
PEOpenMenuItemMnemonic=O
+PEOpenDefaultMenuItemMnemonic=D
PESaveMenuItemMnemonic=S
PEExitMenuItemMnemonic=X
PECustomPermissionsItemMnemonic=U
@@ -800,6 +802,7 @@
PERemoveCodebaseItemAccelerator=DELETE
PENewMenuItemAccelerator=control N
PEOpenMenuItemAccelerator=control O
+PEOpenDefaultMenuItemAccelerator=control D
PESaveMenuItemAccelerator=control S
PESaveAsMenuItemAccelerator=control shift S
PEExitMenuItemAccelerator=control Q
diff -r 62290d68e546 -r a1b50e850558 netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
--- a/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java Tue Feb 17 16:33:14 2015 -0500
+++ b/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java Wed Feb 18 18:47:18 2015 +0100
@@ -61,9 +61,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -102,6 +100,7 @@
import javax.swing.event.ListSelectionListener;
import net.sourceforge.jnlp.about.AboutDialog;
import net.sourceforge.jnlp.OptionsDefinitions;
+import net.sourceforge.jnlp.config.PathsAndFiles;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.security.policyeditor.PolicyEditorPermissions.Group;
@@ -180,7 +179,7 @@
public final PolicyEditorController policyEditorController = new PolicyEditorController();
private final ActionListener okButtonAction, addCodebaseButtonAction,
- removeCodebaseButtonAction, newButtonAction, openButtonAction, saveAsButtonAction, viewCustomButtonAction,
+ removeCodebaseButtonAction, newButtonAction, openButtonAction, openDefaultButtonAction, saveAsButtonAction, viewCustomButtonAction,
renameCodebaseButtonAction, copyCodebaseButtonAction, pasteCodebaseButtonAction,
policyEditorHelpButtonAction, aboutPolicyEditorButtonAction, aboutItwButtonAction;
private final ActionListener closeButtonAction;
@@ -330,6 +329,15 @@
}
}
};
+
+ openDefaultButtonAction = new ActionListener() {
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ if (!promptOnSaveChangesMade(true)) return;
+ PolicyEditor.this.setFile(PathsAndFiles.JAVA_POLICY.getFullPath());
+ openAndParsePolicyFile();
+ }
+ };
saveAsButtonAction = new ActionListener() {
@Override
@@ -1037,6 +1045,12 @@
openItem.addActionListener(editor.openButtonAction);
fileMenu.add(openItem);
+ final JMenuItem openDefaultItem = new JMenuItem(R("PEOpenDefaultMenuItem"));
+ setButtonMnemonic(openDefaultItem, R("PEOpenDefaultMenuItemMnemonic"));
+ setMenuItemAccelerator(openDefaultItem, R("PEOpenDefaultMenuItemAccelerator"));
+ openDefaultItem.addActionListener(editor.openDefaultButtonAction);
+ fileMenu.add(openDefaultItem);
+
final JMenuItem saveItem = new JMenuItem(R("PESaveMenuItem"));
setButtonMnemonic(saveItem, R("PESaveMenuItemMnemonic"));
setMenuItemAccelerator(saveItem, R("PESaveMenuItemAccelerator"));
@@ -1048,7 +1062,7 @@
setMenuItemAccelerator(saveAsItem, R("PESaveAsMenuItemAccelerator"));
saveAsItem.addActionListener(editor.saveAsButtonAction);
fileMenu.add(saveAsItem);
-
+
final JMenuItem exitItem = new JMenuItem(R("PEExitMenuItem"));
setButtonMnemonic(exitItem, R("PEExitMenuItemMnemonic"));
setMenuItemAccelerator(exitItem, R("PEExitMenuItemAccelerator"));
diff -r 62290d68e546 -r a1b50e850558 tests/netx/unit/net/sourceforge/jnlp/InformationDescTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/InformationDescTest.java Tue Feb 17 16:33:14 2015 -0500
+++ b/tests/netx/unit/net/sourceforge/jnlp/InformationDescTest.java Wed Feb 18 18:47:18 2015 +0100
@@ -159,11 +159,19 @@
@Test
public void testIsOfflineAllowed() {
- InformationDesc info = new InformationDesc(new Locale[0]);
+ InformationDesc info = new InformationDesc(new Locale[0], true);
assertFalse(info.isOfflineAllowed());
info.addItem("offline-allowed", new Object());
assertTrue(info.isOfflineAllowed());
}
+
+ @Test
+ public void testIsOfflineAllowedNotStrict() {
+ InformationDesc info = new InformationDesc(new Locale[0], false);
+ assertTrue(info.isOfflineAllowed());
+ info.addItem("offline-allowed", new Object());
+ assertTrue(info.isOfflineAllowed());
+ }
@Test
public void testIsSharingAllowed() {
diff -r 62290d68e546 -r a1b50e850558 tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPFileTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPFileTest.java Tue Feb 17 16:33:14 2015 -0500
+++ b/tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPFileTest.java Wed Feb 18 18:47:18 2015 +0100
@@ -338,7 +338,7 @@
private void setTitle(final DummyJNLPFileWithJar jnlpFile, final String title) {
jnlpFile.setInfo(Arrays.asList(new InformationDesc[]{
- new InformationDesc(new Locale[]{}) {
+ new InformationDesc(new Locale[]{}, false) {
@Override
public String getTitle() {
return title;
More information about the distro-pkg-dev
mailing list