diff options
author | Igor Fedorenko | 2013-03-12 23:01:29 +0000 |
---|---|---|
committer | Igor Fedorenko | 2013-03-12 23:01:29 +0000 |
commit | d4017dc34b0756e6a98fdbb2e772b9777a453e94 (patch) | |
tree | 76896498c5549c0fea01b46b8b45dde479d19c02 /org.eclipse.m2e.launching | |
parent | 435aed83fdbe1590d5e255fa8c0afa42d76e005e (diff) | |
download | m2e-core-d4017dc34b0756e6a98fdbb2e772b9777a453e94.tar.gz m2e-core-d4017dc34b0756e6a98fdbb2e772b9777a453e94.tar.xz m2e-core-d4017dc34b0756e6a98fdbb2e772b9777a453e94.zip |
380484 cleaned up contributed patch
* Fixed layout issues
* Replaced ComboViewer with simpler Combo
* Always show threads dropdown, but disable it on single processor
systems
* Only pass --threads when more than one thread to avoid ugly
maven warning when non-threadsafe plugins are used
Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
Diffstat (limited to 'org.eclipse.m2e.launching')
-rw-r--r-- | org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java | 4 | ||||
-rw-r--r-- | org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenLaunchMainTab.java | 61 |
2 files changed, 25 insertions, 40 deletions
diff --git a/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java b/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java index b24cf74f..fbcb1a78 100644 --- a/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java +++ b/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java @@ -313,8 +313,8 @@ public class MavenLaunchDelegate extends JavaLaunchDelegate implements MavenLaun sb.append(" -Dmaven.test.skip=true"); //$NON-NLS-1$ } - String threads = configuration.getAttribute(MavenLaunchConstants.ATTR_THREADS, (String) null); - if(threads != null && threads.trim().length() > 0) { + int threads = configuration.getAttribute(MavenLaunchConstants.ATTR_THREADS, 1); + if(threads > 1) { sb.append(" --threads ").append(threads); } diff --git a/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenLaunchMainTab.java b/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenLaunchMainTab.java index c8cede6a..b95feb9e 100644 --- a/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenLaunchMainTab.java +++ b/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenLaunchMainTab.java @@ -50,6 +50,7 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.DirectoryDialog; @@ -123,7 +124,7 @@ public class MavenLaunchMainTab extends AbstractLaunchConfigurationTab implement ComboViewer runtimeComboViewer; - private ComboViewer threadsComboViewer; + private Combo threadsCombo; public MavenLaunchMainTab(boolean isBuilder) { this.isBuilder = isBuilder; @@ -133,6 +134,9 @@ public class MavenLaunchMainTab extends AbstractLaunchConfigurationTab implement return MavenImages.IMG_LAUNCH_MAIN; } + /** + * @wbp.parser.entryPoint + */ public void createControl(Composite parent) { Composite mainComposite = new Composite(parent, SWT.NONE); setControl(mainComposite); @@ -357,47 +361,22 @@ public class MavenLaunchMainTab extends AbstractLaunchConfigurationTab implement enableWorkspaceResolution.setData("name", "enableWorkspaceResolution"); //$NON-NLS-1$ //$NON-NLS-2$ enableWorkspaceResolution.setText(org.eclipse.m2e.internal.launch.Messages.MavenLaunchMainTab_btnResolveWorkspace); - final int processors = Runtime.getRuntime().availableProcessors(); - if(processors > 1) { + { + final int processors = Runtime.getRuntime().availableProcessors(); + new Label(mainComposite, SWT.NONE); Composite composite = new Composite(mainComposite, SWT.NONE); composite.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); GridLayout gridLayout = new GridLayout(2, false); gridLayout.marginWidth = 0; gridLayout.marginHeight = 0; composite.setLayout(gridLayout); - - final Object[] threadsToUse = new Object[processors]; + threadsCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY | SWT.SINGLE); + threadsCombo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); for(int i = 1; i <= processors; i++ ) { - threadsToUse[i - 1] = i + ""; + threadsCombo.add(Integer.toString(i)); } - - threadsComboViewer = new ComboViewer(composite, SWT.BORDER | SWT.READ_ONLY | SWT.SINGLE); - threadsComboViewer.getCombo().setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); - threadsComboViewer.setContentProvider(new IStructuredContentProvider() { - - @Override - public Object[] getElements(Object input) { - return threadsToUse; - } - - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - - @Override - public void dispose() { - } - }); - - threadsComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { - @Override - public void selectionChanged(SelectionChangedEvent event) { - entriesChanged(); - } - }); - - threadsComboViewer.setInput("1"); - threadsComboViewer.setSelection(new StructuredSelection("1")); + threadsCombo.setEnabled(processors > 1); + threadsCombo.addSelectionListener(modyfyingListener); Label threadsLabel = new Label(composite, SWT.NONE); threadsLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); @@ -628,7 +607,7 @@ public class MavenLaunchMainTab extends AbstractLaunchConfigurationTab implement this.skipTestsButton.setSelection(getAttribute(configuration, ATTR_SKIP_TESTS, false)); this.nonRecursiveButton.setSelection(getAttribute(configuration, ATTR_NON_RECURSIVE, false)); this.enableWorkspaceResolution.setSelection(getAttribute(configuration, ATTR_WORKSPACE_RESOLUTION, false)); - this.threadsComboViewer.setSelection(new StructuredSelection(getAttribute(configuration, ATTR_THREADS, ""))); //$NON-NLS-1$ + this.threadsCombo.select(getAttribute(configuration, ATTR_THREADS, 1)); String location = getAttribute(configuration, ATTR_RUNTIME, ""); //$NON-NLS-1$ MavenRuntime runtime = runtimeManager.getRuntime(location); @@ -677,6 +656,14 @@ public class MavenLaunchMainTab extends AbstractLaunchConfigurationTab implement } } + private int getAttribute(ILaunchConfiguration configuration, String name, int defaultValue) { + try { + return configuration.getAttribute(name, defaultValue); + } catch(CoreException ex) { + return defaultValue; + } + } + public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { } @@ -721,9 +708,7 @@ public class MavenLaunchMainTab extends AbstractLaunchConfigurationTab implement MavenRuntime runtime = (MavenRuntime) selection.getFirstElement(); configuration.setAttribute(ATTR_RUNTIME, runtime.getLocation()); - IStructuredSelection threadsSelection = (IStructuredSelection) threadsComboViewer.getSelection(); - String threads = (String) threadsSelection.getFirstElement(); - configuration.setAttribute(ATTR_THREADS, threads); + configuration.setAttribute(ATTR_THREADS, threadsCombo.getSelectionIndex()); // store as String in "param=value" format List<String> properties = new ArrayList<String>(); |