How to use the blockly.FieldTextInput function in blockly

To help you get started, we’ve selected a few blockly examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github miguel76 / SparqlBlocks / src / core / exec.js View on Github external
return sparqlExec_(endpointUrl, query, function(err, data) {
    var resultField = null;
    if (err) {
      var errorDescr = err.jqXHR.responseText;
      if (errorDescr) {
        var errorDescrShort = null;
        if (errorDescr.length > DESCR_LENGTH) {
          errorDescrShort = errorDescr.substr(0, DESCR_LENGTH - 3) + '...';
        } else {
          errorDescrShort = errorDescr;
        }
        resultField = new Blockly.FieldTextInput(errorDescrShort);
        // resultField.setEditable(false);
        resultField.setTooltip(errorDescr);
      } else {
        resultField = msg.EXECUTION_CONNECTION_ERROR;
      }
    } else {
      resultField = new FieldTable(data, extraColumns);
    }
    setResult_(resultsInput, resultField);
    callback(data);
  });
};
github miguel76 / SparqlBlocks / src / blocks / exec.js View on Github external
init: function() {
    this.setHelpUrl('http://www.w3.org/TR/2013/REC-sparql11-protocol-20130321/#query-failure');
    this.setColour(330);
    this.appendDummyInput()
        .appendField(" * Error executing query! * ");
    // this.appendDummyInput()
    //     .appendField("Error Name")
    //     .appendField(new Blockly.FieldTextInput("ERROR TYPE"), "ERRORTYPE");
    this.appendDummyInput()
        // .appendField("Description")
        .appendField(new Blockly.FieldTextInput("ERROR"), "ERRORDESCR");
    this.setPreviousStatement(true, "Table");
    this.setTooltip('');
    this.setDeletable(false);
    this.setMovable(false);
    this.setEditable(false);
  }
});
github miguel76 / SparqlBlocks / src / blocks / exec.js View on Github external
init: function() {
      this.setHelpUrl('http://www.w3.org/TR/2013/REC-sparql11-protocol-20130321/#query-operation');
      var titleAndEndpointInput = null;
      if (options.title) {
        titleAndEndpointInput = this.appendDummyInput();
        titleAndEndpointInput.appendField(options.title);
      }
      if (options.endpointField) {
        // if (!titleAndEndpointInput) {
          titleAndEndpointInput = this.appendDummyInput();
        // }
        titleAndEndpointInput
            .appendField("from")
            .appendField(new Blockly.FieldTextInput(""), "ENDPOINT");
      }
      if (options.parameters && _.isArray(options.parameters)) {
        for (var i = 0; i < options.parameters.length; i++) {
          var parameter = options.parameters[i];
          if (parameter.name) {
            var input = this.appendValueInput(parameter.name);
            input.setAlign(Blockly.ALIGN_RIGHT); // or not?
            if (parameter.type) {
               input.setCheck(typeExt(parameter.type));
            }
            if (parameter.label) {
               input.appendField(parameter.label);
            }
          }
        }
      }
github miguel76 / SparqlBlocks / src / blocks / text.js View on Github external
init: function() {
    this.setHelpUrl(Blockly.Msg.TEXT_TEXT_HELPURL);
    this.setColour(HUE);
    this.appendDummyInput()
        .appendField(this.newQuote_(true))
        .appendField(new Blockly.FieldTextInput(''), 'TEXT')
        .appendField(this.newQuote_(false))
        .appendField("^^")
        .appendField(new Blockly.FieldTextInput("prefix"), "DT_PREFIX")
        .appendField(":")
        .appendField(new Blockly.FieldTextInput("localName"), "DT_LOCAL_NAME");
    this.setOutput(true, 'LiteralString');
    this.setTooltip(Msg.TEXT_WITH_TYPE_PREF_TOOLTIP);
  },
  /**
github miguel76 / SparqlBlocks / src / blocks / text.js View on Github external
init: function() {
    this.setHelpUrl(Blockly.Msg.TEXT_TEXT_HELPURL);
    this.setColour(HUE);
    this.appendDummyInput()
        .appendField(this.newQuote_(true))
        .appendField(new Blockly.FieldTextInput(''), 'TEXT')
        .appendField(this.newQuote_(false))
        .appendField("^^")
        .appendField(new Blockly.FieldTextInput("prefix"), "DT_PREFIX")
        .appendField(":")
        .appendField(new Blockly.FieldTextInput("localName"), "DT_LOCAL_NAME");
    this.setOutput(true, 'LiteralString');
    this.setTooltip(Msg.TEXT_WITH_TYPE_PREF_TOOLTIP);
  },
  /**
github miguel76 / SparqlBlocks / src / blocks / resources.js View on Github external
onchange: function(e) {
    if (e.blockId == this.id && !this.usesPrefix_() && e.recordUndo
        && e.type == Blockly.Events.CHANGE && e.element == 'field') {
      var luRes = Prefixes.lookForIri(e.newValue);
      if (luRes) {
        var oldMutation = Blockly.Xml.domToText(this.mutationToDom());
        this.removeInput('RESOURCE');
        this.appendDummyInput('RESOURCE')
            .appendField(new Blockly.FieldTextInput(luRes.prefix), "PREFIX")
            .appendField(":")
            .appendField(new Blockly.FieldTextInput(luRes.localPart), "LOCAL_NAME");
        var newMutation = Blockly.Xml.domToText(this.mutationToDom());
        var mutationEvent = new Blockly.Events.Change(
                this, 'mutation', null, oldMutation, newMutation);
        var changePrefixEvent = new Blockly.Events.Change(
                this, 'field', 'PREFIX', '', luRes.prefix);
        var changeLocalEvent = new Blockly.Events.Change(
                this, 'field', 'LOCAL_NAME', '', luRes.localPart);
        mutationEvent.group = e.group;
        changePrefixEvent.group = e.group;
        changeLocalEvent.group = e.group;
        Blockly.Events.fire(mutationEvent);
        Blockly.Events.fire(changePrefixEvent);
        Blockly.Events.fire(changeLocalEvent);
      }
    }
    Resources.saveResource(this);
github miguel76 / SparqlBlocks / src / blocks / resources.js View on Github external
domToMutation: function(xmlElement) {
    var attrUsesPrefix = xmlElement.getAttribute('uses_prefix')
    if (attrUsesPrefix && attrUsesPrefix == 'true' && !this.usesPrefix_()) {
      this.removeInput('RESOURCE');
      this.appendDummyInput('RESOURCE')
          .appendField(new Blockly.FieldTextInput(''), 'PREFIX')
          .appendField(':')
          .appendField(new Blockly.FieldTextInput(''), 'LOCAL_NAME');
    } else if (this.usesPrefix_()) {
      this.removeInput('RESOURCE');
      this.appendDummyInput('RESOURCE')
          .appendField('<')
          .appendField(new Blockly.FieldTextInput(''), 'IRI')
          .appendField('>');
    }
  }
github miguel76 / SparqlBlocks / src / blocks / text.js View on Github external
init: function() {
    this.setHelpUrl(Blockly.Msg.TEXT_TEXT_HELPURL);
    this.setColour(HUE);
    this.appendDummyInput()
        .appendField(this.newQuote_(true))
        .appendField(new Blockly.FieldTextInput(''), 'TEXT')
        .appendField(this.newQuote_(false))
        .appendField("@")
        .appendField(new Blockly.FieldTextInput(''), 'LANG');
    this.setOutput(true, 'LiteralString');
    this.setTooltip(Msg.TEXT_WITH_LANG_TOOLTIP);
  },
  /**
github miguel76 / SparqlBlocks / src / blocks / query.js View on Github external
init: function() {
    this.setHelpUrl('http://www.w3.org/TR/sparql11-query/#selectExpressions');
    this.setColour(330);
    this.appendValueInput("EXPR")
        .setCheck(typeExt("Expr"));
    this.appendDummyInput()
        .appendField("as")
        .appendField(new Blockly.FieldTextInput("col name"), "COLNAME");
    this.setInputsInline(true);
    this.setPreviousStatement(true, "VarBindings");
    this.setNextStatement(true, "VarBindings");
    this.setTooltip('');
  }
});
github miguel76 / SparqlBlocks / src / blocks / resources.js View on Github external
onchange: function(e) {
    if (e.blockId == this.id && !this.usesPrefix_() && e.recordUndo
        && e.type == Blockly.Events.CHANGE && e.element == 'field') {
      var luRes = Prefixes.lookForIri(e.newValue);
      if (luRes) {
        var oldMutation = Blockly.Xml.domToText(this.mutationToDom());
        this.removeInput('RESOURCE');
        this.appendDummyInput('RESOURCE')
            .appendField(new Blockly.FieldTextInput(luRes.prefix), "PREFIX")
            .appendField(":")
            .appendField(new Blockly.FieldTextInput(luRes.localPart), "LOCAL_NAME");
        var newMutation = Blockly.Xml.domToText(this.mutationToDom());
        var mutationEvent = new Blockly.Events.Change(
                this, 'mutation', null, oldMutation, newMutation);
        var changePrefixEvent = new Blockly.Events.Change(
                this, 'field', 'PREFIX', '', luRes.prefix);
        var changeLocalEvent = new Blockly.Events.Change(
                this, 'field', 'LOCAL_NAME', '', luRes.localPart);
        mutationEvent.group = e.group;
        changePrefixEvent.group = e.group;
        changeLocalEvent.group = e.group;
        Blockly.Events.fire(mutationEvent);
        Blockly.Events.fire(changePrefixEvent);
        Blockly.Events.fire(changeLocalEvent);
      }