Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2019-03-05 17:04:17 -0500
committerMickael Istria2019-03-19 16:19:15 -0400
commit94dbacdbda5749d79f92eeb833f00e5ffd2b5325 (patch)
tree6fc869db59a0b8a2d94e6413efcaeef1a2a21841
parent5e525e76495b17820d4f46ac2c2200d0297d491e (diff)
downloadm2e-core-94dbacdbda5749d79f92eeb833f00e5ffd2b5325.tar.gz
m2e-core-94dbacdbda5749d79f92eeb833f00e5ffd2b5325.tar.xz
m2e-core-94dbacdbda5749d79f92eeb833f00e5ffd2b5325.zip
Bug 545026: fix background color in Source Lookup preferences
Do not override Composite so theme association remains Change-Id: I50662eced34a4ece0011f75001e601bd6ae3bd9d Signed-off-by: Mickael Istria <mistria@redhat.com>
-rw-r--r--org.eclipse.m2e.sourcelookup.ui/src/org/eclipse/m2e/sourcelookup/ui/internal/SourceLookupPreferencePage.java50
1 files changed, 36 insertions, 14 deletions
diff --git a/org.eclipse.m2e.sourcelookup.ui/src/org/eclipse/m2e/sourcelookup/ui/internal/SourceLookupPreferencePage.java b/org.eclipse.m2e.sourcelookup.ui/src/org/eclipse/m2e/sourcelookup/ui/internal/SourceLookupPreferencePage.java
index 69f6fbc7..aa8ffbca 100644
--- a/org.eclipse.m2e.sourcelookup.ui/src/org/eclipse/m2e/sourcelookup/ui/internal/SourceLookupPreferencePage.java
+++ b/org.eclipse.m2e.sourcelookup.ui/src/org/eclipse/m2e/sourcelookup/ui/internal/SourceLookupPreferencePage.java
@@ -11,9 +11,12 @@
package org.eclipse.m2e.sourcelookup.ui.internal;
import org.eclipse.jdt.internal.launching.sourcelookup.advanced.AdvancedSourceLookupSupport;
+import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
@@ -36,16 +39,14 @@ public class SourceLookupPreferencePage extends PreferencePage implements IWorkb
noDefaultAndApplyButton();
}
- public void init(IWorkbench workbench) {}
+ @Override
+public void init(IWorkbench workbench) {}
@Override
protected Control createContents(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE) {
- @Override
- public Point computeSize(int wHint, int hHint, boolean changed) {
- return new Point(0, 0);
- }
- };
+ Composite composite = new Composite(parent, SWT.NONE);
+
+ disableScrollingFor(composite);
GridLayout gl_composite = new GridLayout(1, false);
gl_composite.marginWidth = 0;
@@ -55,25 +56,46 @@ public class SourceLookupPreferencePage extends PreferencePage implements IWorkb
Label lblVMArguments = new Label(composite, SWT.NONE);
lblVMArguments.setText("VM arguments:");
- vmArguments = new Text(composite, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP);
- vmArguments.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
+ GridDataFactory textGridDataFactory = GridDataFactory.createFrom(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)).hint(parent.getSize().x, SWT.DEFAULT);
+
+ vmArguments = new Text(composite, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.MULTI);
+ textGridDataFactory.applyTo(vmArguments);
vmArguments.setText(AdvancedSourceLookupSupport.getJavaagentString());
Label lblLaunchVMArguments = new Label(composite, SWT.NONE);
lblLaunchVMArguments.setText(".launch file VM arguments:");
- launchFileVMArguments = new Text(composite, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP);
- launchFileVMArguments.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
+ launchFileVMArguments = new Text(composite, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.MULTI);
+ textGridDataFactory.applyTo(launchFileVMArguments);
launchFileVMArguments.setText("-javaagent:${sourcelookup_agent_path}");
Label lblLaunchFileAttribute = new Label(composite, SWT.NONE);
lblLaunchFileAttribute.setText(".launch file attribute:");
- launchFileAttribute = new Text(composite, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP);
+ launchFileAttribute = new Text(composite, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.MULTI);
launchFileAttribute.setText(
"<stringAttribute key=\"org.eclipse.debug.core.source_locator_id\" value=\"org.eclipse.m2e.sourcelookupDirector\"/>\n");
- launchFileAttribute.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+ textGridDataFactory.applyTo(launchFileAttribute);
return composite;
}
+
+ private void disableScrollingFor(Composite composite) {
+ Composite temp = composite;
+ while (temp != null && !(temp instanceof ScrolledComposite)) {
+ temp = temp.getParent();
+ }
+ ScrolledComposite scrolledComposite = (ScrolledComposite)temp;
+ if (scrolledComposite != null) {
+ ControlAdapter resizeAndWrapRatherThanScroll = new ControlAdapter() {
+ @Override public void controlResized(ControlEvent e) {
+ if (composite.isVisible()) {
+ scrolledComposite.setMinWidth(scrolledComposite.getSize().x);
+ }
+ }
+ };
+ scrolledComposite.addControlListener(resizeAndWrapRatherThanScroll);
+ composite.addDisposeListener(e -> scrolledComposite.removeControlListener(resizeAndWrapRatherThanScroll));
+ }
+ }
}

Back to the top