Пример #1
0
  public void exit() {
    session.close();

    if (dnsCache != null) {
      System.out.printf(" cache= %s%n", dnsCache.toString());
      System.out.printf(" cache.size= %d%n", dnsCache.getSize());
      System.out.printf(" cache.memorySize= %d%n", dnsCache.getMemoryStoreSize());
      Statistics stats = dnsCache.getStatistics();
      System.out.printf(" stats= %s%n", stats.toString());
    }

    cacheManager.shutdown();
    fileChooser.save();
    managePanel.save();
    accessLogPanel.save();
    servletLogPanel.save();
    urlDump.save();

    Rectangle bounds = frame.getBounds();
    prefs.putBeanObject(FRAME_SIZE, bounds);
    try {
      store.save();
    } catch (IOException ioe) {
      ioe.printStackTrace();
    }

    done = true; // on some systems, still get a window close event
    System.exit(0);
  }
Пример #2
0
  /** Method to check to see what kind of imports are supported by the mapper script */
  private void loadMapperScript() {
    String fileName = mapperScriptTextField.getText();
    File file = new File(fileName);

    if (file.exists()) {
      mapperScript = FileManager.readTextData(file);
      indicateSupportedRecords(null);
      scriptFile = file;
    }
  }
Пример #3
0
 private void generateOutputFiles() throws Exception {
   try {
     File jsonFile = new File(".\\temp-out.json");
     writeJSONContents(jsonFile);
     File target = fileManager.chooseSaveDirectory(this);
     File quizCoreFile = new File(".\\quiz-helper-core\\main.exe");
     RootExecutor executor = new RootExecutor();
     executor.executeCore(quizCoreFile, jsonFile, target, 4);
     jsonFile.delete();
   } catch (Exception ex) {
     exceptionErrorDialog(ex);
   }
 }
Пример #4
0
  public GridUI(
      PreferencesExt pstore, RootPaneContainer root, FileManager fileChooser, int defaultHeight) {
    // this.topUI = topUI;
    this.store = pstore;
    this.fileChooser = fileChooser;

    try {
      choosers = new ArrayList();
      fieldChooser = new SuperComboBox(root, "field", true, null);
      choosers.add(new Chooser("field", fieldChooser, true));
      levelChooser = new SuperComboBox(root, "level", false, null);
      choosers.add(new Chooser("level", levelChooser, false));
      timeChooser = new SuperComboBox(root, "time", false, null);
      choosers.add(new Chooser("time", timeChooser, false));
      ensembleChooser = new SuperComboBox(root, "ensemble", false, null);
      choosers.add(new Chooser("ensemble", ensembleChooser, false));
      runtimeChooser = new SuperComboBox(root, "runtime", false, null);
      choosers.add(new Chooser("runtime", runtimeChooser, false));

      makeActionsDataset();
      makeActionsToolbars();

      gridTable = new GridTable("field");
      gtWindow =
          new IndependentWindow(
              "Grid Table Information", BAMutil.getImage("GDVs"), gridTable.getPanel());

      PreferencesExt dsNode = (PreferencesExt) pstore.node("DatasetTable");
      dsTable = new GeoGridTable(dsNode, true);
      dsDialog = dsTable.makeDialog(root, "NetcdfDataset Info", false);
      // dsDialog.setIconImage( BAMutil.getImage( "GDVs"));
      Rectangle bounds =
          (Rectangle) dsNode.getBean("DialogBounds", new Rectangle(50, 50, 800, 450));
      dsDialog.setBounds(bounds);

      controller = new GridController(this, store);
      makeUI(defaultHeight);
      controller.finishInit();

      // other components
      geotiffFileChooser = new FileManager(parent);
      geotiffFileChooser.setCurrentDirectory(store.get(GEOTIFF_FILECHOOSER_DEFAULTDIR, "."));

    } catch (Exception e) {
      System.out.println("UI creation failed");
      e.printStackTrace();
    }
  }
