Menu Items with secondary Action implemented
This commit is contained in:
1 parent
1854d73ea4
commit
065efd6017
7 files changed
+253
-181
No files matched your search
@@ -57,6 +57,12 @@ function newCircularMenu () {
|
||||
menuItem.workingLabel = menuItemInitialValue.workingLabel
|
||||
menuItem.workDoneLabel = menuItemInitialValue.workDoneLabel
|
||||
menuItem.workFailedLabel = menuItemInitialValue.workFailedLabel
|
||||
menuItem.secondaryAction = menuItemInitialValue.secondaryAction
|
||||
menuItem.secondaryLabel = menuItemInitialValue.secondaryLabel
|
||||
menuItem.secondaryWorkingLabel = menuItemInitialValue.secondaryWorkingLabel
|
||||
menuItem.secondaryWorkDoneLabel = menuItemInitialValue.secondaryWorkDoneLabel
|
||||
menuItem.secondaryWorkFailedLabel = menuItemInitialValue.secondaryWorkFailedLabel
|
||||
menuItem.secondaryIcon = menuItemInitialValue.secondaryIcon
|
||||
menuItem.visible = menuItemInitialValue.visible
|
||||
menuItem.iconPathOn = menuItemInitialValue.iconPathOn
|
||||
menuItem.iconPathOff = menuItemInitialValue.iconPathOff
|
||||
@@ -91,7 +97,9 @@ function newCircularMenu () {
|
||||
if (thisObject.isDeployed === true) {
|
||||
for (let i = 0; i < menuItems.length; i++) {
|
||||
let menutItem = menuItems[i]
|
||||
container = menutItem.getContainer(point)
|
||||
if (menutItem.visible === true) {
|
||||
container = menutItem.getContainer(point)
|
||||
}
|
||||
if (container !== undefined) { return container }
|
||||
}
|
||||
}
|
||||
@@ -125,14 +133,18 @@ function newCircularMenu () {
|
||||
function drawBackground (pFloatingObject) {
|
||||
for (let i = 0; i < menuItems.length; i++) {
|
||||
let menutItem = menuItems[i]
|
||||
menutItem.drawBackground()
|
||||
if (menutItem.visible === true) {
|
||||
menutItem.drawBackground()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function drawForeground (pFloatingObject) {
|
||||
for (let i = 0; i < menuItems.length; i++) {
|
||||
let menutItem = menuItems[i]
|
||||
menutItem.drawForeground()
|
||||
if (menutItem.visible === true) {
|
||||
menutItem.drawForeground()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,12 @@ function newCircularMenuItem () {
|
||||
workingLabel: undefined,
|
||||
workDoneLabel: undefined,
|
||||
workFailedLabel: undefined,
|
||||
secondaryAction: undefined,
|
||||
secondaryLabel: undefined,
|
||||
secondaryWorkingLabel: undefined,
|
||||
secondaryWorkDoneLabel: undefined,
|
||||
secondaryWorkFailedLabel: undefined,
|
||||
secondaryIcon: undefined,
|
||||
visible: false,
|
||||
iconPathOn: undefined,
|
||||
iconPathOff: undefined,
|
||||
@@ -59,6 +65,12 @@ function newCircularMenuItem () {
|
||||
let temporaryStatus = 0
|
||||
|
||||
const EXTRA_MOUSE_OVER_ICON_SIZE = 2
|
||||
|
||||
const STATUS_DEFAULT = 0
|
||||
const STATUS_WORKING = -1
|
||||
const STAtUS_SECONDARY_WORKING = -2
|
||||
const STATUS_PRIMARY_WORK_DONE = -3
|
||||
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
@@ -127,7 +139,7 @@ function newCircularMenuItem () {
|
||||
temporaryStatus--
|
||||
}
|
||||
|
||||
if (temporaryStatus === 0) {
|
||||
if (temporaryStatus === STATUS_DEFAULT) {
|
||||
labelToPrint = thisObject.label
|
||||
backgroundColorToUse = defaultBackgroudColor
|
||||
}
|
||||
@@ -136,12 +148,17 @@ function newCircularMenuItem () {
|
||||
}
|
||||
|
||||
function iconPhysics () {
|
||||
if (thisObject.relatedStrategyPart !== undefined) {
|
||||
thisObject.iconOn = canvas.strategySpace.iconByPartType.get(thisObject.relatedStrategyPart)
|
||||
thisObject.iconOff = canvas.strategySpace.iconByPartType.get(thisObject.relatedStrategyPart)
|
||||
if (temporaryStatus === STATUS_PRIMARY_WORK_DONE || temporaryStatus === STAtUS_SECONDARY_WORKING) {
|
||||
thisObject.iconOn = canvas.strategySpace.iconCollection.get(thisObject.secondaryIcon)
|
||||
thisObject.iconOff = canvas.strategySpace.iconCollection.get(thisObject.secondaryIcon)
|
||||
} else {
|
||||
thisObject.iconOn = canvas.strategySpace.iconCollection.get(thisObject.iconPathOn)
|
||||
thisObject.iconOff = canvas.strategySpace.iconCollection.get(thisObject.iconPathOff)
|
||||
if (thisObject.relatedStrategyPart !== undefined) {
|
||||
thisObject.iconOn = canvas.strategySpace.iconByPartType.get(thisObject.relatedStrategyPart)
|
||||
thisObject.iconOff = canvas.strategySpace.iconByPartType.get(thisObject.relatedStrategyPart)
|
||||
} else {
|
||||
thisObject.iconOn = canvas.strategySpace.iconCollection.get(thisObject.iconPathOn)
|
||||
thisObject.iconOff = canvas.strategySpace.iconCollection.get(thisObject.iconPathOff)
|
||||
}
|
||||
}
|
||||
|
||||
/* Current Status might be linked to some other object status */
|
||||
@@ -173,7 +190,7 @@ function newCircularMenuItem () {
|
||||
|
||||
async function onMouseClick (event) {
|
||||
if (thisObject.askConfirmation !== true) { /* No confirmation is needed */
|
||||
if (temporaryStatus === 0) {
|
||||
if (temporaryStatus === STATUS_DEFAULT || temporaryStatus === STATUS_PRIMARY_WORK_DONE) {
|
||||
executeAction()
|
||||
}
|
||||
} else {
|
||||
@@ -191,22 +208,57 @@ function newCircularMenuItem () {
|
||||
}
|
||||
|
||||
function executeAction () {
|
||||
/* If there is a working label defined, we use it here. */
|
||||
if (thisObject.workingLabel !== undefined) {
|
||||
setTemporaryStatus(thisObject.workingLabel, UI_COLOR.GREY, -1) // Status will not expire, will only change with a callback. Mouse Clicks will be ignored.
|
||||
if (labelToPrint !== thisObject.workingLabel) {
|
||||
/* We need to execute the main Action */
|
||||
/* If there is a working label defined, we use it here. */
|
||||
if (thisObject.workingLabel !== undefined) {
|
||||
setTemporaryStatus(thisObject.workingLabel, UI_COLOR.GREY, STATUS_WORKING) // Status will not expire, will only change with a callback. Mouse Clicks will be ignored.
|
||||
}
|
||||
|
||||
/* Execute the action and wait for callbacks to update our statuus. */
|
||||
thisObject.actionFunction(thisObject.payload, thisObject.action, onPrimaryCallBack)
|
||||
} else {
|
||||
/* We need to execute the secondary action. */
|
||||
if (thisObject.secondaryWorkingLabel !== undefined) {
|
||||
setTemporaryStatus(thisObject.secondaryWorkingLabel, UI_COLOR.GREY, STAtUS_SECONDARY_WORKING) // Status will not expire, will only change with a callback. Mouse Clicks will be ignored.
|
||||
}
|
||||
|
||||
/* Execute the action and wait for callbacks to update our statuus. */
|
||||
thisObject.actionFunction(thisObject.payload, thisObject.secondaryAction, onSecondaryCallBack)
|
||||
}
|
||||
|
||||
/* Execute the action and wait for callbacks to update our statuus. */
|
||||
thisObject.actionFunction(thisObject.payload, thisObject.action, onCallBack)
|
||||
|
||||
function onCallBack (err) {
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
if (thisObject.workDoneLabel !== undefined) {
|
||||
setTemporaryStatus(thisObject.workDoneLabel, UI_COLOR.PATINATED_TURQUOISE, 250)
|
||||
function onPrimaryCallBack (err) {
|
||||
/* If there is a secondary action we will act different that if there is not */
|
||||
if (thisObject.secondaryAction === undefined) {
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
if (thisObject.workDoneLabel !== undefined) {
|
||||
setTemporaryStatus(thisObject.workDoneLabel, UI_COLOR.PATINATED_TURQUOISE, 250)
|
||||
}
|
||||
} else {
|
||||
if (thisObject.workFailedLabel != undefined) {
|
||||
setTemporaryStatus(thisObject.workFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (thisObject.workFailedLabel != undefined) {
|
||||
setTemporaryStatus(thisObject.workFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500)
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
if (thisObject.workDoneLabel !== undefined) {
|
||||
setTemporaryStatus(thisObject.secondaryLabel, defaultBackgroudColor, STATUS_PRIMARY_WORK_DONE)
|
||||
}
|
||||
} else {
|
||||
if (thisObject.workFailedLabel != undefined) {
|
||||
setTemporaryStatus(thisObject.workFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function onSecondaryCallBack (err) {
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
if (thisObject.secondaryWorkDoneLabel !== undefined) {
|
||||
setTemporaryStatus(thisObject.secondaryWorkDoneLabel, UI_COLOR.PATINATED_TURQUOISE, 250)
|
||||
}
|
||||
} else {
|
||||
if (thisObject.secondaryWorkFailedLabel != undefined) {
|
||||
setTemporaryStatus(thisObject.secondaryWorkFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ function newCircularProgressBar () {
|
||||
}
|
||||
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
systemEventHandler.createEventHandler(key)
|
||||
// systemEventHandler.createEventHandler(key)
|
||||
systemEventHandler.listenToEvent(key, 'Heartbeat', undefined, key, undefined, onHeartBeat)
|
||||
}
|
||||
|
||||
|
||||
@@ -530,7 +530,8 @@ function newStrategyPart () {
|
||||
}
|
||||
}
|
||||
|
||||
function run () {
|
||||
function run (callBackFunction) {
|
||||
/* We setup the circular progress bar. */
|
||||
if (thisObject.circularProgressBar !== undefined) {
|
||||
thisObject.circularProgressBar.finalize()
|
||||
}
|
||||
@@ -539,11 +540,23 @@ function newStrategyPart () {
|
||||
thisObject.circularProgressBar.initialize(thisObject.payload)
|
||||
thisObject.circularProgressBar.fitFunction = thisObject.fitFunction
|
||||
thisObject.circularProgressBar.container = thisObject.container
|
||||
|
||||
/* We will wait to the event that the task was terminated in order to call back the menu item */
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
systemEventHandler.listenToEvent(key, 'Task Running', undefined, key, undefined, onTaskTerminated)
|
||||
|
||||
function onTaskTerminated () {
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
}
|
||||
}
|
||||
|
||||
function stop () {
|
||||
setTimeout(removecircularProgressBar, 90000)
|
||||
function removecircularProgressBar () {
|
||||
function stop (callBackFunction) {
|
||||
/* We will wait to the event that the task was terminated in order to call back the menu item */
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
let eventSubscriptionId = systemEventHandler.listenToEvent(key, 'Task Stopped', undefined, key, undefined, onTaskTerminated)
|
||||
|
||||
function onTaskTerminated () {
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
thisObject.circularProgressBar.finalize()
|
||||
thisObject.circularProgressBar = undefined
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -8,7 +8,7 @@ function newTaskFunctions () {
|
||||
|
||||
return thisObject
|
||||
|
||||
function runTask (node, functionLibraryProtocolNode) {
|
||||
function runTask (node, functionLibraryProtocolNode, callBackFunction) {
|
||||
/* Check if it is possible to Run or not */
|
||||
if (node.bot === undefined) { return }
|
||||
if (node.bot.processes.length === 0) { return }
|
||||
@@ -18,7 +18,7 @@ function newTaskFunctions () {
|
||||
process.payload.uiObject.run()
|
||||
}
|
||||
|
||||
node.payload.uiObject.run()
|
||||
node.payload.uiObject.run(callBackFunction)
|
||||
|
||||
let event = {
|
||||
taskId: node.id,
|
||||
@@ -28,14 +28,14 @@ function newTaskFunctions () {
|
||||
systemEventHandler.raiseEvent('Task Manager', 'Run Task', event)
|
||||
}
|
||||
|
||||
function stopTask (node, functionLibraryProtocolNode) {
|
||||
function stopTask (node, functionLibraryProtocolNode, callBackFunction) {
|
||||
let event = {
|
||||
taskId: node.id,
|
||||
taskName: node.name
|
||||
}
|
||||
systemEventHandler.raiseEvent('Task Manager', 'Stop Task', event)
|
||||
|
||||
node.payload.uiObject.stop()
|
||||
node.payload.uiObject.stop(callBackFunction)
|
||||
|
||||
if (node.bot === undefined) { return }
|
||||
if (node.bot.processes.length === 0) { return }
|
||||
|
||||
@@ -227,12 +227,12 @@ function newWorkspace () {
|
||||
break
|
||||
case 'Run Task':
|
||||
{
|
||||
functionLibraryTaskFunctions.runTask(payload.node, functionLibraryProtocolNode)
|
||||
functionLibraryTaskFunctions.runTask(payload.node, functionLibraryProtocolNode, callBackFunction)
|
||||
}
|
||||
break
|
||||
case 'Stop Task':
|
||||
{
|
||||
functionLibraryTaskFunctions.stopTask(payload.node, functionLibraryProtocolNode)
|
||||
functionLibraryTaskFunctions.stopTask(payload.node, functionLibraryProtocolNode, callBackFunction)
|
||||
}
|
||||
break
|
||||
case 'Run All Tasks':
|
||||
|
||||
Reference in new issue
Block a user