use of org.netxms.client.datacollection.DciValue in project netxms by netxms.
the class AbstractNetworkMapView method openLinkDci.
/**
* Handler for opening network map dci on double click
*/
private void openLinkDci() {
final NetworkMapLink link = (NetworkMapLink) currentSelection.getFirstElement();
if (!link.hasDciData())
return;
new ConsoleJob("Open link dci job", this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.jobs.ConsoleJob#runInternal(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
DciValue[] values = session.getLastValues(link.getDciAsList());
final StringBuilder sb = new StringBuilder();
for (DciValue v : values) {
sb.append("&");
sb.append(Integer.toString(v instanceof SimpleDciValue ? ChartDciConfig.ITEM : ChartDciConfig.TABLE));
sb.append("@");
sb.append(Long.toString(v.getNodeId()));
sb.append("@");
sb.append(Long.toString(v.getId()));
sb.append("@");
sb.append(URLEncoder.encode(v.getDescription(), "UTF-8"));
sb.append("@");
sb.append(URLEncoder.encode(v.getName(), "UTF-8"));
}
runInUIThread(new Runnable() {
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
try {
getSite().getPage().showView(HistoricalGraphView.ID, sb.toString(), IWorkbenchPage.VIEW_ACTIVATE);
} catch (PartInitException e) {
MessageDialogHelper.openError(getSite().getShell(), "Error", String.format("Error opening view: %s", e.getLocalizedMessage()));
}
}
});
}
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.jobs.ConsoleJob#getErrorMessage()
*/
@Override
protected String getErrorMessage() {
return "Cannot open dci link historical graph view";
}
}.start();
}
use of org.netxms.client.datacollection.DciValue in project netxms by netxms.
the class LinkDciValueProvider method getDciDataAsString.
/**
* @param DCIList
* @return
*/
public String getDciDataAsString(List<SingleDciConfig> DCIList) {
// $NON-NLS-1$
String result = "";
for (int i = 0; i < DCIList.size(); ) {
DciValue v = getDciLastValue(DCIList.get(i).dciId);
if (v != null) {
String formatString = DCIList.get(i).getFormatString();
// $NON-NLS-1$
result += v.format(formatString.isEmpty() ? "%s" : formatString);
}
if (++i != DCIList.size())
// $NON-NLS-1$
result += "\n";
}
return result;
}
use of org.netxms.client.datacollection.DciValue in project netxms by netxms.
the class LinkDciValueProvider method getDciDataAsString.
/**
* @param link
* @return
*/
public String getDciDataAsString(NetworkMapLink link) {
if (!link.hasDciData())
// $NON-NLS-1$
return "";
// $NON-NLS-1$
String result = "";
SingleDciConfig[] dciList = link.getDciList();
for (int i = 0; i < dciList.length; ) {
DciValue v = getDciLastValue(dciList[i].dciId);
if (v != null) {
String formatString = dciList[i].getFormatString();
// $NON-NLS-1$
result += v.format(formatString.isEmpty() ? "%s" : formatString);
}
if (++i != dciList.length)
// $NON-NLS-1$
result += "\n";
}
return result;
}
use of org.netxms.client.datacollection.DciValue in project netxms by netxms.
the class DCIContainerDataSources method addItem.
/**
* Add new item
*/
private void addItem() {
SelectDciDialog dlg = new SelectDciDialog(getShell(), 0);
if (dlg.open() == Window.OK) {
List<DciValue> selection = dlg.getSelection();
List<SingleDciConfig> select = new ArrayList<SingleDciConfig>();
for (DciValue item : selection) {
SingleDciConfig dci = new SingleDciConfig(item);
select.add(dci);
labelProvider.addCacheEntry(dci.getNodeId(), dci.dciId, dci.name);
dciList.add(dci);
}
viewer.setInput(dciList.toArray());
viewer.setSelection(new StructuredSelection(select));
}
}
use of org.netxms.client.datacollection.DciValue in project netxms by netxms.
the class DCIImageFigure method paintFigure.
/* (non-Javadoc)
* @see org.eclipse.draw2d.Figure#paintFigure(org.eclipse.draw2d.Graphics)
*/
@Override
protected void paintFigure(Graphics gc) {
DciValue latDCIValue = dciValueProvider.getLastDciData(dciImageConfiguration.getDci());
try {
UUID guid = dciImageConfiguration.getCorrectImage(latDCIValue);
Image image = ImageProvider.getInstance().getImage(guid);
Rectangle rect = new Rectangle(getBounds());
gc.drawImage(image, rect.x, rect.y);
} catch (IllegalArgumentException e) {
}
}
Aggregations