use of org.netxms.client.datacollection.DciValue in project netxms by netxms.
the class LastValues method refresh.
/**
* Refresh view
*/
private void refresh() {
final NXCSession session = ConsoleSharedData.getSession();
final long nodeId = getObject().getObjectId();
ConsoleJob job = new ConsoleJob(Messages.get().LastValues_JobName, getObjectTab().getViewPart(), Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
try {
final DciValue[] list = session.getLastValues(nodeId, false, true, false);
runInUIThread(new Runnable() {
@Override
public void run() {
if (viewer.getControl().isDisposed() || (getObject().getObjectId() != nodeId))
return;
viewer.setInput(list);
viewer.getTable().getColumn(0).pack();
viewer.getTable().getColumn(1).pack();
}
});
} catch (Exception e) {
// $NON-NLS-1$
Activator.log("Exception in last values overview element", e);
}
}
@Override
protected String getErrorMessage() {
return Messages.get().LastValues_JobErrorMsg;
}
};
job.setUser(false);
job.setSystem(true);
job.start();
}
use of org.netxms.client.datacollection.DciValue in project netxms by netxms.
the class ObjectPopupDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.PopupDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogArea = (Composite) super.createDialogArea(parent);
statusLabel = new CLabel(dialogArea, SWT.NONE);
statusLabel.setText(StatusDisplayInfo.getStatusText(object.getStatus()).toUpperCase());
statusLabel.setForeground(StatusDisplayInfo.getStatusColor(object.getStatus()));
statusLabel.setFont(boldFont);
StringBuilder sb = new StringBuilder();
if (object instanceof AbstractNode) {
appendText(sb, ((AbstractNode) object).getPrimaryIP().getHostAddress());
appendText(sb, ((AbstractNode) object).getPlatformName());
String sd = ((AbstractNode) object).getSystemDescription();
if (sd.length() > 127)
// $NON-NLS-1$
sd = sd.substring(0, 127) + "...";
appendText(sb, sd);
appendText(sb, ((AbstractNode) object).getSnmpSysName());
appendText(sb, ((AbstractNode) object).getSnmpSysContact());
}
if (sb.length() > 0) {
createSeparator(dialogArea);
if (sb.charAt(sb.length() - 1) == '\n')
sb.deleteCharAt(sb.length() - 1);
CLabel infoText = new CLabel(dialogArea, SWT.MULTI);
infoText.setText(sb.toString());
}
if (object instanceof DataCollectionTarget) {
List<DciValue> values = ((DataCollectionTarget) object).getTooltipDciData();
if (!values.isEmpty()) {
createSeparator(dialogArea);
Composite group = new Composite(dialogArea, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
group.setLayout(layout);
StringBuilder leftColumn = new StringBuilder();
StringBuilder rightColumn = new StringBuilder();
for (DciValue v : values) {
if (leftColumn.length() > 0) {
leftColumn.append('\n');
rightColumn.append('\n');
}
leftColumn.append(v.getDescription());
rightColumn.append(v.getValue());
}
new CLabel(group, SWT.MULTI).setText(leftColumn.toString());
new CLabel(group, SWT.MULTI).setText(rightColumn.toString());
}
}
if (!object.getComments().isEmpty()) {
createSeparator(dialogArea);
new CLabel(dialogArea, SWT.MULTI).setText(object.getComments());
}
return dialogArea;
}
Aggregations