Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,12 @@ Hop Web creates one RAP `UISession` (and one SWT `Display`) per browser session.
* **Perspectives:** `getInstance()` must prefer `HopGui.findSessionPerspective(...)`. A static `instance` field is only a fallback for tests and disabled perspectives.
* **Caches of SWT `Image`s:** key by `Device`/`Display` and dispose on *that* device. Never one process-wide dispose hook.
* **Engine-thread maps (drill-down):** stamp `hopGui.getId()` on the engine in the GUI thread; do not call `HopGui.getInstance()` from pipeline worker threads (no RAP `UISession`).
* **Background threads started by a dialog:** start them with `BackgroundThreadFacade.start(runnable)` instead of `new Thread(runnable).start()`. A dialog that looks up its input fields in the background reads session state while doing so (`ConstUi.sortFieldNames` asks `PropsUi`), and a plain thread has no `UISession` to read it from.

Do not store `Control`, `Shell`, `SashForm`, `Image`, `Color`, `Font` or `GC` in `static` fields. When session A ends RAP disposes those objects; session B then hits `Invalid thread access` or `Widget is disposed`.

A thread that carries a session is still not the UI thread: widgets stay off limits to it, and it reaches them the same way as before, through `Display.asyncExec`.

== Avoid use of unimplemented SWT APIs

=== Example: drawing on an Image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.apache.hop.ui.core.widget.PasswordTextVar;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
Expand Down Expand Up @@ -382,7 +383,7 @@ public void run() {
}
}
};
new Thread(runnable).start();
BackgroundThreadFacade.start(runnable);
}

private void addAwsAuthenticationTab(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.apache.hop.ui.core.widget.PasswordTextVar;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
Expand Down Expand Up @@ -570,7 +571,7 @@ public void run() {
}
}
};
new Thread(runnable).start();
BackgroundThreadFacade.start(runnable);

getData();
focusTransformName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.apache.hop.ui.core.widget.MetaSelectionLine;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.apache.hop.ui.pipeline.transform.ITableItemInsertListener;
import org.eclipse.swt.SWT;
Expand Down Expand Up @@ -697,7 +698,7 @@ public void widgetSelected(SelectionEvent arg0) {
}
}
};
new Thread(runnable).start();
BackgroundThreadFacade.start(runnable);

wbLogFile.addListener(
SWT.Selection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.apache.hop.ui.core.widget.MetaSelectionLine;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
Expand Down Expand Up @@ -178,23 +179,22 @@ public void focusLost(FocusEvent event) {
wSettingsComp.layout();

// Look up the incoming fields in the background, they feed the stream field drop-down.
new Thread(
() -> {
TransformMeta stepMeta = pipelineMeta.findTransform(transformName);
if (stepMeta == null) {
return;
}
try {
IRowMeta row = pipelineMeta.getPrevTransformFields(variables, stepMeta);
for (int i = 0; i < row.size(); i++) {
inputFields.put(row.getValueMeta(i).getName(), i);
}
setComboBoxes();
} catch (HopException e) {
logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
})
.start();
BackgroundThreadFacade.start(
() -> {
TransformMeta stepMeta = pipelineMeta.findTransform(transformName);
if (stepMeta == null) {
return;
}
try {
IRowMeta row = pipelineMeta.getPrevTransformFields(variables, stepMeta);
for (int i = 0; i < row.size(); i++) {
inputFields.put(row.getValueMeta(i).getName(), i);
}
setComboBoxes();
} catch (HopException e) {
logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
});

wContent.pack();
Rectangle bounds = wContent.getBounds();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.apache.hop.ui.core.widget.MetaSelectionLine;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.apache.hop.ui.pipeline.transform.ITableItemInsertListener;
import org.eclipse.swt.SWT;
Expand Down Expand Up @@ -568,7 +569,7 @@ public void widgetSelected(SelectionEvent arg0) {
}
}
};
new Thread(runnable).start();
BackgroundThreadFacade.start(runnable);

wContent.pack();
Rectangle bounds = wContent.getBounds();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.apache.hop.ui.core.widget.MetaSelectionLine;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.apache.hop.ui.pipeline.transform.ITableItemInsertListener;
import org.eclipse.swt.SWT;
Expand Down Expand Up @@ -849,7 +850,7 @@ public void widgetSelected(SelectionEvent e) {
}
}
};
new Thread(runnable).start();
BackgroundThreadFacade.start(runnable);

SelectionListener fileSelectionListener =
new SelectionAdapter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.apache.hop.ui.core.widget.MetaSelectionLine;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.apache.hop.ui.pipeline.transform.ITableItemInsertListener;
import org.eclipse.swt.SWT;
Expand Down Expand Up @@ -397,7 +398,7 @@ public void widgetSelected(SelectionEvent e) {
}
}
};
new Thread(runnable).start();
BackgroundThreadFacade.start(runnable);

// Add listeners
wGetLU.addListener(SWT.Selection, e -> getUpdate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.apache.hop.ui.core.widget.MetaSelectionLine;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
Expand Down Expand Up @@ -1105,7 +1106,7 @@ public void focusGained(FocusEvent focusEvent) {
}
}
};
new Thread(runnable).start();
BackgroundThreadFacade.start(runnable);

