Skip to content

Commit a614e30

Browse files
committed
Remove beeping from FilteredTree
beeping is annoying and beeping in a FilteredTree in certain internal situations does not add value for the user.
1 parent 50c2ad6 commit a614e30

File tree

2 files changed

+34
-40
lines changed

2 files changed

+34
-40
lines changed

bundles/org.eclipse.e4.ui.dialogs/src/org/eclipse/e4/ui/dialogs/filteredtree/FilteredTree.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.eclipse.swt.layout.RowData;
3737
import org.eclipse.swt.widgets.Composite;
3838
import org.eclipse.swt.widgets.Control;
39-
import org.eclipse.swt.widgets.Display;
4039
import org.eclipse.swt.widgets.Text;
4140
import org.eclipse.swt.widgets.Tree;
4241
import org.eclipse.swt.widgets.TreeItem;
@@ -391,25 +390,24 @@ public void keyPressed(KeyEvent e) {
391390
if (e.detail == SWT.TRAVERSE_RETURN) {
392391
e.doit = false;
393392
if (getViewer().getTree().getItemCount() == 0) {
394-
Display.getCurrent().beep();
395-
} else {
396-
// if the initial filter text hasn't changed, do not try
397-
// to match
398-
boolean hasFocus = getViewer().getTree().setFocus();
399-
boolean textChanged = !getInitialText().equals(filterText.getText().trim());
400-
if (hasFocus && textChanged && filterText.getText().trim().length() > 0) {
401-
Tree tree = getViewer().getTree();
402-
TreeItem item;
403-
if (tree.getSelectionCount() > 0) {
404-
item = getFirstMatchingItem(tree.getSelection());
405-
} else {
406-
item = getFirstMatchingItem(tree.getItems());
407-
}
408-
if (item != null) {
409-
tree.setSelection(new TreeItem[] { item });
410-
ISelection sel = getViewer().getSelection();
411-
getViewer().setSelection(sel, true);
412-
}
393+
return;
394+
}
395+
// if the initial filter text hasn't changed, do not try
396+
// to match
397+
boolean hasFocus = getViewer().getTree().setFocus();
398+
boolean textChanged = !getInitialText().equals(filterText.getText().trim());
399+
if (hasFocus && textChanged && filterText.getText().trim().length() > 0) {
400+
Tree tree = getViewer().getTree();
401+
TreeItem item;
402+
if (tree.getSelectionCount() > 0) {
403+
item = getFirstMatchingItem(tree.getSelection());
404+
} else {
405+
item = getFirstMatchingItem(tree.getItems());
406+
}
407+
if (item != null) {
408+
tree.setSelection(new TreeItem[] { item });
409+
ISelection sel = getViewer().getSelection();
410+
getViewer().setSelection(sel, true);
413411
}
414412
}
415413
}

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/dialogs/FilteredTree.java

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.eclipse.swt.layout.GridLayout;
3838
import org.eclipse.swt.widgets.Composite;
3939
import org.eclipse.swt.widgets.Control;
40-
import org.eclipse.swt.widgets.Display;
4140
import org.eclipse.swt.widgets.Text;
4241
import org.eclipse.swt.widgets.Tree;
4342
import org.eclipse.swt.widgets.TreeItem;
@@ -584,26 +583,23 @@ public void keyPressed(KeyEvent e) {
584583
protected void updateTreeSelection(boolean setFocus) {
585584
Tree tree = getViewer().getTree();
586585
if (tree.getItemCount() == 0) {
587-
if (setFocus) {
588-
Display.getCurrent().beep();
586+
return;
587+
}
588+
// if the initial filter text hasn't changed, do not try
589+
// to match
590+
boolean hasFocus = setFocus ? tree.setFocus() : true;
591+
boolean textChanged = !getInitialText().equals(filterText.getText().trim());
592+
if (hasFocus && textChanged && filterText.getText().trim().length() > 0) {
593+
TreeItem item;
594+
if (tree.getSelectionCount() > 0) {
595+
item = getFirstMatchingItem(tree.getSelection());
596+
} else {
597+
item = getFirstMatchingItem(tree.getItems());
589598
}
590-
} else {
591-
// if the initial filter text hasn't changed, do not try
592-
// to match
593-
boolean hasFocus = setFocus ? tree.setFocus() : true;
594-
boolean textChanged = !getInitialText().equals(filterText.getText().trim());
595-
if (hasFocus && textChanged && filterText.getText().trim().length() > 0) {
596-
TreeItem item;
597-
if (tree.getSelectionCount() > 0) {
598-
item = getFirstMatchingItem(tree.getSelection());
599-
} else {
600-
item = getFirstMatchingItem(tree.getItems());
601-
}
602-
if (item != null) {
603-
tree.setSelection(new TreeItem[] { item });
604-
ISelection sel = getViewer().getSelection();
605-
getViewer().setSelection(sel, true);
606-
}
599+
if (item != null) {
600+
tree.setSelection(new TreeItem[] { item });
601+
ISelection sel = getViewer().getSelection();
602+
getViewer().setSelection(sel, true);
607603
}
608604
}
609605
}

0 commit comments

Comments
 (0)