summaryrefslogtreecommitdiff
path: root/tutorials/java/src/phpdbg/ui/JConsole.java
diff options
context:
space:
mode:
authorkrakjoe <joe.watkins@live.co.uk>2013-11-30 07:27:11 +0000
committerkrakjoe <joe.watkins@live.co.uk>2013-11-30 07:27:11 +0000
commit4fa2f01c4e8d0390e1406d0ebdcd040698426fa0 (patch)
treeb4c7a2a79a052f9843516720ce326dff630c7e77 /tutorials/java/src/phpdbg/ui/JConsole.java
parent16edd155cbabe46f7083a449a6718cbb19873248 (diff)
downloadphp-git-4fa2f01c4e8d0390e1406d0ebdcd040698426fa0.tar.gz
add systray and logo
Diffstat (limited to 'tutorials/java/src/phpdbg/ui/JConsole.java')
-rw-r--r--tutorials/java/src/phpdbg/ui/JConsole.java52
1 files changed, 52 insertions, 0 deletions
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),