Пример #5
0
  /** save all data in the PersistentStore */
  public void storePersistentData() {
    store.putInt("vertSplit", splitDraw.getDividerLocation());

    store.putBoolean(
        "navToolbarAction", ((Boolean) navToolbarAction.getValue(BAMutil.STATE)).booleanValue());
    store.putBoolean(
        "moveToolbarAction", ((Boolean) moveToolbarAction.getValue(BAMutil.STATE)).booleanValue());

    if (projManager != null) projManager.storePersistentData();
    /* if (csManager != null)
      csManager.storePersistentData();
    if (sysConfigDialog != null)
      sysConfigDialog.storePersistentData(); */

    dsTable.save();
    dsTable.getPrefs().putBeanObject("DialogBounds", dsDialog.getBounds());

    store.put(GEOTIFF_FILECHOOSER_DEFAULTDIR, geotiffFileChooser.getCurrentDirectory());

    controller.storePersistentData();
  }
Пример #6
0
  public static Boolean getLogin() {

    Boolean status = false;

    try {
      Person person = new Person();
      person = csv.findPerson(userName, passWord, "src/people.csv");
      if (person.getUsername() != null && person.getPassword() != null) {
        //				if (person.getRole() == "user") {
        lblWelcome.setText("Welcome : " + person.getUsername());
        //				}
        status = true;
      } else {
        JOptionPane.showMessageDialog(null, "Incorrect Username/Password");
      }

    } catch (Exception e) {
      // TODO Auto-generated catch block
      JOptionPane.showMessageDialog(null, e.getMessage());
      e.printStackTrace();
    }

    return status;
  }
Пример #7
0
 private File loadSerializedContents() throws Exception {
   File f = fileManager.chooseLoadFile(this);
   Quiz qz = loadSerializedQuiz(f);
   setContents(qz);
   return f;
 }
Пример #8
0
 private File saveSerializedContents() throws Exception {
   File f = fileManager.chooseSaveFile(this);
   writeSerializedContents(f);
   return f;
 }
Пример #9
0
public class CAMenuControl extends JFrame {

  JButton randomB, loadFileB, helpB, exitB;
  JComboBox populationCB, rulesetCB, filenameCB;
  JTextField pathTF;
  JLabel randomL, loadL, populationL, rulesetL, pathL;
  JSeparator sep1, sep2;
  JPanel buttonP;
  ActionListener handler = new ButtonHandler();
  FileManager fm = FileManager.getInstance();

