use of org.netxms.client.mt.MappingTableDescriptor in project netxms by netxms.
the class NXCSession method listMappingTables.
/**
* Get list of all configured mapping tables.
*
* @return List of MappingTableDescriptor objects
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public List<MappingTableDescriptor> listMappingTables() throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_LIST_MAPPING_TABLES);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_ELEMENTS);
final List<MappingTableDescriptor> list = new ArrayList<MappingTableDescriptor>(count);
long varId = NXCPCodes.VID_ELEMENT_LIST_BASE;
for (int i = 0; i < count; i++) {
list.add(new MappingTableDescriptor(response, varId));
varId += 10;
}
return list;
}
use of org.netxms.client.mt.MappingTableDescriptor in project netxms by netxms.
the class MappingTableListComparator 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;
MappingTableDescriptor d1 = (MappingTableDescriptor) e1;
MappingTableDescriptor d2 = (MappingTableDescriptor) e2;
switch(// $NON-NLS-1$
(Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID")) {
case MappingTables.COLUMN_ID:
result = d1.getId() - d2.getId();
break;
case MappingTables.COLUMN_NAME:
result = d1.getName().compareToIgnoreCase(d2.getName());
break;
case MappingTables.COLUMN_DESCRIPTION:
result = d1.getDescription().compareToIgnoreCase(d2.getDescription());
break;
case MappingTables.COLUMN_FLAGS:
result = d1.getFlags() - d2.getFlags();
break;
default:
result = 0;
break;
}
return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
use of org.netxms.client.mt.MappingTableDescriptor in project netxms by netxms.
the class MappingTables method editTable.
/**
* Edit selected table
*/
private void editTable() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if ((selection == null) || (selection.size() != 1))
return;
MappingTableDescriptor d = (MappingTableDescriptor) selection.getFirstElement();
try {
getSite().getPage().showView(MappingTableEditor.ID, Integer.toString(d.getId()), IWorkbenchPage.VIEW_ACTIVATE);
} catch (PartInitException e) {
MessageDialogHelper.openError(getSite().getShell(), Messages.get().MappingTables_Error, String.format(Messages.get().MappingTables_ErrorOpeningView, e.getLocalizedMessage()));
}
}
use of org.netxms.client.mt.MappingTableDescriptor in project netxms by netxms.
the class MappingTables method createNewTable.
/**
* Create new table
*/
private void createNewTable() {
final CreateMappingTableDialog dlg = new CreateMappingTableDialog(getSite().getShell());
if (dlg.open() != Window.OK)
return;
new ConsoleJob(Messages.get().MappingTables_CreateJobName, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final Integer assignedId = session.createMappingTable(dlg.getName(), dlg.getDescription(), 0);
runInUIThread(new Runnable() {
@Override
public void run() {
// descriptor may already be presented if creation notification
// was already processed
MappingTableDescriptor d = mappingTables.get(assignedId);
if (d == null) {
d = new MappingTableDescriptor(assignedId, dlg.getName(), dlg.getDescription(), 0);
mappingTables.put(assignedId, d);
}
viewer.setInput(mappingTables.values().toArray());
viewer.setSelection(new StructuredSelection(d));
editTable();
}
});
}
@Override
protected String getErrorMessage() {
// TODO Auto-generated method stub
return null;
}
}.start();
}
use of org.netxms.client.mt.MappingTableDescriptor in project netxms by netxms.
the class MappingTables method deleteTables.
/**
* Delete selected tables
*/
private void deleteTables() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if ((selection == null) || (selection.size() == 0))
return;
if (!MessageDialogHelper.openQuestion(getSite().getShell(), Messages.get().MappingTables_DeleteConfirmation, Messages.get().MappingTables_DeleteConfirmationText))
return;
final List<Integer> tables = new ArrayList<Integer>(selection.size());
for (Object o : selection.toList()) {
if (o instanceof MappingTableDescriptor)
tables.add(((MappingTableDescriptor) o).getId());
}
new ConsoleJob(Messages.get().MappingTables_DeleteJobName, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (Integer id : tables) session.deleteMappingTable(id);
runInUIThread(new Runnable() {
@Override
public void run() {
for (Integer id : tables) mappingTables.remove(id);
viewer.setInput(mappingTables.values().toArray());
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().MappingTables_DeleteJobError;
}
}.start();
}
Aggregations