mattcasters commented on code in PR #9428:
URL: https://github.com/apache/hop/pull/9428#discussion_r4560714183
##########
ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java:
##########
@@ -426,10 +428,21 @@ public class HopGuiPipelineGraph extends
HopGuiAbstractGraph
private int debugDiscardGeneration;
/**
- * The output-rows dialog is on screen. It runs its own event loop, which
delivers any click made
- * while it is up; that click must not move transforms or open a second copy
of the dialog.
+ * Row buffers whose "Output of" window is currently on screen.
+ *
+ * Opening a preview runs a nested event loop, so the canvas keeps handling
clicks while the
Review Comment:
google-java-format needs `<p>` at the start of each paragraph after the
first one (here and on the next two paragraphs). The previous commit had them;
`spotless:apply` puts them back.
##########
rcp/src/test/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraphOutputDataTest.java:
##########
@@ -99,6 +100,98 @@ void clickingTheBadgeOpensTheRowsOnce() {
});
}
+ /**
+ * Every window runs its own event loop, so the rows of a second transform
open from inside the
+ * first one's loop. That must be a new window, not another click on the
open one, and the first
+ * window must stay up.
+ */
+ @Test
+ void rowsOfASecondTransformOpenWhileTheFirstWindowIsUp() {
+ onCanvas(
+ scene -> {
+ Shell first = openRows(scene, scene.source);
+ assertNotNull(first, "the first badge opens its rows");
+ assertEquals(scene.transformRowsTitle, titleOf(first));
+
+ Shell second = openRows(scene, scene.target);
+ assertNotNull(second, "a second badge opens a second window while
the first is up");
+ assertEquals(rowsTitle(TARGET_TRANSFORM), titleOf(second));
+ assertFalse(first.isDisposed(), "opening the second window leaves
the first one up");
+
+ // Newest first, so each nested loop can return to the one below it.
+ closeShell(scene.bot, second);
+ closeShell(scene.bot, first);
+ assertIdle(scene.graph);
+ assertTrue(swallowed.isEmpty(), "the canvas must not throw, but got
" + swallowed);
+ });
+ }
+
+
Review Comment:
Double blank line. Spotless collapses it.
##########
ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java:
##########
@@ -1796,78 +1799,127 @@ private boolean showOutputDataDialog(String titleName,
String messageName, RowBu
if (rowBuffer == null) {
return false;
}
- // Already inside this dialog's event loop: the click that got us here is
not another preview.
- if (showingOutputRows) {
+ // Already inside this buffer's dialog event loop: the click that got us
here is not another
+ // preview of the same rows. A preview of another transform is a new
request, and does open.
+ if (openOutputRowsBuffers.contains(rowBuffer)) {
return true;
}
+ // A running pipeline appends its sampled rows to this list from its own
threads, under the
+ // list's lock. Copy the rows inside that lock and release it before the
window opens.
+ final IRowMeta rowMeta;
+ final List<Object[]> rows;
synchronized (rowBuffer.getBuffer()) {
- if (!rowBuffer.isEmpty()) {
- showingOutputRows = true;
- try {
- String title =
- BaseMessages.getString(
- PKG, "PipelineGraph.ViewOutput.OutputDialog.Header",
titleName);
- String message =
- BaseMessages.getString(
- PKG,
"PipelineGraph.ViewOutput.OutputDialog.OutputRows.Text", messageName);
- String prefix = "";
-
- if (pipeline != null && pipeline.getPipelineRunConfiguration() !=
null) {
- PipelineRunConfiguration pipelineRunConfiguration =
- pipeline.getPipelineRunConfiguration();
- if (pipelineRunConfiguration.getEngineRunConfiguration()
- instanceof LocalPipelineRunConfiguration
localPipelineRunConfiguration) {
- String sampleTypeInGui =
localPipelineRunConfiguration.getSampleTypeInGui();
- if (StringUtils.isNotEmpty(sampleTypeInGui)) {
- try {
- SampleType sampleType = SampleType.valueOf(sampleTypeInGui);
- switch (sampleType) {
- case None:
- break;
- case First:
- prefix =
- BaseMessages.getString(
- PKG,
"PipelineGraph.ViewOutput.OutputDialog.First.Text");
- break;
- case Last:
- prefix =
- BaseMessages.getString(
- PKG,
"PipelineGraph.ViewOutput.OutputDialog.Last.Text");
- break;
- case Random:
- prefix +=
- BaseMessages.getString(
- PKG,
"PipelineGraph.ViewOutput.OutputDialog.Random.Text");
- break;
- default:
- break;
- }
- } catch (Exception ex) {
- LogChannel.UI.logError("Unknown sample type: " +
sampleTypeInGui);
- }
+ if (rowBuffer.isEmpty()) {
+ return true;
+ }
+ rowMeta = rowBuffer.getRowMeta();
+ rows = new ArrayList<>(rowBuffer.getBuffer());
+ }
+
+ openOutputRowsBuffers.add(rowBuffer);
+ // Every window runs its own event loop, so a window opened from within
the first one's loop
+ // nests inside it: open() returns when the newest window closes, not when
this one does.
+ // Releasing the buffer from this window's own dispose event keeps the
mark tied to the window
+ // on screen. The flag makes the release happen once, so a late return
cannot clear a window
+ // that was reopened in the meantime.
+ final AtomicBoolean released = new AtomicBoolean();
+ final Runnable release =
+ () -> {
+ if (released.compareAndSet(false, true)) {
+ openOutputRowsBuffers.remove(rowBuffer);
+ }
+ };
+ try {
+ String title =
+ BaseMessages.getString(PKG,
"PipelineGraph.ViewOutput.OutputDialog.Header", titleName);
+ String message =
+ BaseMessages.getString(
+ PKG, "PipelineGraph.ViewOutput.OutputDialog.OutputRows.Text",
messageName);
+ String prefix = "";
+
+ if (pipeline != null && pipeline.getPipelineRunConfiguration() != null) {
+ PipelineRunConfiguration pipelineRunConfiguration =
pipeline.getPipelineRunConfiguration();
+ if (pipelineRunConfiguration.getEngineRunConfiguration()
+ instanceof LocalPipelineRunConfiguration
localPipelineRunConfiguration) {
+ String sampleTypeInGui =
localPipelineRunConfiguration.getSampleTypeInGui();
+ if (StringUtils.isNotEmpty(sampleTypeInGui)) {
+ try {
+ SampleType sampleType = SampleType.valueOf(sampleTypeInGui);
+ switch (sampleType) {
+ case None:
+ break;
+ case First:
+ prefix =
+ BaseMessages.getString(
+ PKG,
"PipelineGraph.ViewOutput.OutputDialog.First.Text");
+ break;
+ case Last:
+ prefix =
+ BaseMessages.getString(
+ PKG,
"PipelineGraph.ViewOutput.OutputDialog.Last.Text");
+ break;
+ case Random:
+ prefix +=
+ BaseMessages.getString(
+ PKG,
"PipelineGraph.ViewOutput.OutputDialog.Random.Text");
+ break;
+ default:
+ break;
}
+ } catch (Exception ex) {
+ LogChannel.UI.logError("Unknown sample type: " +
sampleTypeInGui);
}
}
-
- new ShowRowsDialog(
- hopGui.getActiveShell(),
- variables,
- title,
- prefix + message,
- rowBuffer.getRowMeta(),
- rowBuffer.getBuffer())
- .open();
- } catch (Exception ex) {
- new ErrorDialog(
- hopGui.getActiveShell(), CONST_ERROR, "Error showing output rows
dialog", ex);
- } finally {
- showingOutputRows = false;
}
}
+
+ watchOutputRowsShell(title, release);
+ new ShowRowsDialog(hopGui.getActiveShell(), variables, title, prefix +
message, rowMeta, rows)
+ .open();
+ } catch (Exception ex) {
+ new ErrorDialog(hopGui.getActiveShell(), CONST_ERROR, "Error showing
output rows dialog", ex);
+ } finally {
+ release.run();
}
return true;
}
+ /**
+ * Calls {@code onDisposed} when the window {@link ShowRowsDialog} is about
to open is disposed,
+ * and brings that window to the front.
+ *
+ * The window creates its shell privately, and {@code open()} does not
return until a nested
Review Comment:
Same here: this paragraph and the one starting with "A window opened
while..." need a leading `<p>`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]