  public CAMenuControl(RuleSet[] rules, String[] files) {

    super();

    // buttons
    randomB = new JButton("Create Simulation");
    randomB.addActionListener(handler);
    loadFileB = new JButton("Load Simulation");
    loadFileB.addActionListener(handler);
    helpB = new JButton("Help");
    helpB.addActionListener(handler);
    exitB = new JButton("Exit");
    exitB.addActionListener(handler);

    // comboboxes
    Integer[] populations = {10, 20, 30, 40, 50, 60, 70, 80, 90};
    populationCB = new JComboBox<Integer>(populations);
    rulesetCB = new JComboBox<RuleSet>(rules);
    rulesetCB.addActionListener(handler);
    filenameCB = new JComboBox<String>(files);

    // labels
    Font title = new Font("Ariel", Font.BOLD, 14);
    randomL = new JLabel("Create a simulation:", JLabel.CENTER);
    randomL.setFont(title);
    populationL = new JLabel("Population (%): ", JLabel.RIGHT);
    rulesetL = new JLabel("Ruleset to use: ", JLabel.RIGHT);

    loadL = new JLabel("Load simulation from xml file:", JLabel.CENTER);
    loadL.setFont(title);
    pathL = new JLabel("Select file: ", JLabel.RIGHT);

    sep1 = new JSeparator(JSeparator.HORIZONTAL);
    sep1.setPreferredSize(new Dimension(50, 5));
    sep1.setBackground(Color.DARK_GRAY);

    sep2 = new JSeparator(JSeparator.HORIZONTAL);
    sep2.setPreferredSize(new Dimension(50, 5));
    sep2.setBackground(Color.DARK_GRAY);

    buttonP = new JPanel();
    buttonP.setLayout(new GridLayout(1, 2, 1, 1));
    buttonP.add(helpB);
    buttonP.add(exitB);

    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    // row1
    c.gridwidth = 2;
    add(randomL, c);
    // row2
    c.gridwidth = 1;
    c.gridy = 1;
    c.gridx = 0;
    add(rulesetL, c);
    c.gridx = 1;
    add(rulesetCB, c);
    // row3
    c.gridwidth = 1;
    c.gridy++;
    c.gridx = 0;
    add(populationL, c);
    c.gridx++;
    add(populationCB, c);
    c.gridy++;
    c.gridx = 1;
    add(randomB, c);
    // sep
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 2;
    add(sep1, c);
    // row4
    c.gridwidth = 2;
    c.gridy++;
    c.gridx = 0;
    add(loadL, c);
    // row5
    c.gridwidth = 1;
    c.gridy++;
    c.gridx = 0;
    add(pathL, c);
    c.gridx = 1;
    add(filenameCB, c);
    c.gridy++;
    c.gridx = 1;
    add(loadFileB, c);
    // sep
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 3;
    add(sep2, c);
    // row6
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 3;
    add(buttonP, c);

    setSize(500, 300);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setVisible(true);
  }

  private Simulation loadAnt() {
    return fm.loadXML("LANGTONS_ANT.xml");
  }

  class ButtonHandler implements ActionListener {

    @Override
    public void actionPerformed(ActionEvent e) {
      if (e.getSource() == randomB) {
        Simulation sim;
        if (rulesetCB.getSelectedItem().getClass().getName().equals("CS415.LangtonsAnt")) {
          sim = loadAnt();
        } else {
          sim =
              new Simulation(
                  (RuleSet) rulesetCB.getSelectedItem(),
                  50,
                  50,
                  (int) populationCB.getSelectedItem());
        }

        if (sim != null) {
          CAApplication.control = new SimControl(sim);
          setVisible(false);
        }
      } else if (e.getSource() == loadFileB) {
        Simulation sim = fm.loadXML(filenameCB.getSelectedItem().toString());
        new SimControl(sim);
        setVisible(false);
      } else if (e.getSource() == exitB) {
        JOptionPane op = new JOptionPane();
        op.showMessageDialog(null, "Your application is awesome, and ran perfectly!");
        System.exit(0);
      } else if (e.getSource() == rulesetCB) {
        if (rulesetCB.getSelectedItem().getClass().getName().equals("CS415.LangtonsAnt")) {
          populationL.setVisible(false);
          populationCB.setVisible(false);
        } else {
          populationL.setVisible(true);
          populationCB.setVisible(true);
        }
      }
    }
  }
}
Пример #10
0
 private Simulation loadAnt() {
   return fm.loadXML("LANGTONS_ANT.xml");
 }
