use of org.netxms.ui.eclipse.jobs.ConsoleJob 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.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class AlarmLogViewer method createIssue.
/**
* Create helpdesk ticket (issue) from selected alarms
*/
private void createIssue() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
final long id = Long.parseLong(((TableRow) selection.getFirstElement()).get(0).getValue());
new ConsoleJob("Create helpdesk ticket", this, Activator.PLUGIN_ID, JOB_FAMILY) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.openHelpdeskIssue(id);
}
@Override
protected String getErrorMessage() {
return "Cannot create helpdesk ticket from alarm";
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class AlarmLogViewer method unlinkIssue.
/**
* Unlink helpdesk ticket (issue) from selected alarm
*/
private void unlinkIssue() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
final long id = Long.parseLong(((TableRow) selection.getFirstElement()).get(0).getValue());
new ConsoleJob("Unlink alarm from helpdesk ticket", this, Activator.PLUGIN_ID, JOB_FAMILY) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.unlinkHelpdeskIssue(id);
}
@Override
protected String getErrorMessage() {
return "Cannot unlink alarm from helpdesk ticket";
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class CloneDashboard method run.
@Override
public void run(final IAction action) {
final long parentId = sourceObject.getParentIdList()[0];
final CreateObjectDialog dlg = new CreateObjectDialog(window.getShell(), Messages.get().CloneDashboard_Dashboard);
if (dlg.open() == Window.OK) {
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().CloneDashboard_JobTitle, part, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_DASHBOARD, dlg.getObjectName(), parentId);
final long newDashboardId = session.createObject(cd);
final NXCObjectModificationData md = new NXCObjectModificationData(newDashboardId);
md.setDashboardElements(sourceObject.getElements());
md.setColumnCount(sourceObject.getNumColumns());
md.setObjectFlags(sourceObject.getOptions());
session.modifyObject(md);
}
@Override
protected String getErrorMessage() {
return String.format(Messages.get().CloneDashboard_Error, dlg.getObjectName());
}
}.start();
}
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class CreateDashboardGroup method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
final CreateObjectDialog dlg = new CreateObjectDialog(window.getShell(), "Create dashboard group");
if (dlg.open() != Window.OK)
return;
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob("Create dashboard group", part, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_DASHBOARDGROUP, dlg.getObjectName(), parentId);
session.createObject(cd);
}
@Override
protected String getErrorMessage() {
return String.format("Cannot create dashboard group object %s", dlg.getObjectName());
}
}.start();
}
Aggregations