From: krakjoe Date: Thu, 28 Nov 2013 22:55:07 +0000 (+0000) Subject: java example stuff X-Git-Tag: php-5.6.0alpha1~110^2~30^2~54 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f342ca88fafa56d57e75818f379e1f72fbaaf259;p=php java example stuff --- diff --git a/tutorials/java-example.png b/tutorials/java-example.png index 7ec07d122b..618882d834 100644 Binary files a/tutorials/java-example.png and b/tutorials/java-example.png differ diff --git a/tutorials/java/build.xml b/tutorials/java/build.xml new file mode 100644 index 0000000000..b8895fa38e --- /dev/null +++ b/tutorials/java/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project phpdbg-ui. + + + diff --git a/tutorials/java/build/built-jar.properties b/tutorials/java/build/built-jar.properties new file mode 100644 index 0000000000..79923e55d4 --- /dev/null +++ b/tutorials/java/build/built-jar.properties @@ -0,0 +1,4 @@ +#Thu, 28 Nov 2013 22:53:51 +0000 + + +/home/joe/NetBeansProjects/phpdbg-ui= diff --git a/tutorials/java/build/classes/DBGThread.class b/tutorials/java/build/classes/DBGThread.class new file mode 100644 index 0000000000..4bf0a8f9f5 Binary files /dev/null and b/tutorials/java/build/classes/DBGThread.class differ diff --git a/tutorials/java/build/classes/Main$1.class b/tutorials/java/build/classes/Main$1.class new file mode 100644 index 0000000000..8e19c106e1 Binary files /dev/null and b/tutorials/java/build/classes/Main$1.class differ diff --git a/tutorials/java/build/classes/Main$2.class b/tutorials/java/build/classes/Main$2.class new file mode 100644 index 0000000000..df1dd09e78 Binary files /dev/null and b/tutorials/java/build/classes/Main$2.class differ diff --git a/tutorials/java/build/classes/Main$3$1.class b/tutorials/java/build/classes/Main$3$1.class new file mode 100644 index 0000000000..6d285e65e7 Binary files /dev/null and b/tutorials/java/build/classes/Main$3$1.class differ diff --git a/tutorials/java/build/classes/Main$3.class b/tutorials/java/build/classes/Main$3.class new file mode 100644 index 0000000000..4004150309 Binary files /dev/null and b/tutorials/java/build/classes/Main$3.class differ diff --git a/tutorials/java/build/classes/Main$4.class b/tutorials/java/build/classes/Main$4.class new file mode 100644 index 0000000000..0008d127fe Binary files /dev/null and b/tutorials/java/build/classes/Main$4.class differ diff --git a/tutorials/java/build/classes/Main.class b/tutorials/java/build/classes/Main.class new file mode 100644 index 0000000000..2d965ed816 Binary files /dev/null and b/tutorials/java/build/classes/Main.class differ diff --git a/tutorials/java/dist/README.TXT b/tutorials/java/dist/README.TXT new file mode 100644 index 0000000000..74e385cc4f --- /dev/null +++ b/tutorials/java/dist/README.TXT @@ -0,0 +1,32 @@ +======================== +BUILD OUTPUT DESCRIPTION +======================== + +When you build an Java application project that has a main class, the IDE +automatically copies all of the JAR +files on the projects classpath to your projects dist/lib folder. The IDE +also adds each of the JAR files to the Class-Path element in the application +JAR files manifest file (MANIFEST.MF). + +To run the project from the command line, go to the dist folder and +type the following: + +java -jar "phpdbg-ui.jar" + +To distribute this project, zip up the dist folder (including the lib folder) +and distribute the ZIP file. + +Notes: + +* If two JAR files on the project classpath have the same name, only the first +JAR file is copied to the lib folder. +* Only JAR files are copied to the lib folder. +If the classpath contains other types of files or folders, these files (folders) +are not copied. +* If a library on the projects classpath also has a Class-Path element +specified in the manifest,the content of the Class-Path element has to be on +the projects runtime path. +* To set a main class in a standard Java project, right-click the project node +in the Projects window and choose Properties. Then click Run and enter the +class name in the Main Class field. Alternatively, you can manually type the +class name in the manifest Main-Class element. diff --git a/tutorials/java/dist/phpdbg-ui.jar b/tutorials/java/dist/phpdbg-ui.jar new file mode 100644 index 0000000000..24dd4b911a Binary files /dev/null and b/tutorials/java/dist/phpdbg-ui.jar differ diff --git a/tutorials/java/manifest.mf b/tutorials/java/manifest.mf new file mode 100644 index 0000000000..328e8e5bc3 --- /dev/null +++ b/tutorials/java/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/tutorials/java/nbproject/build-impl.xml b/tutorials/java/nbproject/build-impl.xml new file mode 100644 index 0000000000..f937ce8944 --- /dev/null +++ b/tutorials/java/nbproject/build-impl.xml @@ -0,0 +1,1407 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tutorials/java/nbproject/genfiles.properties b/tutorials/java/nbproject/genfiles.properties new file mode 100644 index 0000000000..0b6d3d0efb --- /dev/null +++ b/tutorials/java/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=ed67686a +build.xml.script.CRC32=8c03bdb5 +build.xml.stylesheet.CRC32=8064a381@1.68.1.46 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=ed67686a +nbproject/build-impl.xml.script.CRC32=ea01fe36 +nbproject/build-impl.xml.stylesheet.CRC32=5a01deb7@1.68.1.46 diff --git a/tutorials/java/nbproject/private/config.properties b/tutorials/java/nbproject/private/config.properties new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tutorials/java/nbproject/private/private.properties b/tutorials/java/nbproject/private/private.properties new file mode 100644 index 0000000000..5d050e308e --- /dev/null +++ b/tutorials/java/nbproject/private/private.properties @@ -0,0 +1,7 @@ +application.args=127.0.0.1 4000 +compile.on.save=true +do.depend=false +do.jar=true +javac.debug=true +javadoc.preview=true +user.properties.file=/home/joe/.netbeans/7.4/build.properties diff --git a/tutorials/java/nbproject/project.properties b/tutorials/java/nbproject/project.properties new file mode 100644 index 0000000000..c1f3c54997 --- /dev/null +++ b/tutorials/java/nbproject/project.properties @@ -0,0 +1,75 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=phpdbg-ui +application.vendor=joe +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/phpdbg-ui.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.7 +javac.target=1.7 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=Main +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/tutorials/java/nbproject/project.xml b/tutorials/java/nbproject/project.xml new file mode 100644 index 0000000000..0c410ae796 --- /dev/null +++ b/tutorials/java/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + phpdbg-ui + + + + + + + + + diff --git a/tutorials/java/src/DBGThread.java b/tutorials/java/src/DBGThread.java new file mode 100644 index 0000000000..9f00faaf7f --- /dev/null +++ b/tutorials/java/src/DBGThread.java @@ -0,0 +1,115 @@ + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +/** + * In a RUSH !!! + * @author joe + */ +public class DBGThread extends Socket implements Runnable { + private final String host; + private final Integer port; + private final Boolean reader; + private final JTextField field; + private final JTextArea area; + private final JScrollPane pane; + private InputStream input; + private OutputStream output; + private String buffer; + private Boolean quit; + + public DBGThread(final String host, final Integer port, final JTextField field) throws IOException { + super(host, port); + + this.host = host; + this.port = port; + this.reader = true; + this.field = field; + this.area = null; + this.pane = null; + this.quit = false; + this.buffer = null; + } + + public DBGThread(final String host, final Integer port, final JTextArea area, JScrollPane pane) throws IOException { + super(host, port); + + this.host = host; + this.port = port; + this.reader = false; + this.field = null; + this.area = area; + this.pane = pane; + this.quit = false; + this.buffer = null; + } + + public Boolean isReader() { + return this.reader; + } + + public void quit() { + synchronized(this) { + this.quit = true; + this.notifyAll(); + } + } + + @Override + public void run() { + try { + if (this.reader) { + output = this.getOutputStream(); + } else input = this.getInputStream(); + + synchronized(this) { + do { + if (this.reader) { + this.wait(); + + /* send command to stdin socket */ + if (this.field.getText() != null) { + output.write( + this.field.getText().getBytes()); + output.write("\n".getBytes()); + output.flush(); + } + this.field.setText(null); + + } else { + /* get data from stdout socket */ + byte[] bytes = new byte[1]; + do { + /* this is some of the laziest programming I ever done */ + if (input.available() == 0) { + this.wait(666); + continue; + } + + if (input.read(bytes, 0, 1) > -1) { + area.setCaretPosition( + area.getText().length()); + area.append(new String(bytes)); + } + } while (!this.quit); + } + } while(!this.quit); + } + } catch (IOException | InterruptedException ex) { + Logger.getLogger(DBGThread.class.getName()).log(Level.SEVERE, null, ex); + } + } +} diff --git a/tutorials/java/src/Main.form b/tutorials/java/src/Main.form new file mode 100644 index 0000000000..0d4c93d88c --- /dev/null +++ b/tutorials/java/src/Main.form @@ -0,0 +1,100 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tutorials/java/src/Main.java b/tutorials/java/src/Main.java new file mode 100644 index 0000000000..1aa792eeeb --- /dev/null +++ b/tutorials/java/src/Main.java @@ -0,0 +1,173 @@ + +import static java.awt.event.KeyEvent.VK_ENTER; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +/** + * + * @author joe + */ +public class Main extends javax.swing.JDialog { + + /** + * Creates new form NewJDialog + */ + public Main(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jSplitPane1 = new javax.swing.JSplitPane(); + input = new javax.swing.JTextField(); + outScrollPane = new javax.swing.JScrollPane(); + output = new javax.swing.JTextArea(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("phpdbg jui"); + + jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); + jSplitPane1.setToolTipText(""); + + input.setToolTipText(""); + input.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + inputActionPerformed(evt); + } + }); + input.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + inputKeyReleased(evt); + } + }); + jSplitPane1.setLeftComponent(input); + + output.setColumns(20); + output.setFont(new java.awt.Font("DialogInput", 0, 12)); // NOI18N + output.setRows(5); + outScrollPane.setViewportView(output); + + jSplitPane1.setRightComponent(outScrollPane); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 796, Short.MAX_VALUE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 457, Short.MAX_VALUE) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void inputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inputActionPerformed + // TODO add your handling code here: + + }//GEN-LAST:event_inputActionPerformed + + private void inputKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_inputKeyReleased + // TODO add your handling code here: + if (evt.getKeyCode() == VK_ENTER) { + synchronized(this.in) { + this.in.notifyAll(); + } + } + }//GEN-LAST:event_inputKeyReleased + + /** + * @param args the command line arguments + */ + public static void main(final String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the dialog */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + dialog = new Main(new javax.swing.JFrame(), true); + dialog.addWindowListener(new java.awt.event.WindowAdapter() { + @Override + public void windowClosing(java.awt.event.WindowEvent e) { + dialog.in.quit(); + dialog.out.quit(); + System.exit(0); + } + }); + dialog.setVisible(true); + } + }); + + java.awt.EventQueue.invokeLater(new Runnable(){ + public void run(){ + try { + dialog.in = new DBGThread( + args[0], Integer.parseInt(args[1]), input); + dialog.out = new DBGThread( + args[0], Integer.parseInt(args[1]) * 2, output, outScrollPane); + + new Thread(dialog.in).start(); + new Thread(dialog.out).start(); + + } catch (IOException ex) { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + System.exit(0); + } + } + }); + } + + private DBGThread in; + private DBGThread out; + protected static Main dialog; + + // Variables declaration - do not modify//GEN-BEGIN:variables + protected static javax.swing.JTextField input; + private javax.swing.JSplitPane jSplitPane1; + protected static javax.swing.JScrollPane outScrollPane; + protected static javax.swing.JTextArea output; + // End of variables declaration//GEN-END:variables +}