Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial import

  • Loading branch information...
commit ee37042b90e005eb46fd46f7ca1176ce365ffa0f 0 parents
@jdf authored
6 .classpath
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/Java 5"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
14 .fatjar
@@ -0,0 +1,14 @@
+#Fat Jar Configuration File
+#Fri Jun 26 12:42:06 EDT 2009
+onejar.license.required=true
+manifest.classpath=
+manifest.removesigners=true
+onejar.checkbox=false
+jarname=enable-wordle-printing.jar
+manifest.mergeall=true
+manifest.mainclass=wordle.DoPolicy
+manifest.file=<createnew>
+jarname.isextern=false
+onejar.expand=
+excludes=
+includes=
2  .gitignore
@@ -0,0 +1,2 @@
+bin
+
17 .project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>wordle.policy</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
12 .settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Fri Jun 26 11:28:38 EDT 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
119 src/wordle/DoPolicy.java
@@ -0,0 +1,119 @@
+package wordle;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Writer;
+
+import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
+
+public class DoPolicy
+{
+ public static void main(final String[] args)
+ {
+ final String home = System.getProperty("user.home");
+ File homeDir = home == null ? null : new File(home);
+ if (home == null || !homeDir.exists())
+ {
+ final JFileChooser jfc = new JFileChooser("/users");
+ jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ if (jfc.showOpenDialog(null) != JFileChooser.APPROVE_OPTION)
+ return;
+ homeDir = jfc.getSelectedFile();
+ }
+ if (!homeDir.exists())
+ {
+ JOptionPane.showMessageDialog(null, homeDir + " does not exist.",
+ "Fatal Error", JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+ final File policyFile = new File(homeDir, ".java.policy");
+ final StringBuilder policyBuilder = new StringBuilder();
+ if (policyFile.exists())
+ {
+ final int r = JOptionPane.showConfirmDialog(null, "Modify the existing file "
+ + policyFile + " to permit Wordle to print?",
+ "Modify Existing Policy File?", JOptionPane.OK_CANCEL_OPTION);
+ if (r != JOptionPane.OK_OPTION)
+ return;
+ try
+ {
+ final BufferedReader in = new BufferedReader(new FileReader(policyFile));
+ try
+ {
+ String line;
+ while ((line = in.readLine()) != null)
+ policyBuilder.append(line).append("\n");
+ }
+ finally
+ {
+ in.close();
+ }
+ }
+ catch (Exception e)
+ {
+ JOptionPane.showMessageDialog(null, e.getMessage(), "Fatal Error",
+ JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+ }
+ else
+ {
+ final int r = JOptionPane.showConfirmDialog(null, "Create the file "
+ + policyFile + "\nin order to permit Wordle to print?",
+ "Modify Existing Policy File?", JOptionPane.OK_CANCEL_OPTION);
+ if (r != JOptionPane.OK_OPTION)
+ return;
+ }
+ try
+ {
+ final BufferedReader in = new BufferedReader(new InputStreamReader(
+ DoPolicy.class.getResourceAsStream("policy.txt")));
+ try
+ {
+ String line;
+ while ((line = in.readLine()) != null)
+ policyBuilder.append(line).append("\n");
+ }
+ finally
+ {
+ in.close();
+ }
+ }
+ catch (Exception e)
+ {
+ JOptionPane.showMessageDialog(null, e.getMessage(), "Fatal Error",
+ JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+
+ try
+ {
+ final Writer out = new FileWriter(policyFile);
+ try
+ {
+ out.write(policyBuilder.toString());
+ out.flush();
+ }
+ finally
+ {
+ out.close();
+ }
+ }
+ catch (IOException e)
+ {
+ JOptionPane.showMessageDialog(null, e.getMessage(), "Fatal Error",
+ JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+ JOptionPane
+ .showMessageDialog(
+ null,
+ "Please close any open browser windows, and visit Wordle to try and print.",
+ "Mission Accomplished", JOptionPane.INFORMATION_MESSAGE);
+ }
+}
4 src/wordle/policy.txt
@@ -0,0 +1,4 @@
+grant codeBase "http://wordle.appspot.com/-" {
+ permission java.net.SocketPermission "localhost:631", "connect,resolve";
+ permission java.lang.RuntimePermission "queuePrintJob";
+};
Please sign in to comment.
Something went wrong with that request. Please try again.