|
1 | 1 | /*******************************************************************************
|
2 |
| - * Copyright (c) 2000, 2017 IBM Corporation and others. |
| 2 | + * Copyright (c) 2000, 2025 IBM Corporation and others. |
3 | 3 | *
|
4 | 4 | * This program and the accompanying materials
|
5 | 5 | * are made available under the terms of the Eclipse Public License 2.0
|
|
13 | 13 | *******************************************************************************/
|
14 | 14 | package org.eclipse.jdt.internal.ui.search;
|
15 | 15 |
|
| 16 | +import java.text.MessageFormat; |
16 | 17 | import java.util.ArrayList;
|
17 | 18 | import java.util.List;
|
18 | 19 |
|
|
78 | 79 |
|
79 | 80 | import org.eclipse.jdt.internal.corext.util.Messages;
|
80 | 81 |
|
| 82 | +import org.eclipse.jdt.launching.IVMInstall2; |
| 83 | +import org.eclipse.jdt.launching.JavaRuntime; |
| 84 | + |
81 | 85 | import org.eclipse.jdt.ui.search.ElementQuerySpecification;
|
82 | 86 | import org.eclipse.jdt.ui.search.PatternQuerySpecification;
|
83 | 87 | import org.eclipse.jdt.ui.search.QuerySpecification;
|
@@ -283,6 +287,7 @@ public static SearchPatternData create(IDialogSettings settings) {
|
283 | 287 | private Button[] fLimitTo;
|
284 | 288 | private Button[] fIncludeMasks;
|
285 | 289 | private Group fLimitToGroup;
|
| 290 | + private Label fMessageLabel; |
286 | 291 |
|
287 | 292 | private int fMatchLocations;
|
288 | 293 | private Link fMatchLocationsLink;
|
@@ -540,6 +545,9 @@ public void createControl(Composite parent) {
|
540 | 545 | Control includeMask= createIncludeMask(result);
|
541 | 546 | includeMask.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
|
542 | 547 |
|
| 548 | + Control messageLabel= createMessageLabel(result); |
| 549 | + messageLabel.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1)); |
| 550 | + |
543 | 551 | //createParticipants(result);
|
544 | 552 |
|
545 | 553 | SelectionAdapter javaElementInitializer= new SelectionAdapter() {
|
@@ -588,6 +596,18 @@ public void widgetSelected(SelectionEvent e) {
|
588 | 596 | }*/
|
589 | 597 |
|
590 | 598 |
|
| 599 | + private Control createMessageLabel(Composite parent) { |
| 600 | + Composite result= new Composite(parent, SWT.NONE); |
| 601 | + GridLayout layout= new GridLayout(1, false); |
| 602 | + layout.marginWidth= 5; |
| 603 | + layout.marginHeight= 5; |
| 604 | + result.setLayout(layout); |
| 605 | + |
| 606 | + fMessageLabel= new Label(result, SWT.NONE); |
| 607 | + fMessageLabel.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1)); |
| 608 | + return result; |
| 609 | + } |
| 610 | + |
591 | 611 | private Control createExpression(Composite parent) {
|
592 | 612 | Composite result= new Composite(parent, SWT.NONE);
|
593 | 613 | GridLayout layout= new GridLayout(2, false);
|
@@ -637,6 +657,20 @@ public void widgetSelected(SelectionEvent e) {
|
637 | 657 | final void updateOKStatus() {
|
638 | 658 | boolean isValidPattern= isValidSearchPattern();
|
639 | 659 | boolean isValidMask= getIncludeMask() != 0;
|
| 660 | + fMessageLabel.setText(""); //$NON-NLS-1$ |
| 661 | + if ((getIncludeMask() & JavaSearchScopeFactory.JRE) != 0) { |
| 662 | + String release= JavaCore.getOption(JavaCore.COMPILER_RELEASE); |
| 663 | + if (release.equals(JavaCore.ENABLED)) { |
| 664 | + String compliance= JavaCore.getOption(JavaCore.COMPILER_COMPLIANCE); |
| 665 | + if (compliance != null) { |
| 666 | + if (JavaRuntime.getVMInstall(JavaRuntime.newDefaultJREContainerPath()) instanceof IVMInstall2 jreInstall) { |
| 667 | + if (JavaCore.compareJavaVersions(compliance, jreInstall.getJavaVersion()) < 0) { |
| 668 | + fMessageLabel.setText(MessageFormat.format(SearchMessages.JavaSearchPage_release_warning_message, compliance, jreInstall.getJavaVersion())); |
| 669 | + } |
| 670 | + } |
| 671 | + } |
| 672 | + } |
| 673 | + } |
640 | 674 | getContainer().setPerformActionEnabled(isValidPattern && isValidMask);
|
641 | 675 | }
|
642 | 676 |
|
|
0 commit comments