use of org.netxms.ui.eclipse.objectbrowser.widgets.internal.ObjectFilter in project netxms by netxms.
the class ChildObjectListDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogArea = (Composite) super.createDialogArea(parent);
AbstractObject object = ((NXCSession) ConsoleSharedData.getSession()).findObjectById(parentObject);
AbstractObject[] sourceObjects = (object != null) ? object.getChildsAsArray() : new AbstractObject[0];
GridLayout layout = new GridLayout();
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
dialogArea.setLayout(layout);
// Create filter area
Composite filterArea = new Composite(dialogArea, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
layout.horizontalSpacing = WidgetHelper.INNER_SPACING;
layout.marginHeight = 0;
layout.marginWidth = 0;
filterArea.setLayout(layout);
filterArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label filterLabel = new Label(filterArea, SWT.NONE);
filterLabel.setText(Messages.get().ChildObjectListDialog_Filter);
filterText = new Text(filterArea, SWT.BORDER);
filterText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
filter.setFilterString(filterText.getText());
objectList.refresh(false);
AbstractObject obj = filter.getLastMatch();
if (obj != null) {
objectList.setSelection(new StructuredSelection(obj), true);
objectList.reveal(obj);
}
}
});
// Create object list
objectList = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
TableColumn tc = new TableColumn(objectList.getTable(), SWT.LEFT);
tc.setText(Messages.get().ChildObjectListDialog_Name);
tc.setWidth(280);
objectList.getTable().setHeaderVisible(false);
objectList.setContentProvider(new ArrayContentProvider());
objectList.setLabelProvider(new WorkbenchLabelProvider());
objectList.setComparator(new ViewerComparator());
filter = new ObjectFilter(null, sourceObjects, classFilter);
objectList.addFilter(filter);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
objectList.getControl().setLayoutData(gd);
objectList.getTable().addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
Table table = objectList.getTable();
int w = table.getSize().x - table.getBorderWidth() * 2;
ScrollBar sc = table.getVerticalBar();
if ((sc != null) && sc.isVisible())
w -= sc.getSize().x;
table.getColumn(0).setWidth(w);
}
});
if (object != null)
objectList.setInput(sourceObjects);
filterText.setFocus();
return dialogArea;
}
Aggregations