diff options
author | krakjoe <joe.watkins@live.co.uk> | 2013-11-30 07:27:11 +0000 |
---|---|---|
committer | krakjoe <joe.watkins@live.co.uk> | 2013-11-30 07:27:11 +0000 |
commit | 4fa2f01c4e8d0390e1406d0ebdcd040698426fa0 (patch) | |
tree | b4c7a2a79a052f9843516720ce326dff630c7e77 /tutorials/java/src | |
parent | 16edd155cbabe46f7083a449a6718cbb19873248 (diff) | |
download | php-git-4fa2f01c4e8d0390e1406d0ebdcd040698426fa0.tar.gz |
add systray and logo
Diffstat (limited to 'tutorials/java/src')
-rw-r--r-- | tutorials/java/src/phpdbg/ui/JConsole.form | 22 | ||||
-rw-r--r-- | tutorials/java/src/phpdbg/ui/JConsole.java | 52 | ||||
-rw-r--r-- | tutorials/java/src/phpdbg/ui/logo-dbg.png | bin | 0 -> 248 bytes |
3 files changed, 74 insertions, 0 deletions
diff --git a/tutorials/java/src/phpdbg/ui/JConsole.form b/tutorials/java/src/phpdbg/ui/JConsole.form index fb2e622f5b..2db69b086d 100644 --- a/tutorials/java/src/phpdbg/ui/JConsole.form +++ b/tutorials/java/src/phpdbg/ui/JConsole.form @@ -18,6 +18,28 @@ </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"/> diff --git a/tutorials/java/src/phpdbg/ui/JConsole.java b/tutorials/java/src/phpdbg/ui/JConsole.java index 60001d385c..383e225a85 100644 --- a/tutorials/java/src/phpdbg/ui/JConsole.java +++ b/tutorials/java/src/phpdbg/ui/JConsole.java @@ -1,9 +1,15 @@ 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; @@ -46,6 +52,8 @@ public class JConsole extends javax.swing.JDialog { 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(); @@ -67,6 +75,22 @@ public class JConsole extends javax.swing.JDialog { }); 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"); @@ -219,6 +243,16 @@ public class JConsole extends javax.swing.JDialog { // 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) { @@ -376,6 +410,21 @@ public class JConsole extends javax.swing.JDialog { 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); } }); @@ -386,6 +435,7 @@ public class JConsole extends javax.swing.JDialog { 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; @@ -402,6 +452,8 @@ public class JConsole extends javax.swing.JDialog { 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), diff --git a/tutorials/java/src/phpdbg/ui/logo-dbg.png b/tutorials/java/src/phpdbg/ui/logo-dbg.png Binary files differnew file mode 100644 index 0000000000..621f29b53e --- /dev/null +++ b/tutorials/java/src/phpdbg/ui/logo-dbg.png |