You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Platform.runLater(() -> {//Run this function on the main gui thread
67
+
finalStepmovedStep = event.getStep(); //The step whose position in the pipeline has changed
68
+
finalintdistanceMoved = event.getDistance(); //The number of indices (positive or negative) the step has been moved by
69
+
finalintnumberOfSourcePreviews = getNumbOfSourcePreviews();//The number of previews opened that are displaying sources (NOT steps)
70
+
71
+
finalOutputSocket<?>[] socketsMovedArray = movedStep.getOutputSockets();//Grab all the output sockets of the step that has moved
72
+
73
+
//Find the rightmost and leftmost position in the previews of the previewed sockets of the step that has moved
74
+
intrightmostIndex = 0; //Set to minimum possible value so that the first index will overwrite it
75
+
intleftmostIndex = this.previewedSockets.size();//Set to maximum possible value so that the first index will overwrite it
76
+
77
+
Stack<OutputSocket<?>> previewedMovedSockets = newStack<OutputSocket<?>>();//This will hold the sockets of the step that was moved that are open for preview
78
+
79
+
for (OutputSocket<?> i : socketsMovedArray) {
80
+
if (this.previewedSockets.indexOf(i) != -1) {//If this socket is previewed
81
+
previewedMovedSockets.push(i);
82
+
83
+
if (rightmostIndex < this.previewedSockets.indexOf(i)) {
if (leftmostIndex > this.previewedSockets.indexOf(i)) {
88
+
leftmostIndex = this.previewedSockets.indexOf(i);
89
+
}
90
+
91
+
}
92
+
}
93
+
94
+
//Deal with each previewed socket from the step that was moved in turn
95
+
while (previewedMovedSockets.size() != 0) { //While there are still sockets to deal with on the stack
96
+
OutputSocket<?> current = previewedMovedSockets.pop();//Grab the top socket on the stack
97
+
intoldIndex = this.previewedSockets.indexOf(current);//Get the index of this preview so we can remove the correct entry
98
+
99
+
intnewLocation = 0;//This will hold the new index in the list of previewed sockets for this socket
100
+
101
+
if (distanceMoved < 0) { //If the step moved left....
102
+
newLocation = leftmostIndex + distanceMoved; //Calculate the new index from the leftmost previewed socket of this step
103
+
} else { //The step must have moved right....
104
+
newLocation = rightmostIndex + distanceMoved;//So calculate the new index from the rightmost previewed socket of this step
105
+
}
106
+
107
+
if (newLocation < numberOfSourcePreviews) {//If the new calculated index would put it in the midst of source previews
108
+
newLocation = numberOfSourcePreviews;//Make the index the location of the first non-source preview
109
+
} else { //The new index is the current location of another step (NOT a source)
110
+
111
+
//So we need to make sure that we jump over GROUPS of previews associated with the SAME step as a unit
112
+
intcount = 0;//This will hold the number of previews open from the same step in sequence, starting from the new location and going in the direction we are moving
113
+
114
+
if (distanceMoved < 0) {//If the step moved left....
115
+
OutputSocket<?> nextSocketInDirection = this.previewedSockets.get(newLocation);//Grab the socket whose preview is open at the new location
116
+
booleanzeroReached = false;//We will set this to true if we reach the beginning of the list of previews (there are no source previews open)
117
+
while ((!zeroReached) &&
118
+
((nextSocketInDirection.getStep().isPresent())
119
+
&& (nextSocketInDirection.getStep().get() == this.previewedSockets.get(newLocation).getStep().get()))) { //While we haven't reached the beginning of the list of previews, the socket at this location is a socket from a step, and it is the SAME step as the step of the socket at the new location...
120
+
count++;
121
+
if ((newLocation - count) > 0) {//If we haven't reached the beginning of the list of open previews...
122
+
nextSocketInDirection = this.previewedSockets.get(newLocation - count);//Grab the next previewed socket to examine in the direction we are moving
123
+
} else {
124
+
zeroReached = true;//Mark that we've reached the beginning of the list of previews so we know to stop looking for more
125
+
}
126
+
}
127
+
newLocation = newLocation - (count - 1);//Since the first compare of the while loop will always be true, we subract one from the count when we use it to adjust newLocation
128
+
129
+
} else {//The step must have moved right....
130
+
while ((newLocation + count < this.previewedSockets.size())
131
+
&& (this.previewedSockets.get(newLocation + count).getStep().get() == this.previewedSockets.get(newLocation).getStep().get())) { //While there are still previewed sockets to examine, and the socket being examined is one from the SAME step of the socket at the new location....
132
+
count++;
133
+
}
134
+
newLocation = newLocation + (count - 1);//Since the first compare of the while loop will always be true, we subract one from the count when we use it to adjust newLocation
135
+
}
136
+
}
137
+
138
+
//Remove this socket from the old point in the previews
if (newLocation > this.previewedSockets.size()) {//If the new index is now too big for the list of previews
143
+
newLocation = this.previewedSockets.size();//Make it so it will be added to the end of the list of previews
144
+
}
145
+
this.previewedSockets.add(newLocation, current);//...add it to the correct location in the list of previews open
146
+
this.previewBox.getChildren().add(newLocation, SocketPreviewViewFactory.createPreviewView(this.eventBus, current));//...and display it in the correct location in the list of previews open
147
+
}
148
+
});
149
+
}
150
+
151
+
/**
152
+
* This function is called when a preview button is pushed/triggered
this.previewedSockets.add(indexInPreviews, socket);//...use this index to add it to the correct location in the list of previews open
170
+
this.previewBox.getChildren().add(indexInPreviews, SocketPreviewViewFactory.createPreviewView(this.eventBus, socket));//...and display it in the correct location in the list of previews open in the gui
171
+
172
+
} else {//This is a socket associated with a source and not a pipeline step...
173
+
174
+
//Find the appropriate index to add this preview with.
this.previewedSockets.add(indexInSourcePreviews, socket);//Add the preview to the appropriate place in the list of previewed sockets
178
+
this.previewBox.getChildren().add(indexInSourcePreviews, SocketPreviewViewFactory.createPreviewView(this.eventBus, socket));//Display the preview in the appropriate place
179
+
}
60
180
}
61
-
} else {
62
-
// If the socket was just set as not previewed, remove both it and the corresponding control
63
-
intindex = this.previewedSockets.indexOf(socket);
64
-
if (index != -1) {
181
+
} else {//The socket was already previewed, so the user must be requesting to not show this preview (remove both it and the corresponding control)
182
+
183
+
intindex = this.previewedSockets.indexOf(socket);//Get the index of this preview so we can remove the correct entry
184
+
if (index != -1) {//False when the preview isn't currently displayed
finalSourcesocketSource = socket.getSource().get();//The source socket associated with the socket whose preview has changed
203
+
finalSourceViewsourceView = this.pipeline.findSourceView(socketSource);//The gui object that displays the socketSource
204
+
intindexOfSource = this.pipeline.getSources().indexOf(sourceView); //The index of the source that has the socket in the pipeline
205
+
206
+
//Start with the first socket in the list of previewed sockets
207
+
intindexInSourcePreviews = 0;
208
+
//Find the correct index in the displayed source previews by comparing the indices
209
+
while (((this.previewedSockets.size() > indexInSourcePreviews)//If there are previews still to be examined AND
210
+
&& (this.previewedSockets.get(indexInSourcePreviews).getSource().isPresent()))//AND If the preview at this index is a source...
211
+
&& ((this.pipeline.getSources().indexOf(this.pipeline.findSourceView(this.previewedSockets.get(indexInSourcePreviews).getSource().get()))) < indexOfSource)) {//AND the preview at this index is a source with an index in the list of sources less than this source
212
+
indexInSourcePreviews++;
213
+
}
214
+
returnindexInSourcePreviews;
215
+
}
216
+
217
+
/**
218
+
* Find the correct index in the displayed previews for a socket associated with a step (NOT a source socket)
219
+
* by comparing the indices in the pipeline, starting with the first non-source preview displayed.
220
+
* Made to be called in {@link PreviewsView#onSocketPreviewChanged}
221
+
*
222
+
* @param socket An output socket associated with a step (NOT a source)
223
+
* @return The correct index in the list of displayed previews for the given <code>socket</code>
intnumbOfSourcePreviews = getNumbOfSourcePreviews();//Count how many *source* previews (not *step* previews) are currently displayed
228
+
229
+
finalStepsocketStep = socket.getStep().get();//The pipeline step associated with the socket whose preview has changed
230
+
finalStepViewstepView = this.pipeline.findStepView(socketStep);//The gui object that displays the socketStep
231
+
intindexOfStep = this.pipeline.getSteps().indexOf(stepView); //The index of the step that has the socket in the pipeline
232
+
233
+
//Start at the first non-source socket in the list of previewed sockets
234
+
intindexInPreviews = numbOfSourcePreviews;
235
+
236
+
while ((this.previewedSockets.size() > indexInPreviews)//While there are sockets in the list of previewed sockets yet to be examined
237
+
&& ((this.pipeline.getSteps().indexOf(this.pipeline.findStepView(this.previewedSockets.get(indexInPreviews).getStep().get()))) < indexOfStep)) {//...AND the socket at this index in the list of displayed sockets has an index in the pipeline less than the socket passed in as "socket"
238
+
indexInPreviews++;
239
+
}
240
+
returnindexInPreviews;
241
+
}
242
+
243
+
/**
244
+
* Counts how many source previews (NOT step previews) are currently displayed.
245
+
* Called in {@link PreviewsView#getIndexInPreviewsOfAStepSocket} and {@link PreviewsView#onPreviewOrderChanged(StepMovedEvent)}
246
+
*
247
+
* @return The number of source (NOT step) previews that are currently displayed
0 commit comments