use of org.netxms.client.datacollection.ChartDciConfig in project netxms by netxms.
the class DataSources method drawColorCell.
/**
* @param event
*/
private void drawColorCell(Event event) {
TableItem item = (TableItem) event.item;
ChartDciConfig dci = (ChartDciConfig) item.getData();
if (dci.color.equalsIgnoreCase(ChartDciConfig.UNSET_COLOR))
return;
int width = viewer.getTable().getColumn(COLUMN_COLOR).getWidth();
Color color = ColorConverter.colorFromInt(dci.getColorAsInt(), colorCache);
event.gc.setForeground(colorCache.create(0, 0, 0));
event.gc.setBackground(color);
event.gc.setLineWidth(1);
event.gc.fillRectangle(event.x + 3, event.y + 2, width - 7, event.height - 5);
event.gc.drawRectangle(event.x + 3, event.y + 2, width - 7, event.height - 5);
}
use of org.netxms.client.datacollection.ChartDciConfig in project netxms by netxms.
the class TemplateDataSources method drawColorCell.
/**
* @param event
*/
private void drawColorCell(Event event) {
TableItem item = (TableItem) event.item;
ChartDciConfig dci = (ChartDciConfig) item.getData();
if (dci.color.equalsIgnoreCase(ChartDciConfig.UNSET_COLOR))
return;
int width = viewer.getTable().getColumn(COLUMN_COLOR).getWidth();
Color color = ColorConverter.colorFromInt(dci.getColorAsInt(), colorCache);
event.gc.setForeground(colorCache.create(0, 0, 0));
event.gc.setBackground(color);
event.gc.setLineWidth(1);
event.gc.fillRectangle(event.x + 3, event.y + 2, width - 7, event.height - 5);
event.gc.drawRectangle(event.x + 3, event.y + 2, width - 7, event.height - 5);
}
use of org.netxms.client.datacollection.ChartDciConfig in project netxms by netxms.
the class AbstractChartConfig method remapDataCollectionItems.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.dashboard.widgets.internal.DashboardElementConfig#remapDataCollectionItems(java.util.Map)
*/
@Override
public void remapDataCollectionItems(Map<Long, DciIdMatchingData> remapData) {
super.remapDataCollectionItems(remapData);
for (ChartDciConfig dci : dciList) {
DciIdMatchingData md = remapData.get(dci.dciId);
if (md != null) {
dci.dciId = md.dstDciId;
dci.nodeId = md.dstNodeId;
}
}
}
use of org.netxms.client.datacollection.ChartDciConfig in project netxms by netxms.
the class LineChartElement method refreshData.
/**
* Refresh graph's data
*/
private void refreshData() {
if (updateInProgress)
return;
updateInProgress = true;
ConsoleJob job = new ConsoleJob(Messages.get().LineChartElement_JobTitle, viewPart, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
private ChartDciConfig currentDci;
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final Date from = new Date(System.currentTimeMillis() - config.getTimeRangeMillis());
final Date to = new Date(System.currentTimeMillis());
final ChartDciConfig[] dciList = config.getDciList();
final DciData[] data = new DciData[dciList.length];
for (int i = 0; i < dciList.length; i++) {
currentDci = dciList[i];
if (currentDci.type == ChartDciConfig.ITEM)
data[i] = session.getCollectedData(currentDci.nodeId, currentDci.dciId, from, to, 0, false);
else
data[i] = session.getCollectedTableData(currentDci.nodeId, currentDci.dciId, currentDci.instance, currentDci.column, from, to, 0);
}
runInUIThread(new Runnable() {
@Override
public void run() {
if (!((Widget) chart).isDisposed()) {
dataCache.clear();
chart.setTimeRange(from, to);
for (int i = 0; i < data.length; i++) {
chart.updateParameter(i, data[i], false);
dataCache.add(new DataCacheElement(dciList[i], data[i]));
}
chart.refresh();
chart.clearErrors();
}
updateInProgress = false;
}
});
}
@Override
protected String getErrorMessage() {
return String.format(Messages.get().LineChartElement_JobError, session.getObjectName(currentDci.nodeId), currentDci.name);
}
@Override
protected void jobFailureHandler() {
updateInProgress = false;
super.jobFailureHandler();
}
@Override
protected IStatus createFailureStatus(final Exception e) {
runInUIThread(new Runnable() {
@Override
public void run() {
// $NON-NLS-1$ //$NON-NLS-2$
chart.addError(getErrorMessage() + " (" + e.getLocalizedMessage() + ")");
}
});
return Status.OK_STATUS;
}
};
job.setUser(false);
job.start();
}
use of org.netxms.client.datacollection.ChartDciConfig in project netxms by netxms.
the class DataSources 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<ChartDciConfig> select = new ArrayList<ChartDciConfig>();
for (DciValue item : selection) {
ChartDciConfig dci = new ChartDciConfig(item);
select.add(dci);
labelProvider.addCacheEntry(dci.nodeId, dci.dciId, dci.name);
dciList.add(dci);
}
viewer.setInput(dciList.toArray());
viewer.setSelection(new StructuredSelection(select));
}
}
Aggregations