Search in sources :

Example 26 with GeoLocation

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;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GeoLocation(org.netxms.base.GeoLocation) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

GeoLocation (org.netxms.base.GeoLocation)26 Point (org.eclipse.swt.graphics.Point)7 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 GeoLocationFormatException (org.netxms.base.GeoLocationFormatException)4 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)4 NXCSession (org.netxms.client.NXCSession)3 Area (org.netxms.ui.eclipse.osm.tools.Area)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 SelectionListener (org.eclipse.swt.events.SelectionListener)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Button (org.eclipse.swt.widgets.Button)2 Composite (org.eclipse.swt.widgets.Composite)2 Group (org.eclipse.swt.widgets.Group)2 NXCPMessage (org.netxms.base.NXCPMessage)2 NXCObjectModificationData (org.netxms.client.NXCObjectModificationData)2 AbstractObject (org.netxms.client.objects.AbstractObject)2 AccessPoint (org.netxms.client.objects.AccessPoint)2 Node (org.netxms.client.objects.Node)2