use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class CreateInterfraceDci method run.
/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
final CreateInterfaceDciDialog dlg = new CreateInterfaceDciDialog(shell, (objects.size() == 1) ? objects.get(0) : null);
if (dlg.open() == Window.OK) {
final List<Interface> ifaces = new ArrayList<Interface>(objects);
// Get set of nodes
final Set<AbstractNode> nodes = new HashSet<AbstractNode>();
for (Interface iface : ifaces) {
AbstractNode node = iface.getParentNode();
if (node != null) {
nodes.add(node);
}
}
// Check what nodes requires DCI list lock
final Map<Long, Boolean> lockRequired = new HashMap<Long, Boolean>(nodes.size());
final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
for (AbstractNode n : nodes) {
IViewReference ref = page.findViewReference(DataCollectionEditor.ID, Long.toString(n.getObjectId()));
lockRequired.put(n.getObjectId(), !((ref != null) && (ref.getView(false) != null)));
}
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().CreateInterfraceDci_JobTitle, viewPart, Activator.PLUGIN_ID, null) {
@Override
protected String getErrorMessage() {
return Messages.get().CreateInterfraceDci_JobError;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
InterfaceDciInfo[] dciInfo = dlg.getDciInfo();
monitor.beginTask(Messages.get(getDisplay()).CreateInterfraceDci_TaskName, ifaces.size() * dciInfo.length);
for (int i = 0; i < ifaces.size(); i++) {
for (int j = 0; j < dciInfo.length; j++) {
if (dciInfo[j].enabled) {
createInterfaceDci(session, ifaces.get(i), j, dciInfo[j], dlg.getPollingInterval(), dlg.getRetentionTime(), ifaces.size() > 1, lockRequired);
}
monitor.worked(1);
}
}
monitor.done();
}
}.start();
}
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class RemoveTemplate method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run(IAction action) {
final ChildObjectListDialog dlg = new ChildObjectListDialog(shell, parentId, null);
if (dlg.open() == Window.OK) {
final DciRemoveConfirmationDialog dlg2 = new DciRemoveConfirmationDialog(shell);
if (dlg2.open() == Window.OK) {
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().RemoveTemplate_JobTitle, viewPart, Activator.PLUGIN_ID, null) {
@Override
protected String getErrorMessage() {
return Messages.get().RemoveTemplate_JobError;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
List<AbstractObject> objects = dlg.getSelectedObjects();
for (int i = 0; i < objects.size(); i++) session.removeTemplate(parentId, objects.get(i).getObjectId(), dlg2.getRemoveFlag());
}
}.start();
}
}
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class StartDataRecalculation method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
if (objects == null)
return;
if (!MessageDialogHelper.openQuestion(part.getSite().getShell(), "Start Data Recalculation", "Collected values will be re-calculated using stored raw values and current transformation settings. Continue?"))
return;
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final Set<DCI> dciToProcess = objects;
new ConsoleJob("Start DCI data recalculation", part, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
monitor.beginTask("Start DCI data recalculation", dciToProcess.size());
for (DCI d : dciToProcess) {
session.recalculateDCIValues(d.nodeId, d.dciId);
monitor.worked(1);
}
monitor.done();
}
@Override
protected String getErrorMessage() {
return "Cannot initiate data recalculation";
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class SelectAgentParamDlg method fillParameterList.
/*
* (non-Javadoc)
*
* @see org.netxms.ui.eclipse.datacollection.dialogs.AbstractSelectParamDlg#fillParameterList()
*/
@Override
protected void fillParameterList() {
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().SelectAgentParamDlg_JobTitle + object.getObjectName(), null, Activator.PLUGIN_ID, null) {
@Override
protected String getErrorMessage() {
return Messages.get().SelectAgentParamDlg_JobError;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
if (selectTables) {
final List<AgentTable> tables = session.getSupportedTables(object.getObjectId());
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(tables.toArray());
}
});
} else {
final List<AgentParameter> parameters = session.getSupportedParameters(object.getObjectId(), origin);
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(parameters.toArray());
}
});
}
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class TestTransformationDlg method runScript.
/**
* Run script
*/
private void runScript() {
getButton(RUN).setEnabled(false);
final String input = inputValue.getText();
inputValue.getTextControl().setEditable(false);
status.setText(Messages.get().TestTransformationDlg_Running);
status.setImage(imageWaiting);
// $NON-NLS-1$
result.setText("");
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().TestTransformationDlg_JobTitle, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final TransformationTestResult r = session.testTransformationScript(nodeId, script, input);
runInUIThread(new Runnable() {
@Override
public void run() {
if ((getShell() == null) || getShell().isDisposed())
return;
if (r.success) {
status.setText(Messages.get().TestTransformationDlg_Success);
status.setImage(StatusDisplayInfo.getStatusImage(Severity.NORMAL));
} else {
status.setText(Messages.get().TestTransformationDlg_Failure);
status.setImage(StatusDisplayInfo.getStatusImage(Severity.CRITICAL));
}
result.setText(r.result);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().TestTransformationDlg_JobError;
}
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.jobs.ConsoleJob#jobFinalize()
*/
@Override
protected void jobFinalize() {
runInUIThread(new Runnable() {
@Override
public void run() {
if ((getShell() == null) || getShell().isDisposed())
return;
getButton(RUN).setEnabled(true);
inputValue.getTextControl().setEditable(true);
inputValue.getTextControl().setFocus();
}
});
}
}.start();
}
Aggregations