Package de.mud.jta.event

Examples of de.mud.jta.event.SocketRequest


    }

    String addr = mudAddr.getText();
    String port = mudPort.getText();
    if (addr != null) {
      bus.broadcast(new SocketRequest());
      if (port == null || port.length() <= 0)
        port = "23";
      bus.broadcast(new SocketRequest(addr, Integer.parseInt(port)));
    }
  }
View Full Code Here


  }
      }
      public void offline() {
        handler.disconnect();
  auth=false;
        bus.broadcast(new SocketRequest());
      }
    });
  }
View Full Code Here

            cmd = cmd.substring(0, idx);
          }
          if (cmd.length() > 0) address = cmd;
          if (address != null)
            if (port != -1)
              bus.broadcast(new SocketRequest(address, port));
            else
              bus.broadcast(new SocketRequest(address, 23));
          else
            error("connect: no address");
        } catch (Exception e) {
          error("connect(): failed");
          e.printStackTrace();
        }
      } else if (function.equals("disconnect"))
        bus.broadcast(new SocketRequest());
      else if (function.equals("detach")) {
        error("detach not implemented yet");
      } else
        error("ERROR: function not implemented: \"" + function + "\"");
      return;
View Full Code Here

    timeoutThread = null;
    final Thread grace = new Thread(new Runnable() {
      public void run() {
        try {
                Thread.currentThread().sleep(1000*timeout);
          Timeout.this.pluginBus.broadcast(new SocketRequest());
              } catch(InterruptedException e) {
          // ignore exception
        }
      }
    });
    grace.start();
  } else // if not graceful exit exists, be rude
    bus.broadcast(new SocketRequest());
      }
    }
  }
View Full Code Here

    if (!personalJava) {

      frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
          setup.broadcast(new SocketRequest());
          frame.setVisible(false);
          frame.dispose();
          System.exit(0);
        }
      });

      // add a menu bar
      JMenuBar mb = new JMenuBar();
      JMenu file = new JMenu("File");
      file.setMnemonic(KeyEvent.VK_F);
      JMenuItem tmp;
      file.add(tmp = new JMenuItem("Connect"));
      tmp.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.SHIFT_MASK | KeyEvent.CTRL_MASK));
      tmp.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
          String destination =
                  JOptionPane.showInputDialog(frame,
                                              new JLabel("Enter your destination host (host[:port])"),
                                              "Connect", JOptionPane.QUESTION_MESSAGE
                  );
          if (destination != null) {
            int sep = 0;
            if ((sep = destination.indexOf(' ')) > 0 || (sep = destination.indexOf(':')) > 0) {
              host = destination.substring(0, sep);
              port = destination.substring(sep + 1);
            } else {
              host = destination;
            }
            setup.broadcast(new SocketRequest());
            setup.broadcast(new SocketRequest(host, Integer.parseInt(port)));
          }
        }
      });
      file.add(tmp = new JMenuItem("Disconnect"));
      tmp.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
          setup.broadcast(new SocketRequest());
        }
      });
      file.addSeparator();
      if (setup.getComponents().get("Terminal") != null) {
        file.add(tmp = new JMenuItem("Print"));
        tmp.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_MASK));
        tmp.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
              PrintJob printJob =
                      frame.getToolkit().getPrintJob(frame, "JTA Terminal", null);
              // return if the user clicked cancel
              if (printJob == null) return;
              ((JComponent) setup.getComponents().get("Terminal"))
                      .print(printJob.getGraphics());
              printJob.end();
          }
        });
        file.addSeparator();
      }
      file.add(tmp = new JMenuItem("Exit"));
      tmp.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
          frame.dispose();
          System.exit(0);
        }
      });
      mb.add(file);

      JMenu edit = new JMenu("Edit");
      edit.add(tmp = new JMenuItem("Copy"));
      tmp.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK));
      tmp.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
          if (focussedPlugin instanceof VisualTransferPlugin)
            ((VisualTransferPlugin) focussedPlugin).copy(clipboard);
        }
      });
      edit.add(tmp = new JMenuItem("Paste"));
      tmp.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_MASK));
      tmp.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
          if (focussedPlugin instanceof VisualTransferPlugin)
            ((VisualTransferPlugin) focussedPlugin).paste(clipboard);
        }
      });
      mb.add(edit);

      Map menuList = setup.getMenus();
      names = menuList.keySet().iterator();
      while (names.hasNext()) {
        String name = (String) names.next();
        mb.add((JMenu) menuList.get(name));
      }

      JMenu help = new JMenu("Help");
      help.setMnemonic(KeyEvent.VK_HELP);
      help.add(tmp = new JMenuItem("General"));
      tmp.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          Help.show(frame, options.getProperty("Help.url"));
        }
      });
      mb.add(help);

      frame.setJMenuBar(mb);

    } // !personalJava

    frame.pack();

    if ((new Boolean(options.getProperty("Applet.detach.fullscreen"))
            .booleanValue()))
      frame.setSize(frame.getToolkit().getScreenSize());
    else
      frame.pack();

    frame.setVisible(true);

    if(debug > 0)
      System.err.println("host: '"+host+"', "+host.length());
    if (host != null && host.length() > 0) {
      setup.broadcast(new SocketRequest(host, Integer.parseInt(port)));
    }
    /* make sure the focus goes somewhere to start off with */
    setup.broadcast(new ReturnFocusRequest());
  }
