use of org.netxms.ui.eclipse.objectbrowser.views.helpers.ObjectSearchResultComparator in project netxms by netxms.
the class ObjectFinder method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
session = ConsoleSharedData.getSession();
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
parent.setLayout(layout);
Composite conditionGroup = new Composite(parent, SWT.NONE);
conditionGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
layout = new GridLayout();
layout.numColumns = session.isZoningEnabled() ? 3 : 2;
conditionGroup.setLayout(layout);
/**
* Full text search **
*/
Composite fullTextSearchGroup = new Composite(conditionGroup, SWT.NONE);
fullTextSearchGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
layout = new GridLayout();
fullTextSearchGroup.setLayout(layout);
text = new LabeledText(fullTextSearchGroup, SWT.NONE);
text.setLabel("Search string");
text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
TraverseListener traverseListener = new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_RETURN)
startSearch();
}
};
text.addTraverseListener(traverseListener);
Group searchModeGroup = new Group(fullTextSearchGroup, SWT.NONE);
searchModeGroup.setText("Search mode");
layout = new GridLayout();
searchModeGroup.setLayout(layout);
radioPlainText = new Button(searchModeGroup, SWT.RADIO);
radioPlainText.setText("&Normal");
radioPlainText.setSelection(true);
radioPattern = new Button(searchModeGroup, SWT.RADIO);
radioPattern.setText("&Pattern (* = any string, ? = any character)");
radioRegularExpression = new Button(searchModeGroup, SWT.RADIO);
radioRegularExpression.setText("&Regular expression");
/**
* Class filter **
*/
Composite classFilterGroup = new Composite(conditionGroup, SWT.NONE);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.verticalSpan = 2;
classFilterGroup.setLayoutData(gd);
layout = new GridLayout();
classFilterGroup.setLayout(layout);
Label classFilterTitle = new Label(classFilterGroup, SWT.NONE);
classFilterTitle.setText("Class filter");
classList = CheckboxTableViewer.newCheckList(classFilterGroup, SWT.BORDER | SWT.CHECK);
classList.setContentProvider(new ArrayContentProvider());
classList.setInput(OBJECT_CLASSES);
classList.setAllChecked(true);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = 100;
classList.getTable().setLayoutData(gd);
Composite classListButtons = new Composite(classFilterGroup, SWT.NONE);
RowLayout rlayout = new RowLayout();
rlayout.marginLeft = 0;
classListButtons.setLayout(rlayout);
Button selectAll = new Button(classListButtons, SWT.PUSH);
selectAll.setText("Select &all");
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
selectAll.setLayoutData(rd);
selectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
classList.setAllChecked(true);
}
});
Button clearAll = new Button(classListButtons, SWT.PUSH);
clearAll.setText("&Clear all");
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
clearAll.setLayoutData(rd);
clearAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
classList.setAllChecked(false);
}
});
/**
* Zone filter **
*/
if (session.isZoningEnabled()) {
Composite zoneFilterGroup = new Composite(conditionGroup, SWT.NONE);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.verticalSpan = 2;
zoneFilterGroup.setLayoutData(gd);
layout = new GridLayout();
zoneFilterGroup.setLayout(layout);
Label zoneFilterTitle = new Label(zoneFilterGroup, SWT.NONE);
zoneFilterTitle.setText("Zone filter");
zoneList = CheckboxTableViewer.newCheckList(zoneFilterGroup, SWT.BORDER | SWT.CHECK);
zoneList.setContentProvider(new ArrayContentProvider());
List<Zone> zones = session.getAllZones();
zoneList.setLabelProvider(new WorkbenchLabelProvider());
zoneList.setInput(zones);
zoneList.setAllChecked(true);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = 100;
zoneList.getTable().setLayoutData(gd);
Composite zoneListButtons = new Composite(zoneFilterGroup, SWT.NONE);
rlayout = new RowLayout();
rlayout.marginLeft = 0;
zoneListButtons.setLayout(rlayout);
selectAll = new Button(zoneListButtons, SWT.PUSH);
selectAll.setText("Select &all");
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
selectAll.setLayoutData(rd);
selectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
zoneList.setAllChecked(true);
}
});
clearAll = new Button(zoneListButtons, SWT.PUSH);
clearAll.setText("&Clear all");
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
clearAll.setLayoutData(rd);
clearAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
zoneList.setAllChecked(false);
}
});
}
/**
* IP filter **
*/
Group ipFilterGroup = new Group(conditionGroup, SWT.NONE);
ipFilterGroup.setText("IP Range");
ipFilterGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
layout = new GridLayout();
layout.numColumns = 3;
ipFilterGroup.setLayout(layout);
ipRangeStart = new Text(ipFilterGroup, SWT.BORDER);
ipRangeStart.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
ipRangeStart.addTraverseListener(traverseListener);
new Label(ipFilterGroup, SWT.NONE).setText(" - ");
ipRangeEnd = new Text(ipFilterGroup, SWT.BORDER);
ipRangeEnd.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
ipRangeEnd.addTraverseListener(traverseListener);
/**
* Search button **
*/
Button searchButton = new Button(conditionGroup, SWT.PUSH);
searchButton.setText("&Search");
gd = new GridData(SWT.LEFT, SWT.BOTTOM, true, false);
gd.widthHint = WidgetHelper.BUTTON_WIDTH_HINT;
searchButton.setLayoutData(gd);
searchButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
startSearch();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
final String[] names = { "ID", "Class", "Name", "IP Address", "Parent", "Zone" };
final int[] widths = { 90, 120, 300, 250, 300, 200 };
results = new SortableTableViewer(parent, names, widths, 0, SWT.UP, SWT.MULTI | SWT.FULL_SELECTION);
if (!ConsoleSharedData.getSession().isZoningEnabled())
results.removeColumnById(COL_ZONE);
results.setContentProvider(new ArrayContentProvider());
results.setLabelProvider(new ObjectSearchResultLabelProvider());
results.setComparator(new ObjectSearchResultComparator());
results.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
final IDialogSettings settings = Activator.getDefault().getDialogSettings();
WidgetHelper.restoreTableViewerSettings(results, settings, "ResultTable");
results.getTable().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
WidgetHelper.saveTableViewerSettings(results, settings, "ResultTable");
}
});
getSite().setSelectionProvider(results);
createResultsContextMenu();
activateContext();
createActions();
contributeToActionBars();
}
Aggregations