use of org.netxms.client.objecttools.ObjectToolTableColumn in project netxms by netxms.
the class Columns method addColumn.
/**
* Add new column
*/
private void addColumn() {
ObjectToolTableColumn tc = new ObjectToolTableColumn(Messages.get().Columns_DefName + Integer.toString(columns.size() + 1));
EditColumnDialog dlg = new EditColumnDialog(getShell(), true, objectTool.getToolType() == ObjectTool.TYPE_TABLE_SNMP, tc);
if (dlg.open() == Window.OK) {
columns.add(tc);
viewer.setInput(columns.toArray());
viewer.setSelection(new StructuredSelection(tc));
}
}
use of org.netxms.client.objecttools.ObjectToolTableColumn in project netxms by netxms.
the class Columns method removeColumn.
/**
* Remove selected column(s)
*/
@SuppressWarnings("unchecked")
private void removeColumn() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
Iterator<ObjectToolTableColumn> it = selection.iterator();
while (it.hasNext()) {
columns.remove(it.next());
}
viewer.setInput(columns.toArray());
}
use of org.netxms.client.objecttools.ObjectToolTableColumn in project netxms by netxms.
the class Columns method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
objectTool = (ObjectToolDetails) getElement().getAdapter(ObjectToolDetails.class);
for (ObjectToolTableColumn tc : objectTool.getColumns()) columns.add(new ObjectToolTableColumn(tc));
Composite dialogArea = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
viewer.getTable().setLayoutData(gd);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new ToolColumnLabelProvider(objectTool.getToolType() == ObjectTool.TYPE_TABLE_SNMP));
setupTableColumns();
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
buttonEdit.setEnabled(selection.size() == 1);
buttonRemove.setEnabled(selection.size() > 0);
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
editColumn();
}
});
viewer.setInput(columns.toArray());
Composite buttons = new Composite(dialogArea, SWT.NONE);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttons.setLayout(buttonLayout);
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(Messages.get().Columns_Add);
buttonAdd.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
addColumn();
}
});
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
buttonAdd.setLayoutData(rd);
buttonEdit = new Button(buttons, SWT.PUSH);
buttonEdit.setText(Messages.get().Columns_Edit);
buttonEdit.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
editColumn();
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
buttonEdit.setLayoutData(rd);
buttonRemove = new Button(buttons, SWT.PUSH);
buttonRemove.setText(Messages.get().Columns_Delete);
buttonRemove.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
removeColumn();
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
buttonRemove.setLayoutData(rd);
return dialogArea;
}
Aggregations