text: ///////////////////////////////////////////////////////////////////////////
  // Copyright © 2014 - 2017 Esri. All Rights Reserved.
  //
  // Licensed under the Apache License Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //    http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  ///////////////////////////////////////////////////////////////////////////
  
  define(['dojo/_base/declare',
    'dojo/Deferred',
    'dojo/_base/lang',
    'dijit/_TemplatedMixin',
    'jimu/dijit/SpatialFilterByFeatures',
    'jimu/utils',
    './BaseFeatureSetEditor',
    'dojo/text!./SelectFeatureSetFromLayer.html',
    'esri/tasks/query'
  ], function(declare, Deferred, lang, _TemplatedMixin, SpatialFilterByFeatures, jimuUtils,
   BaseFeatureSetEditor, template, Query){
    //from layers in map
    var clazz = declare([BaseFeatureSetEditor, _TemplatedMixin], {
      templateString: template,
      editorName: 'SelectFeatureSetFromLayer',
  
      postCreate: function(){
        this.inherited(arguments);
  
        this.spatialFilterByFeatures = new SpatialFilterByFeatures({
          map: this.map,
          types: this.param.defaultValue && this.param.defaultValue.geometryType?
                 [jimuUtils.getTypeByGeometryType(this.param.defaultValue.geometryType)]:
                 ['point', 'polyline', 'polygon']
        });
        this.spatialFilterByFeatures.placeAt(this.layerChooseNode);
        this.spatialFilterByFeatures.startup();
      },
  
      getGPValue: function(){
        if(this.activeViewIndex === 0) {
          var def = new Deferred();
  
          this.spatialFilterByFeatures.getFeatureSet(true).then(lang.hitch(this, function(featureSet){
            def.resolve(featureSet);
          }), lang.hitch(this, function(err){
            if(err && err.type === SpatialFilterByFeatures.NONE_SELECTED_FEATURES_NOT_DRAW_SHAPES){
              var layer = this.spatialFilterByFeatures.getSelectedLayer();
              if(layer && layer.url){
                var query = new Query();
                query.where = '1=1';
                layer.queryFeatures(query).then(lang.hitch(this, function(response){
                  def.resolve(response);
                }), lang.hitch(this, function(error){
                  def.reject(error);
                }));
              }else{
                def.reject(err);
              }
            }else{
              def.reject(err);
            }
          }));
  
          return def;
        } else {
          return this.wrapValueToDeferred(this.getFeatureSet());
        }
      }
    });
  
    return clazz;
  });
  