Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce NodeAutoComplete Feature #11120

Merged
merged 20 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/DynamoCore/Configuration/PreferenceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ public string PythonTemplateFilePath
/// </summary>
public bool ShowTabsAndSpacesInScriptEditor { get; set; }

/// <summary>
/// This defines if user wants to see the enabled node Auto Complete feature for port interaction.
/// </summary>
public bool EnableNodeAutoComplete { get; set; }

/// <summary>
/// Engine used by default for new Python script and string nodes. If not empty, this takes precedence over any system settings.
/// </summary>
Expand Down Expand Up @@ -408,6 +413,7 @@ public PreferenceSettings()
PythonTemplateFilePath = "";
IsIronPythonDialogDisabled = false;
ShowTabsAndSpacesInScriptEditor = false;
EnableNodeAutoComplete = false;
DefaultPythonEngine = string.Empty;
}

Expand Down
52 changes: 52 additions & 0 deletions src/DynamoCore/Graph/Nodes/PortModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Xml;
using Dynamo.Configuration;
using Dynamo.Engine;
using Dynamo.Graph.Connectors;
using Dynamo.Graph.Nodes.ZeroTouch;
using Dynamo.Graph.Workspaces;
using Dynamo.Utilities;
using Newtonsoft.Json;
Expand Down Expand Up @@ -386,6 +389,55 @@ public override int GetHashCode()
return GUID.GetHashCode();
}

/// <summary>
/// Returns the string representation of the fully qualified typename
/// where possible for the port if it's an input port. This method currently
/// returns a valid type for only Zero Touch, Builtin and NodeModel nodes,
/// and returns null otherwise. The string representation of the type also
/// contains the rank information of the type, e.g. Point[], or var[]..[].
/// </summary>
/// <returns>input port type</returns>
internal string GetInputPortType()
{
if (PortType == PortType.Output) return null;

var ztNode = Owner as DSFunction;
if (ztNode != null)
{
var fd = ztNode.Controller.Definition;
string type;
// In the case of a node for an instance method, the first port
// type is the declaring class type of the method itself.
if (fd.Type == FunctionType.InstanceMethod)
{
if (Index > 0)
{
var param = fd.Parameters.ElementAt(Index - 1);
type = param.Type.ToString();
}
else
{
type = fd.ClassName;
}
}
else
{
var param = fd.Parameters.ElementAt(Index);
type = param.Type.ToString();
}
return type;
}

var nmNode = Owner as NodeModel;
if (nmNode != null)
{
var classType = nmNode.GetType();
var inPortAttribute = classType.GetCustomAttributes().OfType<InPortTypesAttribute>().FirstOrDefault();

return inPortAttribute?.PortTypes.ElementAt(Index);
}
return null;
}
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCore/Search/SearchElements/NodeSearchElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public SearchElementGroup Group
}

