use of org.netxms.ui.eclipse.datacollection.widgets.SummaryTableSelector in project netxms by netxms.
the class DciSummaryTable method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
config = (DciSummaryTableConfig) getElement().getAdapter(DciSummaryTableConfig.class);
Composite dialogArea = new Composite(parent, SWT.NONE);
currSortingList = config.getSortingColumnList();
GridLayout layout = new GridLayout();
dialogArea.setLayout(layout);
objectSelector = new ObjectSelector(dialogArea, SWT.NONE, true);
objectSelector.setLabel(Messages.get().DciSummaryTable_BaseObject);
objectSelector.setObjectClass(AbstractObject.class);
objectSelector.setObjectId(config.getBaseObjectId());
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
objectSelector.setLayoutData(gd);
tableSelector = new SummaryTableSelector(dialogArea, SWT.NONE, AbstractSelector.SHOW_CLEAR_BUTTON);
tableSelector.setLabel(Messages.get().DciSummaryTable_SummaryTable);
tableSelector.setTableId(config.getTableId());
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
tableSelector.setLayoutData(gd);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
refreshInterval = WidgetHelper.createLabeledSpinner(dialogArea, SWT.BORDER, Messages.get().DciSummaryTable_RefreshInterval, 0, 10000, gd);
refreshInterval.setSelection(config.getRefreshInterval());
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
checkShowSortAndLimitFields = new Button(dialogArea, SWT.CHECK);
checkShowSortAndLimitFields.setText("Show top N nodes");
checkShowSortAndLimitFields.setSelection(config.isEnableSortingAndLineLimit());
checkShowSortAndLimitFields.setLayoutData(gd);
checkShowSortAndLimitFields.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
if (checkShowSortAndLimitFields.getSelection()) {
sortTables.setSelection(null);
buttonAdd.setEnabled(true);
numRowsShow.setEnabled(true);
} else {
buttonUp.setEnabled(false);
buttonDown.setEnabled(false);
buttonEdit.setEnabled(false);
buttonRemove.setEnabled(false);
buttonAdd.setEnabled(false);
numRowsShow.setEnabled(false);
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
Composite showTopNNodes = new Composite(dialogArea, SWT.BORDER);
layout = new GridLayout();
showTopNNodes.setLayout(layout);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
numRowsShow = WidgetHelper.createLabeledSpinner(showTopNNodes, SWT.BORDER, "Number of lines to show", 0, 10000, gd);
numRowsShow.setSelection(config.getNumRowShown());
numRowsShow.setEnabled(config.isEnableSortingAndLineLimit());
Label label = new Label(showTopNNodes, SWT.NONE);
label.setText("Sort by columns");
final String[] columnNames = { "Name", "Sort order" };
final int[] columnWidths = { 320, 120 };
sortTables = new SortableTableViewer(showTopNNodes, columnNames, columnWidths, 0, 0, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.verticalSpan = 2;
gd.heightHint = 150;
sortTables.getTable().setLayoutData(gd);
sortTables.setContentProvider(new ArrayContentProvider());
sortTables.setLabelProvider(new SortColumnTableLabelProvider());
sortTables.setInput(currSortingList);
sortTables.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (checkShowSortAndLimitFields.getSelection()) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
int index = currSortingList.indexOf(selection.getFirstElement());
buttonUp.setEnabled((selection.size() == 1) && (index > 0));
buttonDown.setEnabled((selection.size() == 1) && (index >= 0) && (index < currSortingList.size() - 1));
buttonEdit.setEnabled(selection.size() == 1);
buttonRemove.setEnabled(selection.size() > 0);
} else {
buttonUp.setEnabled(false);
buttonDown.setEnabled(false);
buttonEdit.setEnabled(false);
buttonRemove.setEnabled(false);
}
}
});
sortTables.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
buttonEdit.notifyListeners(SWT.Selection, new Event());
}
});
Composite buttons = new Composite(showTopNNodes, SWT.NONE);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
buttons.setLayoutData(gd);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttons.setLayout(buttonLayout);
buttonUp = new Button(buttons, SWT.PUSH);
buttonUp.setText("UP");
buttonUp.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
moveUp();
}
});
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
buttonUp.setLayoutData(rd);
buttonUp.setEnabled(false);
buttonDown = new Button(buttons, SWT.PUSH);
buttonDown.setText("Down");
buttonDown.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
moveDown();
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
buttonDown.setLayoutData(rd);
buttonDown.setEnabled(false);
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
gd.verticalIndent = WidgetHelper.OUTER_SPACING - WidgetHelper.INNER_SPACING;
buttons.setLayoutData(gd);
buttonAdd = new Button(buttons, SWT.PUSH);
buttonAdd.setText("Add");
buttonAdd.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
add();
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
buttonAdd.setLayoutData(rd);
buttonAdd.setEnabled(config.isEnableSortingAndLineLimit());
buttonEdit = new Button(buttons, SWT.PUSH);
buttonEdit.setText("Edit");
buttonEdit.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
edit();
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
buttonEdit.setLayoutData(rd);
buttonEdit.setEnabled(false);
buttonRemove = new Button(buttons, SWT.PUSH);
buttonRemove.setText("Delete");
buttonRemove.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
remove();
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
buttonRemove.setLayoutData(rd);
buttonRemove.setEnabled(false);
return dialogArea;
}
Aggregations