Skip to content
Draft
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 @@ -282,6 +282,9 @@ private void addDataGrid(boolean refresh) {
fdData.bottom = new FormAttachment(100, 0);
wData.setLayoutData(fdData);

// Set a theme for this control that changes dynamically
PropsUi.setTheme(wData);

wTabFolder.layout(true, true);

wFields.nrNonEmpty();
Expand Down
35 changes: 23 additions & 12 deletions ui/src/main/java/org/apache/hop/ui/core/PropsUi.java
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,18 @@ public void setMetricsPanelShowDataVolumeOut(boolean show) {
setProperty(METRICS_PANEL_SHOW_DATA_VOLUME_OUT, show ? YES : NO);
}

@Deprecated(since = "2.19.0", forRemoval = true)
public static void setLook(Widget widget) {
// Do nothing
}

@Deprecated(since = "2.19.0", forRemoval = true)
public static void setLook(final Widget widget, int style) {
// Do nothing
}

/** Set themes colors and font to the widget and all its children. */
public static void setTheme(final Widget widget) {
int style = WIDGET_STYLE_DEFAULT;
if (widget instanceof Table) {
style = WIDGET_STYLE_TABLE;
Expand All @@ -755,31 +766,31 @@ public static void setLook(Widget widget) {
}
}

setLook(widget, style);
setTheme(widget, style);

if (widget instanceof Composite composite) {
for (Control child : composite.getChildren()) {
setLook(child);
for (Control control : composite.getChildren()) {
setTheme(control);
}
}
}

public static void setLook(final Widget widget, int style) {
public static void setTheme(final Widget widget, int style) {
if (EnvironmentUtils.getInstance().isWeb()) {
setLookOnWeb(widget, style);
setThemeOnWeb(widget, style);
return;
}
if (OsHelper.isWindows()) {
setLookOnWindows(widget, style);
setThemeOnWindows(widget, style);
} else if (OsHelper.isMac()) {
setLookOnMac(widget, style);
setThemeOnMac(widget, style);
} else {
setLookOnLinux(widget, style);
setThemeOnLinux(widget, style);
}
}

/** Hop Web (RAP) specific look. Keeps web theme logic separate from OS-specific setLookOn*. */
protected static void setLookOnWeb(final Widget widget, int style) {
protected static void setThemeOnWeb(final Widget widget, int style) {
final GuiResource gui = GuiResource.getInstance();
Font font = gui.getFontDefault();
Color background = gui.getWidgetBackGroundColor();
Expand Down Expand Up @@ -891,7 +902,7 @@ private static void ensureSafeRenderer(CTabFolder tabFolder) {
}
}

protected static void setLookOnWindows(final Widget widget, int style) {
protected static void setThemeOnWindows(final Widget widget, int style) {
final GuiResource gui = GuiResource.getInstance();
Font font = gui.getFontDefault();
Color background = gui.getWidgetBackGroundColor();
Expand Down Expand Up @@ -968,7 +979,7 @@ protected static void setLookOnWindows(final Widget widget, int style) {
}
}

protected static void setLookOnMac(final Widget widget, int style) {
protected static void setThemeOnMac(final Widget widget, int style) {
final GuiResource gui = GuiResource.getInstance();
Font font = gui.getFontDefault();
Color background = null;
Expand Down Expand Up @@ -1030,7 +1041,7 @@ protected static void setLookOnMac(final Widget widget, int style) {
}
}

protected static void setLookOnLinux(final Widget widget, int style) {
protected static void setThemeOnLinux(final Widget widget, int style) {
final GuiResource gui = GuiResource.getInstance();
Font font = gui.getFontDefault();
Color background = GuiResource.getInstance().getWidgetBackGroundColor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.hop.i18n.BaseMessages;
import org.apache.hop.ui.core.ConstUi;
import org.apache.hop.ui.core.PropsUi;
import org.apache.hop.ui.core.dialog.BaseDialog;
import org.apache.hop.ui.core.dialog.EnterSelectionDialog;
import org.apache.hop.ui.core.dialog.ErrorDialog;
import org.apache.hop.ui.core.dialog.MessageBox;
Expand All @@ -57,15 +58,13 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
Expand Down Expand Up @@ -276,23 +275,8 @@ public boolean open() {
setTreeMenu();
}
});
shell.addListener(SWT.Close, e -> cancel());

// Prevent resizing below the complete control layout (notably right-side action buttons).
Point minSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
shell.setMinimumSize(minSize);
BaseTransformDialog.setSize(shell);

shell.open();

// Handle the event loop until we're done with this shell...
//
Display display = shell.getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());

return tableName != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,8 @@ public static void defaultShellHandling(
//
addSpacesOnTabs(shell);

PropsUi.setTheme(shell);

if (useStandardMinimumSize) {
shell.setMinimumSize(650, 250);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,8 @@ public GuiAction open() {
// Manually set canvas size otherwise canvas never gets drawn.
wCanvas.setSize(10, 10);

PropsUi.setTheme(shell);

// Show the dialog now
//
shell.open();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,11 @@ public int open() {
BaseTransformDialog.positionBottomButtons(
shell, buttons.toArray(new Button[0]), formMargin, wLabel);

BaseTransformDialog.setSize(shell);
shell.addListener(SWT.Close, e -> dispose());
BaseTransformDialog.setSize(shell);

PropsUi.setTheme(shell);

shell.open();

Display display = shell.getDisplay();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
Expand Down Expand Up @@ -316,26 +315,7 @@ public java.util.List<SourceToTargetMapping> open() {

getData();

// Set the size as well...
//
BaseTransformDialog.setSize(shell);

// Shell closed?
//
shell.addListener(SWT.Close, e -> cancel());

// Open the shell
//
shell.open();

// Handle the event loop until we're done with this shell...
//
Display display = shell.getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
BaseDialog.defaultShellHandling(shell, e -> ok(), e -> cancel());

return mappings;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@
import org.apache.hop.ui.hopgui.file.workflow.HopGuiWorkflowGraph;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
Expand Down Expand Up @@ -184,34 +182,10 @@ public String open() {

enrich(this);

// Detect [X] or ALT-F4 or something that kills this window...
shell.addShellListener(
new ShellAdapter() {
@Override
public void shellClosed(ShellEvent e) {
checkCancel(e);
}
});

origText = text;
getData();

// Set the size as well...
//
BaseTransformDialog.setSize(shell);

// Open the shell
//
shell.open();

// Handle the event loop until we're done with this shell...
//
Display display = shell.getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());

return text;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public int open() {

int shellStyle = style & (SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL | SWT.PRIMARY_MODAL);
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN | shellStyle);
PropsUi.setLook(shell);
shell.setImage(GuiResource.getInstance().getImageHop());
shell.setText(Const.NVL(text, ""));

Expand All @@ -92,7 +91,6 @@ public int open() {
int margin = PropsUi.getMargin();

Composite composite = new Composite(shell, SWT.NONE);
PropsUi.setLook(composite);
composite.setLayout(new GridLayout());
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
Expand All @@ -102,7 +100,6 @@ public int open() {
// The message...
//
Label wMessage = new Label(composite, SWT.LEFT | SWT.WRAP);
PropsUi.setLook(wMessage);
wMessage.setText(message);
wMessage.setLayoutData(new GridData(GridData.FILL_BOTH));

Expand Down Expand Up @@ -184,6 +181,8 @@ public int open() {

BaseTransformDialog.setSize(shell);

PropsUi.setTheme(shell);

// If minimum size is set, use it directly instead of packing
if (minimumWidth > 0 || minimumHeight > 0) {
shell.layout();
Expand All @@ -204,6 +203,8 @@ public int open() {
}
}

// BaseDialog.defaultShellHandling(shell, c -> ok(), c -> dispose());

return returnValue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ public int open() {
}
});

PropsUi.setTheme(shell);

shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ public void run(boolean cancelable, IRunnableWithProgress runnable)
addCancelButtonIfNeeded(cancelable, margin);
BaseTransformDialog.setSize(shell);
addShellCloseHandler();

PropsUi.setTheme(shell);

shell.open();

Cursor oldCursor = shell.getCursor();
Expand All @@ -92,6 +95,7 @@ private void createModalShell(boolean cancelable) {
new Shell(parent, SWT.RESIZE | SWT.APPLICATION_MODAL | (cancelable ? SWT.CLOSE : SWT.NONE));
shell.setText(BaseMessages.getString(PKG, "ProgressMonitorDialog.Shell.Title"));
shell.setImage(GuiResource.getInstance().getImageHopUi());
shell.setMinimumSize(500, 200);
PropsUi.setLook(shell);
display = shell.getDisplay();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ public void shellClosed(ShellEvent e) {
final String ok = button.getText();
long startTime = new Date().getTime();

PropsUi.setTheme(shell);

shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
Expand Down
Loading
Loading