/// <summary>
/// Group to which Node belongs to
/// Assembly to which Node belongs to
/// </summary>
public string Assembly
{
Expand Down
23 changes: 19 additions & 4 deletions src/DynamoCoreWpf/Commands/PortCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ namespace Dynamo.ViewModels
{
public partial class PortViewModel
{
private DelegateCommand _connectCommand;
private DelegateCommand connectCommand;
private DelegateCommand autoCompleteCommand;
private DelegateCommand portMouseEnterCommand;
private DelegateCommand portMouseLeaveCommand;
private DelegateCommand portMouseLeftButtonCommand;
Expand All @@ -15,10 +16,24 @@ public DelegateCommand ConnectCommand
{
get
{
if(_connectCommand == null)
_connectCommand = new DelegateCommand(Connect, CanConnect);
if(connectCommand == null)
connectCommand = new DelegateCommand(Connect, CanConnect);

return _connectCommand;
return connectCommand;
}
}

/// <summary>
/// Command to trigger Node Auto Complete from node port interaction
/// </summary>
public DelegateCommand NodeAutoCompleteCommand
{
get
{
if (autoCompleteCommand == null)
autoCompleteCommand = new DelegateCommand(AutoComplete, CanAutoComplete);

return autoCompleteCommand;
}
}

Expand Down
110 changes: 53 additions & 57 deletions src/DynamoCoreWpf/Commands/WorkspaceCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,20 @@ public partial class WorkspaceViewModel
{
#region Private Delegate Command Data Members

private DelegateCommand _hideCommand;
private DelegateCommand _setCurrentOffsetCommand;
private DelegateCommand _nodeFromSelectionCommand;
private DelegateCommand _setZoomCommand;
private DelegateCommand _resetFitViewToggleCommand;
private DelegateCommand _findByIdCommand;
private DelegateCommand _alignSelectedCommand;
private DelegateCommand _setArgumentLacingCommand;
private DelegateCommand _findNodesFromSelectionCommand;
private DelegateCommand _selectAllCommand;
private DelegateCommand _graphAutoLayoutCommand;
private DelegateCommand _pauseVisualizationManagerUpdateCommand;
private DelegateCommand _unpauseVisualizationManagerUpdateCommand;
private DelegateCommand _showHideAllGeometryPreviewCommand;
private DelegateCommand _showInCanvasSearchCommand;
private DelegateCommand _pasteCommand;
private DelegateCommand _computeRunStateCommand;
private DelegateCommand hideCommand;
private DelegateCommand setCurrentOffsetCommand;
private DelegateCommand nodeFromSelectionCommand;
private DelegateCommand setZoomCommand;
private DelegateCommand resetFitViewToggleCommand;
private DelegateCommand findByIdCommand;
private DelegateCommand alignSelectedCommand;
private DelegateCommand setArgumentLacingCommand;
private DelegateCommand findNodesFromSelectionCommand;
private DelegateCommand selectAllCommand;
private DelegateCommand graphAutoLayoutCommand;
private DelegateCommand showHideAllGeometryPreviewCommand;
private DelegateCommand showInCanvasSearchCommand;
private DelegateCommand pasteCommand;

#endregion

Expand All @@ -43,26 +40,26 @@ public DelegateCommand CopyCommand
[JsonIgnore]
public DelegateCommand PasteCommand
{
get { return _pasteCommand ?? (_pasteCommand = new DelegateCommand(Paste, DynamoViewModel.CanPaste)); }
get { return pasteCommand ?? (pasteCommand = new DelegateCommand(Paste, DynamoViewModel.CanPaste)); }
}

[JsonIgnore]
public DelegateCommand SelectAllCommand
{
get
{
if(_selectAllCommand == null)
_selectAllCommand = new DelegateCommand(SelectAll, CanSelectAll);
return _selectAllCommand;
if(selectAllCommand == null)
selectAllCommand = new DelegateCommand(SelectAll, CanSelectAll);
return selectAllCommand;
}
}

[JsonIgnore]
public DelegateCommand GraphAutoLayoutCommand
{
get {
return _graphAutoLayoutCommand
?? (_graphAutoLayoutCommand =
return graphAutoLayoutCommand
?? (graphAutoLayoutCommand =
new DelegateCommand(DoGraphAutoLayout, CanDoGraphAutoLayout));
}
}
Expand All @@ -86,10 +83,10 @@ public DelegateCommand HideCommand
{
get
{
if(_hideCommand == null)
_hideCommand = new DelegateCommand(Hide, CanHide);
if(hideCommand == null)
hideCommand = new DelegateCommand(Hide, CanHide);

return _hideCommand;
return hideCommand;
}
}

Expand All @@ -98,10 +95,10 @@ public DelegateCommand SetCurrentOffsetCommand
{
get
{
if(_setCurrentOffsetCommand == null)
_setCurrentOffsetCommand = new DelegateCommand(SetCurrentOffset, CanSetCurrentOffset);
if(setCurrentOffsetCommand == null)
setCurrentOffsetCommand = new DelegateCommand(SetCurrentOffset, CanSetCurrentOffset);

return _setCurrentOffsetCommand;
return setCurrentOffsetCommand;
}
}

Expand All @@ -110,10 +107,10 @@ public DelegateCommand NodeFromSelectionCommand
{
get
{
if(_nodeFromSelectionCommand == null)
_nodeFromSelectionCommand = new DelegateCommand(CreateNodeFromSelection, CanCreateNodeFromSelection);
if(nodeFromSelectionCommand == null)
nodeFromSelectionCommand = new DelegateCommand(CreateNodeFromSelection, CanCreateNodeFromSelection);

return _nodeFromSelectionCommand;
return nodeFromSelectionCommand;
}
}

Expand All @@ -122,9 +119,9 @@ public DelegateCommand SetZoomCommand
{
get
{
if(_setZoomCommand == null)
_setZoomCommand = new DelegateCommand(SetZoom, CanSetZoom);
return _setZoomCommand;
if(setZoomCommand == null)
setZoomCommand = new DelegateCommand(SetZoom, CanSetZoom);
return setZoomCommand;
}
}

Expand All @@ -133,9 +130,9 @@ public DelegateCommand ResetFitViewToggleCommand
{
get
{
if (_resetFitViewToggleCommand == null)
_resetFitViewToggleCommand = new DelegateCommand(ResetFitViewToggle, CanResetFitViewToggle);
return _resetFitViewToggleCommand;
if (resetFitViewToggleCommand == null)
resetFitViewToggleCommand = new DelegateCommand(ResetFitViewToggle, CanResetFitViewToggle);
return resetFitViewToggleCommand;
}
}

Expand All @@ -144,10 +141,10 @@ public DelegateCommand FindByIdCommand
{
get
{
if(_findByIdCommand == null)
_findByIdCommand = new DelegateCommand(FindById, CanFindById);
if(findByIdCommand == null)
findByIdCommand = new DelegateCommand(FindById, CanFindById);

return _findByIdCommand;
return findByIdCommand;
}
}

Expand All @@ -156,10 +153,10 @@ public DelegateCommand AlignSelectedCommand
{
get
{
if(_alignSelectedCommand == null)
_alignSelectedCommand = new DelegateCommand(AlignSelected, CanAlignSelected);
if(alignSelectedCommand == null)
alignSelectedCommand = new DelegateCommand(AlignSelected, CanAlignSelected);

return _alignSelectedCommand;
return alignSelectedCommand;
}
}

Expand All @@ -168,13 +165,13 @@ public DelegateCommand SetArgumentLacingCommand
{
get
{
if (_setArgumentLacingCommand == null)
if (setArgumentLacingCommand == null)
{
_setArgumentLacingCommand = new DelegateCommand(
setArgumentLacingCommand = new DelegateCommand(
SetArgumentLacing, p => HasSelection);
}

return _setArgumentLacingCommand;
return setArgumentLacingCommand;
}
}

Expand All @@ -183,10 +180,10 @@ public DelegateCommand FindNodesFromSelectionCommand
{
get
{
if(_findNodesFromSelectionCommand == null)
_findNodesFromSelectionCommand = new DelegateCommand(FindNodesFromSelection, CanFindNodesFromSelection);
if(findNodesFromSelectionCommand == null)
findNodesFromSelectionCommand = new DelegateCommand(FindNodesFromSelection, CanFindNodesFromSelection);

return _findNodesFromSelectionCommand;
return findNodesFromSelectionCommand;
}
}

Expand All @@ -195,13 +192,13 @@ public DelegateCommand ShowHideAllGeometryPreviewCommand
{
get
{
if (_showHideAllGeometryPreviewCommand == null)
if (showHideAllGeometryPreviewCommand == null)
{
_showHideAllGeometryPreviewCommand = new DelegateCommand(
showHideAllGeometryPreviewCommand = new DelegateCommand(
ShowHideAllGeometryPreview);
}

return _showHideAllGeometryPreviewCommand;
return showHideAllGeometryPreviewCommand;
}
}

Expand All @@ -211,13 +208,12 @@ public DelegateCommand ShowInCanvasSearchCommand
{
get
{
if (_showInCanvasSearchCommand == null)
_showInCanvasSearchCommand = new DelegateCommand(OnRequestShowInCanvasSearch);
if (showInCanvasSearchCommand == null)
showInCanvasSearchCommand = new DelegateCommand(OnRequestShowInCanvasSearch);

return _showInCanvasSearchCommand;
return showInCanvasSearchCommand;
}
}

#endregion

#region Properties for Command Data Binding
Expand Down
Loading