use of org.netxms.client.NXCSession in project netxms by netxms.
the class CreateTemplateGroup 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(), Messages.get().CreateTemplateGroup_TemplateGroup);
if (dlg.open() != Window.OK)
return;
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().CreateTemplateGroup_JobTitle, part, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_TEMPLATEGROUP, dlg.getObjectName(), parentId);
session.createObject(cd);
}
@Override
protected String getErrorMessage() {
return String.format(Messages.get().CreateTemplateGroup_JobError, dlg.getObjectName());
}
}.start();
}
use of org.netxms.client.NXCSession 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.client.NXCSession 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.client.NXCSession 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();
}
use of org.netxms.client.NXCSession in project netxms by netxms.
the class General method performDefaults.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#performDefaults()
*/
@Override
protected void performDefaults() {
super.performDefaults();
NXCSession session = (NXCSession) ConsoleSharedData.getSession();
schedulingMode.select(0);
pollingInterval.setSelection(session.getDefaultDciPollingInterval());
statusActive.setSelection(true);
statusDisabled.setSelection(false);
statusUnsupported.setSelection(false);
retentionTime.setSelection(session.getDefaultDciRetentionTime());
checkInterpretRawSnmpValue.setSelection(false);
checkUseCustomSnmpPort.setSelection(false);
customSnmpPort.setSelection(161);
}
Aggregations