use of org.netxms.base.PostalAddress 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