use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class ClusterNetworks method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite dialogArea = new Composite(parent, SWT.NONE);
object = (Cluster) getElement().getAdapter(Cluster.class);
if (// Paranoid check
object == null)
return dialogArea;
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
final String[] columnNames = { Messages.get().ClusterNetworks_ColAddress, Messages.get().ClusterNetworks_ColMask };
final int[] columnWidths = { 150, 150 };
viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new NetworkListLabelProvider());
viewer.setComparator(new NetworkListComparator());
networks = new ArrayList<InetAddressEx>(object.getSyncNetworks().size());
for (InetAddressEx n : object.getSyncNetworks()) networks.add(new InetAddressEx(n));
viewer.setInput(networks.toArray());
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.heightHint = 0;
viewer.getControl().setLayoutData(gridData);
Composite buttons = new Composite(dialogArea, SWT.NONE);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttonLayout.marginRight = 0;
buttons.setLayout(buttonLayout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.RIGHT;
buttons.setLayoutData(gridData);
addButton = new Button(buttons, SWT.PUSH);
addButton.setText(Messages.get().ClusterNetworks_Add);
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
addButton.setLayoutData(rd);
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
addNetwork();
}
});
editButton = new Button(buttons, SWT.PUSH);
editButton.setText(Messages.get().ClusterNetworks_Modify);
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
editButton.setLayoutData(rd);
editButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
editNetwork();
}
});
deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText(Messages.get().ClusterNetworks_Delete);
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
deleteButton.setLayoutData(rd);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
deleteNetwork();
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
editButton.notifyListeners(SWT.Selection, new Event());
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
editButton.setEnabled(selection.size() == 1);
deleteButton.setEnabled(selection.size() > 0);
}
});
return dialogArea;
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class ExternalResources method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite dialogArea = new Composite(parent, SWT.NONE);
object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
if (// Paranoid check
object == null)
return dialogArea;
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.numColumns = 2;
dialogArea.setLayout(layout);
final String[] columnNames = { "URL", "Description" };
final int[] columnWidths = { 300, 300 };
viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new UrlListLabelProvider());
urls = new ArrayList<ObjectUrl>(object.getUrls());
viewer.setInput(urls);
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalSpan = 2;
gridData.heightHint = 0;
viewer.getControl().setLayoutData(gridData);
Composite buttonsLeft = new Composite(dialogArea, SWT.NONE);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttonLayout.marginRight = 0;
buttonsLeft.setLayout(buttonLayout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.LEFT;
buttonsLeft.setLayoutData(gridData);
moveUpButton = new Button(buttonsLeft, SWT.PUSH);
moveUpButton.setText("&Up");
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
moveUpButton.setLayoutData(rd);
moveUpButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
moveSelection(true);
}
});
moveDownButton = new Button(buttonsLeft, SWT.PUSH);
moveDownButton.setText("&Down");
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
moveDownButton.setLayoutData(rd);
moveDownButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
moveSelection(false);
}
});
Composite buttonsRight = new Composite(dialogArea, SWT.NONE);
buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttonLayout.marginRight = 0;
buttonsRight.setLayout(buttonLayout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.RIGHT;
buttonsRight.setLayoutData(gridData);
addButton = new Button(buttonsRight, SWT.PUSH);
addButton.setText(Messages.get().CustomAttributes_Add);
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
addButton.setLayoutData(rd);
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
addUrl();
}
});
editButton = new Button(buttonsRight, SWT.PUSH);
editButton.setText(Messages.get().CustomAttributes_Modify);
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
editButton.setLayoutData(rd);
editButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
editUrl();
}
});
deleteButton = new Button(buttonsRight, SWT.PUSH);
deleteButton.setText(Messages.get().CustomAttributes_Delete);
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
deleteButton.setLayoutData(rd);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
deleteUrl();
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
editButton.notifyListeners(SWT.Selection, new Event());
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
moveUpButton.setEnabled(selection.size() == 1);
moveDownButton.setEnabled(selection.size() == 1);
editButton.setEnabled(selection.size() == 1);
deleteButton.setEnabled(selection.size() > 0);
}
});
return dialogArea;
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class TrustedNodes method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite dialogArea = new Composite(parent, SWT.NONE);
object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
final String[] columnNames = { Messages.get().TrustedNodes_Node };
final int[] columnWidths = { 300 };
viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new WorkbenchLabelProvider());
viewer.setComparator(new ObjectLabelComparator((ILabelProvider) viewer.getLabelProvider()));
AbstractObject[] nodes = object.getTrustedNodes();
for (int i = 0; i < nodes.length; i++) {
if (nodes[i] != null)
trustedNodes.put(nodes[i].getObjectId(), nodes[i]);
}
viewer.setInput(trustedNodes.values().toArray());
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.heightHint = 0;
viewer.getControl().setLayoutData(gridData);
Composite buttons = new Composite(dialogArea, SWT.NONE);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttons.setLayout(buttonLayout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.RIGHT;
buttons.setLayoutData(gridData);
addButton = new Button(buttons, SWT.PUSH);
addButton.setText(Messages.get().TrustedNodes_Add);
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(true));
if (dlg.open() == Window.OK) {
AbstractObject[] nodes = dlg.getSelectedObjects(AbstractNode.class);
for (int i = 0; i < nodes.length; i++) trustedNodes.put(nodes[i].getObjectId(), nodes[i]);
viewer.setInput(trustedNodes.values().toArray());
isModified = true;
}
}
});
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
addButton.setLayoutData(rd);
deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText(Messages.get().TrustedNodes_Delete);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@SuppressWarnings("unchecked")
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
Iterator<AbstractObject> it = selection.iterator();
if (it.hasNext()) {
while (it.hasNext()) {
AbstractObject object = it.next();
trustedNodes.remove(object.getObjectId());
}
viewer.setInput(trustedNodes.values().toArray());
isModified = true;
}
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
deleteButton.setLayoutData(rd);
return dialogArea;
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class Dashboards method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite dialogArea = new Composite(parent, SWT.NONE);
object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
final String[] columnNames = { Messages.get().Dashboards_Dashboard };
final int[] columnWidths = { 300 };
viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new WorkbenchLabelProvider());
viewer.setComparator(new ObjectLabelComparator((ILabelProvider) viewer.getLabelProvider()));
for (AbstractObject d : object.getDashboards(false)) dashboards.put(d.getObjectId(), d);
viewer.setInput(dashboards.values().toArray());
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.heightHint = 0;
viewer.getControl().setLayoutData(gridData);
Composite buttons = new Composite(dialogArea, SWT.NONE);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttons.setLayout(buttonLayout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.RIGHT;
buttons.setLayoutData(gridData);
addButton = new Button(buttons, SWT.PUSH);
addButton.setText(Messages.get().TrustedNodes_Add);
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, ObjectSelectionDialog.createDashboardSelectionFilter());
dlg.showFilterToolTip(false);
if (dlg.open() == Window.OK) {
AbstractObject[] d = dlg.getSelectedObjects(Dashboard.class);
for (int i = 0; i < d.length; i++) dashboards.put(d[i].getObjectId(), d[i]);
viewer.setInput(dashboards.values().toArray());
isModified = true;
}
}
});
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
addButton.setLayoutData(rd);
deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText(Messages.get().TrustedNodes_Delete);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@SuppressWarnings("unchecked")
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
Iterator<AbstractObject> it = selection.iterator();
if (it.hasNext()) {
while (it.hasNext()) {
AbstractObject object = it.next();
dashboards.remove(object.getObjectId());
}
viewer.setInput(dashboards.values().toArray());
isModified = true;
}
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
deleteButton.setLayoutData(rd);
return dialogArea;
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class ReportExecutionForm method createResultsSection.
/**
* Create "Results" section's content
*
* @param parent
* parent composite
*/
private void createResultsSection(Composite parent) {
GridLayout layout = new GridLayout();
parent.setLayout(layout);
final String[] names = { "Execution Time", "Started by", "Status" };
final int[] widths = { 180, 140, 100 };
resultList = new SortableTableViewer(parent, names, widths, 0, SWT.DOWN, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
resultList.getControl().setLayoutData(gd);
resultList.setContentProvider(new ArrayContentProvider());
resultList.setLabelProvider(new ReportResultLabelProvider());
WidgetHelper.restoreTableViewerSettings(resultList, Activator.getDefault().getDialogSettings(), "ReportExecutionForm.ResultList");
resultList.getControl().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
WidgetHelper.saveTableViewerSettings(resultList, Activator.getDefault().getDialogSettings(), "ReportExecutionForm.ResultList");
}
});
ImageHyperlink link = toolkit.createImageHyperlink(parent, SWT.WRAP);
link.setImage(SharedIcons.IMG_EXECUTE);
link.setText("Execute Report");
link.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
executeReport();
}
});
createResultsContextMenu();
resultList.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) resultList.getSelection();
actionDeleteResult.setEnabled(selection.size() > 0);
actionRenderPDF.setEnabled(selection.size() == 1);
actionRenderXLS.setEnabled(selection.size() == 1);
}
});
}
Aggregations