use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class CloneNetworkMap method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
if (source == null)
return;
final CreateObjectDialog dlg = new CreateObjectDialog(window.getShell(), Messages.get().CloneNetworkMap_NetworkMap);
if (dlg.open() != Window.OK)
return;
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().CreateNetworkMap_JobName, part, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_NETWORKMAP, dlg.getObjectName(), source.getParentIdList()[0]);
NXCObjectModificationData md = new NXCObjectModificationData(0);
source.prepareCopy(cd, md);
long id = session.createObject(cd);
md.setObjectId(id);
session.modifyObject(md);
}
@Override
protected String getErrorMessage() {
return String.format(Messages.get().CreateNetworkMap_JobError, dlg.getObjectName());
}
}.start();
}
use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class WorldMap method placeObject.
/**
* Place object on map at mouse position
*/
private void placeObject() {
final ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(true));
if (dlg.open() == Window.OK) {
final NXCObjectModificationData md = new NXCObjectModificationData(dlg.getSelectedObjects().get(0).getObjectId());
md.setGeolocation(map.getLocationAtPoint(map.getCurrentPoint()));
final NXCSession session = ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().WorldMap_JobTitle, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
}
@Override
protected String getErrorMessage() {
return Messages.get().WorldMap_JobError;
}
}.start();
}
}
use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class Agent method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected boolean applyChanges(final boolean isApply) {
final NXCObjectModificationData md = new NXCObjectModificationData(node.getObjectId());
if (isApply)
setValid(false);
try {
md.setAgentPort(Integer.parseInt(agentPort.getText(), 10));
} catch (NumberFormatException e) {
MessageDialog.openWarning(getShell(), Messages.get().Communication_Warning, Messages.get().Communication_WarningInvalidAgentPort);
if (isApply)
setValid(true);
return false;
}
md.setAgentProxy(agentProxy.getObjectId());
md.setAgentAuthMethod(agentAuthMethod.getSelectionIndex());
md.setAgentSecret(agentSharedSecret.getText());
md.setAgentCompressionMode(collectAgentCompressionMode());
md.setObjectFlags(agentForceEncryption.getSelection() ? AbstractNode.NF_FORCE_ENCRYPTION : 0, AbstractNode.NF_FORCE_ENCRYPTION);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(String.format("Updating agent communication settings for node %s", node.getObjectName()), null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
}
@Override
protected String getErrorMessage() {
return String.format("Cannot update communication settings for node %s", node.getObjectName());
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
Agent.this.setValid(true);
}
});
}
}
}.start();
return true;
}
use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class ClusterNetworks method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected void applyChanges(final boolean isApply) {
if (!isModified)
// Nothing to apply
return;
if (isApply)
setValid(false);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
md.setNetworkList(networks);
new ConsoleJob(Messages.get().ClusterNetworks_JobName, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
isModified = false;
}
@Override
protected String getErrorMessage() {
return Messages.get().ClusterNetworks_JobError;
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
ClusterNetworks.this.setValid(true);
}
});
}
}
}.start();
}
use of org.netxms.client.NXCObjectModificationData in project netxms by netxms.
the class Location method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected boolean applyChanges(final boolean isApply) {
int type = GeoLocation.UNSET;
if (radioTypeManual.getSelection())
type = GeoLocation.MANUAL;
else if (radioTypeAuto.getSelection())
type = GeoLocation.GPS;
GeoLocation location;
if (type == GeoLocation.MANUAL) {
try {
location = GeoLocation.parseGeoLocation(latitude.getText(), longitude.getText());
} catch (GeoLocationFormatException e) {
MessageDialogHelper.openError(getShell(), Messages.get().Location_Error, Messages.get().Location_FormatError);
return false;
}
} else {
location = new GeoLocation(type == GeoLocation.GPS);
}
final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
md.setGeolocation(location);
md.setPostalAddress(new PostalAddress(country.getText().trim(), city.getText().trim(), streetAddress.getText().trim(), postcode.getText().trim()));
if (isApply)
setValid(false);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(String.format(Messages.get().Location_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().Location_JobError;
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
Location.this.setValid(true);
}
});
}
}
}.start();
return true;
}
Aggregations