use of org.netxms.ui.eclipse.tools.StringComparator 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;
}
use of org.netxms.ui.eclipse.tools.StringComparator in project netxms by netxms.
the class WinPerfCounterSelectionDialog 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.numColumns = 2;
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
layout.verticalSpacing = WidgetHelper.INNER_SPACING;
dialogArea.setLayout(layout);
new Label(dialogArea, SWT.NONE).setText(Messages.get().WinPerfCounterSelectionDialog_ObjectsAndCounters);
new Label(dialogArea, SWT.NONE).setText(Messages.get().WinPerfCounterSelectionDialog_Instances);
objectTree = new TreeViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 400;
gd.widthHint = 350;
objectTree.getControl().setLayoutData(gd);
objectTree.setContentProvider(new WinPerfObjectTreeContentProvider());
objectTree.setLabelProvider(new WinPerfObjectTreeLabelProvider());
objectTree.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
String s1 = (e1 instanceof WinPerfCounter) ? ((WinPerfCounter) e1).getName() : ((WinPerfObject) e1).getName();
String s2 = (e2 instanceof WinPerfCounter) ? ((WinPerfCounter) e2).getName() : ((WinPerfObject) e2).getName();
return s1.compareToIgnoreCase(s2);
}
});
objectTree.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
onObjectSelection();
}
});
instanceList = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.widthHint = 350;
instanceList.getControl().setLayoutData(gd);
instanceList.setContentProvider(new ArrayContentProvider());
instanceList.setLabelProvider(new LabelProvider());
instanceList.setComparator(new StringComparator());
fillData();
return dialogArea;
}
use of org.netxms.ui.eclipse.tools.StringComparator in project netxms by netxms.
the class SnmpCredentials method createSnmpCommunitySection.
/**
* Create "SNMP Communities" section
*/
private void createSnmpCommunitySection() {
Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TITLE_BAR);
section.setText(Messages.get().SnmpConfigurator_SectionCommunities);
section.setDescription(Messages.get().SnmpConfigurator_SectionCommunitiesDescr);
TableWrapData td = new TableWrapData();
td.align = TableWrapData.FILL;
td.grabHorizontal = true;
section.setLayoutData(td);
Composite clientArea = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
clientArea.setLayout(layout);
section.setClient(clientArea);
snmpCommunityList = new TableViewer(clientArea, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
toolkit.adapt(snmpCommunityList.getTable());
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.verticalSpan = 2;
gd.heightHint = 150;
snmpCommunityList.getTable().setLayoutData(gd);
snmpCommunityList.getTable().setSortDirection(SWT.UP);
snmpCommunityList.setContentProvider(new ArrayContentProvider());
snmpCommunityList.setComparator(new StringComparator());
final ImageHyperlink linkAdd = toolkit.createImageHyperlink(clientArea, SWT.NONE);
linkAdd.setText(Messages.get().SnmpConfigurator_Add);
linkAdd.setImage(SharedIcons.IMG_ADD_OBJECT);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
linkAdd.setLayoutData(gd);
linkAdd.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
addCommunity();
}
});
final ImageHyperlink linkRemove = toolkit.createImageHyperlink(clientArea, SWT.NONE);
linkRemove.setText(Messages.get().SnmpConfigurator_Remove);
linkRemove.setImage(SharedIcons.IMG_DELETE_OBJECT);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
linkRemove.setLayoutData(gd);
linkRemove.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
removeCommunity();
}
});
}
use of org.netxms.ui.eclipse.tools.StringComparator in project netxms by netxms.
the class SnmpCredentials method createSnmpPortList.
/**
* Create "Port List" section
*/
private void createSnmpPortList() {
Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TITLE_BAR);
section.setText("SNMP Ports");
section.setDescription("SNMP ports used in the network");
TableWrapData td = new TableWrapData();
td.align = TableWrapData.FILL;
td.grabHorizontal = true;
section.setLayoutData(td);
Composite clientArea = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
clientArea.setLayout(layout);
section.setClient(clientArea);
snmpPortList = new TableViewer(clientArea, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
toolkit.adapt(snmpPortList.getTable());
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.verticalSpan = 2;
gd.heightHint = 150;
snmpPortList.getTable().setLayoutData(gd);
snmpPortList.setContentProvider(new ArrayContentProvider());
snmpPortList.setComparator(new StringComparator());
final ImageHyperlink linkAdd = toolkit.createImageHyperlink(clientArea, SWT.NONE);
linkAdd.setText(Messages.get().SnmpConfigurator_Add);
linkAdd.setImage(SharedIcons.IMG_ADD_OBJECT);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
linkAdd.setLayoutData(gd);
linkAdd.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
addSnmpPort();
}
});
final ImageHyperlink linkRemove = toolkit.createImageHyperlink(clientArea, SWT.NONE);
linkRemove.setText(Messages.get().SnmpConfigurator_Remove);
linkRemove.setImage(SharedIcons.IMG_DELETE_OBJECT);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
linkRemove.setLayoutData(gd);
linkRemove.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
removeSnmpPort();
}
});
}
Aggregations