use of org.netxms.base.GeoLocation in project netxms by netxms.
the class Location method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite dialogArea = new Composite(parent, SWT.NONE);
object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
GeoLocation gl = object.getGeolocation();
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.numColumns = 2;
dialogArea.setLayout(layout);
Group typeGroup = new Group(dialogArea, SWT.NONE);
typeGroup.setText(Messages.get().Location_LocationType);
GridData gd = new GridData();
gd.verticalSpan = 2;
typeGroup.setLayoutData(gd);
layout = new GridLayout();
typeGroup.setLayout(layout);
radioTypeUndefined = new Button(typeGroup, SWT.RADIO);
radioTypeUndefined.setText(Messages.get().Location_Undefined);
radioTypeUndefined.setSelection(gl.getType() == GeoLocation.UNSET);
radioTypeManual = new Button(typeGroup, SWT.RADIO);
radioTypeManual.setText(Messages.get().Location_Manual);
radioTypeManual.setSelection(gl.getType() == GeoLocation.MANUAL);
radioTypeAuto = new Button(typeGroup, SWT.RADIO);
radioTypeAuto.setText(Messages.get().Location_Automatic);
radioTypeAuto.setSelection(gl.getType() == GeoLocation.GPS);
latitude = new LabeledText(dialogArea, SWT.NONE);
latitude.setLabel(Messages.get().Location_Latitude);
if (gl.getType() != GeoLocation.UNSET)
latitude.setText(gl.getLatitudeAsString());
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
latitude.setLayoutData(gd);
latitude.setEnabled(gl.getType() == GeoLocation.MANUAL);
longitude = new LabeledText(dialogArea, SWT.NONE);
longitude.setLabel(Messages.get().Location_Longitude);
if (gl.getType() != GeoLocation.UNSET)
longitude.setText(gl.getLongitudeAsString());
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
longitude.setLayoutData(gd);
longitude.setEnabled(gl.getType() == GeoLocation.MANUAL);
final SelectionListener listener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
latitude.setEnabled(radioTypeManual.getSelection());
longitude.setEnabled(radioTypeManual.getSelection());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
};
radioTypeUndefined.addSelectionListener(listener);
radioTypeManual.addSelectionListener(listener);
radioTypeAuto.addSelectionListener(listener);
country = new LabeledText(dialogArea, SWT.NONE);
country.setLabel(Messages.get().Location_Country);
country.setText(object.getPostalAddress().country);
country.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
city = new LabeledText(dialogArea, SWT.NONE);
city.setLabel(Messages.get().Location_City);
city.setText(object.getPostalAddress().city);
city.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
streetAddress = new LabeledText(dialogArea, SWT.NONE);
streetAddress.setLabel(Messages.get().Location_StreetAddress);
streetAddress.setText(object.getPostalAddress().streetAddress);
streetAddress.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
postcode = new LabeledText(dialogArea, SWT.NONE);
postcode.setLabel(Messages.get().Location_Postcode);
postcode.setText(object.getPostalAddress().postcode);
postcode.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
return dialogArea;
}
Aggregations