use of org.netxms.client.datacollection.DciValue in project netxms by netxms.
the class IdMatchingDialog method updateDciMapping.
/**
* Update mapping for all DCIs of given node after node mapping change
*
* @param objData
*/
private void updateDciMapping(final ObjectIdMatchingData objData) {
if (objData.dcis.size() == 0)
return;
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().IdMatchingDialog_JobTitle, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final DciValue[] dciValues = session.getLastValues(objData.dstId);
runInUIThread(new Runnable() {
@Override
public void run() {
for (DciIdMatchingData d : objData.dcis) {
d.dstNodeId = objData.dstId;
d.dstDciId = 0;
d.dstName = null;
for (DciValue v : dciValues) {
if (v.getDescription().equalsIgnoreCase(d.srcName)) {
d.dstDciId = v.getId();
d.dstName = v.getDescription();
break;
}
}
}
viewer.refresh(true);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().IdMatchingDialog_JobErrorText;
}
}.start();
}
use of org.netxms.client.datacollection.DciValue in project netxms by netxms.
the class LastValuesWidget method copySelection.
/**
* Copy selection to clipboard
*/
private void copySelection() {
IStructuredSelection selection = (IStructuredSelection) dataViewer.getSelection();
if (selection.isEmpty())
return;
// $NON-NLS-1$
final String nl = System.getProperty("line.separator");
StringBuilder sb = new StringBuilder();
for (Object o : selection.toList()) {
if (sb.length() > 0)
sb.append(nl);
DciValue v = (DciValue) o;
sb.append(v.getDescription());
// $NON-NLS-1$
sb.append(" = ");
sb.append(v.getValue());
}
if (selection.size() > 1)
sb.append(nl);
WidgetHelper.copyToClipboard(sb.toString());
}
use of org.netxms.client.datacollection.DciValue in project netxms by netxms.
the class ClearCollectedData method selectionChanged.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
@Override
public void selectionChanged(IAction action, ISelection selection) {
Set<DCI> dciList = null;
if (selection instanceof IStructuredSelection) {
dciList = new HashSet<DCI>();
for (Object o : ((IStructuredSelection) selection).toList()) {
if (o instanceof DciValue) {
dciList.add(new DCI(((DciValue) o).getNodeId(), ((DciValue) o).getId()));
} else if (o instanceof DataCollectionObject) {
dciList.add(new DCI(((DataCollectionObject) o).getNodeId(), ((DataCollectionObject) o).getId()));
} else {
dciList = null;
break;
}
}
}
objects = dciList;
action.setEnabled((objects != null) && (objects.size() > 0));
}
use of org.netxms.client.datacollection.DciValue in project netxms by netxms.
the class LastValuesWidget method getDataFromServer.
/**
* Get data from server
*/
private void getDataFromServer() {
if (dcTarget == null) {
dataViewer.setInput(new DciValue[0]);
return;
}
ConsoleJob job = new ConsoleJob(Messages.get(getDisplay()).LastValuesWidget_JobTitle + dcTarget.getObjectName(), viewPart, Activator.PLUGIN_ID, LastValuesWidget.JOB_FAMILY, getDisplay()) {
@Override
protected String getErrorMessage() {
return String.format(Messages.get().LastValuesWidget_JobError, (dcTarget != null) ? dcTarget.getObjectName() : null);
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
try {
final DciValue[] data = session.getLastValues(dcTarget.getObjectId());
runInUIThread(new Runnable() {
@Override
public void run() {
if (!isDisposed()) {
dataViewer.setInput(data);
hideMessage();
}
}
});
} catch (final Exception e) {
runInUIThread(new Runnable() {
@Override
public void run() {
if (!isDisposed()) {
showMessage(ERROR, String.format("Cannot read data from server: %s", e.getLocalizedMessage()));
}
}
});
}
}
};
job.setUser(false);
job.start();
}
use of org.netxms.client.datacollection.DciValue in project netxms by netxms.
the class SummaryTableColumns method importColumns.
/**
* Import Columns from node
*/
private void importColumns() {
final SelectDciDialog dialog = new SelectDciDialog(getShell(), 0);
dialog.setAllowTemplateItems(true);
dialog.setEnableEmptySelection(false);
if (dialog.open() == Dialog.OK) {
final List<DciValue> selection = dialog.getSelection();
List<DciSummaryTableColumn> select = new ArrayList<DciSummaryTableColumn>();
for (DciValue item : selection) {
DciSummaryTableColumn column = new DciSummaryTableColumn(item.getDescription(), item.getName(), 0, ";");
select.add(column);
columns.add(column);
}
viewer.setInput(columns.toArray());
viewer.setSelection(new StructuredSelection(select));
}
}
Aggregations