summaryrefslogtreecommitdiff
path: root/tutorials/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'tutorials/java/src')
-rw-r--r--tutorials/java/src/phpdbg/ui/CommandHistory.java49
-rw-r--r--tutorials/java/src/phpdbg/ui/DebugSocket.java157
-rw-r--r--tutorials/java/src/phpdbg/ui/JConsole.form225
-rw-r--r--tutorials/java/src/phpdbg/ui/JConsole.java471
-rw-r--r--tutorials/java/src/phpdbg/ui/JTerminalPane.java182
-rw-r--r--tutorials/java/src/phpdbg/ui/logo-dbg.pngbin248 -> 0 bytes
-rw-r--r--tutorials/java/src/phpdbg/ui/logo-small.pngbin4964 -> 0 bytes
7 files changed, 0 insertions, 1084 deletions
diff --git a/tutorials/java/src/phpdbg/ui/CommandHistory.java b/tutorials/java/src/phpdbg/ui/CommandHistory.java
deleted file mode 100644
index b8a3b0ff0a..0000000000
--- a/tutorials/java/src/phpdbg/ui/CommandHistory.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package phpdbg.ui;
-
-
-import java.util.ArrayList;
-
-/*
- * 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.
- */
-
-/**
- * Implement a simple history list for command input
- * @author krakjoe
- */
-public class CommandHistory extends ArrayList<String> {
- private Integer position = new Integer(0);
-
- public CommandHistory() {
- super();
- }
-
- @Override public boolean add(String text) {
- String last = last();
- if (text != null) {
- if (last == null || !last.equals(text)) {
- if (super.add(text)) {
- position = size();
- return true;
- }
- }
- }
- return false;
- }
-
- public String last() {
- if (position >= 1) {
- position--;
- return get(position);
- } else return new String();
- }
-
- public String next() {
- if (position+1 < size()) {
- position++;
- return get(position);
- } else return new String();
- }
-} \ No newline at end of file
diff --git a/tutorials/java/src/phpdbg/ui/DebugSocket.java b/tutorials/java/src/phpdbg/ui/DebugSocket.java
deleted file mode 100644
index 8e811e9be9..0000000000
--- a/tutorials/java/src/phpdbg/ui/DebugSocket.java
+++ /dev/null
@@ -1,157 +0,0 @@
-package phpdbg.ui;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.nio.ByteBuffer;
-import java.nio.channels.SelectionKey;
-import static java.nio.channels.SelectionKey.OP_READ;
-import java.nio.channels.Selector;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-import java.nio.channels.spi.SelectorProvider;
-import java.util.Iterator;
-import java.util.Set;
-import phpdbg.ui.JConsole.MessageType;
-
-/*
- * 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.
- */
-
-/**
- * Manage input and output data
- * @author krakjoe
- */
-public class DebugSocket implements Runnable {
- private final String host;
- private final Integer port;
- private final Boolean reader;
- private final JConsole main;
- private final Thread thread;
-
- private volatile Boolean quit;
- private volatile Boolean started;
-
- public DebugSocket(final String host, final Integer port, final JConsole main, Boolean reader) throws IOException {
- this.host = host;
- this.port = port;
- this.main = main;
- this.reader = reader;
- this.quit = false;
- this.started = false;
- this.thread = new Thread(this);
- }
-
- public void start() {
- synchronized(this) {
- if (!started) {
- quit = false;
- started = true;
- thread.start();
- }
- }
- }
-
- public void quit() {
- synchronized(this) {
- quit = true;
- started = false;
- notifyAll();
- }
- }
-
- @Override public void run() {
- try {
- synchronized(main) {
- if (!main.isConnected()) {
- main.setConnected(true);
- }
- }
-
- if (reader) {
- /* The reader thread will wait() until there is input */
- Socket socket = new Socket(this.host, this.port);
- String command;
- OutputStream output = socket.getOutputStream();
-
- do {
- synchronized(this) {
- wait();
-
- if (!quit) {
- command = main.getInputField().getText();
- /* send command to stdin socket */
- if (command != null) {
- if (main.isEchoing()) {
- main.getOutputField()
- .appendANSI(
- String.format("remote> %s\n", command));
- }
- output.write(
- command.getBytes());
- output.write("\n".getBytes());
- output.flush();
- }
- main.getInputField().setText(null);
- }
- }
- } while (!quit);
-
- socket.close();
- } else {
- /*
- * The writer thread will use non-blocking i/o consuming
- * resources only when there is data to read
- */
- Selector selector = Selector.open();
- SocketChannel channel = SocketChannel.open();
-
- channel.connect(
- new InetSocketAddress(this.host, this.port));
- channel.configureBlocking(false);
- channel.register(selector, OP_READ);
-
- while (!quit) {
- selector.select();
-
- Iterator<SelectionKey> iter = selector.selectedKeys().iterator();
-
- while (iter.hasNext()) {
- if (!quit) {
- SocketChannel ready = (SocketChannel) (iter.next().channel());
- ByteBuffer bytes = ByteBuffer.allocate(128);
-
- if (ready != null) {
- if (ready.read(bytes) != -1) {
- bytes.flip();
-
- main.getOutputField()
- .appendANSI(new String(bytes.array()));
-
- }
- }
-
- iter.remove();
- }
- }
- }
- channel.close();
- }
- } catch (IOException | InterruptedException ex) {
- if (!quit) {
- main.messageBox(ex.getMessage(), MessageType.ERROR);
- }
- } finally {
- synchronized(main) {
- if (main.isConnected()) {
- main.setConnected(false);
- }
- }
- }
- }
-}
diff --git a/tutorials/java/src/phpdbg/ui/JConsole.form b/tutorials/java/src/phpdbg/ui/JConsole.form
deleted file mode 100644
index d2808942db..0000000000
--- a/tutorials/java/src/phpdbg/ui/JConsole.form
+++ /dev/null
@@ -1,225 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
- <NonVisualComponents>
- <Container class="javax.swing.JPopupMenu" name="stdoutPopupMenu">
-
- <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
- <Property name="useNullLayout" type="boolean" value="true"/>
- </Layout>
- <SubComponents>
- <MenuItem class="javax.swing.JMenuItem" name="resetStdout">
- <Properties>
- <Property name="text" type="java.lang.String" value="Clear"/>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="resetStdoutActionPerformed"/>
- </Events>
- </MenuItem>
- </SubComponents>
- </Container>
- <Menu class="java.awt.PopupMenu" name="systrayMenu">
- <Properties>
- <Property name="label" type="java.lang.String" value="phpdbg"/>
- <Property name="name" type="java.lang.String" value=""/>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="systrayMenuActionPerformed"/>
- </Events>
- <AuxValues>
- <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="10"/>
- </AuxValues>
- <SubComponents>
- <MenuItem class="java.awt.MenuItem" name="systrayExitMenuItem">
- <Properties>
- <Property name="label" type="java.lang.String" value="Exit"/>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="systrayExitMenuItemActionPerformed"/>
- </Events>
- </MenuItem>
- </SubComponents>
- </Menu>
- </NonVisualComponents>
- <Properties>
- <Property name="defaultCloseOperation" type="int" value="2"/>
- <Property name="title" type="java.lang.String" value="phpdbg jui"/>
- <Property name="iconImage" type="java.awt.Image" editor="org.netbeans.modules.form.ComponentChooserEditor">
- <ComponentRef name="default"/>
- </Property>
- </Properties>
- <SyntheticProperties>
- <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
- <SyntheticProperty name="generateCenter" type="boolean" value="false"/>
- </SyntheticProperties>
- <AuxValues>
- <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
- <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
- <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
- <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
- <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
- <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
- <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
- <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
- <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
- </AuxValues>
-
- <Layout>
- <DimensionLayout dim="0">
- <Group type="103" groupAlignment="0" attributes="0">
- <Group type="102" alignment="0" attributes="0">
- <EmptySpace max="-2" attributes="0"/>
- <Group type="103" groupAlignment="0" attributes="0">
- <Component id="outputScrollPane" max="32767" attributes="0"/>
- <Group type="102" alignment="0" attributes="0">
- <Group type="103" groupAlignment="0" attributes="0">
- <Component id="hostnameLabel" min="-2" max="-2" attributes="0"/>
- <Component id="commandLabel" alignment="0" min="-2" max="-2" attributes="0"/>
- </Group>
- <EmptySpace max="-2" attributes="0"/>
- <Group type="103" groupAlignment="0" attributes="0">
- <Group type="102" alignment="1" attributes="0">
- <Component id="input" max="32767" attributes="0"/>
- <EmptySpace type="unrelated" max="-2" attributes="0"/>
- <Component id="echoCheckBox" min="-2" max="-2" attributes="0"/>
- </Group>
- <Group type="102" alignment="1" attributes="0">
- <Component id="host" pref="345" max="32767" attributes="0"/>
- <EmptySpace type="unrelated" max="-2" attributes="0"/>
- <Component id="stdinCheckBox" min="-2" max="-2" attributes="0"/>
- <EmptySpace type="unrelated" max="-2" attributes="0"/>
- <Component id="stdinPort" min="-2" pref="60" max="-2" attributes="0"/>
- <EmptySpace type="separate" max="-2" attributes="0"/>
- <Component id="stdoutCheckBox" min="-2" max="-2" attributes="0"/>
- <EmptySpace type="unrelated" max="-2" attributes="0"/>
- <Component id="stdoutPort" min="-2" pref="60" max="-2" attributes="0"/>
- <EmptySpace type="unrelated" max="-2" attributes="0"/>
- <Component id="openButton" min="-2" pref="100" max="-2" attributes="0"/>
- </Group>
- </Group>
- </Group>
- </Group>
- <EmptySpace max="-2" attributes="0"/>
- </Group>
- </Group>
- </DimensionLayout>
- <DimensionLayout dim="1">
- <Group type="103" groupAlignment="0" attributes="0">
- <Group type="102" alignment="0" attributes="0">
- <EmptySpace max="-2" attributes="0"/>
- <Component id="outputScrollPane" pref="403" max="32767" attributes="0"/>
- <EmptySpace type="unrelated" max="-2" attributes="0"/>
- <Group type="103" groupAlignment="3" attributes="0">
- <Component id="input" alignment="3" min="-2" max="-2" attributes="0"/>
- <Component id="echoCheckBox" alignment="3" max="-2" attributes="0"/>
- <Component id="commandLabel" alignment="3" min="-2" max="-2" attributes="0"/>
- </Group>
- <EmptySpace max="-2" attributes="0"/>
- <Group type="103" groupAlignment="0" attributes="0">
- <Group type="103" groupAlignment="3" attributes="0">
- <Component id="stdoutPort" alignment="3" min="-2" max="-2" attributes="0"/>
- <Component id="stdinCheckBox" alignment="3" min="-2" max="-2" attributes="0"/>
- <Component id="stdoutCheckBox" alignment="3" min="-2" max="-2" attributes="0"/>
- <Component id="stdinPort" alignment="3" min="-2" max="-2" attributes="0"/>
- <Component id="hostnameLabel" alignment="3" min="-2" max="-2" attributes="0"/>
- <Component id="host" alignment="3" min="-2" max="-2" attributes="0"/>
- </Group>
- <Component id="openButton" min="-2" max="-2" attributes="0"/>
- </Group>
- <EmptySpace max="-2" attributes="0"/>
- </Group>
- </Group>
- </DimensionLayout>
- </Layout>
- <SubComponents>
- <Component class="javax.swing.JTextField" name="host">
- <Properties>
- <Property name="text" type="java.lang.String" value="127.0.0.1"/>
- <Property name="toolTipText" type="java.lang.String" value="Set the hostname, or IPv4 address of the machine running the phpdbg remote console server"/>
- </Properties>
- </Component>
- <Component class="javax.swing.JTextField" name="stdoutPort">
- <Properties>
- <Property name="text" type="java.lang.String" value="8000"/>
- <Property name="toolTipText" type="java.lang.String" value="By default, stdin * 2"/>
- </Properties>
- </Component>
- <Component class="javax.swing.JCheckBox" name="stdinCheckBox">
- <Properties>
- <Property name="selected" type="boolean" value="true"/>
- <Property name="text" type="java.lang.String" value="stdin:"/>
- <Property name="toolTipText" type="java.lang.String" value="Set the port for stdin, or uncheck to disable stdin"/>
- </Properties>
- </Component>
- <Component class="javax.swing.JCheckBox" name="stdoutCheckBox">
- <Properties>
- <Property name="selected" type="boolean" value="true"/>
- <Property name="text" type="java.lang.String" value="stdout:"/>
- <Property name="toolTipText" type="java.lang.String" value="Set the port for stdout, or unset to disable stdout"/>
- </Properties>
- </Component>
- <Component class="javax.swing.JButton" name="openButton">
- <Properties>
- <Property name="text" type="java.lang.String" value="Connect"/>
- <Property name="actionCommand" type="java.lang.String" value="open"/>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="openButtonActionPerformed"/>
- </Events>
- </Component>
- <Component class="javax.swing.JTextField" name="stdinPort">
- <Properties>
- <Property name="text" type="java.lang.String" value="4000"/>
- <Property name="toolTipText" type="java.lang.String" value="The listen port passed to phpdbg (-l option)"/>
- </Properties>
- </Component>
- <Component class="javax.swing.JLabel" name="hostnameLabel">
- <Properties>
- <Property name="text" type="java.lang.String" value="Hostname:"/>
- </Properties>
- </Component>
- <Component class="javax.swing.JTextField" name="input">
- <Properties>
- <Property name="toolTipText" type="java.lang.String" value="Enter phpdbg commands here!"/>
- <Property name="enabled" type="boolean" value="false"/>
- </Properties>
- <Events>
- <EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="inputKeyReleased"/>
- </Events>
- </Component>
- <Container class="javax.swing.JScrollPane" name="outputScrollPane">
- <AuxValues>
- <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
- </AuxValues>
-
- <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
- <SubComponents>
- <Component class="phpdbg.ui.JTerminalPane" name="output">
- <Properties>
- <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
- <Font name="DialogInput" size="12" style="0"/>
- </Property>
- <Property name="componentPopupMenu" type="javax.swing.JPopupMenu" editor="org.netbeans.modules.form.ComponentChooserEditor">
- <ComponentRef name="stdoutPopupMenu"/>
- </Property>
- </Properties>
- </Component>
- </SubComponents>
- </Container>
- <Component class="javax.swing.JCheckBox" name="echoCheckBox">
- <Properties>
- <Property name="selected" type="boolean" value="true"/>
- <Property name="toolTipText" type="java.lang.String" value="Check to echo sent commands in output"/>
- <Property name="enabled" type="boolean" value="false"/>
- <Property name="horizontalAlignment" type="int" value="2"/>
- <Property name="label" type="java.lang.String" value="echo"/>
- </Properties>
- </Component>
- <Component class="javax.swing.JLabel" name="commandLabel">
- <Properties>
- <Property name="text" type="java.lang.String" value="Command:"/>
- <Property name="enabled" type="boolean" value="false"/>
- </Properties>
- </Component>
- </SubComponents>
-</Form>
diff --git a/tutorials/java/src/phpdbg/ui/JConsole.java b/tutorials/java/src/phpdbg/ui/JConsole.java
deleted file mode 100644
index 6c8cfb364b..0000000000
--- a/tutorials/java/src/phpdbg/ui/JConsole.java
+++ /dev/null
@@ -1,471 +0,0 @@
-package phpdbg.ui;
-
-
-import java.awt.AWTException;
-import java.awt.Frame;
-import java.awt.Image;
-import java.awt.SystemTray;
-import java.awt.TrayIcon;
-import static java.awt.event.KeyEvent.VK_DOWN;
-import static java.awt.event.KeyEvent.VK_ENTER;
-import static java.awt.event.KeyEvent.VK_UP;
-import java.awt.event.WindowEvent;
-import java.io.IOException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.imageio.ImageIO;
-import javax.swing.JOptionPane;
-import javax.swing.JScrollPane;
-import javax.swing.JTextField;
-import javax.swing.UIManager;
-import javax.swing.UnsupportedLookAndFeelException;
-
-/*
- * 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 krakjoe
- */
-public class JConsole extends javax.swing.JDialog {
- /**
- * Creates user interface
- * @param parent
- * @param modal
- */
- public JConsole(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")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
-
- stdoutPopupMenu = new javax.swing.JPopupMenu();
- resetStdout = new javax.swing.JMenuItem();
- systrayMenu = new java.awt.PopupMenu();
- systrayExitMenuItem = new java.awt.MenuItem();
- host = new javax.swing.JTextField();
- stdoutPort = new javax.swing.JTextField();
- stdinCheckBox = new javax.swing.JCheckBox();
- stdoutCheckBox = new javax.swing.JCheckBox();
- openButton = new javax.swing.JButton();
- stdinPort = new javax.swing.JTextField();
- hostnameLabel = new javax.swing.JLabel();
- input = new javax.swing.JTextField();
- outputScrollPane = new javax.swing.JScrollPane();
- output = new phpdbg.ui.JTerminalPane();
- echoCheckBox = new javax.swing.JCheckBox();
- commandLabel = new javax.swing.JLabel();
-
- resetStdout.setText("Clear");
- resetStdout.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- resetStdoutActionPerformed(evt);
- }
- });
- stdoutPopupMenu.add(resetStdout);
-
- systrayMenu.setLabel("phpdbg");
- systrayMenu.setName("");
- systrayMenu.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- systrayMenuActionPerformed(evt);
- }
- });
-
- systrayExitMenuItem.setLabel("Exit");
- systrayExitMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- systrayExitMenuItemActionPerformed(evt);
- }
- });
- systrayMenu.add(systrayExitMenuItem);
-
- setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
- setTitle("phpdbg jui");
-
- host.setText("127.0.0.1");
- host.setToolTipText("Set the hostname, or IPv4 address of the machine running the phpdbg remote console server");
-
- stdoutPort.setText("8000");
- stdoutPort.setToolTipText("By default, stdin * 2");
-
- stdinCheckBox.setSelected(true);
- stdinCheckBox.setText("stdin:");
- stdinCheckBox.setToolTipText("Set the port for stdin, or uncheck to disable stdin");
-
- stdoutCheckBox.setSelected(true);
- stdoutCheckBox.setText("stdout:");
- stdoutCheckBox.setToolTipText("Set the port for stdout, or unset to disable stdout");
-
- openButton.setText("Connect");
- openButton.setActionCommand("open");
- openButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- openButtonActionPerformed(evt);
- }
- });
-
- stdinPort.setText("4000");
- stdinPort.setToolTipText("The listen port passed to phpdbg (-l option)");
-
- hostnameLabel.setText("Hostname:");
-
- input.setToolTipText("Enter phpdbg commands here!");
- input.setEnabled(false);
- input.addKeyListener(new java.awt.event.KeyAdapter() {
- public void keyReleased(java.awt.event.KeyEvent evt) {
- inputKeyReleased(evt);
- }
- });
-
- output.setFont(new java.awt.Font("DialogInput", 0, 12)); // NOI18N
- output.setComponentPopupMenu(stdoutPopupMenu);
- outputScrollPane.setViewportView(output);
-
- echoCheckBox.setSelected(true);
- echoCheckBox.setToolTipText("Check to echo sent commands in output");
- echoCheckBox.setEnabled(false);
- echoCheckBox.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
- echoCheckBox.setLabel("echo");
-
- commandLabel.setText("Command:");
- commandLabel.setEnabled(false);
-
- 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()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(outputScrollPane)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(hostnameLabel)
- .addComponent(commandLabel))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addComponent(input)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(echoCheckBox))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addComponent(host, javax.swing.GroupLayout.DEFAULT_SIZE, 345, Short.MAX_VALUE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(stdinCheckBox)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(stdinPort, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addComponent(stdoutCheckBox)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(stdoutPort, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(openButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))))
- .addContainerGap())
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(outputScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(input, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(echoCheckBox)
- .addComponent(commandLabel))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(stdoutPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(stdinCheckBox)
- .addComponent(stdoutCheckBox)
- .addComponent(stdinPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(hostnameLabel)
- .addComponent(host, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(openButton))
- .addContainerGap())
- );
-
- pack();
- }// </editor-fold>//GEN-END:initComponents
-
- private void inputKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_inputKeyReleased
- switch (evt.getKeyCode()) {
- case VK_ENTER: {
- if (in != null) {
- history.add(input.getText());
- synchronized(in) {
- in.notifyAll();
- }
- }
- } break;
-
- case VK_UP: {
- String last = history.last();
- if (last.length() > 0) {
- input.setText(last);
- }
- } break;
-
- case VK_DOWN: {
- String next = history.next();
- if (next.length() > 0) {
- input.setText(next);
- }
- } break;
- }
- }//GEN-LAST:event_inputKeyReleased
-
- private void openButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openButtonActionPerformed
- try {
- if (!connected) {
- connect();
- } else {
- disconnect();
- }
- } catch (IOException ex) {
- messageBox(ex.getMessage(), MessageType.ERROR);
- }
- }//GEN-LAST:event_openButtonActionPerformed
-
- private void resetStdoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetStdoutActionPerformed
- // TODO add your handling code here:
- output.setText(null);
- }//GEN-LAST:event_resetStdoutActionPerformed
-
- private void systrayExitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_systrayExitMenuItemActionPerformed
- // TODO add your handling code here:
- dialog.disconnect();
- System.exit(0);
- }//GEN-LAST:event_systrayExitMenuItemActionPerformed
-
- private void systrayMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_systrayMenuActionPerformed
- // TODO add your handling code here:
- }//GEN-LAST:event_systrayMenuActionPerformed
-
- private void disconnect() {
- if (in != null) {
- in.quit();
- }
- if (out != null) {
- out.quit();
- }
- }
-
- private void connect() throws IOException {
- Integer ports[] = new Integer[2];
- String address = getHost();
-
- if (address != null) {
- ports[0] = stdinCheckBox.isSelected() ? getStdinPort() : -1;
- ports[1] = stdoutCheckBox.isSelected() ? getStdoutPort() : -1;
-
- if (ports[0] != 0 && ports[1] != 0) {
- if (stdinCheckBox.isSelected()) {
- if (ports[0] > 0) {
- in = new DebugSocket(
- address, ports[0], this, true);
- in.start();
- }
- }
-
- if (stdoutCheckBox.isSelected()) {
- if (ports[1] > 0) {
- out = new DebugSocket(
- address, ports[1], this, false);
- out.start();
- }
- }
- }
- }
- }
-
- public Boolean isConnected() {
- return connected;
- }
-
- public Boolean isEchoing() {
- return echoCheckBox.isSelected();
- }
-
- public void setConnected(Boolean isConnected) {
- synchronized(this) {
- if (isConnected) {
- connected = true;
- openButton.setText("Disconnect");
- host.setEnabled(false);
- stdinPort.setEnabled(false);
- stdinCheckBox.setEnabled(false);
- if (stdinCheckBox.isSelected()) {
- input.setEnabled(true);
- commandLabel.setEnabled(true);
- echoCheckBox.setEnabled(true);
- } else {
- input.setEnabled(false);
- commandLabel.setEnabled(false);
- echoCheckBox.setEnabled(false);
- }
- stdoutPort.setEnabled(false);
- stdoutCheckBox.setEnabled(false);
- hostnameLabel.setEnabled(false);
- commandLabel.setEnabled(true);
- } else {
- connected = false;
- openButton.setText("Connect");
- host.setEnabled(true);
- stdinPort.setEnabled(true);
- input.setEnabled(false);
- commandLabel.setEnabled(false);
- echoCheckBox.setEnabled(false);
- stdinCheckBox.setEnabled(true);
- stdoutPort.setEnabled(true);
- stdoutCheckBox.setEnabled(true);
- hostnameLabel.setEnabled(true);
- }
- }
- }
-
- public JTextField getInputField() { return input; }
- public JTerminalPane getOutputField() { return output; }
-
- public String getHost() {
- String address = host.getText();
- if (address != null && address.length() > 0) {
- return address;
- } else {
- messageBox("Invalid hostname provided!", MessageType.WARN);
- }
-
- return null;
- }
-
- public Integer getStdinPort() {
- try {
- return Integer.parseInt(stdinPort.getText());
- } catch (NumberFormatException ex) {
- messageBox("Invalid stdin port provided!", MessageType.WARN);
- }
- return 0;
- }
-
- public Integer getStdoutPort() {
- try {
- return Integer.parseInt(stdoutPort.getText());
- } catch (NumberFormatException ex) {
- messageBox("Invalid stdout port provided!", MessageType.WARN);
- }
- return 0;
- }
-
- public JScrollPane getOutputScrollPane() {
- return outputScrollPane;
- }
-
- public synchronized void messageBox(String message) {
- messageBox(message, MessageType.INFO);
- }
-
- public synchronized void messageBox(String message, MessageType type) {
- JOptionPane.showMessageDialog(this, message, "phpdbg jui", type.getType());
- }
- /**
- * @param args the command line arguments
- */
- public static void main(final String args[]) {
-
- for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
- if (info.getName().equals("Nimbus")) {
- try {
- UIManager.setLookAndFeel(
- info.getClassName());
- break;
- } catch (ClassNotFoundException |
- InstantiationException |
- IllegalAccessException |
- UnsupportedLookAndFeelException ex) {
- Logger.getLogger(JConsole.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
-
- /* Create and display the dialog */
- java.awt.EventQueue.invokeLater(new Runnable() {
- @Override public void run() {
- dialog = new JConsole(new javax.swing.JFrame(), true);
- dialog.addWindowListener(new java.awt.event.WindowAdapter() {
- @Override
- public void windowClosing(java.awt.event.WindowEvent e) {
- dialog.disconnect();
- System.exit(0);
- }
- });
- try {
- if (tray == null) {
- Image trayIconImage = ImageIO.read(
- JConsole.class.getResource("logo-dbg.png"));
- dialog.setIconImage(trayIconImage);
-
- tray = new TrayIcon(trayIconImage);
- tray.setPopupMenu(systrayMenu);
- tray.setToolTip("phpdbg - The Interactive PHP Debugger");
-
- SystemTray.getSystemTray().add(tray);
- }
- } catch ( AWTException | IOException ex) {
- dialog.messageBox(ex.getMessage(), MessageType.ERROR);
- }
- dialog.setVisible(true);
- }
- });
- }
-
- private static DebugSocket in;
- private static DebugSocket out;
- private static JConsole dialog;
- private static Boolean connected = false;
- private static CommandHistory history = new CommandHistory();
- private static TrayIcon tray;
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JLabel commandLabel;
- private javax.swing.JCheckBox echoCheckBox;
- private javax.swing.JTextField host;
- private javax.swing.JLabel hostnameLabel;
- private javax.swing.JTextField input;
- private javax.swing.JButton openButton;
- private phpdbg.ui.JTerminalPane output;
- private javax.swing.JScrollPane outputScrollPane;
- private javax.swing.JMenuItem resetStdout;
- private javax.swing.JCheckBox stdinCheckBox;
- private javax.swing.JTextField stdinPort;
- private javax.swing.JCheckBox stdoutCheckBox;
- private javax.swing.JPopupMenu stdoutPopupMenu;
- private javax.swing.JTextField stdoutPort;
- private java.awt.MenuItem systrayExitMenuItem;
- private static java.awt.PopupMenu systrayMenu;
- // End of variables declaration//GEN-END:variables
- public enum MessageType {
- INFO (JOptionPane.INFORMATION_MESSAGE),
- WARN (JOptionPane.WARNING_MESSAGE),
- ERROR (JOptionPane.ERROR_MESSAGE);
-
- private final Integer type;
- private MessageType(Integer type) {
- this.type = type;
- }
- public Integer getType() { return this.type; }
- public Boolean equals(Integer other) { return this.type.equals(other); }
- public Boolean equals(MessageType other) { return this.type.equals(other.getType()); }
- }
-}
diff --git a/tutorials/java/src/phpdbg/ui/JTerminalPane.java b/tutorials/java/src/phpdbg/ui/JTerminalPane.java
deleted file mode 100644
index a08be440d3..0000000000
--- a/tutorials/java/src/phpdbg/ui/JTerminalPane.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * 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.
- */
-
-package phpdbg.ui;
-
-/**
- *
- * @author krakjoe
- */
-import javax.swing.*;
-import javax.swing.text.*;
-import java.awt.Color;
-import java.awt.Graphics;
-import java.awt.Image;
-import java.io.IOException;
-import java.util.HashMap;
-import javax.imageio.ImageIO;
-
-public class JTerminalPane extends JTextPane {
- private static class JTerminalColor {
- private final Color color;
- private final Boolean bold;
- private final Boolean underline;
-
- public JTerminalColor(Float h, Float s, Float b, Boolean bold, Boolean underline) {
- this.color = Color.getHSBColor(h, s, b);
- this.bold = bold;
- this.underline = underline;
- }
-
- public JTerminalColor(Float h, Float s, Float b, Boolean bold) {
- this(h, s, b, bold, false);
- }
-
- public JTerminalColor(Float h, Float s, Float b) {
- this(h, s, b, false, false);
- }
-
- public Boolean isUnderlined() { return this.underline; }
- public Boolean isBold() { return this.bold; }
- public Color getColor() { return this.color; }
- }
-
- private static class JTerminalColors extends HashMap<String, JTerminalColor> {
- public JTerminalColors() {
- put("\u001B[0;30m", new JTerminalColor(0.000f, 0.000f, 0.502f));
- put("\u001B[0;31m", new JTerminalColor(0.000f, 1.000f, 1.000f));
- put("\u001B[0;32m", new JTerminalColor(0.333f, 1.000f, 1.000f));
- put("\u001B[0;33m", new JTerminalColor(0.167f, 1.000f, 1.000f));
- put("\u001B[0;34m", new JTerminalColor(0.667f, 1.000f, 1.000f));
- put("\u001B[0;35m", new JTerminalColor(0.833f, 1.000f, 1.000f));
- put("\u001B[0;36m", new JTerminalColor(0.500f, 1.000f, 1.000f));
- put("\u001B[0;37m", new JTerminalColor(0.000f, 0.000f, 1.000f));
- put("\u001B[0;64m", new JTerminalColor(0.000f, 0.000f, 1.000f));
- put("\u001B[1;30m", new JTerminalColor(0.000f, 0.000f, 0.502f, true));
- put("\u001B[1;31m", new JTerminalColor(0.000f, 1.000f, 1.000f, true));
- put("\u001B[1;32m", new JTerminalColor(0.333f, 1.000f, 1.000f, true));
- put("\u001B[1;33m", new JTerminalColor(0.167f, 1.000f, 1.000f, true));
- put("\u001B[1;34m", new JTerminalColor(0.667f, 1.000f, 1.000f, true));
- put("\u001B[1;35m", new JTerminalColor(0.833f, 1.000f, 1.000f, true));
- put("\u001B[1;36m", new JTerminalColor(0.500f, 1.000f, 1.000f, true));
- put("\u001B[1;37m", new JTerminalColor(0.000f, 0.000f, 1.000f, true));
- put("\u001B[1;64m", new JTerminalColor(0.000f, 0.000f, 1.000f, true));
- put("\u001B[4;30m", new JTerminalColor(0.000f, 0.000f, 0.502f, false, true));
- put("\u001B[4;31m", new JTerminalColor(0.000f, 1.000f, 1.000f, false, true));
- put("\u001B[4;32m", new JTerminalColor(0.333f, 1.000f, 1.000f, false, true));
- put("\u001B[4;33m", new JTerminalColor(0.167f, 1.000f, 1.000f, false, true));
- put("\u001B[4;34m", new JTerminalColor(0.667f, 1.000f, 1.000f, false, true));
- put("\u001B[4;35m", new JTerminalColor(0.833f, 1.000f, 1.000f, false, true));
- put("\u001B[4;36m", new JTerminalColor(0.500f, 1.000f, 1.000f, false, true));
- put("\u001B[4;37m", new JTerminalColor(0.000f, 0.000f, 1.000f, false, true));
- put("\u001B[4;64m", new JTerminalColor(0.000f, 0.000f, 1.000f, false, true));
-
- put("reset", new JTerminalColor(0.000f, 0.000f, 1.000f));
- }
-
- public JTerminalColor find(String ANSIColor) {
- if (containsKey(ANSIColor)) {
- return get(ANSIColor);
- } else return get("reset");
- }
- }
-
- public JTerminalPane() {
- super();
- setOpaque(false);
- setBackground(new Color(0, 0, 0, 0));
- colorCurrent = colors.find("reset");
- }
-
- @Override public void paintComponent(Graphics g) {
- g.setColor(Color.BLACK);
- g.fillRect(0, 0, getWidth(), getHeight());
-
- try {
- Image image = ImageIO.read(
- JTerminalPane.class.getResource("logo-small.png"));
-
- g.drawImage(
- image,
- getWidth() - image.getWidth(this) - 10,
- getHeight() - image.getHeight(this) - 10,
- image.getWidth(this), image.getHeight(this), this);
-
- } catch (IOException | NullPointerException | IllegalArgumentException ex) {}
-
- super.paintComponent(g);
- }
-
- private void append(JTerminalColor c, String s) {
- StyleContext sc = StyleContext.getDefaultStyleContext();
- AttributeSet aset = sc.addAttribute(
- SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c.getColor());
-
- aset = sc.addAttribute(aset, StyleConstants.Underline, c.isUnderlined());
- aset = sc.addAttribute(aset, StyleConstants.Bold, c.isBold());
-
- setCharacterAttributes(aset, false);
- replaceSelection(s);
- setCaretPosition(getDocument().getLength());
- }
-
- public synchronized void appendANSI(String s) {
- int aPos = 0;
- int aIndex;
- int mIndex;
- String tmpString;
- boolean stillSearching;
-
- String addString = remaining + s;
-
- remaining = "";
-
- if (addString.length() > 0) {
- aIndex = addString.indexOf("\u001B");
- if (aIndex == -1) {
- append(colorCurrent,addString);
- return;
- }
-
- if (aIndex > 0) {
- tmpString = addString.substring(0,aIndex);
- append(colorCurrent, tmpString);
- aPos = aIndex;
- }
-
- stillSearching = true;
- while (stillSearching) {
- mIndex = addString.indexOf("m",aPos);
- if (mIndex < 0) {
- remaining = addString.substring(aPos,addString.length());
- stillSearching = false;
- continue;
- }
- else {
- tmpString = addString.substring(aPos,mIndex+1);
- colorCurrent = colors.find(tmpString);
- }
- aPos = mIndex + 1;
-
- aIndex = addString.indexOf("\u001B", aPos);
-
- if (aIndex == -1) {
- tmpString = addString.substring(aPos,addString.length());
- append(colorCurrent, tmpString);
- stillSearching = false;
- continue;
- }
- tmpString = addString.substring(aPos,aIndex);
- aPos = aIndex;
- append(colorCurrent, tmpString);
- }
- }
- }
-
- private static JTerminalColors colors = new JTerminalColors();
- private JTerminalColor colorCurrent;
- private String remaining = "";
-}
diff --git a/tutorials/java/src/phpdbg/ui/logo-dbg.png b/tutorials/java/src/phpdbg/ui/logo-dbg.png
deleted file mode 100644
index 621f29b53e..0000000000
--- a/tutorials/java/src/phpdbg/ui/logo-dbg.png
+++ /dev/null
Binary files differ
diff --git a/tutorials/java/src/phpdbg/ui/logo-small.png b/tutorials/java/src/phpdbg/ui/logo-small.png
deleted file mode 100644
index 1792379f77..0000000000
--- a/tutorials/java/src/phpdbg/ui/logo-small.png
+++ /dev/null
Binary files differ