View Full Code Here

                    .setSize(appletFrame.getContentPane().getToolkit().getScreenSize());
          else
            ((JFrame) appletFrame).pack();

          ((JFrame) appletFrame).show();
          pluginLoader.broadcast(new SocketRequest(host, Integer.parseInt(port)));
          pluginLoader.broadcast(new ReturnFocusRequest());
          close.setLabel(startText != null ? stopText : "Disconnect");
        } else
          close.setLabel(startText != null ? startText : "Connect");

        close.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            if (((JFrame) appletFrame).isVisible()) {
              pluginLoader.broadcast(new SocketRequest());
              ((JFrame) appletFrame).setVisible(false);
              close.setLabel(startText != null ? startText : "Connect");
            } else {
              if (frameTitle == null)
                ((JFrame) appletFrame)
                        .setTitle("jta: " + host + (port.equals("23")?"":" " + port));
              if ((new Boolean(options.getProperty("Applet.detach.fullscreen"))
                      .booleanValue()))
                ((JFrame) appletFrame)
                        .setSize(appletFrame.getContentPane().getToolkit().getScreenSize());
              else
                ((JFrame) appletFrame).pack();
              ((JFrame) appletFrame).show();
              if (port == null || port.length() <= 0)
    port = "23";
              getAppletContext().showStatus("Trying " + host + " " + port + " ...");
              pluginLoader.broadcast(new SocketRequest(host,
                                                       Integer.parseInt(port)));
              pluginLoader.broadcast(new ReturnFocusRequest());
              close.setLabel(stopText != null ? stopText : "Disconnect");
            }
          }
        });

        getContentPane().setLayout(new BorderLayout());
        getContentPane().add("Center", close);

        // add a menu bar
        MenuBar mb = new MenuBar();
        Menu file = new Menu("File");
        file.setShortcut(new MenuShortcut(KeyEvent.VK_F, true));
        MenuItem tmp;
        file.add(tmp = new MenuItem("Connect"));
        tmp.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            pluginLoader.broadcast(new SocketRequest(host,
                                                     Integer.parseInt(port)));
          }
        });
        file.add(tmp = new MenuItem("Disconnect"));
        tmp.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            pluginLoader.broadcast(new SocketRequest());
          }
        });
        file.add(new MenuItem("-"));
        file.add(tmp = new MenuItem("Print"));
        tmp.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            if (pluginLoader.getComponents().get("Terminal") != null) {
              PrintJob printJob =
                      appletFrame.getContentPane().getToolkit()
                      .getPrintJob((JFrame) appletFrame, "JTA Terminal", null);
              ((Component) pluginLoader.getComponents().get("Terminal"))
                      .print(printJob.getGraphics());
              printJob.end();
            }
          }
        });
        file.add(new MenuItem("-"));
        file.add(tmp = new MenuItem("Exit"));
        tmp.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            ((JFrame) appletFrame).setVisible(false);
            pluginLoader.broadcast(new SocketRequest());
            close.setLabel(startText != null ? startText : "Connect");
          }
        });
        mb.add(file);

        Menu edit = new Menu("Edit");
        edit.setShortcut(new MenuShortcut(KeyEvent.VK_E, true));
        edit.add(tmp = new MenuItem("Copy"));
        tmp.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            if (debug > 2)
              System.err.println("Applet: copy: " + focussedPlugin);
            if (focussedPlugin instanceof VisualTransferPlugin)
              ((VisualTransferPlugin) focussedPlugin).copy(clipboard);
          }
        });
        edit.add(tmp = new MenuItem("Paste"));
        tmp.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            if (debug > 2)
              System.err.println("Applet: paste: " + focussedPlugin);
            if (focussedPlugin instanceof VisualTransferPlugin)
              ((VisualTransferPlugin) focussedPlugin).paste(clipboard);
          }
        });
        mb.add(edit);

        Map menuList = pluginLoader.getMenus();
        names = menuList.keySet().iterator();
        while (names.hasNext()) {
          String name = (String) names.next();
    Object o = menuList.get(name);
          if (o instanceof Menu) mb.add((Menu) o);
        }

        Menu help = new Menu("Help");
        help.setShortcut(new MenuShortcut(KeyEvent.VK_HELP, true));
        help.add(tmp = new MenuItem("General"));
        tmp.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Help.show(appletFrame.getContentPane(), options.getProperty("Help.url"));
          }
        });
        mb.setHelpMenu(help);

        // only add the menubar if the property is true
        if ((new Boolean(options.getProperty("Applet.detach.menuBar"))
                .booleanValue()))
          ((JFrame) appletFrame).setMenuBar(mb);

        // add window closing event handler
        try {
          ((JFrame) appletFrame).addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent evt) {
              pluginLoader.broadcast(new SocketRequest());
              ((JFrame) appletFrame).setVisible(false);
              close.setLabel(startText != null ? startText : "Connect");
            }
          });
        } catch (Exception e) {
View Full Code Here

   */
  public void start() {
    if (!online && (appletFrame == this || connect)) {
      if (debug > 0) System.err.println("start(" + host + ", " + port + ")");
      getAppletContext().showStatus("Trying " + host + " " + port + " ...");
      pluginLoader.broadcast(new SocketRequest(host, Integer.parseInt(port)));
      pluginLoader.broadcast(new ReturnFocusRequest());
    }
  }
View Full Code Here

   * Stop the applet and disconnect.
   */
  public void stop() {
    if (online && disconnect) {
      if (debug > 0) System.err.println("stop()");
      pluginLoader.broadcast(new SocketRequest());
    }
  }
View Full Code Here

TOP

Related Classes of de.mud.jta.event.SocketRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.