Exemplo n.º 1
0
 /**
  * Set the value of taskbar
  *
  * @param newVar the new value of taskbar
  */
 private void setTaskbar() {
   /** *****************Task Bar**************** */
   taskbar = new JTextArea();
   taskbar.setVisible(true);
   taskbar.setBackground(Color.lightGray);
   taskbar.setEditable(false);
   /** *****************End of Task Bar**************** */
 }
Exemplo n.º 2
0
  /**
   * @param path_ret where the file will be saved
   * @param a getting the information of current status of the editor
   * @param cnc_a getting the information of current status of the editor
   * @throws ParserConfigurationException
   * @throws IOException
   */
  public void save(String tempPath, counts a, connections cnc_a)
      throws ParserConfigurationException, IOException {
    try {
      DocumentBuilderFactory dbf = DocumentBuilderFactoryImpl.newInstance();
      // get an instance of builder
      DocumentBuilder db = dbf.newDocumentBuilder();
      // create an instance of DOM
      Document dom = db.newDocument();

      Element el_root = dom.createElement("circuit");
      dom.appendChild(el_root);

      // Root of the components
      Element cmp_root = dom.createElement("components");
      el_root.appendChild(cmp_root);
      for (component x : a.getComponent_list()) {
        Element cmpEle = this.createCmpEle(x, dom);
        cmp_root.appendChild(cmpEle);
      }

      // Root of the components
      Element wire_root = dom.createElement("wires");
      el_root.appendChild(wire_root);
      for (line x : cnc_a.getLine_logs()) {
        Element wireEle = null;
        if (x.getId() > 0) {
          wireEle = this.createWireEle(x, dom);
          wire_root.appendChild(wireEle);
        }
      }

      OutputFormat format = new OutputFormat();
      XMLSerializer serializer =
          new XMLSerializer(new FileOutputStream(new File(tempPath)), format);

      serializer.serialize(dom);
      this.changeTitle(new File(tempPath).getName());
      this.setSaved(true);
      this.setPath(tempPath);
      taskbar.setText("File is saved successfully.");
    } catch (FileNotFoundException ex) {
      Logger.getLogger(Pad_Draw.class.getName()).log(Level.SEVERE, null, ex);
    }
  }