use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class ChangeInterfaceExpectedState method run.
/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
if (objects.size() == 0)
return;
SetInterfaceExpStateDlg dlg = new SetInterfaceExpStateDlg(shell);
if (dlg.open() != Window.OK)
return;
final long[] idList = new long[objects.size()];
for (int i = 0; i < idList.length; i++) idList[i] = objects.get(i).getObjectId();
final int newState = dlg.getExpectedState();
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().ChangeInterfaceExpectedState_JobTitle, viewPart, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (int i = 0; i < idList.length; i++) {
NXCObjectModificationData md = new NXCObjectModificationData(idList[i]);
md.setExpectedState(newState);
session.modifyObject(md);
}
}
@Override
protected String getErrorMessage() {
return Messages.get().ChangeInterfaceExpectedState_JobError;
}
}.start();
}
use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class StatusCalculation method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected boolean applyChanges(final boolean isApply) {
if (!WidgetHelper.validateTextInput(textRelativeStatus, Messages.get().StatusCalculation_Validate_RelativeStatus, new NumericTextFieldValidator(-4, 4), this) || !WidgetHelper.validateTextInput(textSingleThreshold, Messages.get().StatusCalculation_Validate_SingleThreshold, new NumericTextFieldValidator(0, 100), this) || !WidgetHelper.validateTextInput(textThresholds[0], String.format(Messages.get().StatusCalculation_Validate_Threshold, StatusDisplayInfo.getStatusText(Severity.WARNING)), new NumericTextFieldValidator(0, 100), this) || !WidgetHelper.validateTextInput(textThresholds[1], String.format(Messages.get().StatusCalculation_Validate_Threshold, StatusDisplayInfo.getStatusText(Severity.MINOR)), new NumericTextFieldValidator(0, 100), this) || !WidgetHelper.validateTextInput(textThresholds[2], String.format(Messages.get().StatusCalculation_Validate_Threshold, StatusDisplayInfo.getStatusText(Severity.MAJOR)), new NumericTextFieldValidator(0, 100), this) || !WidgetHelper.validateTextInput(textThresholds[3], String.format(Messages.get().StatusCalculation_Validate_Threshold, StatusDisplayInfo.getStatusText(Severity.CRITICAL)), new NumericTextFieldValidator(0, 100), this))
return false;
final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
md.setStatusCalculationMethod(calculationMethod);
md.setStatusPropagationMethod(propagationMethod);
md.setFixedPropagatedStatus(ObjectStatus.getByValue(comboFixedStatus.getSelectionIndex()));
md.setStatusShift(Integer.parseInt(textRelativeStatus.getText()));
ObjectStatus[] transformations = new ObjectStatus[4];
for (int i = 0; i < 4; i++) transformations[i] = ObjectStatus.getByValue(comboTranslatedStatus[i].getSelectionIndex());
md.setStatusTransformation(transformations);
md.setStatusSingleThreshold(Integer.parseInt(textSingleThreshold.getText()));
int[] thresholds = new int[4];
for (int i = 0; i < 4; i++) thresholds[i] = Integer.parseInt(textThresholds[i].getText());
md.setStatusThresholds(thresholds);
if (!hasChanges(md))
// Nothing to apply
return true;
currentState = md;
if (isApply)
setValid(false);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(String.format(Messages.get().StatusCalculation_JobName, object.getObjectName()), null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
}
@Override
protected String getErrorMessage() {
return Messages.get().StatusCalculation_JobError;
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
StatusCalculation.this.setValid(true);
}
});
}
}
}.start();
return true;
}
use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class VPNSubnets method applyChanges.
/**
* Saves changes
*/
private void applyChanges(final boolean isApply) {
if (!modified)
// Nothing to apply
return;
if (isApply)
setValid(false);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final NXCObjectModificationData md = new NXCObjectModificationData(connector.getObjectId());
md.setVpnNetworks(localNetworksElements, remoteNetworksElements);
md.setPeerGatewayId(objectSelector.getObjectId());
new ConsoleJob(Messages.get().VPNSubnets_JobName, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
VPNSubnets.this.setValid(true);
}
});
}
}
@Override
protected String getErrorMessage() {
return Messages.get().VPNSubnets_JobError;
}
}.schedule();
}
use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class ConfigPolicyEditor method doSaveInternal.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.policymanager.views.AbstractPolicyEditor#doSaveInternal(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public void doSaveInternal(IProgressMonitor monitor) throws Exception {
editor.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
content = editor.getText();
}
});
NXCObjectModificationData md = new NXCObjectModificationData(policy.getObjectId());
md.setConfigFileContent(content);
session.modifyObject(md);
}
use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class LogParserPolicyEditor method doSaveInternal.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.policymanager.views.AbstractPolicyEditor#doSaveInternal(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public void doSaveInternal(IProgressMonitor monitor) throws Exception {
editor.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
content = editor.getParserXml();
}
});
NXCObjectModificationData md = new NXCObjectModificationData(policy.getObjectId());
md.setConfigFileContent(content);
session.modifyObject(md);
}
Aggregations