FormData fdFieldsComp = new FormData();
fdFieldsComp.left = new FormAttachment(0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.apache.hop.ui.core.widget.PluginWidgetFactory;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.apache.hop.ui.pipeline.transform.ITableItemInsertListener;
import org.eclipse.swt.SWT;
Expand Down Expand Up @@ -191,7 +192,7 @@ public String open() {
BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
};
new Thread(runnable).start();
BackgroundThreadFacade.start(runnable);

getData();
this.meta.setChanged(this.changed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.apache.hop.ui.core.widget.MetaSelectionLine;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
Expand Down Expand Up @@ -600,7 +601,7 @@ public void run() {
}
}
};
new Thread(runnable).start();
BackgroundThreadFacade.start(runnable);

fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.hop.ui.core.widget.ColumnInfo;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.apache.hop.ui.pipeline.transform.ITableItemInsertListener;
import org.eclipse.swt.SWT;
Expand Down Expand Up @@ -759,7 +760,7 @@ public void widgetSelected(SelectionEvent arg0) {
}
}
};
new Thread(runnable).start();
BackgroundThreadFacade.start(runnable);

FormData fdFieldsComp = new FormData();
fdFieldsComp.left = new FormAttachment(0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.hop.ui.core.widget.PasswordTextVar;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
Expand Down Expand Up @@ -497,7 +498,7 @@ private void setComboValues() {
Arrays.sort(prevTransformFieldNames);
fieldColumn.setComboValues(prevTransformFieldNames);
};
new Thread(fieldLoader).start();
BackgroundThreadFacade.start(fieldLoader);
}

/** This method fills the ComboVar with common AWS region IDs (SNS-supported). */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.apache.hop.ui.core.widget.MetaSelectionLine;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
Expand Down Expand Up @@ -738,7 +739,7 @@ public void run() {
}
}
};
new Thread(runnable).start();
BackgroundThreadFacade.start(runnable);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextComposite;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.bson.Document;
import org.eclipse.swt.SWT;
Expand Down Expand Up @@ -341,7 +342,7 @@ public void run() {
}
}
};
new Thread(runnable).start();
BackgroundThreadFacade.start(runnable);

// get fields but
wbGetFields = new Button(wFieldsComp, SWT.PUSH | SWT.CENTER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.apache.hop.ui.core.widget.MetaSelectionLine;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.hopgui.HopGui;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.apache.hop.ui.pipeline.transform.ComponentSelectionListener;
Expand Down Expand Up @@ -566,7 +567,7 @@ public void focusGained(org.eclipse.swt.events.FocusEvent e) {
}
}
};
new Thread(runnable).start();
BackgroundThreadFacade.start(runnable);

FormData fdGeneralComp = new FormData();
fdGeneralComp.left = new FormAttachment(0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.apache.hop.ui.core.widget.MetaSelectionLine;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.hopgui.HopGui;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.apache.hop.ui.pipeline.transform.ComponentSelectionListener;
Expand Down Expand Up @@ -513,7 +514,7 @@ public void focusGained(org.eclipse.swt.events.FocusEvent e) {
}
}
};
new Thread(runnable).start();
BackgroundThreadFacade.start(runnable);

FormData fdGeneralComp = new FormData();
fdGeneralComp.left = new FormAttachment(0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.apache.hop.ui.core.widget.MetaSelectionLine;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.hopgui.HopGui;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.apache.hop.ui.pipeline.transform.ComponentSelectionListener;
Expand Down Expand Up @@ -636,7 +637,7 @@ public void focusLost(FocusEvent e) {
}
}
};
new Thread(runnable).start();
BackgroundThreadFacade.start(runnable);

FormData fdGeneralComp = new FormData();
fdGeneralComp.left = new FormAttachment(0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.hop.ui.core.dialog.MessageDialogWithToggle;
import org.apache.hop.ui.core.widget.ColumnInfo;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyListener;
Expand Down Expand Up @@ -191,7 +192,7 @@ public String open() {
}
}
};
new Thread(runnable).start();
BackgroundThreadFacade.start(runnable);

FormData fdAgg = new FormData();
fdAgg.left = new FormAttachment(0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.hop.ui.core.dialog.EnterSelectionDialog;
import org.apache.hop.ui.core.widget.ColumnInfo;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.apache.hop.ui.util.SwtSvgImageUtil;
import org.eclipse.swt.SWT;
Expand Down Expand Up @@ -226,7 +227,7 @@ public void widgetSelected(SelectionEvent e) {
}
}
};
new Thread(runnable).start();
BackgroundThreadFacade.start(runnable);

wFields.addModifyListener(
arg0 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.hop.ui.core.widget.ColumnInfo;
import org.apache.hop.ui.core.widget.TableView;
import org.apache.hop.ui.core.widget.TextVar;
import org.apache.hop.ui.hopgui.BackgroundThreadFacade;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.apache.hop.ui.pipeline.transform.ITableItemInsertListener;
import org.eclipse.swt.SWT;
Expand Down Expand Up @@ -262,7 +263,7 @@ public void widgetSelected(SelectionEvent e) {
}
}
};
new Thread(runnable).start();
BackgroundThreadFacade.start(runnable);

getData();
activeResultType();
Expand Down
Loading
Loading