Ejemplo n.º 1
0
  /** Make a main window by instantiating the my custom window. */
  public void makeMainWindow() {
    mainWindow = new SCLMonWindow(this);

    // for PV Logger snapshot chooser
    plsc = new PVLogSnapshotChooser(mainWindow);
    plsc.setGroup("SCL HOM");

    if (getSource() != null) {
      XmlDataAdaptor xda = XmlDataAdaptor.adaptorForUrl(getSource(), false);
      DataAdaptor da1 = xda.childAdaptor("AcceleratorApplicationSCLMon");

      // restore accelerator file
      this.setAcceleratorFilePath(da1.childAdaptor("accelerator").stringValue("xalFile"));

      String accelUrl = this.getAcceleratorFilePath();
      try {
        this.setAccelerator(
            XMLDataManager.acceleratorWithPath(accelUrl), this.getAcceleratorFilePath());
      } catch (Exception exception) {
        JOptionPane.showMessageDialog(
            null,
            "Hey - I had trouble parsing the accelerator input xml file you fed me",
            "AOC error",
            JOptionPane.ERROR_MESSAGE);
      }
      this.acceleratorChanged();
    }
    setHasChanges(false);
  }
Ejemplo n.º 2
0
  /**
   * Save the document to the specified URL.
   *
   * @param url The URL to which the document should be saved.
   */
  public void saveDocumentAs(URL url) {
    XmlDataAdaptor xda = XmlDataAdaptor.newEmptyDocumentAdaptor();
    DataAdaptor daLevel1 = xda.createChild("SCLMon");
    // save accelerator file
    DataAdaptor daXMLFile = daLevel1.createChild("accelerator");
    try {
      daXMLFile.setValue("xalFile", new URL(this.getAcceleratorFilePath()).getPath());
    } catch (java.net.MalformedURLException e) {
      daXMLFile.setValue("xalFile", this.getAcceleratorFilePath());
    }
    // save selected sequences
    ArrayList<String> seqs;
    if (getSelectedSequence() != null) {
      DataAdaptor daSeq = daLevel1.createChild("sequences");
      daSeq.setValue("name", getSelectedSequence().getId());
      if (getSelectedSequence().getClass() == AcceleratorSeqCombo.class) {
        AcceleratorSeqCombo asc = (AcceleratorSeqCombo) getSelectedSequence();
        seqs = (ArrayList<String>) asc.getConstituentNames();
      } else {
        seqs = new ArrayList<String>();
        seqs.add(getSelectedSequence().getId());
      }

      Iterator<String> itr = seqs.iterator();

      while (itr.hasNext()) {
        DataAdaptor daSeqComponents = daSeq.createChild("seq");
        daSeqComponents.setValue("name", itr.next());
      }
    }

    // write to the document file
    xda.writeToUrl(url);
    setHasChanges(false);
  }
Ejemplo n.º 3
0
  /**
   * Uses an <code>XmlDataAdaptor</code> to write out the contents of this configuration to a memory
   * buffer and returns it.
   *
   * @see java.lang.Object#toString()
   * @author Christopher K. Allen
   * @since Apr 17, 2014
   */
  @Override
  public String toString() {

    //        InMemoryDataAdaptor daptBuf = new InMemoryDataAdaptor();
    XmlDataAdaptor daptBuf = XmlDataAdaptor.newEmptyDocumentAdaptor();
    this.write(daptBuf);

    StringWriter wtrBuf = new StringWriter();
    daptBuf.writeTo(wtrBuf);

    return wtrBuf.toString();
  }