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 @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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());
}
}
Comment on lines +105 to +110
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}

/**
* 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);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}));
Comment on lines 147 to +151
}

/**
Expand All @@ -163,4 +168,4 @@ private void updateLinkWidth() {
parent.requestLayout();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}));
Comment on lines 106 to +110
}

/**
Expand Down Expand Up @@ -182,4 +187,4 @@ public Label getPrefixLabel() {
public Label getContentLabel() {
return contentLabel;
}
}
}