*/
try {
Display d = composite.getDisplay();
GridLayout configLayout;
SashForm form = new SashForm(cConfig,SWT.HORIZONTAL);
gridData = new GridData(GridData.FILL_BOTH);
form.setLayoutData(gridData);
Composite cLeftSide = new Composite(form, SWT.BORDER);
gridData = new GridData(GridData.FILL_BOTH);
cLeftSide.setLayoutData(gridData);
FormLayout layout = new FormLayout();
cLeftSide.setLayout(layout);
Composite cFilterArea = new Composite(cLeftSide, SWT.NONE);
cFilterArea.setLayout(new FormLayout());
final Text txtFilter = new Text(cFilterArea, SWT.BORDER);
final String sFilterText = MessageText.getString("ConfigView.filter");
txtFilter.setText(sFilterText);
txtFilter.selectAll();
txtFilter.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
filterTree(txtFilter.getText());
}
});
txtFilter.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent e) {
if (txtFilter.getText().equals(sFilterText)) {
txtFilter.selectAll();
}
}
});
txtFilter.setFocus();
ImageLoader imageLoader = ImageLoader.getInstance();
imgSmallXGray = imageLoader.getImage("smallx-gray");
imgSmallX = imageLoader.getImage("smallx");
lblX = new Label(cFilterArea, SWT.WRAP);
Messages.setLanguageTooltip(lblX, "MyTorrentsView.clearFilter.tooltip");
lblX.setImage(imgSmallXGray);
lblX.addMouseListener(new MouseAdapter() {
public void mouseUp(MouseEvent e) {
txtFilter.setText("");
}
});
lblX.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent arg0) {
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.releaseImage("smallx-gray");
imageLoader.releaseImage("smallx");
}
});
Label lblSearch = new Label(cFilterArea, SWT.NONE);
imageLoader.setLabelImage(lblSearch, "search");
tree = new Tree(cLeftSide, SWT.NONE);
FontData[] fontData = tree.getFont().getFontData();
fontData[0].setStyle(SWT.BOLD);
filterFoundFont = new Font(d, fontData);
FormData formData;
formData = new FormData();
formData.bottom = new FormAttachment(100, -5);
formData.left = new FormAttachment(0, 0);
formData.right = new FormAttachment(100, 0);
cFilterArea.setLayoutData(formData);
formData = new FormData();
formData.top = new FormAttachment(0,5);
formData.left = new FormAttachment(0, 5);
lblSearch.setLayoutData(formData);
formData = new FormData();
formData.top = new FormAttachment(0,5);
formData.left = new FormAttachment(lblSearch,5);
formData.right = new FormAttachment(lblX, -3);
txtFilter.setLayoutData(formData);
formData = new FormData();
formData.top = new FormAttachment(0,5);
formData.right = new FormAttachment(100,-5);
lblX.setLayoutData(formData);
formData = new FormData();
formData.top = new FormAttachment(0, 0);
formData.left = new FormAttachment(0,0);
formData.right = new FormAttachment(100,0);
formData.bottom = new FormAttachment(cFilterArea,-1);
tree.setLayoutData(formData);
Composite cRightSide = new Composite(form, SWT.NULL);
configLayout = new GridLayout();
configLayout.marginHeight = 3;
configLayout.marginWidth = 0;
cRightSide.setLayout(configLayout);
// Header
Composite cHeader = new Composite(cRightSide, SWT.BORDER);
configLayout = new GridLayout();
configLayout.marginHeight = 3;
configLayout.marginWidth = 0;
configLayout.numColumns = 2;
configLayout.marginRight = 5;
cHeader.setLayout(configLayout);
gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
cHeader.setLayoutData(gridData);
cHeader.setBackground(d.getSystemColor(SWT.COLOR_LIST_SELECTION));
cHeader.setForeground(d.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
lHeader = new Label(cHeader, SWT.NULL);
lHeader.setBackground(d.getSystemColor(SWT.COLOR_LIST_SELECTION));
lHeader.setForeground(d.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
fontData = lHeader.getFont().getFontData();
fontData[0].setStyle(SWT.BOLD);
int fontHeight = (int)(fontData[0].getHeight() * 1.2);
fontData[0].setHeight(fontHeight);
headerFont = new Font(d, fontData);
lHeader.setFont(headerFont);
gridData = new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.HORIZONTAL_ALIGN_BEGINNING);
lHeader.setLayoutData(gridData);
usermodeHint = new Label(cHeader, SWT.NULL);
usermodeHint.setBackground(d.getSystemColor(SWT.COLOR_LIST_SELECTION));
usermodeHint.setForeground(d.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
gridData = new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
usermodeHint.setLayoutData(gridData);
// Config Section
cConfigSection = new Composite(cRightSide, SWT.NULL);
layoutConfigSection = new StackLayout();
cConfigSection.setLayout(layoutConfigSection);
gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalIndent = 2;
cConfigSection.setLayoutData(gridData);
form.setWeights(new int[] {20,80});
tree.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Tree tree = (Tree)e.getSource();
//Check that at least an item is selected