use of org.netxms.client.datacollection.GraphSettings in project netxms by netxms.
the class PredefinedGraphTree method notificationHandler.
/* (non-Javadoc)
* @see org.netxms.api.client.SessionListener#notificationHandler(org.netxms.api.client.SessionNotification)
*/
@Override
public void notificationHandler(final SessionNotification n) {
switch(n.getCode()) {
case SessionNotification.PREDEFINED_GRAPHS_DELETED:
viewer.getControl().getDisplay().asyncExec(new Runnable() {
@SuppressWarnings("unchecked")
@Override
public void run() {
List<GraphSettings> list = (List<GraphSettings>) viewer.getInput();
for (int i = 0; i < list.size(); i++) if (list.get(i).getId() == n.getSubCode()) {
Object o = list.get(i);
list.remove(o);
viewer.refresh();
break;
}
}
});
break;
case SessionNotification.PREDEFINED_GRAPHS_CHANGED:
if (((GraphSettings) n.getObject()).isTemplate())
return;
viewer.getControl().getDisplay().asyncExec(new Runnable() {
@SuppressWarnings("unchecked")
@Override
public void run() {
final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
final List<GraphSettings> list = (List<GraphSettings>) viewer.getInput();
boolean objectUpdated = false;
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getId() == n.getSubCode()) {
list.set(i, (GraphSettings) n.getObject());
objectUpdated = true;
break;
}
}
if (!objectUpdated) {
list.add((GraphSettings) n.getObject());
viewer.setInput(list);
}
viewer.refresh();
if ((selection.size() == 1) && (selection.getFirstElement() instanceof GraphSettings)) {
GraphSettings element = (GraphSettings) selection.getFirstElement();
if (element.getId() == n.getSubCode())
viewer.setSelection(new StructuredSelection((GraphSettings) n.getObject()), true);
}
}
});
break;
}
}
use of org.netxms.client.datacollection.GraphSettings in project netxms by netxms.
the class TemplateGraphView method notificationHandler.
/* (non-Javadoc)
* @see org.netxms.api.client.SessionListener#notificationHandler(org.netxms.api.client.SessionNotification)
*/
@Override
public void notificationHandler(final SessionNotification n) {
switch(n.getCode()) {
case SessionNotification.PREDEFINED_GRAPHS_DELETED:
viewer.getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
for (int i = 0; i < graphList.size(); i++) if (graphList.get(i).getId() == n.getSubCode()) {
Object o = graphList.get(i);
graphList.remove(o);
viewer.setInput(graphList);
break;
}
}
});
break;
case SessionNotification.PREDEFINED_GRAPHS_CHANGED:
viewer.getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (!(n.getObject() instanceof GraphSettings)) {
return;
}
final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
boolean objectUpdated = false;
for (int i = 0; i < graphList.size(); i++) {
if (graphList.get(i).getId() == n.getSubCode()) {
graphList.set(i, (GraphSettings) n.getObject());
objectUpdated = true;
break;
}
}
if (!objectUpdated) {
if (((GraphSettings) n.getObject()).isTemplate())
graphList.add((GraphSettings) n.getObject());
}
viewer.setInput(graphList);
if (selection.size() == 1) {
if (selection.getFirstElement() instanceof GraphSettings) {
GraphSettings element = (GraphSettings) selection.getFirstElement();
if (element.getId() == n.getSubCode())
viewer.setSelection(new StructuredSelection((GraphSettings) n.getObject()), true);
}
}
}
});
break;
}
}
use of org.netxms.client.datacollection.GraphSettings in project netxms by netxms.
the class General method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected void applyChanges(final boolean isApply) {
config.setTitle(title.getText());
config.setShowGrid(checkShowGrid.getSelection());
config.setShowLegend(checkShowLegend.getSelection());
config.setAutoScale(yAxisRange.isAuto());
config.setShowHostNames(checkShowHostNames.getSelection());
config.setAutoRefresh(checkAutoRefresh.getSelection());
config.setLogScale(checkLogScale.getSelection());
config.setRefreshRate(refreshIntervalSpinner.getSelection());
config.setStacked(checkStacked.getSelection());
config.setExtendedLegend(checkExtendedLegend.getSelection());
config.setArea(checkAreaChart.getSelection());
config.setLegendPosition((int) Math.pow(2, legendLocation.getSelectionIndex()));
config.setTranslucent(checkTranslucent.getSelection());
config.setLineWidth(lineWidth.getSelection());
config.setTimeFrameType(timeSelector.getTimeFrameType());
config.setTimeUnits(timeSelector.getTimeUnitValue());
config.setTimeRange(timeSelector.getTimeRangeValue());
config.setTimeFrom(timeSelector.getTimeFrom());
config.setTimeTo(timeSelector.getTimeTo());
config.setUseMultipliers(checkUseMultipliers.getSelection());
config.setMinYScaleValue(yAxisRange.getMinY());
config.setMaxYScaleValue(yAxisRange.getMaxY());
config.setModifyYBase(yAxisRange.modifyYBase());
if ((config instanceof GraphSettings) && isApply) {
setValid(false);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().General_JobName, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.saveGraph((GraphSettings) config, true);
runInUIThread(new Runnable() {
@Override
public void run() {
General.this.setValid(true);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().General_JobError;
}
}.start();
}
}
Aggregations