Esempio n. 1
0
  /** Reads the XML data and create the data */
  public void readDOMDataElement(Element element, IDataSets datasets) {
    // start with source data
    for (Object child : CodeFragment.getDataElementsOfType(CodeFragment.TYPE.SOURCE, element)) {
      Element code = (Element) child;
      try {
        collectSourceDataFromDOM(code, datasets);
      } catch (Exception e) {
        e.printStackTrace();
        Util.errorMessage(
            "Failed to load source "
                + code.getAttributeValue("name")
                + ", error "
                + e.getMessage());
      }
    }

    // process the data
    for (Object child : CodeFragment.getDataElementsOfType(CodeFragment.TYPE.GENERATED, element)) {
      Element code = (Element) child;
      try {
        processDataFromDOM(code, datasets);
      } catch (Exception e) {
        e.printStackTrace();
        Util.errorMessage("Failed to run process " + e.getMessage());
      }
    }
  }
Esempio n. 2
0
 public void save(boolean forcenew) {
   String filename = "";
   if ((m_filename.length() == 0) || forcenew) {
     FileDialog dialog = new FileDialog(new Shell(), SWT.SAVE);
     if (dialog.open() == null) {
       return;
     }
     filename = dialog.getFilterPath() + "/" + dialog.getFileName();
   } else {
     filename = m_filename;
   }
   FileOutputStream fileoutputstream;
   try {
     fileoutputstream = new FileOutputStream(filename);
     writeToStream(fileoutputstream);
     m_filename = filename;
     Element element = new Element("com.metaaps.eoclipse.workflow.filename");
     element.setAttribute("filename", m_filename);
     Util.setConfiguration(element, "filename");
   } catch (FileNotFoundException e) {
     e.printStackTrace();
     Util.errorMessage("Could not access file");
   } catch (IOException e) {
     e.printStackTrace();
     Util.errorMessage("Could not save file");
   }
 }
Esempio n. 3
0
  private void collectSourceDataFromDOM(Element code, IDataSets dataset) throws Exception {
    // get code fragment
    CodeFragment.TYPE type = CodeFragment.TYPE.valueOf(code.getAttributeValue("type"));
    if (type == CodeFragment.TYPE.SOURCE) {
      String dataname = code.getAttributeValue("name");
      String dataid = code.getAttributeValue("dataid");
      // check import method and reader
      Element importelement = code.getChild(IImport.class.getName());
      Element readerelement = code.getChild(IReader.class.getName());
      // get URI
      String URI = importelement.getAttributeValue("URI");
      String scheme = (new URI(URI)).getScheme();
      // look for a suitable import method
      IImports allimports = WorkFlowManager.getInstance().getImports();
      IImportMethod importmethod = allimports.findImport(scheme);
      if (importmethod == null) {
        Util.errorMessage("Could not find suitable import for scheme '" + scheme + "'");
        return;
      }
      IImport method = importmethod.getImport();
      method.setURI(URI);
      // get reader
      String readername = readerelement.getAttributeValue("name");
      String format = readerelement.getAttributeValue("format");
      String readertype = readerelement.getAttributeValue("datatype");
      IReaders allreaders = WorkFlowManager.getInstance().getReaders();
      IReader reader = allreaders.findReaderWithName(readername);
      if (reader == null) {
        Util.errorMessage("Could not find reader " + readername);
        return;
      }
      reader.setType(readertype);
      reader.setDataFormat(format);
      reader.setType(readertype);

      dataset.importDataContent(method, reader, dataname, dataid);
    }
  }
Esempio n. 4
0
 @Override
 public void modelChanged(Object element, String event) {
   if (element instanceof IDataContent) {
     try {
       IDataContent datacontent = (IDataContent) element;
       if (event == com.metaaps.eoclipse.common.Model.ADDED) {
         addDataLayer(datacontent);
       } else if (event == com.metaaps.eoclipse.common.Model.REMOVED) {
         removeDataLayer(datacontent);
       }
     } catch (ParseException e) {
       Util.errorMessage("Could not remove data layer.");
       e.printStackTrace();
     }
   }
 }
Esempio n. 5
0
 @Override
 public IDataSets getDataSets() {
   return (IDataSets) Util.searchForInterface(IDataSets.class, getChildren());
 }