diff --git a/com.microsoft.copilot.eclipse.anypoint/src/com/microsoft/copilot/eclipse/anypoint/MuleSoftMcpPreferencePage.java b/com.microsoft.copilot.eclipse.anypoint/src/com/microsoft/copilot/eclipse/anypoint/MuleSoftMcpPreferencePage.java index 6a568331..5e9a2386 100644 --- a/com.microsoft.copilot.eclipse.anypoint/src/com/microsoft/copilot/eclipse/anypoint/MuleSoftMcpPreferencePage.java +++ b/com.microsoft.copilot.eclipse.anypoint/src/com/microsoft/copilot/eclipse/anypoint/MuleSoftMcpPreferencePage.java @@ -37,10 +37,12 @@ protected Control createContents(Composite parent) { Composite container = new Composite(parent, SWT.NONE); container.setLayout(new GridLayout(2, false)); container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + container.setBackground(parent.getBackground()); enabledButton = new Button(container, SWT.CHECK); enabledButton.setText("Enable MuleSoft MCP Server registration"); enabledButton.setLayoutData(spanTwoColumns()); + useParentBackground(enabledButton); createLabel(container, "Client ID:"); clientIdText = createText(container, SWT.BORDER); @@ -56,6 +58,7 @@ protected Control createContents(Composite parent) { note.setText("Credentials are stored in Eclipse secure storage. If a field is blank, the integration also checks " + "ANYPOINT_CLIENT_ID, ANYPOINT_CLIENT_SECRET, and ANYPOINT_REGION from the Studio process environment."); note.setLayoutData(spanTwoColumns()); + useParentBackground(note); loadSettings(); return container; @@ -84,6 +87,7 @@ private void loadSettings() { private static void createLabel(Composite container, String text) { Label label = new Label(container, SWT.NONE); label.setText(text); + useParentBackground(label); } private static Text createText(Composite container, int style) { @@ -97,4 +101,11 @@ private static GridData spanTwoColumns() { gridData.horizontalSpan = 2; return gridData; } + + private static void useParentBackground(Control control) { + if (control != null && !control.isDisposed() && control.getParent() != null + && !control.getParent().isDisposed()) { + control.setBackground(control.getParent().getBackground()); + } + } } diff --git a/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/PreferencePageUtils.java b/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/PreferencePageUtils.java index ab676ebf..01736806 100644 --- a/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/PreferencePageUtils.java +++ b/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/PreferencePageUtils.java @@ -10,8 +10,10 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PartInitException; @@ -68,6 +70,7 @@ private static void createLink(Composite composite, String label, String tooltip link.setText(label); link.setToolTipText(tooltip); link.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1)); + inheritParentBackground(link); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -99,4 +102,32 @@ private static void openUrlInBrowser(SelectionEvent event) { private static void openPreferencePage(Shell shell, String preferenceId, SelectionEvent event) { PreferencesUtil.createPreferenceDialogOn(shell, preferenceId, null, event); } -} \ No newline at end of file + + /** + * Applies a control's parent background to layout-only preference controls and their children. + * + * @param control the control whose background should match its parent + */ + public static void inheritParentBackground(Control control) { + if (control == null || control.isDisposed() || control.getParent() == null + || control.getParent().isDisposed()) { + return; + } + + applyBackground(control, control.getParent().getBackground()); + } + + private static void applyBackground(Control control, Color background) { + if (control == null || control.isDisposed() || background == null || background.isDisposed()) { + return; + } + + control.setBackground(background); + if (control instanceof Composite composite) { + composite.setBackgroundMode(SWT.INHERIT_FORCE); + for (Control child : composite.getChildren()) { + applyBackground(child, background); + } + } + } +} diff --git a/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/WrappableIconLink.java b/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/WrappableIconLink.java index 591f0617..2b4280ee 100644 --- a/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/WrappableIconLink.java +++ b/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/WrappableIconLink.java @@ -137,13 +137,18 @@ public void widgetSelected(SelectionEvent e) { icon.dispose(); } }); + + PreferencePageUtils.inheritParentBackground(this); } /** * Sets up the resize listener to dynamically adjust the link width. */ private void setupResizeListener() { - parent.addControlListener(ControlListener.controlResizedAdapter(e -> updateLinkWidth())); + parent.addControlListener(ControlListener.controlResizedAdapter(e -> { + PreferencePageUtils.inheritParentBackground(this); + updateLinkWidth(); + })); } /** @@ -163,4 +168,4 @@ private void updateLinkWidth() { parent.requestLayout(); } } -} \ No newline at end of file +} diff --git a/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/WrappableNoteLabel.java b/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/WrappableNoteLabel.java index ce4bd16a..55ae279b 100644 --- a/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/WrappableNoteLabel.java +++ b/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/WrappableNoteLabel.java @@ -96,13 +96,18 @@ private void createControls() { boldFont.dispose(); } }); + + PreferencePageUtils.inheritParentBackground(this); } /** * Sets up the resize listener to dynamically adjust the content label width. */ private void setupResizeListener() { - parentToWatch.addControlListener(ControlListener.controlResizedAdapter(e -> updateContentLabelWidth())); + parentToWatch.addControlListener(ControlListener.controlResizedAdapter(e -> { + PreferencePageUtils.inheritParentBackground(this); + updateContentLabelWidth(); + })); } /** @@ -182,4 +187,4 @@ public Label getPrefixLabel() { public Label getContentLabel() { return contentLabel; } -} \ No newline at end of file +}