http://git-wip-us.apache.org/repos/asf/nifi/blob/bf3b1640/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js
----------------------------------------------------------------------
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js
index 05bf2af..4be7299 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js
@@ -14,10 +14,44 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/* global nf, d3 */
-
-nf.CanvasUtils = (function () {
+/* global define, module, require, exports */
+
+(function (root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ define(['d3',
+ 'jquery',
+ 'nf.Common',
+ 'nf.Dialog',
+ 'nf.Clipboard',
+ 'nf.Storage'],
+ function (d3, $, common, dialog, clipboard, storage) {
+ return (nf.CanvasUtils = factory(d3, $, common, dialog,
clipboard, storage));
+ });
+ } else if (typeof exports === 'object' && typeof module === 'object') {
+ module.exports = (nf.CanvasUtils = factory(
+ require('d3'),
+ require('jquery'),
+ require('nf.Common'),
+ require('nf.Dialog'),
+ require('nf.Clipboard'),
+ require('nf.Storage')));
+ } else {
+ nf.CanvasUtils = factory(
+ root.d3,
+ root.$,
+ root.nf.Common,
+ root.nf.Dialog,
+ root.nf.Clipboard,
+ root.nf.Storage);
+ }
+}(this, function (d3, $, common, dialog, clipboard, storage) {
+ 'use strict';
+
+ var nfCanvas;
+ var nfActions;
+ var nfSnippet;
+ var nfBirdseye;
+ var nfGraph;
var config = {
storage: {
@@ -50,14 +84,14 @@ nf.CanvasUtils = (function () {
return mid;
};
-
+
var moveComponents = function (components, groupId) {
return $.Deferred(function (deferred) {
// create a snippet for the specified components
- var snippet = nf.Snippet.marshal(components);
- nf.Snippet.create(snippet).done(function (response) {
+ var snippet = nfSnippet.marshal(components);
+ nfSnippet.create(snippet).done(function (response) {
// move the snippet into the target
- nf.Snippet.move(response.snippet.id, groupId).done(function ()
{
+ nfSnippet.move(response.snippet.id, groupId).done(function () {
var componentMap = d3.map();
// add the id to the type's array
@@ -75,22 +109,41 @@ nf.CanvasUtils = (function () {
// refresh all component types as necessary (handle
components that have been removed)
componentMap.forEach(function (type, ids) {
- nf[type].remove(ids);
- });
+ nfCanvasUtils.getComponentByType(type).remove(ids);
+ });â¨â¨
// refresh the birdseye
- nf.Birdseye.refresh();
+ nfBirdseye.refresh();
+
deferred.resolve();
- }).fail(nf.Common.handleAjaxError).fail(function () {
+ }).fail(common.handleAjaxError).fail(function () {
deferred.reject();
});
- }).fail(nf.Common.handleAjaxError).fail(function () {
+ }).fail(common.handleAjaxError).fail(function () {
deferred.reject();
});
}).promise();
};
- return {
+ var nfCanvasUtils = {
+
+ /**
+ * Initialize the canvas utils.
+ *
+ * @param canvas The reference to the canvas controller.
+ * @param actions The reference to the actions controller.
+ * @param snippet The reference to the snippet controller.
+ * @param birdseye The reference to the birdseye controller.
+ * @param graph The reference to the graph controller.
+ */
+ init: function(canvas, actions, snippet, birdseye, graph){
+ nfCanvas = canvas;
+ nfActions = actions;
+ nfSnippet = snippet;
+ nfBirdseye = birdseye;
+ nfGraph = graph;
+ },
+
config: {
systemTooltipConfig: {
style: {
@@ -111,9 +164,18 @@ nf.CanvasUtils = (function () {
},
/**
+ * Gets a graph component `type`.
+ *
+ * @param type The type of component.
+ */
+ getComponentByType: function (type) {
+ return nfGraph.getComponentByType(type);
+ },
+
+ /**
* Calculates the point on the specified bounding box that is closest
to the
* specified point.
- *
+ *
* @param {object} p The point
* @param {object} bBox The bounding box
*/
@@ -170,7 +232,7 @@ nf.CanvasUtils = (function () {
};
}
},
-
+
/**
* Shows the specified component in the specified group.
*
@@ -179,19 +241,19 @@ nf.CanvasUtils = (function () {
*/
showComponent: function (groupId, componentId) {
// ensure the group id is specified
- if (nf.Common.isDefinedAndNotNull(groupId)) {
+ if (common.isDefinedAndNotNull(groupId)) {
// initiate a graph refresh
var refreshGraph = $.Deferred(function (deferred) {
// load a different group if necessary
- if (groupId !== nf.Canvas.getGroupId()) {
+ if (groupId !== nfCanvas.getGroupId()) {
// set the new group id
- nf.Canvas.setGroupId(groupId);
+ nfCanvas.setGroupId(groupId);
// reload
- nf.Canvas.reload().done(function () {
+ nfCanvas.reload().done(function () {
deferred.resolve();
}).fail(function () {
- nf.Dialog.showOkDialog({
+ dialog.showOkDialog({
headerText: 'Process Group',
dialogContent: 'Unable to load the group for
the specified component.'
});
@@ -207,9 +269,9 @@ nf.CanvasUtils = (function () {
// attempt to locate the corresponding component
var component = d3.select('#id-' + componentId);
if (!component.empty()) {
- nf.Actions.show(component);
+ nfActions.show(component);
} else {
- nf.Dialog.showOkDialog({
+ dialog.showOkDialog({
headerText: 'Process Group',
dialogContent: 'Unable to find the specified
component.'
});
@@ -217,10 +279,10 @@ nf.CanvasUtils = (function () {
});
}
},
-
+
/**
* Gets the currently selected components and connections.
- *
+ *
* @returns {selection} The currently selected components and
connections
*/
getSelection: function () {
@@ -229,11 +291,11 @@ nf.CanvasUtils = (function () {
/**
* Centers the specified bounding box.
- *
+ *
* @param {type} boundingBox
*/
centerBoundingBox: function (boundingBox) {
- var scale = nf.Canvas.View.scale();
+ var scale = nfCanvas.View.scale();
// get the canvas normalized width and height
var canvasContainer = $('#canvas-container');
@@ -244,32 +306,32 @@ nf.CanvasUtils = (function () {
var center = [(screenWidth / 2) - (boundingBox.width / 2),
(screenHeight / 2) - (boundingBox.height / 2)];
// calculate the difference between the center point and the
position of this component and convert to screen space
- nf.Canvas.View.translate([(center[0] - boundingBox.x) * scale,
(center[1] - boundingBox.y) * scale]);
+ nfCanvas.View.translate([(center[0] - boundingBox.x) * scale,
(center[1] - boundingBox.y) * scale]);
},
/**
* Enables/disables the editable behavior for the specified selection
based on their access policies.
- *
+ *
* @param selection selection
*/
- editable: function (selection) {
- if (nf.CanvasUtils.canModify(selection)) {
+ editable: function (selection, connectable, draggable) {
+ if (nfCanvasUtils.canModify(selection)) {
if (!selection.classed('connectable')) {
- selection.call(nf.Connectable.activate);
+ selection.call(connectable.activate);
}
if (!selection.classed('moveable')) {
- selection.call(nf.Draggable.activate);
+ selection.call(draggable.activate);
}
} else {
if (selection.classed('connectable')) {
- selection.call(nf.Connectable.deactivate);
+ selection.call(connectable.deactivate);
}
if (selection.classed('moveable')) {
- selection.call(nf.Draggable.deactivate);
+ selection.call(draggable.deactivate);
}
}
},
-
+
/**
* Conditionally apply the transition.
*
@@ -286,23 +348,23 @@ nf.CanvasUtils = (function () {
/**
* Position the component accordingly.
- *
+ *
* @param {selection} updated
*/
position: function (updated, transition) {
if (updated.empty()) {
return;
}
-
- return nf.CanvasUtils.transition(updated, transition)
+
+ return nfCanvasUtils.transition(updated, transition)
.attr('transform', function (d) {
return 'translate(' + d.position.x + ', ' + d.position.y +
')';
});
},
-
+
/**
* Applies single line ellipsis to the component in the specified
selection if necessary.
- *
+ *
* @param {selection} selection
* @param {string} text
*/
@@ -335,11 +397,11 @@ nf.CanvasUtils = (function () {
selection.text(text.substring(0, i) +
String.fromCharCode(8230));
}
},
-
+
/**
* Applies multiline ellipsis to the component in the specified
seleciton. Text will
* wrap for the specified number of lines. The last line will be
ellipsis if necessary.
- *
+ *
* @param {selection} selection
* @param {integer} lineCount
* @param {string} text
@@ -355,15 +417,15 @@ nf.CanvasUtils = (function () {
var line = [];
var tspan = selection.append('tspan')
- .attr({
- 'x': x,
- 'y': y,
- 'width': width
- });
+ .attr({
+ 'x': x,
+ 'y': y,
+ 'width': width
+ });
// go through each word
var word = words.pop();
- while (nf.Common.isDefinedAndNotNull(word)) {
+ while (common.isDefinedAndNotNull(word)) {
// add the current word
line.push(word);
@@ -380,20 +442,20 @@ nf.CanvasUtils = (function () {
// create the tspan for the next line
tspan = selection.append('tspan')
- .attr({
- 'x': x,
- 'dy': '1.2em',
- 'width': width
- });
+ .attr({
+ 'x': x,
+ 'dy': '1.2em',
+ 'width': width
+ });
// if we've reached the last line, use single line ellipsis
if (++i >= lineCount) {
- // get the remainder using the current word and
+ // get the remainder using the current word and
// reversing whats left
var remainder = [word].concat(words.reverse());
// apply ellipsis to the last line
- nf.CanvasUtils.ellipsis(tspan, remainder.join(' '));
+ nfCanvasUtils.ellipsis(tspan, remainder.join(' '));
// we've reached the line count
break;
@@ -409,52 +471,52 @@ nf.CanvasUtils = (function () {
word = words.pop();
}
},
-
+
/**
* Updates the active thread count on the specified selection.
- *
+ *
* @param {selection} selection The selection
* @param {object} d The data
* @param {function} setOffset Optional function to handle
the width of the active thread count component
- * @return
+ * @return
*/
activeThreadCount: function (selection, d, setOffset) {
// if there is active threads show the count, otherwise hide
if (d.status.aggregateSnapshot.activeThreadCount > 0) {
// update the active thread count
var activeThreadCount =
selection.select('text.active-thread-count')
- .text(function () {
- return
d.status.aggregateSnapshot.activeThreadCount;
- })
- .style('display', 'block')
- .each(function () {
- var bBox = this.getBBox();
- d3.select(this).attr('x', function () {
- return d.dimensions.width - bBox.width - 15;
- });
+ .text(function () {
+ return d.status.aggregateSnapshot.activeThreadCount;
+ })
+ .style('display', 'block')
+ .each(function () {
+ var bBox = this.getBBox();
+ d3.select(this).attr('x', function () {
+ return d.dimensions.width - bBox.width - 15;
});
+ });
// update the background width
selection.select('text.active-thread-count-icon')
- .attr('x', function () {
- var bBox = activeThreadCount.node().getBBox();
+ .attr('x', function () {
+ var bBox = activeThreadCount.node().getBBox();
- // update the offset
- if (typeof setOffset === 'function') {
- setOffset(bBox.width + 6);
- }
+ // update the offset
+ if (typeof setOffset === 'function') {
+ setOffset(bBox.width + 6);
+ }
- return d.dimensions.width - bBox.width - 20;
- })
- .style('display', 'block');
+ return d.dimensions.width - bBox.width - 20;
+ })
+ .style('display', 'block');
} else {
selection.selectAll('text.active-thread-count,
text.active-thread-count-icon').style('display', 'none');
}
},
-
+
/**
* Disables the default browser behavior of following image href when
control clicking.
- *
+ *
* @param {selection} selection The image
*/
disableImageHref: function (selection) {
@@ -464,30 +526,30 @@ nf.CanvasUtils = (function () {
}
});
},
-
+
/**
* Handles component bulletins.
- *
+ *
* @param {selection} selection The component
* @param {object} d The data
* @param {function} getTooltipContainer Function to get
the tooltip container
* @param {function} offset Optional offset
*/
bulletins: function (selection, d, getTooltipContainer, offset) {
- offset = nf.Common.isDefinedAndNotNull(offset) ? offset : 0;
+ offset = common.isDefinedAndNotNull(offset) ? offset : 0;
// get the tip
var tip = d3.select('#bulletin-tip-' + d.id);
var hasBulletins = false;
- if (!nf.Common.isEmpty(d.bulletins)) {
+ if (!common.isEmpty(d.bulletins)) {
// format the bulletins
- var bulletins = nf.Common.getFormattedBulletins(d.bulletins);
+ var bulletins = common.getFormattedBulletins(d.bulletins);
hasBulletins = bulletins.length > 0;
if (hasBulletins) {
// create the unordered list based off the formatted
bulletins
- var list = nf.Common.formatUnorderedList(bulletins);
+ var list = common.formatUnorderedList(bulletins);
}
}
@@ -495,24 +557,24 @@ nf.CanvasUtils = (function () {
if (hasBulletins) {
// update the tooltip
selection.select('text.bulletin-icon')
- .each(function () {
- // create the tip if necessary
- if (tip.empty()) {
- tip = getTooltipContainer().append('div')
- .attr('id', function () {
- return 'bulletin-tip-' + d.id;
- })
- .attr('class', 'tooltip nifi-tooltip');
- }
-
- // add the tooltip
- tip.html(function () {
- return $('<div></div>').append(list).html();
- });
+ .each(function () {
+ // create the tip if necessary
+ if (tip.empty()) {
+ tip = getTooltipContainer().append('div')
+ .attr('id', function () {
+ return 'bulletin-tip-' + d.id;
+ })
+ .attr('class', 'tooltip nifi-tooltip');
+ }
- nf.CanvasUtils.canvasTooltip(tip, d3.select(this));
+ // add the tooltip
+ tip.html(function () {
+ return $('<div></div>').append(list).html();
});
+ nfCanvasUtils.canvasTooltip(tip, d3.select(this));
+ });
+
// update the tooltip background
selection.select('text.bulletin-icon').style("visibility",
"visible");
selection.select('rect.bulletin-background').style("visibility", "visible");
@@ -527,10 +589,10 @@ nf.CanvasUtils = (function () {
selection.select('rect.bulletin-background').style("visibility", "hidden");
}
},
-
+
/**
* Adds the specified tooltip to the specified target.
- *
+ *
* @param {selection} tip The tooltip
* @param {selection} target The target of the tooltip
*/
@@ -538,12 +600,12 @@ nf.CanvasUtils = (function () {
target.on('mouseenter', function () {
tip.style('top', (d3.event.pageY + 15) + 'px').style('left',
(d3.event.pageX + 15) + 'px').style('display', 'block');
})
- .on('mousemove', function () {
- tip.style('top', (d3.event.pageY + 15) + 'px').style('left',
(d3.event.pageX + 15) + 'px');
- })
- .on('mouseleave', function () {
- tip.style('display', 'none');
- });
+ .on('mousemove', function () {
+ tip.style('top', (d3.event.pageY + 15) +
'px').style('left', (d3.event.pageX + 15) + 'px');
+ })
+ .on('mouseleave', function () {
+ tip.style('display', 'none');
+ });
},
/**
@@ -558,7 +620,7 @@ nf.CanvasUtils = (function () {
// determine if the current selection is entirely connections
var selectedConnections = selection.filter(function(d) {
var connection = d3.select(this);
- return nf.CanvasUtils.isConnection(connection);
+ return nfCanvasUtils.isConnection(connection);
});
// require multiple selections besides connections
@@ -567,16 +629,16 @@ nf.CanvasUtils = (function () {
}
// require write permissions
- if (nf.CanvasUtils.canModify(selection) === false) {
+ if (nfCanvasUtils.canModify(selection) === false) {
canAlign = false;
}
return canAlign;
},
-
+
/**
* Determines if the specified selection is colorable (in a single
action).
- *
+ *
* @param {selection} selection The selection
* @returns {boolean}
*/
@@ -586,26 +648,26 @@ nf.CanvasUtils = (function () {
}
// require read and write permissions
- if (nf.CanvasUtils.canRead(selection) === false ||
nf.CanvasUtils.canModify(selection) === false) {
+ if (nfCanvasUtils.canRead(selection) === false ||
nfCanvasUtils.canModify(selection) === false) {
return false;
}
-
+
// determine if the current selection is entirely processors or
labels
var selectedProcessors = selection.filter(function(d) {
var processor = d3.select(this);
- return nf.CanvasUtils.isProcessor(processor) &&
nf.CanvasUtils.canModify(processor);
+ return nfCanvasUtils.isProcessor(processor) &&
nfCanvasUtils.canModify(processor);
});
var selectedLabels = selection.filter(function(d) {
var label = d3.select(this);
- return nf.CanvasUtils.isLabel(label) &&
nf.CanvasUtils.canModify(label);
+ return nfCanvasUtils.isLabel(label) &&
nfCanvasUtils.canModify(label);
});
var allProcessors = selectedProcessors.size() === selection.size();
var allLabels = selectedLabels.size() === selection.size();
-
+
return allProcessors || allLabels;
},
-
+
/**
* Determines if the specified selection is a connection.
*
@@ -614,7 +676,7 @@ nf.CanvasUtils = (function () {
isConnection: function (selection) {
return selection.classed('connection');
},
-
+
/**
* Determines if the specified selection is a remote process group.
*
@@ -623,7 +685,7 @@ nf.CanvasUtils = (function () {
isRemoteProcessGroup: function (selection) {
return selection.classed('remote-process-group');
},
-
+
/**
* Determines if the specified selection is a processor.
*
@@ -632,7 +694,7 @@ nf.CanvasUtils = (function () {
isProcessor: function (selection) {
return selection.classed('processor');
},
-
+
/**
* Determines if the specified selection is a label.
*
@@ -641,7 +703,7 @@ nf.CanvasUtils = (function () {
isLabel: function (selection) {
return selection.classed('label');
},
-
+
/**
* Determines if the specified selection is an input port.
*
@@ -650,7 +712,7 @@ nf.CanvasUtils = (function () {
isInputPort: function (selection) {
return selection.classed('input-port');
},
-
+
/**
* Determines if the specified selection is an output port.
*
@@ -659,7 +721,7 @@ nf.CanvasUtils = (function () {
isOutputPort: function (selection) {
return selection.classed('output-port');
},
-
+
/**
* Determines if the specified selection is a process group.
*
@@ -668,7 +730,7 @@ nf.CanvasUtils = (function () {
isProcessGroup: function (selection) {
return selection.classed('process-group');
},
-
+
/**
* Determines if the specified selection is a funnel.
*
@@ -677,7 +739,7 @@ nf.CanvasUtils = (function () {
isFunnel: function (selection) {
return selection.classed('funnel');
},
-
+
/**
* Determines if the components in the specified selection are
runnable.
*
@@ -691,7 +753,7 @@ nf.CanvasUtils = (function () {
var runnable = true;
selection.each(function () {
- if (!nf.CanvasUtils.isRunnable(d3.select(this))) {
+ if (!nfCanvasUtils.isRunnable(d3.select(this))) {
runnable = false;
return false;
}
@@ -699,7 +761,7 @@ nf.CanvasUtils = (function () {
return runnable;
},
-
+
/**
* Determines if the component in the specified selection is runnable.
*
@@ -711,23 +773,23 @@ nf.CanvasUtils = (function () {
return false;
}
- if (nf.CanvasUtils.isProcessGroup(selection)) {
+ if (nfCanvasUtils.isProcessGroup(selection)) {
return true;
}
- if (nf.CanvasUtils.canModify(selection) === false) {
+ if (nfCanvasUtils.canModify(selection) === false) {
return false;
}
var runnable = false;
var selectionData = selection.datum();
- if (nf.CanvasUtils.isProcessor(selection) ||
nf.CanvasUtils.isInputPort(selection) ||
nf.CanvasUtils.isOutputPort(selection)) {
- runnable = nf.CanvasUtils.supportsModification(selection) &&
selectionData.status.aggregateSnapshot.runStatus === 'Stopped';
+ if (nfCanvasUtils.isProcessor(selection) ||
nfCanvasUtils.isInputPort(selection) || nfCanvasUtils.isOutputPort(selection)) {
+ runnable = nfCanvasUtils.supportsModification(selection) &&
selectionData.status.aggregateSnapshot.runStatus === 'Stopped';
}
return runnable;
},
-
+
/**
* Determines if the components in the specified selection are
stoppable.
*
@@ -741,7 +803,7 @@ nf.CanvasUtils = (function () {
var stoppable = true;
selection.each(function () {
- if (!nf.CanvasUtils.isStoppable(d3.select(this))) {
+ if (!nfCanvasUtils.isStoppable(d3.select(this))) {
stoppable = false;
return false;
}
@@ -749,7 +811,7 @@ nf.CanvasUtils = (function () {
return stoppable;
},
-
+
/**
* Determines if the component in the specified selection is runnable.
*
@@ -761,17 +823,17 @@ nf.CanvasUtils = (function () {
return false;
}
- if (nf.CanvasUtils.isProcessGroup(selection)) {
+ if (nfCanvasUtils.isProcessGroup(selection)) {
return true;
}
- if (nf.CanvasUtils.canModify(selection) === false) {
+ if (nfCanvasUtils.canModify(selection) === false) {
return false;
}
var stoppable = false;
var selectionData = selection.datum();
- if (nf.CanvasUtils.isProcessor(selection) ||
nf.CanvasUtils.isInputPort(selection) ||
nf.CanvasUtils.isOutputPort(selection)) {
+ if (nfCanvasUtils.isProcessor(selection) ||
nfCanvasUtils.isInputPort(selection) || nfCanvasUtils.isOutputPort(selection)) {
stoppable = selectionData.status.aggregateSnapshot.runStatus
=== 'Running';
}
@@ -789,9 +851,9 @@ nf.CanvasUtils = (function () {
var selectedData = selected.datum();
// ensure its a processor, input port, or output port and
supports modification and is disabled (can enable)
- return ((nf.CanvasUtils.isProcessor(selected) ||
nf.CanvasUtils.isInputPort(selected) || nf.CanvasUtils.isOutputPort(selected))
&&
- nf.CanvasUtils.supportsModification(selected) &&
- selectedData.status.aggregateSnapshot.runStatus ===
'Disabled');
+ return ((nfCanvasUtils.isProcessor(selected) ||
nfCanvasUtils.isInputPort(selected) || nfCanvasUtils.isOutputPort(selected)) &&
+ nfCanvasUtils.supportsModification(selected) &&
+ selectedData.status.aggregateSnapshot.runStatus ===
'Disabled');
});
},
@@ -805,11 +867,11 @@ nf.CanvasUtils = (function () {
return false;
}
- if (nf.CanvasUtils.canModify(selection) === false) {
+ if (nfCanvasUtils.canModify(selection) === false) {
return false;
}
- return nf.CanvasUtils.filterEnable(selection).size() ===
selection.size();
+ return nfCanvasUtils.filterEnable(selection).size() ===
selection.size();
},
/**
@@ -823,10 +885,10 @@ nf.CanvasUtils = (function () {
var selectedData = selected.datum();
// ensure its a processor, input port, or output port and
supports modification and is stopped (can disable)
- return ((nf.CanvasUtils.isProcessor(selected) ||
nf.CanvasUtils.isInputPort(selected) || nf.CanvasUtils.isOutputPort(selected))
&&
- nf.CanvasUtils.supportsModification(selected) &&
- (selectedData.status.aggregateSnapshot.runStatus ===
'Stopped' ||
- selectedData.status.aggregateSnapshot.runStatus ===
'Invalid'));
+ return ((nfCanvasUtils.isProcessor(selected) ||
nfCanvasUtils.isInputPort(selected) || nfCanvasUtils.isOutputPort(selected)) &&
+ nfCanvasUtils.supportsModification(selected) &&
+ (selectedData.status.aggregateSnapshot.runStatus === 'Stopped'
||
+ selectedData.status.aggregateSnapshot.runStatus ===
'Invalid'));
});
},
@@ -840,11 +902,11 @@ nf.CanvasUtils = (function () {
return false;
}
- if (nf.CanvasUtils.canModify(selection) === false) {
+ if (nfCanvasUtils.canModify(selection) === false) {
return false;
}
- return nf.CanvasUtils.filterDisable(selection).size() ===
selection.size();
+ return nfCanvasUtils.filterDisable(selection).size() ===
selection.size();
},
@@ -861,7 +923,7 @@ nf.CanvasUtils = (function () {
var canStartTransmitting = true;
selection.each(function () {
- if (!nf.CanvasUtils.canStartTransmitting(d3.select(this))) {
+ if (!nfCanvasUtils.canStartTransmitting(d3.select(this))) {
canStartTransmitting = false;
}
});
@@ -878,13 +940,13 @@ nf.CanvasUtils = (function () {
return false;
}
- if (nf.CanvasUtils.canModify(selection) === false ||
nf.CanvasUtils.canRead(selection) === false) {
+ if (nfCanvasUtils.canModify(selection) === false ||
nfCanvasUtils.canRead(selection) === false) {
return false;
}
- return nf.CanvasUtils.isRemoteProcessGroup(selection);
+ return nfCanvasUtils.isRemoteProcessGroup(selection);
},
-
+
/**
* Determines if the specified selection can all stop transmitting.
*
@@ -898,13 +960,13 @@ nf.CanvasUtils = (function () {
var canStopTransmitting = true;
selection.each(function () {
- if (!nf.CanvasUtils.canStopTransmitting(d3.select(this))) {
+ if (!nfCanvasUtils.canStopTransmitting(d3.select(this))) {
canStopTransmitting = false;
}
});
return canStopTransmitting;
},
-
+
/**
* Determines if the specified selection can stop transmission.
*
@@ -915,11 +977,11 @@ nf.CanvasUtils = (function () {
return false;
}
- if (nf.CanvasUtils.canModify(selection) === false ||
nf.CanvasUtils.canRead(selection) === false) {
+ if (nfCanvasUtils.canModify(selection) === false ||
nfCanvasUtils.canRead(selection) === false) {
return false;
}
- return nf.CanvasUtils.isRemoteProcessGroup(selection);
+ return nfCanvasUtils.isRemoteProcessGroup(selection);
},
/**
@@ -935,7 +997,7 @@ nf.CanvasUtils = (function () {
var isDeletable = true;
selection.each(function () {
- if (!nf.CanvasUtils.isDeletable(d3.select(this))) {
+ if (!nfCanvasUtils.isDeletable(d3.select(this))) {
isDeletable = false;
}
});
@@ -954,15 +1016,15 @@ nf.CanvasUtils = (function () {
}
// ensure the user has write permissions to the current process
group
- if (nf.Canvas.canWrite() === false) {
+ if (nfCanvas.canWrite() === false) {
return false;
}
- if (nf.CanvasUtils.canModify(selection) === false) {
+ if (nfCanvasUtils.canModify(selection) === false) {
return false;
}
- return nf.CanvasUtils.supportsModification(selection);
+ return nfCanvasUtils.supportsModification(selection);
},
/**
@@ -976,17 +1038,17 @@ nf.CanvasUtils = (function () {
return false;
}
- if (nf.CanvasUtils.isProcessGroup(selection)) {
+ if (nfCanvasUtils.isProcessGroup(selection)) {
return true;
}
- if (nf.CanvasUtils.canRead(selection) === false ||
nf.CanvasUtils.canModify(selection) === false) {
+ if (nfCanvasUtils.canRead(selection) === false ||
nfCanvasUtils.canModify(selection) === false) {
return false;
}
- if (nf.CanvasUtils.isFunnel(selection)) {
+ if (nfCanvasUtils.isFunnel(selection)) {
return false;
}
- return nf.CanvasUtils.supportsModification(selection);
+ return nfCanvasUtils.supportsModification(selection);
},
/**
@@ -1000,15 +1062,15 @@ nf.CanvasUtils = (function () {
return false;
}
- if (nf.CanvasUtils.canRead(selection) === false) {
+ if (nfCanvasUtils.canRead(selection) === false) {
return false;
}
- if (nf.CanvasUtils.canModify(selection)) {
- if (nf.CanvasUtils.isProcessor(selection) ||
nf.CanvasUtils.isInputPort(selection) || nf.CanvasUtils.isOutputPort(selection)
|| nf.CanvasUtils.isRemoteProcessGroup(selection) ||
nf.CanvasUtils.isConnection(selection)) {
- return !nf.CanvasUtils.isConfigurable(selection);
+ if (nfCanvasUtils.canModify(selection)) {
+ if (nfCanvasUtils.isProcessor(selection) ||
nfCanvasUtils.isInputPort(selection) || nfCanvasUtils.isOutputPort(selection)
|| nfCanvasUtils.isRemoteProcessGroup(selection) ||
nfCanvasUtils.isConnection(selection)) {
+ return !nfCanvasUtils.isConfigurable(selection);
}
} else {
- return nf.CanvasUtils.isProcessor(selection) ||
nf.CanvasUtils.isConnection(selection) || nf.CanvasUtils.isInputPort(selection)
|| nf.CanvasUtils.isOutputPort(selection) ||
nf.CanvasUtils.isRemoteProcessGroup(selection);
+ return nfCanvasUtils.isProcessor(selection) ||
nfCanvasUtils.isConnection(selection) || nfCanvasUtils.isInputPort(selection)
|| nfCanvasUtils.isOutputPort(selection) ||
nfCanvasUtils.isRemoteProcessGroup(selection);
}
return false;
@@ -1025,7 +1087,7 @@ nf.CanvasUtils = (function () {
var writableSize = selection.filter(function (d) {
return d.permissions.canWrite;
}).size();
-
+
return selectionSize === writableSize;
},
@@ -1043,7 +1105,7 @@ nf.CanvasUtils = (function () {
return selectionSize === readableSize;
},
-
+
/**
* Determines whether the specified selection is in a state to support
modification.
*
@@ -1058,37 +1120,37 @@ nf.CanvasUtils = (function () {
var selectionData = selection.datum();
var supportsModification = false;
- if (nf.CanvasUtils.isProcessor(selection) ||
nf.CanvasUtils.isInputPort(selection) ||
nf.CanvasUtils.isOutputPort(selection)) {
+ if (nfCanvasUtils.isProcessor(selection) ||
nfCanvasUtils.isInputPort(selection) || nfCanvasUtils.isOutputPort(selection)) {
supportsModification =
!(selectionData.status.aggregateSnapshot.runStatus === 'Running' ||
selectionData.status.aggregateSnapshot.activeThreadCount > 0);
- } else if (nf.CanvasUtils.isRemoteProcessGroup(selection)) {
+ } else if (nfCanvasUtils.isRemoteProcessGroup(selection)) {
supportsModification =
!(selectionData.status.transmissionStatus === 'Transmitting' ||
selectionData.status.aggregateSnapshot.activeThreadCount > 0);
- } else if (nf.CanvasUtils.isProcessGroup(selection)) {
+ } else if (nfCanvasUtils.isProcessGroup(selection)) {
supportsModification = true;
- } else if (nf.CanvasUtils.isFunnel(selection)) {
+ } else if (nfCanvasUtils.isFunnel(selection)) {
supportsModification = true;
- } else if (nf.CanvasUtils.isLabel(selection)) {
+ } else if (nfCanvasUtils.isLabel(selection)) {
supportsModification = true;
- } else if (nf.CanvasUtils.isConnection(selection)) {
+ } else if (nfCanvasUtils.isConnection(selection)) {
var isSourceConfigurable = false;
var isDestinationConfigurable = false;
- var sourceComponentId =
nf.CanvasUtils.getConnectionSourceComponentId(selectionData);
+ var sourceComponentId =
nfCanvasUtils.getConnectionSourceComponentId(selectionData);
var source = d3.select('#id-' + sourceComponentId);
if (!source.empty()) {
- if (nf.CanvasUtils.isRemoteProcessGroup(source) ||
nf.CanvasUtils.isProcessGroup(source)) {
+ if (nfCanvasUtils.isRemoteProcessGroup(source) ||
nfCanvasUtils.isProcessGroup(source)) {
isSourceConfigurable = true;
} else {
- isSourceConfigurable =
nf.CanvasUtils.supportsModification(source);
+ isSourceConfigurable =
nfCanvasUtils.supportsModification(source);
}
}
- var destinationComponentId =
nf.CanvasUtils.getConnectionDestinationComponentId(selectionData);
+ var destinationComponentId =
nfCanvasUtils.getConnectionDestinationComponentId(selectionData);
var destination = d3.select('#id-' + destinationComponentId);
if (!destination.empty()) {
- if (nf.CanvasUtils.isRemoteProcessGroup(destination) ||
nf.CanvasUtils.isProcessGroup(destination)) {
+ if (nfCanvasUtils.isRemoteProcessGroup(destination) ||
nfCanvasUtils.isProcessGroup(destination)) {
isDestinationConfigurable = true;
} else {
- isDestinationConfigurable =
nf.CanvasUtils.supportsModification(destination);
+ isDestinationConfigurable =
nfCanvasUtils.supportsModification(destination);
}
}
@@ -1104,20 +1166,20 @@ nf.CanvasUtils = (function () {
*/
getConnectableTypeForSource: function (selection) {
var type;
- if (nf.CanvasUtils.isProcessor(selection)) {
+ if (nfCanvasUtils.isProcessor(selection)) {
type = 'PROCESSOR';
- } else if (nf.CanvasUtils.isRemoteProcessGroup(selection)) {
+ } else if (nfCanvasUtils.isRemoteProcessGroup(selection)) {
type = 'REMOTE_OUTPUT_PORT';
- } else if (nf.CanvasUtils.isProcessGroup(selection)) {
+ } else if (nfCanvasUtils.isProcessGroup(selection)) {
type = 'OUTPUT_PORT';
- } else if (nf.CanvasUtils.isInputPort(selection)) {
+ } else if (nfCanvasUtils.isInputPort(selection)) {
type = 'INPUT_PORT';
- } else if (nf.CanvasUtils.isFunnel(selection)) {
+ } else if (nfCanvasUtils.isFunnel(selection)) {
type = 'FUNNEL';
}
return type;
},
-
+
/**
* Determines the connectable type for the specified destination
selection.
*
@@ -1125,20 +1187,20 @@ nf.CanvasUtils = (function () {
*/
getConnectableTypeForDestination: function (selection) {
var type;
- if (nf.CanvasUtils.isProcessor(selection)) {
+ if (nfCanvasUtils.isProcessor(selection)) {
type = 'PROCESSOR';
- } else if (nf.CanvasUtils.isRemoteProcessGroup(selection)) {
+ } else if (nfCanvasUtils.isRemoteProcessGroup(selection)) {
type = 'REMOTE_INPUT_PORT';
- } else if (nf.CanvasUtils.isProcessGroup(selection)) {
+ } else if (nfCanvasUtils.isProcessGroup(selection)) {
type = 'INPUT_PORT';
- } else if (nf.CanvasUtils.isOutputPort(selection)) {
+ } else if (nfCanvasUtils.isOutputPort(selection)) {
type = 'OUTPUT_PORT';
- } else if (nf.CanvasUtils.isFunnel(selection)) {
+ } else if (nfCanvasUtils.isFunnel(selection)) {
type = 'FUNNEL';
}
return type;
},
-
+
/**
* Determines if the graph is currently in a state to copy.
*
@@ -1150,143 +1212,122 @@ nf.CanvasUtils = (function () {
return false;
}
- if (nf.CanvasUtils.canRead(selection) === false) {
+ if (nfCanvasUtils.canRead(selection) === false) {
return false;
}
// determine how many copyable components are selected
var copyable = selection.filter(function (d) {
var selected = d3.select(this);
- if (nf.CanvasUtils.isConnection(selected)) {
+ if (nfCanvasUtils.isConnection(selected)) {
var sourceIncluded = !selection.filter(function (source) {
- var sourceComponentId =
nf.CanvasUtils.getConnectionSourceComponentId(d);
+ var sourceComponentId =
nfCanvasUtils.getConnectionSourceComponentId(d);
return sourceComponentId === source.id;
}).empty();
var destinationIncluded = !selection.filter(function
(destination) {
- var destinationComponentId =
nf.CanvasUtils.getConnectionDestinationComponentId(d);
+ var destinationComponentId =
nfCanvasUtils.getConnectionDestinationComponentId(d);
return destinationComponentId === destination.id;
}).empty();
return sourceIncluded && destinationIncluded;
} else {
- return nf.CanvasUtils.isProcessor(selected) ||
nf.CanvasUtils.isFunnel(selected) || nf.CanvasUtils.isLabel(selected) ||
nf.CanvasUtils.isProcessGroup(selected) ||
nf.CanvasUtils.isRemoteProcessGroup(selected) ||
nf.CanvasUtils.isInputPort(selected) || nf.CanvasUtils.isOutputPort(selected);
+ return nfCanvasUtils.isProcessor(selected) ||
nfCanvasUtils.isFunnel(selected) || nfCanvasUtils.isLabel(selected) ||
nfCanvasUtils.isProcessGroup(selected) ||
nfCanvasUtils.isRemoteProcessGroup(selected) ||
nfCanvasUtils.isInputPort(selected) || nfCanvasUtils.isOutputPort(selected);
}
});
// ensure everything selected is copyable
return selection.size() === copyable.size();
},
-
+
/**
* Determines if something is currently pastable.
*/
isPastable: function () {
- return nf.Canvas.canWrite() && nf.Clipboard.isCopied();
+ return nfCanvas.canWrite() && clipboard.isCopied();
},
-
+
/**
* Persists the current user view.
*/
persistUserView: function () {
- var name = config.storage.namePrefix + nf.Canvas.getGroupId();
+ var name = config.storage.namePrefix + nfCanvas.getGroupId();
// create the item to store
- var translate = nf.Canvas.View.translate();
+ var translate = nfCanvas.View.translate();
var item = {
- scale: nf.Canvas.View.scale(),
+ scale: nfCanvas.View.scale(),
translateX: translate[0],
translateY: translate[1]
};
// store the item
- nf.Storage.setItem(name, item);
+ storage.setItem(name, item);
},
-
+
/**
* Gets the name for this connection.
- *
+ *
* @param {object} connection
*/
formatConnectionName: function (connection) {
- if (!nf.Common.isBlank(connection.name)) {
+ if (!common.isBlank(connection.name)) {
return connection.name;
- } else if
(nf.Common.isDefinedAndNotNull(connection.selectedRelationships)) {
+ } else if
(common.isDefinedAndNotNull(connection.selectedRelationships)) {
return connection.selectedRelationships.join(', ');
}
return '';
},
-
+
/**
* Reloads a connection's source and destination.
- *
+ *
* @param {string} sourceComponentId The connection source id
* @param {string} destinationComponentId The connection
destination id
*/
reloadConnectionSourceAndDestination: function (sourceComponentId,
destinationComponentId) {
- if (nf.Common.isBlank(sourceComponentId) === false) {
+ if (common.isBlank(sourceComponentId) === false) {
var source = d3.select('#id-' + sourceComponentId);
if (source.empty() === false) {
- var sourceData = source.datum();
-
- if (sourceData.permissions.canRead) {
- // update the source status if necessary
- if (nf.CanvasUtils.isProcessor(source)) {
- nf.Processor.reload(sourceData.id);
- } else if (nf.CanvasUtils.isInputPort(source)) {
- nf.Port.reload(sourceData.id);
- } else if
(nf.CanvasUtils.isRemoteProcessGroup(source)) {
- nf.RemoteProcessGroup.reload(sourceData.id);
- }
- }
+ nfGraph.reload(source);
}
}
-
- if (nf.Common.isBlank(destinationComponentId) === false) {
+ if (common.isBlank(destinationComponentId) === false) {
var destination = d3.select('#id-' + destinationComponentId);
if (destination.empty() === false) {
- var destinationData = destination.datum();
-
- if (destinationData.permissions.canRead) {
- // update the destination component accordingly
- if (nf.CanvasUtils.isProcessor(destination)) {
- nf.Processor.reload(destinationData.id);
- } else if
(nf.CanvasUtils.isRemoteProcessGroup(destination)) {
- nf.RemoteProcessGroup.reload(destinationData.id);
- }
- }
+ nfGraph.reload(destination);
}
}
},
-
+
/**
* Returns the component id of the source of this processor. If the
connection is attached
* to a port in a [sub|remote] group, the component id will be that of
the group. Otherwise
* it is the component itself.
- *
+ *
* @param {object} connection The connection in question
*/
getConnectionSourceComponentId: function (connection) {
var sourceId = connection.sourceId;
- if (connection.sourceGroupId !== nf.Canvas.getGroupId()) {
+ if (connection.sourceGroupId !== nfCanvas.getGroupId()) {
sourceId = connection.sourceGroupId;
}
return sourceId;
},
-
+
/**
* Returns the component id of the source of this processor. If the
connection is attached
* to a port in a [sub|remote] group, the component id will be that of
the group. Otherwise
* it is the component itself.
- *
+ *
* @param {object} connection The connection in question
*/
getConnectionDestinationComponentId: function (connection) {
var destinationId = connection.destinationId;
- if (connection.destinationGroupId !== nf.Canvas.getGroupId()) {
+ if (connection.destinationGroupId !== nfCanvas.getGroupId()) {
destinationId = connection.destinationGroupId;
}
return destinationId;
},
-
+
/**
* Attempts to restore a persisted view. Returns a flag that indicates
if the
* view was restored.
@@ -1296,18 +1337,18 @@ nf.CanvasUtils = (function () {
try {
// see if we can restore the view position from storage
- var name = config.storage.namePrefix + nf.Canvas.getGroupId();
- var item = nf.Storage.getItem(name);
+ var name = config.storage.namePrefix + nfCanvas.getGroupId();
+ var item = storage.getItem(name);
// ensure the item is valid
- if (nf.Common.isDefinedAndNotNull(item)) {
+ if (common.isDefinedAndNotNull(item)) {
if (isFinite(item.scale) && isFinite(item.translateX) &&
isFinite(item.translateY)) {
// restore previous view
- nf.Canvas.View.translate([item.translateX,
item.translateY]);
- nf.Canvas.View.scale(item.scale);
+ nfCanvas.View.translate([item.translateX,
item.translateY]);
+ nfCanvas.View.scale(item.scale);
// refresh the canvas
- nf.Canvas.View.refresh({
+ nfCanvas.View.refresh({
transition: true
});
@@ -1321,41 +1362,7 @@ nf.CanvasUtils = (function () {
return viewRestored;
},
-
- /**
- * Enters the specified group.
- *
- * @param {string} groupId
- */
- enterGroup: function (groupId) {
- // hide the context menu
- nf.ContextMenu.hide();
-
- // set the new group id
- nf.Canvas.setGroupId(groupId);
- // reload the graph
- return nf.Canvas.reload().done(function () {
- // attempt to restore the view
- var viewRestored = nf.CanvasUtils.restoreUserView();
-
- // if the view was not restore attempt to fit
- if (viewRestored === false) {
- nf.Canvas.View.fit();
-
- // refresh the canvas
- nf.Canvas.View.refresh({
- transition: true
- });
- }
- }).fail(function () {
- nf.Dialog.showOkDialog({
- headerText: 'Process Group',
- dialogContent: 'Unable to enter the selected group.'
- });
- });
- },
-
/**
* Gets the origin of the bounding box for the specified selection.
*
@@ -1366,11 +1373,11 @@ nf.CanvasUtils = (function () {
selection.each(function (d) {
var selected = d3.select(this);
- if (!nf.CanvasUtils.isConnection(selected)) {
- if (nf.Common.isUndefined(origin.x) || d.position.x <
origin.x) {
+ if (!nfCanvasUtils.isConnection(selected)) {
+ if (common.isUndefined(origin.x) || d.position.x <
origin.x) {
origin.x = d.position.x;
}
- if (nf.Common.isUndefined(origin.y) || d.position.y <
origin.y) {
+ if (common.isUndefined(origin.y) || d.position.y <
origin.y) {
origin.y = d.position.y;
}
}
@@ -1378,18 +1385,18 @@ nf.CanvasUtils = (function () {
return origin;
},
-
+
/**
* Moves the specified components into the current parent group.
- *
+ *
* @param {selection} components
*/
moveComponentsToParent: function (components) {
- var groupId = nf.Canvas.getParentGroupId();
-
+ var groupId = nfCanvas.getParentGroupId();
+
// if the group id is null, we're already in the top most group
if (groupId === null) {
- nf.Dialog.showOkDialog({
+ dialog.showOkDialog({
headerText: 'Process Group',
dialogContent: 'Components are already in the topmost
group.'
});
@@ -1397,23 +1404,23 @@ nf.CanvasUtils = (function () {
moveComponents(components, groupId);
}
},
-
+
/**
* Moves the specified components into the specified group.
- *
+ *
* @param {selection} components The components to move
* @param {selection} group The destination group
*/
moveComponents: function (components, group) {
var groupData = group.datum();
-
+
// move the components into the destination and...
moveComponents(components, groupData.id).done(function () {
// reload the target group
- nf.ProcessGroup.reload(groupData.id);
+
nfCanvasUtils.getComponentByType('ProcessGroup').reload(groupData.id);
});
},
-
+
/**
* Removes any dangling edges. All components are retained as well as
any
* edges whose source and destination are also retained.
@@ -1424,8 +1431,8 @@ nf.CanvasUtils = (function () {
trimDanglingEdges: function (selection) {
// returns whether the source and destination of the specified
connection are present in the specified selection
var keepConnection = function (connection) {
- var sourceComponentId =
nf.CanvasUtils.getConnectionSourceComponentId(connection);
- var destinationComponentId =
nf.CanvasUtils.getConnectionDestinationComponentId(connection);
+ var sourceComponentId =
nfCanvasUtils.getConnectionSourceComponentId(connection);
+ var destinationComponentId =
nfCanvasUtils.getConnectionDestinationComponentId(connection);
// determine if both source and destination are selected
var includesSource = false;
@@ -1451,61 +1458,10 @@ nf.CanvasUtils = (function () {
}
});
},
-
- /**
- * Determines if the specified selection is disconnected from other
nodes.
- *
- * @argument {selection} selection The selection
- */
- isDisconnected: function (selection) {
- // if nothing is selected return
- if (selection.empty()) {
- return false;
- }
-
- var connections = d3.map();
- var components = d3.map();
- var isDisconnected = true;
- // include connections
- selection.filter(function (d) {
- return d.type === 'Connection';
- }).each(function (d) {
- connections.set(d.id, d);
- });
-
- // include components and ensure their connections are included
- selection.filter(function (d) {
- return d.type !== 'Connection';
- }).each(function (d) {
- components.set(d.id, d.component);
-
- // check all connections of this component
- $.each(nf.Connection.getComponentConnections(d.id), function
(_, connection) {
- if (!connections.has(connection.id)) {
- isDisconnected = false;
- return false;
- }
- });
- });
-
- if (isDisconnected) {
- // go through each connection to ensure its source and
destination are included
- connections.forEach(function (id, connection) {
- if (isDisconnected) {
- // determine whether this connection and its
components are included within the selection
- isDisconnected =
components.has(nf.CanvasUtils.getConnectionSourceComponentId(connection)) &&
-
components.has(nf.CanvasUtils.getConnectionDestinationComponentId(connection));
- }
- });
- }
-
- return isDisconnected;
- },
-
/**
* Determines if the component in the specified selection is a valid
connection source.
- *
+ *
* @param {selection} selection The selection
* @return {boolean} Whether the selection is a valid connection source
*/
@@ -1515,22 +1471,22 @@ nf.CanvasUtils = (function () {
}
// always allow connections from process groups
- if (nf.CanvasUtils.isProcessGroup(selection)) {
+ if (nfCanvasUtils.isProcessGroup(selection)) {
return true;
}
// require read and write for a connection source since we'll need
to read the source to obtain valid relationships, etc
- if (nf.CanvasUtils.canRead(selection) === false ||
nf.CanvasUtils.canModify(selection) === false) {
+ if (nfCanvasUtils.canRead(selection) === false ||
nfCanvasUtils.canModify(selection) === false) {
return false;
}
- return nf.CanvasUtils.isProcessor(selection) ||
nf.CanvasUtils.isRemoteProcessGroup(selection) ||
- nf.CanvasUtils.isInputPort(selection) ||
nf.CanvasUtils.isFunnel(selection);
+ return nfCanvasUtils.isProcessor(selection) ||
nfCanvasUtils.isRemoteProcessGroup(selection) ||
+ nfCanvasUtils.isInputPort(selection) ||
nfCanvasUtils.isFunnel(selection);
},
-
+
/**
* Determines if the component in the specified selection is a valid
connection destination.
- *
+ *
* @param {selection} selection The selection
* @return {boolean} Whether the selection is a valid connection
destination
*/
@@ -1539,24 +1495,160 @@ nf.CanvasUtils = (function () {
return false;
}
- if (nf.CanvasUtils.isProcessGroup(selection)) {
+ if (nfCanvasUtils.isProcessGroup(selection)) {
return true;
}
// require write for a connection destination
- if (nf.CanvasUtils.canModify(selection) === false) {
+ if (nfCanvasUtils.canModify(selection) === false) {
return false;
}
- if (nf.CanvasUtils.isRemoteProcessGroup(selection) ||
nf.CanvasUtils.isOutputPort(selection) || nf.CanvasUtils.isFunnel(selection)) {
+ if (nfCanvasUtils.isRemoteProcessGroup(selection) ||
nfCanvasUtils.isOutputPort(selection) || nfCanvasUtils.isFunnel(selection)) {
return true;
}
// if processor, ensure it supports input
- if (nf.CanvasUtils.isProcessor(selection)) {
+ if (nfCanvasUtils.isProcessor(selection)) {
var destinationData = selection.datum();
return destinationData.inputRequirement !== 'INPUT_FORBIDDEN';
}
+ },
+
+ /**
+ * Returns whether the authorizer is configurable.
+ */
+ isConfigurableAuthorizer: function () {
+ return nfCanvas.isConfigurableAuthorizer();
+ },
+
+ /**
+ * Set the group id.
+ *
+ * @argument {string} gi The group id
+ */
+ setGroupId: function (gi) {
+ return nfCanvas.setGroupId(gi);
+ },
+
+ /**
+ * Get the group id.
+ */
+ getGroupId: function () {
+ return nfCanvas.getGroupId();
+ },
+
+ /**
+ * Get the group name.
+ */
+ getGroupName: function () {
+ return nfCanvas.getGroupName();
+ },
+
+ /**
+ * Get the parent group id.
+ */
+ getParentGroupId: function () {
+ return nfCanvas.getParentGroupId();
+ },
+
+ /**
+ * Reloads the status for the entire canvas (components and flow.)
+ */
+ reload: function () {
+ return nfCanvas.reload({
+ 'transition': true
+ });
+ },
+
+ /**
+ * Whether the current user can read from this group.
+ *
+ * @returns {boolean} can write
+ */
+ canReadFromGroup: function () {
+ return nfCanvas.canRead();
+ },
+
+ /**
+ * Whether the current user can write in this group.
+ *
+ * @returns {boolean} can write
+ */
+ canWrite: function () {
+ return nfCanvas.canWrite();
+ },
+
+ /**
+ * Refreshes the view based on the configured translation and scale.
+ *
+ * @param {object} options Options for the refresh operation
+ */
+ refreshCanvasView: function (options) {
+ return nfCanvas.View.refresh(options);
+ },
+
+ /**
+ * Sets/gets the current scale.
+ *
+ * @param {number} scale The new scale
+ */
+ scaleCanvasView: function (scale) {
+ return nfCanvas.View.scale(scale);
+ },
+
+ /**
+ * Sets/gets the current translation.
+ *
+ * @param {array} translate [x, y]
+ */
+ translateCanvasView: function (translate) {
+ return nfCanvas.View.translate(translate);
+ },
+
+ /**
+ * Zooms to fit the entire graph on the canvas.
+ */
+ fitCanvasView: function () {
+ return nfCanvas.View.fit();
+ },
+
+ /**
+ * Zooms in a single zoom increment.
+ */
+ zoomCanvasViewIn: function () {
+ return nfCanvas.View.zoomIn();
+ },
+
+ /**
+ * Zooms out a single zoom increment.
+ */
+ zoomCanvasViewOut: function () {
+ return nfCanvas.View.zoomOut();
+ },
+
+ /**
+ * Zooms to the actual size (1 to 1).
+ */
+ actualSizeCanvasView: function () {
+ return nfCanvas.View.actualSize();
+ },
+
+ /**
+ * Whether or not a component should be rendered based solely on the
current scale.
+ *
+ * @returns {Boolean}
+ */
+ shouldRenderPerScale: function () {
+ return nfCanvas.View.shouldRenderPerScale();
+ },
+
+ /**
+ * Gets the canvas offset.
+ */
+ getCanvasOffset: function () {
+ return nfCanvas.CANVAS_OFFSET;
}
};
-}());
\ No newline at end of file
+ return nfCanvasUtils;
+}));
\ No newline at end of file