Search in sources :

Example 1 with MappingTableEntry

use of org.netxms.client.mt.MappingTableEntry in project netxms by netxms.

the class MappingTableEntryComparator 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) {
    int result;
    MappingTableEntry me1 = (MappingTableEntry) e1;
    MappingTableEntry me2 = (MappingTableEntry) e2;
    switch(// $NON-NLS-1$
    (Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID")) {
        case MappingTableEditor.COLUMN_KEY:
            result = me1.getKey().compareToIgnoreCase(me2.getKey());
            break;
        case MappingTableEditor.COLUMN_VALUE:
            result = me1.getValue().compareToIgnoreCase(me2.getValue());
            break;
        case MappingTableEditor.COLUMN_DESCRIPTION:
            result = me1.getDescription().compareToIgnoreCase(me2.getDescription());
            break;
        default:
            result = 0;
            break;
    }
    return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
Also used : SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) MappingTableEntry(org.netxms.client.mt.MappingTableEntry)

Example 2 with MappingTableEntry

use of org.netxms.client.mt.MappingTableEntry in project netxms by netxms.

the class MappingTableEditor method addNewRow.

/**
 * Add new row
 */
private void addNewRow() {
    if (mappingTable == null)
        return;
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    MappingTableEntry e = new MappingTableEntry("", "", "");
    mappingTable.getData().add(e);
    viewer.setInput(mappingTable.getData().toArray());
    viewer.setSelection(new StructuredSelection(e));
    setModified(true);
    viewer.editElement(e, COLUMN_KEY);
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) MappingTableEntry(org.netxms.client.mt.MappingTableEntry)

Aggregations

MappingTableEntry (org.netxms.client.mt.MappingTableEntry)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)1