use of org.netxms.base.GeoLocationFormatException in project netxms by netxms.
the class MapBackground 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(object.getObjectId());
if (radioTypeNone.getSelection()) {
md.setMapBackground(NXCommon.EMPTY_GUID, new GeoLocation(false), 0, ColorConverter.rgbToInt(backgroundColor.getColorValue()));
} else if (radioTypeImage.getSelection()) {
md.setMapBackground(image.getImageGuid(), new GeoLocation(false), 0, ColorConverter.rgbToInt(backgroundColor.getColorValue()));
} else if (!disableGeolocationBackground && radioTypeGeoMap.getSelection()) {
GeoLocation location;
try {
location = GeoLocation.parseGeoLocation(latitude.getText(), longitude.getText());
} catch (GeoLocationFormatException e) {
MessageDialogHelper.openError(getShell(), Messages.get().MapBackground_Error, Messages.get().MapBackground_GeoLocFormatError);
return false;
}
md.setMapBackground(NetworkMap.GEOMAP_BACKGROUND, location, zoomSpinner.getSelection(), ColorConverter.rgbToInt(backgroundColor.getColorValue()));
}
if (isApply)
setValid(false);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().MapBackground_JobTitle + 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().MapBackground_JobError + object.getObjectName();
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
MapBackground.this.setValid(true);
}
});
}
}
}.start();
return true;
}
use of org.netxms.base.GeoLocationFormatException 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;
}
use of org.netxms.base.GeoLocationFormatException in project netxms by netxms.
the class GeoLocationTest method testParser.
public void testParser() throws Exception {
GeoLocation g = GeoLocation.parseGeoLocation(" 47°20'50.79\"N", " 8°33'56,31\"E");
assertEquals(47.34744, g.getLatitude(), 0.00005);
assertEquals(8.56564, g.getLongitude(), 0.00005);
System.out.println(g);
g = GeoLocation.parseGeoLocation("47.34744", "E8.56564°");
assertEquals(47.34744, g.getLatitude(), 0.00005);
assertEquals(8.56564, g.getLongitude(), 0.00005);
System.out.println(g);
try {
g = GeoLocation.parseGeoLocation("W47.34744°", "E8.56564°");
assertFalse(true);
} catch (GeoLocationFormatException e) {
}
}
use of org.netxms.base.GeoLocationFormatException in project netxms by netxms.
the class GeoMap method performOk.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#performOk()
*/
@Override
public boolean performOk() {
try {
GeoLocation center = GeoLocation.parseGeoLocation(latitude.getText(), longitude.getText());
config.setLatitude(center.getLatitude());
config.setLongitude(center.getLongitude());
} catch (GeoLocationFormatException e) {
MessageDialogHelper.openError(getShell(), Messages.get().GeoMap_Error, Messages.get().GeoMap_ErrorText);
}
config.setTitle(title.getText());
config.setZoom(zoom.getSelection());
config.setRootObjectId(objectSelector.getObjectId());
return true;
}
Aggregations