From 031cf03e36ba8d1031509e3d2115c7e91f12db89 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 30 Sep 2020 16:57:47 +0200 Subject: [PATCH] Error Messages Improved --- Canvas.js | 4 ++++ FloatingSpace/UiObject.js | 45 +++++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/Canvas.js b/Canvas.js index e86122018..e926c5acf 100644 --- a/Canvas.js +++ b/Canvas.js @@ -507,6 +507,7 @@ function newCanvas() { if (event.code === 'Period') { if (nodeOnFocus !== undefined) { + nodeOnFocus.payload.uiObject.valueAtAngle = false nodeOnFocus.payload.uiObject.setValue('Id: ' + nodeOnFocus.id) return } @@ -530,6 +531,7 @@ function newCanvas() { if (nodeUsingThisKey !== undefined && nodeOnFocus !== undefined) { if (nodeUsingThisKey.id === nodeOnFocus.id) { nodeOnFocus.payload.uiObject.shortcutKey = '' + nodeOnFocus.payload.uiObject.valueAtAngle = false nodeOnFocus.payload.uiObject.setValue('Shortcut Key Removed ') return } else { @@ -537,6 +539,7 @@ function newCanvas() { nodeUsingThisKey.payload.uiObject.shortcutKey = '' nodeUsingThisKey === undefined nodeOnFocus.payload.uiObject.shortcutKey = event.key + nodeOnFocus.payload.uiObject.valueAtAngle = false nodeOnFocus.payload.uiObject.setValue('Shortcut Key: Ctrl + Alt + ' + event.key) } } @@ -546,6 +549,7 @@ function newCanvas() { if (event.ctrlKey === true && event.altKey === true && nodeOnFocus !== undefined) { if (nodeOnFocus.payload.uiObject.shortcutKey !== undefined && nodeOnFocus.payload.uiObject.shortcutKey !== '') { + nodeOnFocus.payload.uiObject.valueAtAngle = false nodeOnFocus.payload.uiObject.setValue('Shortcut Key: Ctrl + Alt + ' + nodeOnFocus.payload.uiObject.shortcutKey) } } diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 91a22d8c0..9fa1f1cdc 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -619,7 +619,7 @@ function newUiObject() { let distance = nearby[0] let floatingObject = nearby[1] let nearbyNode = floatingObject.payload.node - if (compatibleTypes.indexOf('->' + nearbyNode.type + '->') >= 0 || compatibleTypes === "->*Any Node*->" ) { + if (compatibleTypes.indexOf('->' + nearbyNode.type + '->') >= 0 || compatibleTypes === "->*Any Node*->") { if (nodeDefinition.referenceAttachesTo.incompatibleTypes !== undefined) { if (nodeDefinition.referenceAttachesTo.incompatibleTypes.indexOf('->' + nearbyNode.type + '->') >= 0) { continue @@ -982,26 +982,26 @@ function newUiObject() { eventsServerClient.listenToEvent(key, 'Running', undefined, 'UiObject', onResponse, onRunning) onRunningCallBackFunction = callBackFunction - + function onResponse(message) { eventSubscriptionIdOnRunning = message.eventSubscriptionId } - + function onRunning() { if (thisObject.payload === undefined) { return } - + let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id eventsServerClient.stopListening(key, eventSubscriptionIdOnRunning, 'UiObject') - + thisObject.isRunning = true - + if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) onRunningCallBackFunctionWasCalled = true } } - + /* While it is running, it can happen that it naturally stops or is stopped not from the UI but from other means. In those cases, the stop function would never be called (from the UI). So what we will do is to call it from @@ -1012,7 +1012,7 @@ function newUiObject() { If on the other side, it is executed from the UI, then we will be processing the Stopped event twice, which in both cases will reset the menu item to its default state. */ - + let event = { type: 'Secondary Action Already Executed' } @@ -1022,45 +1022,45 @@ function newUiObject() { function setupErrorEventListener(callBackFunction) { let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id eventsServerClient.listenToEvent(key, 'Error', undefined, key, onResponse, onError) - + function onResponse(message) { eventSubscriptionIdOnError = message.eventSubscriptionId } - + function onError(message) { - + let uiObject = getTargetUiObject(message) uiObject.setErrorMessage(message.event.errorMessage, 10) - + let event = { type: 'Secondary Action Already Executed' } completeStop(callBackFunction, event) } } - + function setupWarningEventListener() { let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id eventsServerClient.listenToEvent(key, 'Warning', undefined, key, onResponse, onWarning) - + function onResponse(message) { eventSubscriptionIdOnWarning = message.eventSubscriptionId } - + function onWarning(message) { let uiObject = getTargetUiObject(message) uiObject.setWarningMessage(message.event.warningMessage, 10) } } - + function setupInfoEventListener() { let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id eventsServerClient.listenToEvent(key, 'Info', undefined, key, onResponse, onInfo) - + function onResponse(message) { eventSubscriptionIdOnInfo = message.eventSubscriptionId } - + function onInfo(message) { let uiObject = getTargetUiObject(message) uiObject.setInfoMessage(message.event.infoMessage, 10) @@ -1600,13 +1600,16 @@ function newUiObject() { let label if (radius > 6) { - const MAX_LABEL_LENGTH = 80 + const IDEAL_LABEL_LENGTH = 80 label = message if (label !== undefined && label !== null) { - if (label.length > MAX_LABEL_LENGTH) { - label = label.substring(0, MAX_LABEL_LENGTH) + '...' + if (label.length > IDEAL_LABEL_LENGTH) { + if (label.length > IDEAL_LABEL_LENGTH * 3) { + label = label.substring(0, IDEAL_LABEL_LENGTH * 3) + '...' + } + fontSize = thisObject.payload.floatingObject.currentFontSize * 2 / 4 } labelPoint = {