10 import QtQuick.Controls 2.15
11 import QtQuick.Layouts 1.4
26 property var filenameHelper: FilenameHelper
29 property var targetModel
31 property var commandCallback
33 property var editorDescription
35 property var dialogManager
42 property var getPropertyDescriptions: function(component) {
45 console.log(
"Component is null");
48 else if (!component.base_properties) {
49 console.log(
"Component dosn't contains a property set");
52 else if (!component.base_properties.property_set_description) {
53 console.log(
"Component dosn't contains a property set description");
57 return component.base_properties.property_set_description.property_descriptions;
61 property var getProperties:
function(component) {
64 console.log(
"Component is null");
67 else if (!component.base_properties) {
68 console.log(
"Component dosn't contains a property set");
72 return component.base_properties.properties;
82 function findService(name) {
84 Utils.each(modelmanager.system.services,
function(service) {
85 if(service.name === name) {
99 function findProperty(component, name) {
100 var properties = getProperties(component)
103 Utils.each(properties,
function(prop) {
104 if (prop.name === name) {
118 function findPropertyDescription(component, name) {
119 var propertyDescs = getPropertyDescriptions(component)
122 Utils.each(propertyDescs,
function(prop) {
123 if (prop.name === name) {
139 function createProperty(component, name, value, type, link) {
140 var description = findPropertyDescription(component, name)
142 if (link === undefined) {
147 if (type !== undefined) {
148 commandCallback(
function(options) {
149 return component.base_properties.createDynamicProperty(name, value, type, link, options)
154 console.error(
"Could not find Plugindescription for property " + name)
158 commandCallback(
function(options) {
159 return component.base_properties.createProperty(description, value, link, options)
168 function removeAllPropertiesWithPrefix(component, prefix)
170 var properties = getProperties(component)
171 var count = properties.rowCount();
173 for(var i = count-1; i >= 0; --i)
175 var index = properties.index(i,0);
176 var prop = properties.data(index, 256);
178 if(prop.name.startsWith(prefix))
180 commandCallback(
function(options)
182 return component.base_properties.removeProperty(prop, options)
194 function setProperty(component, name, value) {
195 console.assert(commandCallback,
"Command callback not found")
196 console.assert(component,
"Component not set")
198 var
property = findProperty(component, name)
200 commandCallback(
function(options) {
201 return property.changeValue(value, options)
205 createProperty(component, name, value)
215 function getPropertyValue(component, name) {
216 console.assert(component,
"Component not set")
218 const property = findProperty(component, name)
220 return property.value
223 const description = findPropertyDescription(component, name)
225 return description.value
228 console.error(
"Property not found")
237 function findInputPin(name) {
239 Utils.each(targetModel.input_pins,
function(pin) {
240 if (pin.name === name) {
251 function createInputPin(name) {
252 const pin = findInputPin(name)
254 commandCallback(
function(options) {
255 return targetModel.addInputPin(name, options)
264 function listInputPins() {
266 Utils.each(targetModel.input_pins,
function(pin) {
276 function removeInputPin(pin) {
277 commandCallback(
function(options) {
278 return targetModel.removeInputPin(pin, options)
287 function findOutputPin(name) {
289 Utils.each(targetModel.output_pins,
function(pin) {
290 if (pin.name === name) {
301 function createOutputPin(name) {
302 const pin = findOutputPin(name)
304 commandCallback(
function(options) {
305 return targetModel.addOutputPin(name, options)
314 function listOutputPins() {
316 Utils.each(targetModel.output_pins,
function(pin) {
326 function removeOutputPin(pin) {
327 commandCallback(
function(options) {
328 return targetModel.removeOutputPin(pin, options)
336 function listRunner()
339 Utils.each(targetModel.runners,
function(runner) {
340 names.push(runner.name)
350 function findRunner(runnerName) {
352 Utils.each(targetModel.runners,
function(runner) {
353 if (runner.name === runnerName) {
364 function createRunner(name) {
365 const runner = findRunner(name)
367 commandCallback(
function(options) {
368 return targetModel.addRunner(name, options)
377 function removeRunner(runner) {
378 commandCallback(
function(options) {
379 return targetModel.removeRunner(runner, options)
391 function resolveAndGetAbsoluteUrl(path, basePath) {
395 return editorDescription.GetAbsoluteUrl(path, basePath)
402 function getPropertyFile() {
403 return targetModel.base_properties.getPropertyFileUrl()
414 function launch(command, args, workingDirectory) {
415 return editorDescription.Launch(command, args, workingDirectory)
425 function parseJsonResult(result)
427 console.log(
"result: " + result)
428 var regex = /json_result:([\s\S]*):end/i
430 var match = regex.exec(result);
431 if(match.length < 2) {
432 throw "Couldn't find Json string"
435 var json_result = match[1]
436 json_result = json_result.replace(/(\r\n|\n|\r)/gm,
"")
438 console.log(
"json_result: " + json_result)
440 return JSON.parse(json_result)
448 function forEach(array, callback) {
449 Utils.each(array, callback)
457 function removeFromArray(array, callback) {
459 forEach(array,
function(item) {
475 function contains(array, value, compare_callback) {
477 forEach(array,
function(item) {
478 if(compare_callback && compare_callback(item, value)) {
481 else if(item === value) {
500 function getContext(model) {
502 if (!model) model = targetModel;
505 return modelmanager.getContext(targetModel);
512 function getEnvironmentFiles() {
513 let context = root.getContext();
515 Utils.each(context[
"environment"].environmentfiles, item => result.push(item));
523 function getPlugindescriptionFiles() {
524 let context = root.getContext();
526 Utils.each(context[
"plugindescription"].plugindescriptions, item => result.push(item));
534 function getGraph() {
535 let context = root.getContext();
536 return context[
"graph"];
543 function getSystem() {
544 let context = root.getContext();
545 return context[
"system"];
552 function getSession() {
553 let context = root.getContext();
554 return context[
"session"];
558 Component.onCompleted: {