Esempio n. 1
0
 protected void doSave(java.io.OutputStream outputStream, java.util.Map<?, ?> options)
     throws java.io.IOException {
   genericity.language.gbind.IGbindTextPrinter printer =
       getMetaInformation().createPrinter(outputStream, this);
   genericity.language.gbind.IGbindReferenceResolverSwitch referenceResolverSwitch =
       getReferenceResolverSwitch();
   printer.setEncoding(getEncoding(options));
   referenceResolverSwitch.setOptions(options);
   for (org.eclipse.emf.ecore.EObject root : getContentsInternal()) {
     if (isLayoutInformationRecordingEnabled()) {
       layoutUtil.transferAllLayoutInformationFromModel(root);
     }
     printer.print(root);
     if (isLayoutInformationRecordingEnabled()) {
       layoutUtil.transferAllLayoutInformationToModel(root);
     }
   }
 }
Esempio n. 2
0
  protected void doLoad(java.io.InputStream inputStream, java.util.Map<?, ?> options)
      throws java.io.IOException {
    synchronized (loadingLock) {
      if (processTerminationRequested()) {
        return;
      }
      this.loadOptions = options;
      delayNotifications = true;
      resetLocationMap();
      String encoding = getEncoding(options);
      java.io.InputStream actualInputStream = inputStream;
      Object inputStreamPreProcessorProvider = null;
      if (options != null) {
        inputStreamPreProcessorProvider =
            options.get(genericity.language.gbind.IGbindOptions.INPUT_STREAM_PREPROCESSOR_PROVIDER);
      }
      if (inputStreamPreProcessorProvider != null) {
        if (inputStreamPreProcessorProvider
            instanceof genericity.language.gbind.IGbindInputStreamProcessorProvider) {
          genericity.language.gbind.IGbindInputStreamProcessorProvider provider =
              (genericity.language.gbind.IGbindInputStreamProcessorProvider)
                  inputStreamPreProcessorProvider;
          genericity.language.gbind.mopp.GbindInputStreamProcessor processor =
              provider.getInputStreamProcessor(inputStream);
          actualInputStream = processor;
        }
      }

      parser = getMetaInformation().createParser(actualInputStream, encoding);
      parser.setOptions(options);
      genericity.language.gbind.IGbindReferenceResolverSwitch referenceResolverSwitch =
          getReferenceResolverSwitch();
      referenceResolverSwitch.setOptions(options);
      genericity.language.gbind.IGbindParseResult result = parser.parse();
      // dispose parser, we don't need it anymore
      parser = null;

      if (processTerminationRequested()) {
        // do nothing if reload was already restarted
        return;
      }

      clearState();
      getContentsInternal().clear();
      org.eclipse.emf.ecore.EObject root = null;
      if (result != null) {
        root = result.getRoot();
        if (root != null) {
          if (isLayoutInformationRecordingEnabled()) {
            layoutUtil.transferAllLayoutInformationToModel(root);
          }
          if (processTerminationRequested()) {
            // the next reload will add new content
            return;
          }
          getContentsInternal().add(root);
        }
        java.util.Collection<
                genericity.language.gbind.IGbindCommand<
                    genericity.language.gbind.IGbindTextResource>>
            commands = result.getPostParseCommands();
        if (commands != null) {
          for (genericity.language.gbind.IGbindCommand<genericity.language.gbind.IGbindTextResource>
              command : commands) {
            command.execute(this);
          }
        }
      }
      getReferenceResolverSwitch().setOptions(options);
      if (getErrors().isEmpty()) {
        if (!runPostProcessors(options)) {
          return;
        }
        if (root != null) {
          runValidators(root);
        }
      }
      notifyDelayed();
    }
  }