Пример #11
0
    /** Runs this thread. */
    public void run() {
      CommonFileChooser file_chooser = new CommonFileChooser();
      file_chooser.setDialogTitle("Choose a directory.");
      file_chooser.setMultiSelectionEnabled(false);
      file_chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

      if (file_chooser.showSaveDialog(pane) == JFileChooser.APPROVE_OPTION) {
        try {
          File directory = file_chooser.getSelectedFile();
          directory.mkdirs();

          // Outputs the variability XML file.

          String path = FileManager.unitePath(directory.getAbsolutePath(), "package.xml");
          File file = new File(path);
          if (file.exists()) {
            String message = "Overwrite to " + file.getPath() + " ?";
            if (0
                != JOptionPane.showConfirmDialog(
                    pane, message, "Confirmation", JOptionPane.YES_NO_OPTION)) {
              return;
            }
          }

          XmlVariabilityHolder holder = new XmlVariabilityHolder();

          Variability[] records = getSelectedRecords();
          for (int i = 0; i < records.length; i++) {
            XmlVariability variability = new XmlVariability(records[i]);
            holder.addVariability(variability);
          }

          holder.write(file);

          // Copies the report XML document files.

          Hashtable hash_xml = new Hashtable();

          for (int i = 0; i < records.length; i++) {
            XmlMagRecord[] mag_records = records[i].getMagnitudeRecords();
            for (int j = 0; j < mag_records.length; j++)
              hash_xml.put(mag_records[j].getImageXmlPath(), this);
          }

          Vector failed_list = new Vector();

          Enumeration keys = hash_xml.keys();
          while (keys.hasMoreElements()) {
            String xml_path = (String) keys.nextElement();
            try {
              File src_file = desktop.getFileManager().newFile(xml_path);
              File dst_file =
                  new File(FileManager.unitePath(directory.getAbsolutePath(), xml_path));
              if (dst_file.exists() == false) FileManager.copy(src_file, dst_file);
            } catch (Exception exception) {
              failed_list.addElement(xml_path);
            }
          }

          if (failed_list.size() > 0) {
            String header = "Failed to copy the following XML files:";
            MessagesDialog dialog = new MessagesDialog(header, failed_list);
            dialog.show(pane, "Error", JOptionPane.ERROR_MESSAGE);
          }

          // Copies the image files.

          failed_list = new Vector();

          keys = hash_xml.keys();
          while (keys.hasMoreElements()) {
            path = (String) keys.nextElement();
            try {
              XmlInformation info =
                  XmlReport.readInformation(desktop.getFileManager().newFile(path));
              path = info.getImage().getContent();

              File src_file = desktop.getFileManager().newFile(path);
              File dst_file = new File(FileManager.unitePath(directory.getAbsolutePath(), path));
              if (dst_file.exists() == false) FileManager.copy(src_file, dst_file);
            } catch (Exception exception) {
              failed_list.addElement(path);
            }
          }

          if (failed_list.size() > 0) {
            String header = "Failed to copy the following image files:";
            MessagesDialog dialog = new MessagesDialog(header, failed_list);
            dialog.show(pane, "Error", JOptionPane.ERROR_MESSAGE);
          }

          // Creates the sub catalog database.

          try {
            DiskFileSystem file_system =
                new DiskFileSystem(
                    new File(
                        directory.getAbsolutePath(),
                        net.aerith.misao.pixy.Properties.getDatabaseDirectoryName()));
            CatalogDBManager new_manager = new GlobalDBManager(file_system).getCatalogDBManager();

            Hashtable hash_stars = new Hashtable();
            for (int i = 0; i < records.length; i++) {
              CatalogStar star = records[i].getStar();

              CatalogDBReader reader =
                  new CatalogDBReader(desktop.getDBManager().getCatalogDBManager());
              StarList list = reader.read(star.getCoor(), 0.5);
              for (int j = 0; j < list.size(); j++) {
                CatalogStar s = (CatalogStar) list.elementAt(j);
                hash_stars.put(s.getOutputString(), s);
              }
            }

            keys = hash_stars.keys();
            while (keys.hasMoreElements()) {
              String string = (String) keys.nextElement();
              CatalogStar star = (CatalogStar) hash_stars.get(string);
              new_manager.addElement(star);
            }
          } catch (Exception exception) {
            String message = "Failed to create sub catalog database.";
            JOptionPane.showMessageDialog(pane, message, "Error", JOptionPane.ERROR_MESSAGE);
          }

          String message = "Completed.";
          JOptionPane.showMessageDialog(pane, message);
        } catch (IOException exception) {
          String message = "Failed.";
          JOptionPane.showMessageDialog(pane, message, "Error", JOptionPane.ERROR_MESSAGE);
        }
      }
    }