1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Launch Bar: ui tweaks for proper re-sizing and keyboard events

- fixed issues when list is not drawn properly
- fixed that Esc does not work to close pop up sometimes
- fixed filtering for list with edit button
- fixed layout issues when only one item in the list and filter becomes
visible (filter is disabled in this case)
Change-Id: I562f12df8326b4efecf75150b57b699c53d398da
This commit is contained in:
Alena Laskavaia 2015-01-19 15:59:53 -05:00
parent 40b6b6c05c
commit faf222b8f2
2 changed files with 28 additions and 17 deletions

View file

@ -271,6 +271,9 @@ public class FilterControl extends Composite {
} else if (e.detail == SWT.TRAVERSE_ARROW_NEXT) {
listViewer.setFocus();
updateListSelection(false);
} else if (e.detail == SWT.TRAVERSE_ESCAPE) {
listViewer.setDefaultSelection(new StructuredSelection());
e.doit = false;
}
}
});

View file

@ -137,7 +137,28 @@ public class LaunchBarListViewer extends StructuredViewer {
}
};
private KeyListener lisItemKeyListener = new KeyListener() {
@Override
public void keyReleased(KeyEvent e) {
// ignore
}
@Override
public void keyPressed(KeyEvent e) {
if (e.character != 0 && e.character >= 0x20 && !filterControl.isVisible()) {
if (listItems.length <= 1)
return; // no filter for 1 item!
// enable filter control and send the character there
filterControl.setVisible(true);
filterControl.setFocus();
filterControl.getParent().layout(true);
filterControl.getFilterText().setText(e.character + "");
filterControl.getFilterText().setSelection(1);
} else if (e.character == SWT.ESC) {
setDefaultSelection(new StructuredSelection());
}
}
};
private class ListItem extends Composite {
@ -171,6 +192,7 @@ public class LaunchBarListViewer extends StructuredViewer {
GC gc = e.gc;
gc.setForeground(outlineColor);
gc.drawLine(0, size.y - 1, size.x, size.y - 1);
System.out.println(ListItem.this.index);
if (label == null)
lazyInit();
}
@ -235,28 +257,13 @@ public class LaunchBarListViewer extends StructuredViewer {
editButton.setBackground(backgroundColor);
editButton.addMouseTrackListener(listItemMouseTrackListener);
editButton.addTraverseListener(listItemTraverseListener);
editButton.addKeyListener(lisItemKeyListener);
} else {
// add traverse listnener to control which will have keyboard focus
addTraverseListener(listItemTraverseListener);
addKeyListener(lisItemKeyListener);
}
addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent e) {
// ignore
}
@Override
public void keyPressed(KeyEvent e) {
if (e.character != 0 && !filterControl.isVisible()) {
// enable filter control and send the character there
filterControl.setVisible(true);
filterControl.setFocus();
filterControl.getParent().layout(true);
filterControl.getFilterText().setText(e.character + "");
filterControl.getFilterText().setSelection(1);
}
}
});
setBackground(backgroundColor);
layout(true);
}
@ -453,6 +460,7 @@ public class LaunchBarListViewer extends StructuredViewer {
createSash(listComposite);
}
listComposite.pack(true);
listComposite.layout(true, true);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
if (elements.length > maxScrollBucket) {
Rectangle bounds = listItems[maxScrollBucket].getBounds();