Exemple #1
0
 /**
  * creates a new channel, if the channel exists it is removed (this method doubles as a
  * removeChannel)
  *
  * @param name the name of the channel
  */
 public void newChannel(String name, boolean pass) {
   if (channels.containsKey(name)) {
     channels.remove(name);
     cboChannels.removeItem(name);
   } else {
     channels.put(name, new Boolean(pass));
     cboChannels.addItem(name);
   }
 }
Exemple #2
0
 private static Hashtable<String, String> getManifestAttributes(Manifest manifest) {
   Hashtable<String, String> h = new Hashtable<String, String>();
   try {
     Attributes attrs = manifest.getMainAttributes();
     Iterator it = attrs.keySet().iterator();
     while (it.hasNext()) {
       String key = it.next().toString();
       h.put(key, attrs.getValue(key));
     }
   } catch (Exception ignore) {
   }
   return h;
 }
Exemple #3
0
 private void save() {
   try {
     Document doc = XmlUtil.getDocument();
     Element root = doc.createElement("profiles");
     doc.appendChild(root);
     Enumeration<String> keys = table.keys();
     while (keys.hasMoreElements()) {
       table.get(keys.nextElement()).appendTo(root);
     }
     FileUtil.setText(new File(filename), FileUtil.utf8, XmlUtil.toString(doc));
   } catch (Exception ignore) {
   }
 }
 public void addMenuItem(String text, String loc) {
   locations.put(text, loc);
   if (filenames.contains("Test Text")) {
     filenames.remove("Test Text");
     filenames.addElement(text);
   } else {
     filenames.addElement(text);
   }
   createPopupMenu();
 }
Exemple #5
0
 /** cleans up a connection by removing all user from all maintained lists */
 public void close() {
   error("Connection to server was lost");
   admin = false;
   users.clear();
   afks.clear();
   ignores.clear();
   admins.clear();
   channels.clear();
   cboChannels.removeAllItems();
   updateList();
 }
  public void displayPage(JEditorPane pane, String text) {
    try {
      File helpFile = new File((String) locations.get(text));
      String loc = "file:" + helpFile.getAbsolutePath();
      URL page = new URL(loc);

      pane.setPage(page);

    } catch (IOException ioe) {
      JOptionPane.showMessageDialog(null, "Help Topic Unavailable");
      pane.getParent().repaint();
    }
  }
Exemple #7
0
 private void load() {
   File file = new File(filename);
   if (file.exists()) {
     try {
       Document doc = XmlUtil.getDocument(file);
       Element root = doc.getDocumentElement();
       Node child = root.getFirstChild();
       while (child != null) {
         if (child.getNodeType() == Node.ELEMENT_NODE) {
           Profile p = new Profile((Element) child);
           table.put(p.name, p);
         }
         child = child.getNextSibling();
       }
     } catch (Exception ignore) {
     }
   }
 }
