Merge branch 'develop', remote branch 'origin/develop' into develop

This commit is contained in:
joewitt 2014-12-09 20:59:30 -05:00
commit c55e851089
7 changed files with 102 additions and 98 deletions

View File

@ -16,11 +16,8 @@
*/
package org.apache.nifi.web.controller;
import java.util.HashMap;
import java.util.Map;
import org.apache.nifi.attribute.expression.language.PreparedQuery;
import org.apache.nifi.attribute.expression.language.Query;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.PropertyValue;
import org.apache.nifi.controller.ControllerServiceLookup;
@ -36,24 +33,11 @@ public class StandardSearchContext implements SearchContext {
private final String searchTerm;
private final ProcessorNode processorNode;
private final ControllerServiceLookup controllerServiceLookup;
private final Map<PropertyDescriptor, PreparedQuery> preparedQueries;
public StandardSearchContext(final String searchTerm, final ProcessorNode processorNode, final ControllerServiceLookup controllerServiceLookup) {
this.searchTerm = searchTerm;
this.processorNode = processorNode;
this.controllerServiceLookup = controllerServiceLookup;
preparedQueries = new HashMap<>();
for (final Map.Entry<PropertyDescriptor, String> entry : processorNode.getProperties().entrySet()) {
final PropertyDescriptor desc = entry.getKey();
String value = entry.getValue();
if (value == null) {
value = desc.getDefaultValue();
}
final PreparedQuery pq = Query.prepare(value);
preparedQueries.put(desc, pq);
}
}
@Override
@ -69,7 +53,7 @@ public class StandardSearchContext implements SearchContext {
@Override
public PropertyValue getProperty(PropertyDescriptor property) {
final String configuredValue = processorNode.getProperty(property);
return new StandardPropertyValue(configuredValue == null ? property.getDefaultValue() : configuredValue, controllerServiceLookup, preparedQueries.get(property));
return new StandardPropertyValue(configuredValue == null ? property.getDefaultValue() : configuredValue, controllerServiceLookup, null);
}
@Override

View File

@ -198,8 +198,6 @@ nf.Canvas = (function () {
// create the canvas
svg = d3.select('#canvas-container').append('svg')
.attr('width', canvasContainer.width())
.attr('height', canvasContainer.height())
.on('contextmenu', function () {
// reset the canvas click flag
canvasClicked = false;
@ -214,14 +212,6 @@ nf.Canvas = (function () {
d3.event.preventDefault();
});
// listen for browser resize events to update the svg
$(window).resize(function () {
svg.attr({
'width': canvasContainer.width(),
'height': canvasContainer.height()
});
});
// create the definitions element
var defs = svg.append('defs');
@ -332,41 +322,41 @@ nf.Canvas = (function () {
// handle canvas events
svg.on('mousedown.selection', function () {
canvasClicked = true;
canvasClicked = true;
if (d3.event.button !== 0) {
// prevent further propagation (to parents and others handlers
// on the same element to prevent zoom behavior)
d3.event.stopImmediatePropagation();
return;
}
if (d3.event.button !== 0) {
// prevent further propagation (to parents and others handlers
// on the same element to prevent zoom behavior)
d3.event.stopImmediatePropagation();
return;
}
// show selection box if control is held down
if (d3.event.ctrlKey) {
var position = d3.mouse(canvas.node());
canvas.append('rect')
.attr('rx', 6)
.attr('ry', 6)
.attr('x', position[0])
.attr('y', position[1])
.attr('class', 'selection')
.attr('width', 0)
.attr('height', 0)
.attr('stroke-width', function () {
return 1 / nf.Canvas.View.scale();
})
.attr('stroke-dasharray', function () {
return 4 / nf.Canvas.View.scale();
})
.datum(position);
// show selection box if shift is held down
if (d3.event.shiftKey) {
var position = d3.mouse(canvas.node());
canvas.append('rect')
.attr('rx', 6)
.attr('ry', 6)
.attr('x', position[0])
.attr('y', position[1])
.attr('class', 'selection')
.attr('width', 0)
.attr('height', 0)
.attr('stroke-width', function () {
return 1 / nf.Canvas.View.scale();
})
.attr('stroke-dasharray', function () {
return 4 / nf.Canvas.View.scale();
})
.datum(position);
// prevent further propagation (to parents)
d3.event.stopPropagation();
}
})
// prevent further propagation (to parents)
d3.event.stopPropagation();
}
})
.on('mousemove.selection', function () {
// update selection box if control is held down
if (d3.event.ctrlKey) {
// update selection box if shift is held down
if (d3.event.shiftKey) {
// get the selection box
var selectionBox = d3.select('rect.selection');
if (!selectionBox.empty()) {
@ -470,13 +460,22 @@ nf.Canvas = (function () {
bottom = footer.height();
}
var graph = $('#canvas-container');
var top = parseInt(graph.css('top'), 10);
// calculate size
var top = parseInt(canvasContainer.css('top'), 10);
var windowHeight = $(window).height();
var graphHeight = (windowHeight - (bottom + top));
graph.css('height', graphHeight + 'px');
graph.css('bottom', bottom + 'px');
var canvasHeight = (windowHeight - (bottom + top));
// canvas/svg
canvasContainer.css({
'height': canvasHeight + 'px',
'bottom': bottom + 'px'
});
svg.attr({
'height': canvasContainer.height(),
'width': canvasContainer.width()
});
// body
$('#canvas-body').css({
'height': windowHeight + 'px',
'width': $(window).width() + 'px'
@ -492,7 +491,7 @@ nf.Canvas = (function () {
return;
}
if (evt.ctrlKey === true) {
if (evt.ctrlKey || evt.metaKey) {
if (evt.keyCode === 82) {
// ctrl-r
nf.Actions.reloadStatus();

View File

@ -160,7 +160,7 @@ nf.Connectable = (function () {
activate: function (components) {
components
.on('mouseenter.connectable', function (d) {
if (!d3.event.ctrlKey && d3.select('rect.drag-selection').empty()) {
if (!d3.event.shiftKey && d3.select('rect.drag-selection').empty()) {
var selection = d3.select(this);
// ensure the current component supports connection source
@ -192,12 +192,12 @@ nf.Connectable = (function () {
connector.remove();
}
})
//Using mouseover/out to workaround chrom issue #122746
// Using mouseover/out to workaround chrome issue #122746
.on('mouseover.connectable', function () {
//mark that we are hovering when appropriate
// mark that we are hovering when appropriate
var selection = d3.select(this);
selection.classed('hover', function () {
return !d3.event.ctrlKey && !selection.classed('hover') && d3.select('rect.drag-selection').empty();
return !d3.event.shiftKey && !selection.classed('hover') && d3.select('rect.drag-selection').empty();
});
})
.on('mouseout.connection', function () {

View File

@ -25,7 +25,7 @@ nf.Draggable = (function () {
*/
var updateComponentsPosition = function (dragSelection) {
var revision = nf.Client.getRevision();
var updates = [];
var updates = d3.map();
// determine the drag delta
var dragData = dragSelection.datum();
@ -38,16 +38,15 @@ nf.Draggable = (function () {
if (delta.x === 0 && delta.y === 0) {
return;
}
// go through each selected component
d3.selectAll('g.component.selected').each(function (d) {
var updateComponentPosition = function(d) {
var newPosition = {
x: d.component.position.x + delta.x,
y: d.component.position.y + delta.y
};
// update the component positioning
updates.push($.Deferred(function (deferred) {
return $.Deferred(function (deferred) {
$.ajax({
type: 'PUT',
url: d.component.uri,
@ -82,11 +81,10 @@ nf.Draggable = (function () {
deferred.reject();
});
}).promise());
});
// go through each selected connection
d3.selectAll('g.connection.selected').each(function (d) {
}).promise();
};
var updateConnectionPosition = function(d) {
// only update if necessary
if (d.component.bends.length === 0) {
return;
@ -109,7 +107,7 @@ nf.Draggable = (function () {
};
// update the component positioning
updates.push($.Deferred(function (deferred) {
return $.Deferred(function (deferred) {
$.ajax({
type: 'PUT',
url: d.component.uri,
@ -146,11 +144,30 @@ nf.Draggable = (function () {
deferred.reject();
});
}).promise());
}).promise();
};
// go through each selected connection
d3.selectAll('g.connection.selected').each(function (d) {
updates.set(d.component.id, updateConnectionPosition(d));
});
// go through each selected component
d3.selectAll('g.component.selected').each(function (d) {
// consider any self looping connections
var connections = nf.Connection.getComponentConnections(d.component.id);
$.each(connections, function(_, connection) {
if (!updates.has(connection.id) && nf.CanvasUtils.getConnectionSourceComponentId(connection) === nf.CanvasUtils.getConnectionDestinationComponentId(connection)) {
updates.set(connection.id, updateConnectionPosition(nf.Connection.get(connection.id)));
}
});
// consider the component itself
updates.set(d.component.id, updateComponentPosition(d));
});
// wait for all updates to complete
$.when.apply(window, updates).done(function () {
$.when.apply(window, updates.values()).done(function () {
var dragged = $.makeArray(arguments);
var connections = d3.set();
@ -251,9 +268,9 @@ nf.Draggable = (function () {
} else {
// update the position of the drag selection
dragSelection.attr('x', function (d) {
d.x += d3.event.dx;
return d.x;
})
d.x += d3.event.dx;
return d.x;
})
.attr('y', function (d) {
d.y += d3.event.dy;
return d.y;

View File

@ -475,11 +475,11 @@ nf.ProcessorPropertyTable = (function () {
// use the display name if possible
displayName = descriptor.displayName;
}
// determine the value
if (nf.Common.isUndefined(value) || nf.Common.isNull(value)) {
value = descriptor.defaultValue;
// determine the value
if (nf.Common.isUndefined(value) || nf.Common.isNull(value)) {
value = descriptor.defaultValue;
}
}
// add the row

View File

@ -27,15 +27,15 @@ nf.Selectable = (function () {
// only need to update selection if necessary
if (!g.classed('selected')) {
// since we're not appending, deselect everything else
if (!d3.event.ctrlKey) {
if (!d3.event.shiftKey) {
d3.selectAll('g.selected').classed('selected', false);
}
// update the selection
g.classed('selected', true);
} else {
// we are currently selected, if control key the deselect
if (d3.event.ctrlKey) {
// we are currently selected, if shift key the deselect
if (d3.event.shiftKey) {
g.classed('selected', false);
}
}

View File

@ -462,6 +462,7 @@ nf.ProcessorDetails = (function () {
// determine the property type
var type = 'userDefined';
var displayName = name;
if (nf.Common.isDefinedAndNotNull(descriptor)) {
if (descriptor.required === true) {
type = 'required';
@ -470,17 +471,20 @@ nf.ProcessorDetails = (function () {
} else {
type = 'optional';
}
}
// determine the value
if (nf.Common.isUndefined(value) || nf.Common.isNull(value)) {
value = descriptor.defaultValue;
// use the display name if possible
displayName = descriptor.displayName;
// determine the value
if (nf.Common.isUndefined(value) || nf.Common.isNull(value)) {
value = descriptor.defaultValue;
}
}
// add the row
propertyData.addItem({
id: i++,
property: name,
property: displayName,
value: value,
type: type
});