/** * Creates the filtering list widgets * * @param ancestor the ancestor */ private void createFilterLists(Composite ancestor) { // Do not show the filter lists if not filter criteria // is defined. if (filterStrings.length == 0) return; // setup layout Composite parent = new Composite(ancestor, SWT.NULL); Composite dummy = new Composite(ancestor, SWT.NULL); GridData dgd = new GridData(); dgd.widthHint = 0; dummy.setLayoutData(dgd); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.numColumns = 3; parent.setLayout(layout); // Create the possible filter items list Label filterItemsLabel = new Label(parent, SWT.LEFT); filterItemsLabel.setText(FILTER_ITEMS_CONTAINING); GridData gd = new GridData(); gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; filterItemsLabel.setLayoutData(gd); // Create the possible filter items list // Label emptyLabel = new Label(parent, SWT.LEFT); // Create the possible filter items list Label filterItemLabel = new Label(parent, SWT.LEFT); filterItemLabel.setText(FILTER_ITEMS_LIST); GridData gd2 = new GridData(); gd2.horizontalAlignment = GridData.BEGINNING; filterItemLabel.setLayoutData(gd2); // Create the possible filter items list filters = new org.eclipse.swt.widgets.List(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); GridData gridData = new GridData(GridData.VERTICAL_ALIGN_FILL); gridData.verticalSpan = 1; gridData.widthHint = 80; int listHeight = filters.getItemHeight() * LIST_HEIGHT; Rectangle trim = filters.computeTrim(0, 0, 0, listHeight); gridData.heightHint = trim.height; filters.setLayoutData(gridData); // Create a new composite for the buttons and add // stack them vertically Composite buttonComposite = new Composite(parent, SWT.NULL); GridLayout buttonLayout = new GridLayout(); buttonLayout.marginHeight = 0; buttonLayout.marginWidth = 0; buttonLayout.numColumns = 1; buttonComposite.setLayout(buttonLayout); GridData buttGD = new GridData(GridData.FILL_VERTICAL | GridData.CENTER); buttGD.horizontalSpan = 1; buttGD.widthHint = 30; buttonComposite.setLayoutData(buttGD); removeFrom = new Button(buttonComposite, SWT.PUSH); removeFrom.setText(REMOVE_FROM_LABEL); removeFrom.setToolTipText(REMOVE_FROM); removeFrom.setLayoutData(makeArrowButtonGridData(removeFrom)); removeFrom.setData(new Integer(REMOVE_FROM_ID)); removeFrom.addSelectionListener(buttonSelectionAdapter); removeFrom.setEnabled(false); addTo = new Button(buttonComposite, SWT.PUSH); addTo.setText(ADD_TO_LABEL); addTo.setToolTipText(ADD_TO); addTo.setLayoutData(makeArrowButtonGridData(addTo)); addTo.setData(new Integer(ADD_TO_ID)); addTo.addSelectionListener(buttonSelectionAdapter); addTo.setEnabled(false); removeAllFrom = new Button(buttonComposite, SWT.PUSH); removeAllFrom.setText(REMOVE_ALL_LABEL); removeAllFrom.setToolTipText(REMOVE_ALL); removeAllFrom.setLayoutData(makeArrowButtonGridData(removeAllFrom)); removeAllFrom.setData(new Integer(REMOVE_ALL_FROM_ID)); removeAllFrom.addSelectionListener(buttonSelectionAdapter); addAllTo = new Button(buttonComposite, SWT.PUSH); addAllTo.setText(ADD_ALL_LABEL); addAllTo.setToolTipText(ADD_ALL); addAllTo.setLayoutData(makeArrowButtonGridData(addAllTo)); addAllTo.setData(Integer.valueOf(ADD_ALL_TO_ID)); addAllTo.addSelectionListener(buttonSelectionAdapter); // Add the possible list of filter items this.filterList = new org.eclipse.swt.widgets.List(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); GridData gridData2 = new GridData(GridData.VERTICAL_ALIGN_FILL); gridData2.verticalSpan = 1; gridData2.widthHint = 80; int listHeight2 = filterList.getItemHeight() * LIST_HEIGHT; Rectangle trim2 = filterList.computeTrim(0, 0, 0, listHeight2); gridData.heightHint = trim2.height; filterList.setLayoutData(gridData2); filters.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { removeFrom.setEnabled(filters.getSelectionCount() > 0); } }); filterList.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { addTo.setEnabled(filterList.getSelectionCount() > 0); } }); populateFilterLists(); }