use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class CertificateView method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
session = (NXCSession) ConsoleSharedData.getSession();
parent.setLayout(new FillLayout());
final String[] columnNames = { Messages.get().CertificateView_ID, Messages.get().CertificateView_Type, Messages.get().CertificateView_Comments, Messages.get().CertificateView_Subject };
final int[] columnWidths = { 30, 100, 200, 200 };
viewer = new SortableTableViewer(parent, columnNames, columnWidths, COLUMN_ID, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new CertificateLabelProvider());
viewer.setComparator(new CertificateComparator());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection != null) {
actionEdit.setEnabled(selection.size() == 1);
actionDelete.setEnabled(selection.size() > 0);
}
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
actionEdit.run();
}
});
viewer.getTable().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
WidgetHelper.saveTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
}
});
createActions();
contributeToActionBars();
createPopupMenu();
session.addListener(this);
refreshCertificateList();
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class AlarmStateChangeFailureDialog 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);
GridLayout layout = new GridLayout();
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
dialogArea.setLayout(layout);
Label text = new Label(dialogArea, SWT.NONE);
text.setText("State of some alarms was not changed due to following reasons:");
final String[] names = { "ID", "Reason" };
final int[] widths = { 80, 250 };
alarmList = new SortableTableViewer(dialogArea, names, widths, 0, SWT.UP, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL);
alarmList.setContentProvider(new MapContentProvider());
alarmList.setLabelProvider(new FailuresLabelProvider());
alarmList.setInput(failures);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 350;
alarmList.getTable().setLayoutData(gd);
return dialogArea;
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class PackageDeploymentMonitor method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
final String[] names = { Messages.get().PackageDeploymentMonitor_ColumnNode, Messages.get().PackageDeploymentMonitor_ColumnStatus, Messages.get().PackageDeploymentMonitor_ColumnMessage };
final int[] widths = { 200, 110, 400 };
viewer = new SortableTableViewer(parent, names, widths, COLUMN_NODE, SWT.DOWN, SWT.FULL_SELECTION | SWT.MULTI);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new DeploymentStatusLabelProvider());
viewer.setComparator(new DeploymentStatusComparator());
createActions();
contributeToActionBars();
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class TunnelListComparator method compare.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
AgentTunnel t1 = (AgentTunnel) e1;
AgentTunnel t2 = (AgentTunnel) e2;
int result;
switch(// $NON-NLS-1$
(Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID")) {
case TunnelManager.COL_AGENT_VERSION:
result = t1.getAgentVersion().compareToIgnoreCase(t2.getAgentVersion());
break;
case TunnelManager.COL_CHANNELS:
result = t1.getActiveChannelCount() - t2.getActiveChannelCount();
break;
case TunnelManager.COL_ID:
result = t1.getId() - t2.getId();
break;
case TunnelManager.COL_IP_ADDRESS:
result = ComparatorHelper.compareInetAddresses(t1.getAddress(), t2.getAddress());
break;
case TunnelManager.COL_NODE:
NXCSession session = ConsoleSharedData.getSession();
result = session.getObjectName(t1.getNodeId()).compareToIgnoreCase(session.getObjectName(t2.getNodeId()));
break;
case TunnelManager.COL_PLATFORM:
result = t1.getPlatformName().compareToIgnoreCase(t2.getPlatformName());
break;
case TunnelManager.COL_STATE:
result = (t1.isBound() ? 1 : 0) - (t2.isBound() ? 1 : 0);
break;
case TunnelManager.COL_SYSINFO:
result = t1.getSystemInformation().compareToIgnoreCase(t2.getSystemInformation());
break;
case TunnelManager.COL_SYSNAME:
result = t1.getSystemName().compareToIgnoreCase(t2.getSystemName());
break;
default:
result = 0;
}
return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class CustomSchedule method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite dialogArea = (Composite) super.createContents(parent);
dci = editor.getObject();
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
final String[] columnNames = { Messages.get().CustomSchedule_Schedule };
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.setComparator(new StringComparator());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection != null) {
editButton.setEnabled(selection.size() == 1);
deleteButton.setEnabled(selection.size() > 0);
}
}
});
schedules = new HashSet<String>();
schedules.addAll(dci.getSchedules());
viewer.setInput(schedules.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.marginBottom = 0;
buttonLayout.marginTop = 0;
buttonLayout.marginLeft = 0;
buttonLayout.marginRight = 0;
buttonLayout.spacing = WidgetHelper.OUTER_SPACING;
buttonLayout.fill = true;
buttonLayout.pack = false;
buttons.setLayout(buttonLayout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.RIGHT;
buttons.setLayoutData(gridData);
addButton = new Button(buttons, SWT.PUSH);
addButton.setText(Messages.get().CustomSchedule_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) {
addSchedule();
}
});
editButton = new Button(buttons, SWT.PUSH);
editButton.setText(Messages.get().CustomSchedule_Edit);
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) {
editSchedule();
}
});
deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText(Messages.get().CustomSchedule_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) {
deleteSchedules();
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
editButton.notifyListeners(SWT.Selection, new Event());
}
});
return dialogArea;
}
Aggregations