Exemple #8
0
  /**
   * Class constructor; creates a new Installer object, displays a JFrame introducing the program,
   * allows the user to select an install directory, and copies files from the jar into the
   * directory.
   */
  public Installer(String args[]) {
    // Inputs are --install-dir INSTALL_DIR
    for (int k = 0; k < args.length; k = k + 2) {

      switch (args[k]) {
        case "--install-dir":
          directory = new File(args[k + 1]);
          System.out.println(directory);
          break;
        case "--port":
          port = Integer.parseInt(args[k + 1]);
          break;
      }
    }

    cp = new Stream();

    // Find the installer program so we can get to the files.
    installer = getInstallerProgramFile();
    String name = installer.getName();
    programName = (name.substring(0, name.indexOf("-"))).toUpperCase();

    // Get the installation information
    thisJava = System.getProperty("java.version");
    thisJavaBits = System.getProperty("sun.arch.data.model") + " bits";

    // Find the ImageIO Tools and get the version
    String javaHome = System.getProperty("java.home");
    File extDir = new File(javaHome);
    extDir = new File(extDir, "lib");
    extDir = new File(extDir, "ext");
    File clib = getFile(extDir, "clibwrapper_jiio", ".jar");
    File jai = getFile(extDir, "jai_imageio", ".jar");
    imageIOTools = (clib != null) && clib.exists() && (jai != null) && jai.exists();
    if (imageIOTools) {
      Hashtable<String, String> jaiManifest = getManifestAttributes(jai);
      imageIOVersion = jaiManifest.get("Implementation-Version");
    }

    // Get the CTP.jar parameters
    Hashtable<String, String> manifest = getJarManifestAttributes("/CTP/libraries/CTP.jar");
    programDate = manifest.get("Date");
    buildJava = manifest.get("Java-Version");

    // Get the util.jar parameters
    Hashtable<String, String> utilManifest = getJarManifestAttributes("/CTP/libraries/util.jar");
    utilJava = utilManifest.get("Java-Version");

    // Get the MIRC.jar parameters (if the plugin is present)
    Hashtable<String, String> mircManifest = getJarManifestAttributes("/CTP/libraries/MIRC.jar");
    if (mircManifest != null) {
      mircJava = mircManifest.get("Java-Version");
      mircDate = mircManifest.get("Date");
      mircVersion = mircManifest.get("Version");
    }

    // Set up the installation information for display
    if (imageIOVersion.equals("")) {
      imageIOVersion = "<b><font color=\"red\">not installed</font></b>";
    } else if (imageIOVersion.startsWith("1.0")) {
      imageIOVersion = "<b><font color=\"red\">" + imageIOVersion + "</font></b>";
    }
    if (thisJavaBits.startsWith("64")) {
      thisJavaBits = "<b><font color=\"red\">" + thisJavaBits + "</font></b>";
    }
    boolean javaOK = (thisJava.compareTo(buildJava) >= 0);
    javaOK &= (thisJava.compareTo(utilJava) >= 0);
    javaOK &= (thisJava.compareTo(mircJava) >= 0);
    if (!javaOK) {
      thisJava = "<b><font color=\"red\">" + thisJava + "</font></b>";
    }

    if (directory == null) exit();

    // Point to the parent of the directory in which to install the program.
    // so the copy process works correctly for directory trees.
    //
    // If the user has selected a directory named "CTP",
    // then assume that this is the directory in which
    // to install the program.
    //
    // If the directory is not CTP, see if it is called "RSNA" and contains
    // the Launcher program, in which case we can assume that it is an
    // installation that was done with Bill Weadock's all-in-one installer for Windows.
    //
    // If neither of those cases is true, then this is already the parent of the
    // directory in which to install the program
    if (directory.getName().equals("CTP")) {
      directory = directory.getParentFile();
    } else if (directory.getName().equals("RSNA")
        && (new File(directory, "Launcher.jar")).exists()) {
      suppressFirstPathElement = true;
    }

    // Cleanup old releases
    cleanup(directory);

    // Get a port for the server.
    if (port < 0) {
      if (checkServer(-port, false)) {
        System.err.println(
            "CTP appears to be running.\nPlease stop CTP and run the installer again.");
        System.exit(0);
      }
    }

    // Now install the files and report the results.
    int count =
        unpackZipFile(installer, "CTP", directory.getAbsolutePath(), suppressFirstPathElement);
    if (count > 0) {
      // Create the service installer batch files.
      updateWindowsServiceInstaller();
      updateLinuxServiceInstaller();

      // If this was a new installation, set up the config file and set the port
      installConfigFile(port);

      // Make any necessary changes in the config file to reflect schema evolution
      fixConfigSchema();

      System.out.println("Installation complete.");
      System.out.println(programName + " has been installed successfully.");
      System.out.println(count + " files were installed.");
    } else {
      System.err.println("Installation failed.");
      System.err.println(programName + " could not be fully installed.");
    }
    if (!programName.equals("ISN") && startRunner(new File(directory, "CTP"))) System.exit(0);
  }
