Skip to content
Draft
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 @@ -1732,7 +1732,7 @@ public void handleEvent(Event e) {
// We never propagate the keystroke for an explicit
// keystroke invocation of the popup
e.doit = false;
openProposalPopup(false);
openProposalPopup0(false);
return;
}
}
Expand Down Expand Up @@ -1874,7 +1874,7 @@ private String hex(int i) {
* a boolean indicating whether the popup was autoactivated. If
* false, a beep will sound when no proposals can be shown.
*/
private void openProposalPopup(boolean autoActivated) {
private void openProposalPopup0(boolean autoActivated) {
if (isValid()) {
if (popup == null) {
// Check whether there are any proposals to be shown.
Expand Down Expand Up @@ -1910,7 +1910,22 @@ private void openProposalPopup(boolean autoActivated) {
* @since 3.22
*/
public void openProposalPopup() {
openProposalPopup(false);
openProposalPopup(true);
}

/**
* Open the proposal popup and display the proposals provided by the proposal
* provider. This method returns immediately. That is, it does not wait for a
* proposal to be selected. This method is used to explicitly invoke the opening
* of the popup. If there are no proposals to show, the popup will not open. If
* {@code beep} is true, a beep will be sounded when there are no proposals.
*
* @param beep
* a boolean indicating whether to beep if no proposals can be shown
* @since 3.23
*/
public void openProposalPopup(boolean beep) {
openProposalPopup0(!beep);
}

/**
Expand Down Expand Up @@ -2052,7 +2067,7 @@ private void autoActivate() {
if (!isValid() || receivedKeyDown) {
return;
}
getControl().getDisplay().syncExec(() -> openProposalPopup(true));
getControl().getDisplay().syncExec(() -> openProposalPopup0(true));
};
Thread t = new Thread(runnable);
t.start();
Expand All @@ -2065,7 +2080,7 @@ private void autoActivate() {
// event occurring.
getControl().getDisplay().asyncExec(() -> {
if (isValid()) {
openProposalPopup(true);
openProposalPopup0(true);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static org.junit.Assert.assertTrue;

import org.eclipse.jface.fieldassist.ContentProposalAdapter;
import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.jface.fieldassist.IContentProposalProvider;
import org.eclipse.jface.fieldassist.SimpleContentProposalProvider;
import org.eclipse.jface.fieldassist.TextContentAdapter;
Expand Down Expand Up @@ -236,4 +237,31 @@ private void assertOneShellUp() {
assertEquals("There should only be one shell up, the dialog", originalShellCount + 1,
text.getDisplay().getShells().length);
}

/**
* Test that openProposalPopup(boolean beep) method is available and can be called
* to suppress the beep. This test verifies that the method accepts both true and false
* for the beep parameter.
*/
@Test
public void testOpenProposalPopupWithBeepParameter() {
// Create an adapter with an empty proposal provider to test the beep control
ContentProposalAdapter adapter = new ContentProposalAdapter(text, new TextContentAdapter(),
(contents, position) -> new IContentProposal[0], null, null);

// Test calling with beep=false (should not beep)
adapter.openProposalPopup(false);
spinEventLoop();
assertOneShellUp(); // No popup should open since there are no proposals

// Test calling with beep=true (would beep, but we can't test the sound)
adapter.openProposalPopup(true);
spinEventLoop();
assertOneShellUp(); // No popup should open since there are no proposals

// Verify the parameterless method still works (should beep by default)
adapter.openProposalPopup();
spinEventLoop();
assertOneShellUp(); // No popup should open since there are no proposals
}
}