fixupActionBarSize();
}
});
final Text text = new Text(cArea, SWT.NONE);
FormData filledFormData = Utils.getFilledFormData();
text.setLayoutData(filledFormData);
text.setData("ObfusticateImage", new ObfusticateImage() {
public Image obfusticatedImage(Image image) {
Point location = Utils.getLocationRelativeToShell(text);
Point size = text.getSize();
UIDebugGenerator.obfusticateArea(display, image, new Rectangle(
location.x, location.y, size.x, size.y));
return image;
}
});
text.addListener(SWT.Resize, new Listener() {
Font lastFont = null;
public void handleEvent(Event event) {
Text text = (Text) event.widget;
int h = text.getClientArea().height - 2;
Font font = FontUtils.getFontWithHeight(text.getFont(), null, h);
if (font != null) {
text.setFont(font);
Utils.disposeSWTObjects(new Object[] {
lastFont
});
text.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
Text text = (Text) e.widget;
text.setFont(null);
Utils.disposeSWTObjects(new Object[] {
lastFont
});
}
});
}
}
});
text.setTextLimit(254);
if (Constants.isWindows) {
text.addListener(SWT.MouseDown, new Listener() {
public void handleEvent(Event event) {
if (event.count == 3) {
text.selectAll();
}
}
});
}
final String sDefault = MessageText.getString("v3.MainWindow.search.defaultText");
SWTSkinProperties properties = skinObject.getProperties();
colorSearchTextBG = properties.getColor("color.search.text.bg");
colorSearchTextFG = properties.getColor("color.search.text.fg");
colorSearchTextFGdef = properties.getColor("color.search.text.fg.default");
if (colorSearchTextFGdef != null) {
text.setForeground(colorSearchTextFGdef);
}
if (colorSearchTextBG != null) {
text.setBackground(colorSearchTextBG);
}
text.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent e) {
Text text = (Text) e.widget;
if (text.getText().equals(sDefault)) {
if (colorSearchTextFG != null) {
text.setForeground(colorSearchTextFG);
}
text.setText("");
}
}
public void mouseDown(MouseEvent e) {
}
public void mouseDoubleClick(MouseEvent e) {
}
});
text.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
if (e.stateMask == SWT.MOD1) {
int key = e.character;
if (key <= 26 && key > 0) {
key += 'a' - 1;
}
if (key == 'a') {
text.selectAll();
}
}
}
public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
}
});
text.addListener(SWT.KeyDown, new Listener() {
public void handleEvent(Event event) {
if (text.getText().equals(sDefault)) {
if (colorSearchTextFG != null) {
text.setForeground(colorSearchTextFG);
}
if (event.character != '\0') {
text.setText("");
}
return;
}
Text text = (Text) event.widget;
if (event.keyCode == SWT.ESC) {
text.setText("");
return;
}
if (event.character == SWT.CR) {
doSearch(text.getText());
}
}
});
// must be done after layout
text.setText(sDefault);
//text.selectAll();
SWTSkinObject searchGo = skin.getSkinObject("search-go");
if (searchGo != null) {
SWTSkinButtonUtility btnGo = new SWTSkinButtonUtility(searchGo);
btnGo.addSelectionListener(new ButtonListenerAdapter() {
public void pressed(SWTSkinButtonUtility buttonUtility,
SWTSkinObject skinObject, int stateMask) {
String sSearchText = text.getText().trim();
doSearch(sSearchText);
}
});
}
SWTSkinObject so = skin.getSkinObject("sidebar-list");
if (so != null
&& so.getProperties().getBooleanValue(
so.getConfigID() + ".resizeSearch", false)) {
Listener l = new Listener() {
public void handleEvent(Event event) {
SWTSkinObject soSearchArea = skin.getSkinObject("topbar-area-search");
if (soSearchArea != null) {
Control c = soSearchArea.getControl();
Rectangle bounds = ((Control) event.widget).getBounds();
FormData fd = (FormData) c.getLayoutData();
int newWidth = bounds.width - 1 - c.getBounds().x;
if (bounds.width < 125) {
return;
}
fd.width = newWidth;