Exemple #9
0
 public void delete(String name) {
   table.remove(name);
   save();
 }
Exemple #10
0
 public void add(Profile profile) {
   table.put(profile.name, profile);
   save();
 }
Exemple #11
0
 public int size() {
   return table.size();
 }
Exemple #12
0
 public Profile getProfile(String name) {
   Profile p = table.get(name);
   if (p == null) p = new Profile(name);
   return p;
 }
Exemple #13
0
 public String[] getNames() {
   String[] names = new String[table.size()];
   names = table.keySet().toArray(names);
   Arrays.sort(names);
   return names;
 }
    private void makeComponents() {
      this.getWwd().setPreferredSize(new Dimension(1024, 768));

      JPanel panel = new JPanel(new BorderLayout());
      {
        panel.setBorder(new EmptyBorder(10, 0, 10, 0));

        JPanel controlPanel = new JPanel(new BorderLayout(0, 10));
        controlPanel.setBorder(new EmptyBorder(20, 10, 20, 10));

        JPanel btnPanel = new JPanel(new GridLayout(5, 1, 0, 5));
        {
          JButton btn = new JButton("Zoom to Matterhorn");
          btn.setActionCommand(ACTION_COMMAND_BUTTON1);
          btn.addActionListener(this.controller);
          btnPanel.add(btn);

          btn = new JButton("DEMO getElevations()");
          btn.setActionCommand(ACTION_COMMAND_BUTTON2);
          btn.addActionListener(this.controller);
          btnPanel.add(btn);

          btn = new JButton("DEMO getElevation()");
          btn.setActionCommand(ACTION_COMMAND_BUTTON3);
          btn.addActionListener(this.controller);
          btnPanel.add(btn);

          btn = new JButton("DEMO new getElevations");
          btn.setActionCommand(ACTION_COMMAND_BUTTON4);
          btn.addActionListener(this.controller);
          btnPanel.add(btn);

          //                    btn = new JButton("Button 5");
          //                    btn.setActionCommand(ACTION_COMMAND_BUTTON5);
          //                    btn.addActionListener(this.controller);
          //                    btnPanel.add(btn);
        }
        controlPanel.add(btnPanel, BorderLayout.NORTH);

        JPanel vePanel = new JPanel(new BorderLayout(0, 5));
        {
          JLabel label = new JLabel("Vertical Exaggeration");
          vePanel.add(label, BorderLayout.NORTH);

          int MIN_VE = 1;
          int MAX_VE = 8;
          int curVe = (int) this.getWwd().getSceneController().getVerticalExaggeration();
          curVe = curVe < MIN_VE ? MIN_VE : (curVe > MAX_VE ? MAX_VE : curVe);
          JSlider slider = new JSlider(MIN_VE, MAX_VE, curVe);
          slider.setMajorTickSpacing(1);
          slider.setPaintTicks(true);
          slider.setSnapToTicks(true);
          Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
          labelTable.put(1, new JLabel("1x"));
          labelTable.put(2, new JLabel("2x"));
          labelTable.put(4, new JLabel("4x"));
          labelTable.put(8, new JLabel("8x"));
          slider.setLabelTable(labelTable);
          slider.setPaintLabels(true);
          slider.addChangeListener(
              new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                  double ve = ((JSlider) e.getSource()).getValue();
                  ActionEvent ae = new ActionEvent(ve, 0, ACTION_COMMAND_VERTICAL_EXAGGERATION);
                  controller.actionPerformed(ae);
                }
              });
          vePanel.add(slider, BorderLayout.SOUTH);
        }
        controlPanel.add(vePanel, BorderLayout.SOUTH);

        panel.add(controlPanel, BorderLayout.SOUTH);

        this.layerPanel = new LayerPanel(this.getWwd(), null);
        panel.add(this.layerPanel, BorderLayout.CENTER);
      }
      getContentPane().add(panel, BorderLayout.WEST);
    }
