Skip to content

Commit

Permalink
Merge pull request #779 from ICRAR/eagle-1351
Browse files Browse the repository at this point in the history
EAGLE-1351: Remove UUIDs from hovers
  • Loading branch information
james-strauss-uwa authored Nov 21, 2024
2 parents c486cee + 59a9650 commit 0ecd0cc
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 135 deletions.
87 changes: 1 addition & 86 deletions src/Eagle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4193,7 +4193,7 @@ export class Eagle {
if (choice === -1){
return;
}
console.log('choice: ', choice)

// hide the custom text input unless the first option in the select is chosen
if (choice === 0){
newField.setParameterType(parameterType);
Expand All @@ -4202,7 +4202,6 @@ export class Eagle {
node.addField(newField);

} else {
console.log('field: ',this.currentField().getDisplayText())
const clone : Field = this.currentField().clone();
clone.setId(Utils.generateFieldId());
clone.setParameterType(parameterType);
Expand Down Expand Up @@ -4276,90 +4275,6 @@ export class Eagle {
}, 100);
}

showFieldValuePicker = (fieldIndex : number, input : boolean) : void => {
const selectedNode = this.selectedNode();

if (selectedNode === null){
console.error("Attempt to show field picker when no node selected");
return;
}

const selectedNodeId: NodeId = selectedNode.getId();

console.log("ShowFieldValuePicker() node:", selectedNode.getName(), "fieldIndex:", fieldIndex, "input", input);

// build list of nodes that are attached to this node
const nodes : string[] = [];
for (const edge of this.logicalGraph().getEdges()){
// add output nodes to the list
if (edge.getSrcNodeId() === selectedNodeId){
const destNode : Node = this.logicalGraph().findNodeById(edge.getDestNodeId());
const s : string = "output:" + destNode.getName() + ":" + destNode.getId();
nodes.push(s);
}

// add input nodes to the list
if (edge.getDestNodeId() === selectedNodeId){
const srcNode : Node = this.logicalGraph().findNodeById(edge.getSrcNodeId());
const s : string = "input:" + srcNode.getName() + ":" + srcNode.getId();
nodes.push(s);
}
}

// ask the user to choose a node
Utils.requestUserChoice("Select node", "Choose the input or output node to connect to this parameter", nodes, 0, false, "", (completed : boolean, userChoiceIndex: number) => {
// abort if the user aborted
if (!completed){
return;
}

// split the user string into input/output, name, key
const isInput : boolean = nodes[userChoiceIndex].split(":")[0] === "input";
const key : string = nodes[userChoiceIndex].split(":")[2];

let newValue : string;
if (isInput){
newValue = "%i[" + key + "]";
} else {
newValue = "%o[" + key + "]";
}

// update the correct field
selectedNode.getFields()[fieldIndex].setValue(newValue);
});
}

private setNodeApplication = (title: string, message: string, callback:(node:Node) => void) : void => {
const applications: Node[] = this.getApplications();
const applicationNames: string[] = [];
for (const application of applications){
applicationNames.push(application.getName())
}

// add "None" to the application list
applicationNames.push(Node.NO_APP_STRING);

Utils.requestUserChoice(title, message, applicationNames, 0, false, "", (completed : boolean, userChoiceIndex: number) => {
if (!completed){
return;
}

// abort if the user picked "None"
if (userChoiceIndex === applicationNames.length - 1){
console.log("User selected no application");
callback(null);
return;
}

const application : Node = applications[userChoiceIndex];

// duplicate the input application
const newNode: Node = Utils.duplicateNode(application);

callback(newNode);
});
}

getNewNodePosition = (radius: number) : {x:number, y:number, extended:boolean} => {
const MARGIN = 100; // buffer to keep new nodes away from the maxX and maxY sides of the LG display area
const navBarHeight = 84
Expand Down
26 changes: 13 additions & 13 deletions src/Edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,25 +273,25 @@ export class Edge {
}

if (sourcePortId === null){
const issue = Errors.Fix("source port has no id", function(){Utils.fixNodeFieldIds(eagle, sourceNodeId)}, "Generate ids for ports on source node");
const issue = Errors.Fix("Source port has no id", function(){Utils.fixNodeFieldIds(eagle, sourceNodeId)}, "Generate ids for ports on source node");
Edge.isValidLog(edge, draggingPortMode, Errors.Validity.Impossible, issue, showNotification, showConsole, errorsWarnings);
return Errors.Validity.Impossible;
}

if (destinationPortId === null){
const issue = Errors.Fix("destination port has no id", function(){Utils.fixNodeFieldIds(eagle, sourceNodeId)}, "Generate ids for ports on destination node");
const issue = Errors.Fix("Destination port has no id", function(){Utils.fixNodeFieldIds(eagle, sourceNodeId)}, "Generate ids for ports on destination node");
Edge.isValidLog(edge, draggingPortMode, Errors.Validity.Impossible, issue, showNotification, showConsole, errorsWarnings);
return Errors.Validity.Impossible;
}

if (sourcePortId === null){
const issue = Errors.Fix("source port id is null", function(){Utils.fixNodeFieldIds(eagle, sourceNodeId)}, "Generate ids for ports on source node");
const issue = Errors.Fix("Source port id is null", function(){Utils.fixNodeFieldIds(eagle, sourceNodeId)}, "Generate ids for ports on source node");
Edge.isValidLog(edge, draggingPortMode, Errors.Validity.Impossible, issue, showNotification, showConsole, errorsWarnings);
return Errors.Validity.Impossible;
}

if (destinationPortId === null){
const issue = Errors.Fix("destination port id is null", function(){Utils.fixNodeFieldIds(eagle, sourceNodeId)}, "Generate ids for ports on destination node");
const issue = Errors.Fix("Destination port id is null", function(){Utils.fixNodeFieldIds(eagle, sourceNodeId)}, "Generate ids for ports on destination node");
Edge.isValidLog(edge, draggingPortMode, Errors.Validity.Impossible, issue, showNotification, showConsole, errorsWarnings);
return Errors.Validity.Impossible;
}
Expand All @@ -316,12 +316,12 @@ export class Edge {

// if source node or destination node is a construct, then something is wrong, constructs should not have ports
if (sourceNode.getCategoryType() === Category.Type.Construct){
const issue: Errors.Issue = Errors.ShowFix("Edge (" + edgeId + ") cannot have a source node (" + sourceNode.getName() + ") that is a construct", function(){Utils.showEdge(eagle, edgeId)}, function(){Utils.fixMoveEdgeToEmbeddedApplication(eagle, edgeId)}, "Move edge to embedded application");
const issue: Errors.Issue = Errors.ShowFix("Edge cannot have a source node (" + sourceNode.getName() + ") that is a construct", function(){Utils.showEdge(eagle, edgeId)}, function(){Utils.fixMoveEdgeToEmbeddedApplication(eagle, edgeId)}, "Move edge to embedded application");
Edge.isValidLog(edge, draggingPortMode, Errors.Validity.Error, issue, showNotification, showConsole, errorsWarnings);
}

if (destinationNode.getCategoryType() === Category.Type.Construct){
const issue: Errors.Issue = Errors.ShowFix("Edge (" + edgeId + ") cannot have a destination node (" + destinationNode.getName() + ") that is a construct", function(){Utils.showEdge(eagle, edgeId)}, function(){Utils.fixMoveEdgeToEmbeddedApplication(eagle, edgeId)}, "Move edge to embedded application");
const issue: Errors.Issue = Errors.ShowFix("Edge cannot have a destination node (" + destinationNode.getName() + ") that is a construct", function(){Utils.showEdge(eagle, edgeId)}, function(){Utils.fixMoveEdgeToEmbeddedApplication(eagle, edgeId)}, "Move edge to embedded application");
Edge.isValidLog(edge, draggingPortMode, Errors.Validity.Error, issue, showNotification, showConsole, errorsWarnings);
}

Expand All @@ -330,7 +330,7 @@ export class Edge {
// this is not supported. How would a BashShellApp read data from another process?
if ((sourceNode.getCategory() === Category.Memory && destinationNode.getCategory() === Category.BashShellApp) ||
(sourceNode.getCategory() === Category.Memory && destinationNode.isGroup() && destinationNode.getInputApplication() !== undefined && destinationNode.hasInputApplication() && destinationNode.getInputApplication().getCategory() === Category.BashShellApp)){
const issue: Errors.Issue = Errors.ShowFix("output from Memory Node cannot be input into a BashShellApp or input into a Group Node with a BashShellApp inputApplicationType", function(){Utils.showNode(eagle, sourceNode.getId())}, function(){Utils.fixNodeCategory(eagle, sourceNode, Category.File, Category.Type.Data)}, "Change data component type to File");
const issue: Errors.Issue = Errors.ShowFix("Output from Memory Node cannot be input into a BashShellApp or input into a Group Node with a BashShellApp inputApplicationType", function(){Utils.showNode(eagle, sourceNode.getId())}, function(){Utils.fixNodeCategory(eagle, sourceNode, Category.File, Category.Type.Data)}, "Change data component type to File");
Edge.isValidLog(edge, draggingPortMode, Errors.Validity.Error, issue, showNotification, showConsole, errorsWarnings);
}

Expand All @@ -339,15 +339,15 @@ export class Edge {

// check if source port was found
if (sourcePort === null) {
const issue: Errors.Issue = Errors.ShowFix("Source port (" + sourcePortId + ") doesn't exist on source node (" + sourceNode.getName() + ")", function(){Utils.showEdge(eagle, edgeId)}, function(){Utils.addSourcePortToSourceNode(eagle, edgeId)}, "Add source port to source node");
const issue: Errors.Issue = Errors.ShowFix("Source port doesn't exist on source node (" + sourceNode.getName() + ")", function(){Utils.showEdge(eagle, edgeId)}, function(){Utils.addSourcePortToSourceNode(eagle, edgeId)}, "Add source port to source node");
Edge.isValidLog(edge, draggingPortMode, Errors.Validity.Impossible, issue, showNotification, showConsole, errorsWarnings);
impossibleEdge = true;
return Errors.Validity.Impossible;
}

// check if destination port was found
if (destinationPort === null){
const issue: Errors.Issue = Errors.ShowFix("Destination port (" + destinationPortId + ") doesn't exist on destination node (" + destinationNode.getName() + ")", function(){Utils.showEdge(eagle, edgeId)}, function(){Utils.addDestinationPortToDestinationNode(eagle, edgeId)}, "Add destination port to destination node");
const issue: Errors.Issue = Errors.ShowFix("Destination port doesn't exist on destination node (" + destinationNode.getName() + ")", function(){Utils.showEdge(eagle, edgeId)}, function(){Utils.addDestinationPortToDestinationNode(eagle, edgeId)}, "Add destination port to destination node");
Edge.isValidLog(edge, draggingPortMode, Errors.Validity.Impossible, issue, showNotification, showConsole, errorsWarnings);
impossibleEdge = true;
return Errors.Validity.Impossible;
Expand Down Expand Up @@ -445,22 +445,22 @@ export class Edge {
// - destNode has a 'group_start' field set to true
if (closesLoop){
if (!sourceNode.isData()){
const x = Errors.Show("Closes Loop Edge (" + edgeId + ") does not start from a Data component.", function(){Utils.showEdge(eagle, edgeId);});
const x = Errors.Show("Closes Loop Edge does not start from a Data component.", function(){Utils.showEdge(eagle, edgeId);});
Edge.isValidLog(edge, draggingPortMode, Errors.Validity.Error, x, showNotification, showConsole, errorsWarnings);
}

if (!destinationNode.isApplication()){
const x = Errors.Show("Closes Loop Edge (" + edgeId + ") does not end at an Application component.", function(){Utils.showEdge(eagle, edgeId);});
const x = Errors.Show("Closes Loop Edge does not end at an Application component.", function(){Utils.showEdge(eagle, edgeId);});
Edge.isValidLog(edge, draggingPortMode, Errors.Validity.Error, x, showNotification, showConsole, errorsWarnings);
}

if (!sourceNode.hasFieldWithDisplayText(Daliuge.FieldName.GROUP_END) || !Utils.asBool(sourceNode.getFieldByDisplayText(Daliuge.FieldName.GROUP_END).getValue())){
const x = Errors.ShowFix("'Closes Loop' Edge (" + edgeId + ") start node (" + sourceNode.getName() + ") does not have 'group_end' set to true.", function(){Utils.showEdge(eagle, edgeId);}, function(){Utils.fixFieldValue(eagle, sourceNode, Daliuge.groupEndField, "true")}, "Set 'group_end' to true");
const x = Errors.ShowFix("'Closes Loop' Edge start node (" + sourceNode.getName() + ") does not have 'group_end' set to true.", function(){Utils.showEdge(eagle, edgeId);}, function(){Utils.fixFieldValue(eagle, sourceNode, Daliuge.groupEndField, "true")}, "Set 'group_end' to true");
Edge.isValidLog(edge, draggingPortMode, Errors.Validity.Error, x, showNotification, showConsole, errorsWarnings);
}

if (!destinationNode.hasFieldWithDisplayText(Daliuge.FieldName.GROUP_START) || !Utils.asBool(destinationNode.getFieldByDisplayText(Daliuge.FieldName.GROUP_START).getValue())){
const x = Errors.ShowFix("'Closes Loop' Edge (" + edgeId + ") end node (" + destinationNode.getName() + ") does not have 'group_start' set to true.", function(){Utils.showEdge(eagle, edgeId);}, function(){Utils.fixFieldValue(eagle, destinationNode, Daliuge.groupStartField, "true")}, "Set 'group_start' to true");
const x = Errors.ShowFix("'Closes Loop' Edge end node (" + destinationNode.getName() + ") does not have 'group_start' set to true.", function(){Utils.showEdge(eagle, edgeId);}, function(){Utils.fixFieldValue(eagle, destinationNode, Daliuge.groupStartField, "true")}, "Set 'group_start' to true");
Edge.isValidLog(edge, draggingPortMode, Errors.Validity.Error, x, showNotification, showConsole, errorsWarnings);
}
}
Expand Down
Loading

0 comments on commit 0ecd0cc

Please sign in to comment.