use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class SummaryTableManager method editSummaryTable.
/**
* Edit existing dataset
*/
private void editSummaryTable() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
final DciSummaryTableDescriptor d = (DciSummaryTableDescriptor) selection.getFirstElement();
new ConsoleJob(Messages.get().SummaryTableManager_ReadJobName, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final DciSummaryTable t = session.getDciSummaryTable(d.getId());
runInUIThread(new Runnable() {
@Override
public void run() {
PropertyDialog dlg = PropertyDialog.createDialogOn(getSite().getShell(), null, t);
dlg.getShell().setText(Messages.get().SummaryTableManager_TitleEdit);
dlg.open();
d.updateFromTable(t);
viewer.update(d, null);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().SummaryTableManager_ReadJobError;
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class LastValuesWidget method getDataFromServer.
/**
* Get data from server
*/
private void getDataFromServer() {
if (dcTarget == null) {
dataViewer.setInput(new DciValue[0]);
return;
}
ConsoleJob job = new ConsoleJob(Messages.get(getDisplay()).LastValuesWidget_JobTitle + dcTarget.getObjectName(), viewPart, Activator.PLUGIN_ID, LastValuesWidget.JOB_FAMILY, getDisplay()) {
@Override
protected String getErrorMessage() {
return String.format(Messages.get().LastValuesWidget_JobError, (dcTarget != null) ? dcTarget.getObjectName() : null);
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
try {
final DciValue[] data = session.getLastValues(dcTarget.getObjectId());
runInUIThread(new Runnable() {
@Override
public void run() {
if (!isDisposed()) {
dataViewer.setInput(data);
hideMessage();
}
}
});
} catch (final Exception e) {
runInUIThread(new Runnable() {
@Override
public void run() {
if (!isDisposed()) {
showMessage(ERROR, String.format("Cannot read data from server: %s", e.getLocalizedMessage()));
}
}
});
}
}
};
job.setUser(false);
job.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class SummaryTableWidget method forcePoll.
/**
* @param pollAll
*/
private void forcePoll(boolean pollAll) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.isEmpty())
return;
final List<PollRequest> requests = new ArrayList<PollRequest>();
for (Object o : selection.toList()) {
TableRow r = (TableRow) o;
long nodeId = r.getObjectId();
if (pollAll) {
int count = ((Table) viewer.getInput()).getColumnCount();
for (int i = 1; i < count; i++) {
long dciId = r.get(i).getObjectId();
if (dciId != 0) {
requests.add(new PollRequest(nodeId, dciId));
}
}
} else {
int index = ((Table) viewer.getInput()).getColumnIndex(currentColumn.getText());
long dciId = r.get(index).getObjectId();
if (dciId != 0) {
requests.add(new PollRequest(nodeId, dciId));
}
}
}
if (requests.isEmpty())
return;
final NXCSession session = ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().SummaryTableWidget_ForceDciPoll, viewPart, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
monitor.beginTask(Messages.get().SummaryTableWidget_DciPoll, requests.size());
for (PollRequest r : requests) {
session.forceDCIPoll(r.nodeId, r.dciId);
monitor.worked(1);
}
monitor.done();
runInUIThread(new Runnable() {
@Override
public void run() {
refresh();
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().SummaryTableWidget_13;
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class SummaryTableFilter method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected void applyChanges(final boolean isApply) {
if (isApply)
setValid(false);
table.setNodeFilter(filter.getText());
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().SummaryTableFilter_JobName, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
synchronized (table) {
int id = session.modifyDciSummaryTable(table);
table.setId(id);
}
}
@Override
protected String getErrorMessage() {
return Messages.get().SummaryTableFilter_JobError;
}
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.jobs.ConsoleJob#jobFinalize()
*/
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
SummaryTableFilter.this.setValid(true);
}
});
}
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class TableColumns method updateColumnsFromAgent.
/**
* Update columns from real table
*/
private void updateColumnsFromAgent(final String name, final boolean interactive, final AbstractObject queryObject) {
final NXCSession session = ConsoleSharedData.getSession();
ConsoleJob job = new ConsoleJob(Messages.get().TableColumns_JobName, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
try {
final org.netxms.client.Table table;
if (editor.getSourceNode() != 0) {
table = session.queryAgentTable(editor.getSourceNode(), name);
} else {
table = session.queryAgentTable((queryObject != null) ? queryObject.getObjectId() : dci.getNodeId(), name);
}
runInUIThread(new Runnable() {
@Override
public void run() {
columns.clear();
for (int i = 0; i < table.getColumnCount(); i++) {
ColumnDefinition c = new ColumnDefinition(table.getColumnName(i), table.getColumnDisplayName(i));
c.setDataType(table.getColumnDefinition(i).getDataType());
c.setInstanceColumn(table.getColumnDefinition(i).isInstanceColumn());
columns.add(c);
}
columnList.setInput(columns.toArray());
}
});
} catch (Exception e) {
Activator.logError("Cannot read table column definition from agent", e);
if (interactive) {
final String msg = (e instanceof NXCException) ? e.getLocalizedMessage() : "Internal error";
runInUIThread(new Runnable() {
@Override
public void run() {
MessageDialogHelper.openError(getShell(), "Error", String.format("Cannot read table column definition from agent (%s)", msg));
}
});
}
}
}
@Override
protected String getErrorMessage() {
return null;
}
};
job.setUser(false);
job.start();
}
Aggregations