Exemple #15
0
 public void run() {
   while (connected) {
     try {
       Object obj = in.readObject();
       if (obj.toString().equals("-101")) {
         connected = false;
         in.close();
         out.close();
         socket.close();
         SwingUtilities.invokeLater(
             new Runnable() {
               public void run() {
                 Cashier.closee = true;
                 JOptionPane.showMessageDialog(
                     null,
                     "Disconnected from server. Please Restart",
                     "Error:",
                     JOptionPane.PLAIN_MESSAGE);
                 try {
                   m.stop();
                 } catch (Exception w) {
                 }
               }
             });
       } else if (obj.toString().split("::")[0].equals("broadcast")) {
         // System.out.println("braodcast received");
         bc.run(obj.toString().substring(obj.toString().indexOf("::") + 2));
       } else if (obj.toString().split("::")[0].equals("chat")) {
         // System.out.println("chat received:
         // "+obj.toString().substring(obj.toString().indexOf("::")+2));
         cc.run(obj.toString().substring(obj.toString().indexOf("::") + 2));
       } else if (obj.toString().split("::")[0].equals("rankings")) {
         String hhh = obj.toString().split("::")[1];
         final JDialog jd = new JDialog();
         jd.setUndecorated(false);
         JPanel pan = new JPanel(new BorderLayout());
         JLabel ppp = new JLabel();
         ppp.setFont(new Font("Arial", Font.BOLD, 20));
         ppp.setText(
             "<html><pre>Thanks for playing !!!<br/>1st: "
                 + hhh.split(":")[0]
                 + "<br/>2nd: "
                 + hhh.split(":")[1]
                 + "<br/>3rd: "
                 + hhh.split(":")[2]
                 + "</pre></html>");
         pan.add(ppp, BorderLayout.CENTER);
         JButton ok = new JButton("Ok");
         ok.addActionListener(
             new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                 jd.setVisible(false);
                 try {
                   m.stop();
                 } catch (Exception w) {
                 }
               }
             });
         pan.add(ok, BorderLayout.SOUTH);
         jd.setContentPane(pan);
         jd.setModalityType(JDialog.ModalityType.APPLICATION_MODAL);
         jd.pack();
         jd.setLocationRelativeTo(null);
         jd.setVisible(true);
       } else if (obj.toString().split("::")[0].equals("rank")) {
         rc.run(obj.toString().substring(obj.toString().indexOf("::") + 2));
       } else {
         User hhh = null;
         try {
           hhh = (User) obj;
           /*if(usrD==1)
           {
               reply=obj;
               ccl.interrupt();
           }
           else*/
           {
             try {
               m.ur.changeData((User) obj);
             } catch (Exception w) {
               try {
                 maain.ur.changeData((User) obj);
               } catch (Exception ppp) {
                 ppp.printStackTrace();
               }
             }
           }
         } catch (Exception p) {
           int iid = -1;
           try {
             iid = Integer.parseInt(obj.toString());
             obj = in.readObject();
             if (obj.toString().equals("-102")) {
               // ccl.interrupt();
               SwingUtilities.invokeLater(
                   new Runnable() {
                     public void run() {
                       Cashier.closee = true;
                       JOptionPane.showMessageDialog(
                           null, "Server Not Running.", "Error:", JOptionPane.PLAIN_MESSAGE);
                     }
                   });
             }
             // Thread th = ((Thread)rev.remove(iid));
             rev2.put(iid, obj);
             // System.out.println("Put: "+iid+"   :   "+obj.toString()+"   :
             // "+Thread.currentThread());
             // th.interrupt();
             // ccl.interrupt();
           } catch (Exception ppp) {
               /*ppp.printStackTrace();*/
             System.out.println(
                 "Shit: "
                     + iid
                     + "   :   "
                     + obj.toString()
                     + "   :   "
                     + Thread.currentThread());
           }
         }
       }
       try {
         Thread.sleep(500);
       } catch (Exception n) {
       }
     } catch (Exception m) {
     }
   }
 }