use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class ServiceCheckScript method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected void applyChanges(final boolean isApply) {
if (initialScript.equals(filterSource.getText()))
// Nothing to apply
return;
if (isApply)
setValid(false);
final String newScript = filterSource.getText();
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().ServiceCheckScript_JobTitle, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
md.setScript(newScript);
session.modifyObject(md);
initialScript = newScript;
}
@Override
protected String getErrorMessage() {
return Messages.get().ServiceCheckScript_JobError;
}
@Override
protected void jobFinalize() {
if (isApply) {
getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
ServiceCheckScript.this.setValid(true);
}
});
}
}
}.start();
}
use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class SnmpConfig method savePortConfig.
private void savePortConfig(final NXCSession session) throws IOException, NXCException {
// $NON-NLS-1$
session.setServerVariable("SNMPPorts", parsePorts());
for (Integer i : ports.keySet()) {
if (ports.get(i).isEmpty() || session.findZone(i) == null)
continue;
final NXCObjectModificationData data = new NXCObjectModificationData(session.findZone(i).getObjectId());
data.setSnmpPorts(ports.get(i));
session.modifyObject(data);
}
}
use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class InterfacesFragment method modifyExpectedState.
/**
* Modifies expected state of the selected interface
* @param newState The new infterface state
* @return true if the command can be issued properly
*/
private boolean modifyExpectedState(int newState) {
if (selectedObject != null) {
NXCSession session = service.getSession();
if (session != null) {
NXCObjectModificationData md = new NXCObjectModificationData(selectedObject.getObjectId());
md.setExpectedState(newState);
try {
session.modifyObject(md);
} catch (NXCException e) {
Log.e(TAG, "NXCException in modifyState...", e);
e.printStackTrace();
} catch (IOException e) {
Log.e(TAG, "IOException in modifyState...", e);
e.printStackTrace();
}
return true;
}
}
return false;
}
use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class DashboardElements method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
private boolean applyChanges(final boolean isApply) {
final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
md.setDashboardElements(elements);
md.setColumnCount(columnCount.getSelection());
if (isApply)
setValid(false);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().DashboardElements_JobTitle, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
}
@Override
protected String getErrorMessage() {
return Messages.get().DashboardElements_JobError;
}
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.jobs.ConsoleJob#jobFinalize()
*/
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
DashboardElements.this.setValid(true);
}
});
}
}
}.start();
return true;
}
use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class DashboardControl method saveDashboard.
/**
* Save dashboard layout
*
* @param viewPart
*/
public void saveDashboard(IViewPart viewPart) {
final NXCObjectModificationData md = new NXCObjectModificationData(dashboard.getObjectId());
md.setDashboardElements(new ArrayList<DashboardElement>(elements));
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().DashboardControl_SaveLayout, viewPart, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
runInUIThread(new Runnable() {
@Override
public void run() {
if (isDisposed())
return;
modified = false;
if (modifyListener != null)
modifyListener.save();
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().DashboardControl_SaveError + dashboard.getObjectName();
}
}.start();
}
Aggregations