Search in sources :

Example 1 with GPClientViewport

use of org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport in project geo-platform by geosdi.

the class MapLayoutWidget method setMapCenter.

/**
 * Set center of the Map on Italy
 */
public void setMapCenter() {
    IGPAccountDetail accountDetail = Registry.get(UserSessionEnum.ACCOUNT_DETAIL_IN_SESSION.name());
    GPClientViewport viewport = accountDetail.getViewport();
    if (viewport != null) {
        ViewportUtility.gotoViewportLocation(map, viewport);
    } else {
        LonLat center = new LonLat(13.375, 42.329);
        if (map.getProjection().equals(GPCoordinateReferenceSystem.GOOGLE_MERCATOR.getCode())) {
            center.transform(WGS_84.getCode(), GPCoordinateReferenceSystem.EPSG_GOOGLE.getCode());
        }
        float zoomLevel = 5;
        this.map.setCenter(center, (int) zoomLevel);
    }
    this.mapControl.clearNavigationHistory();
}
Also used : IGPAccountDetail(org.geosdi.geoplatform.gui.global.security.IGPAccountDetail) GPClientViewport(org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport)

Example 2 with GPClientViewport

use of org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport in project geo-platform by geosdi.

the class SaveViewportAction method isStoreModelCorrect.

private boolean isStoreModelCorrect() {
    boolean check = true;
    BBoxClientInfo bbox;
    for (GPClientViewport viewport : store.getModels()) {
        bbox = viewport.getBbox();
        System.out.println("BBOXXX: " + bbox.getLowerLeftX());
        if (bbox == null || bbox.getLowerLeftX() == 0.0d || bbox.getLowerLeftY() == 0.0d || bbox.getUpperRightX() == 0.0d || bbox.getUpperRightY() == 0.0d || viewport.getName() == null || viewport.getName().isEmpty() || viewport.getZoomLevel() < 0) {
            check = false;
            break;
        }
    }
    return check;
}
Also used : BBoxClientInfo(org.geosdi.geoplatform.gui.configuration.map.client.geometry.BBoxClientInfo) GPClientViewport(org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport)

Example 3 with GPClientViewport

use of org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport in project geo-platform by geosdi.

the class ViewportGridFieldSet method addComponents.

@Override
public void addComponents() {
    store.addStoreListener(new StoreListener<GPClientViewport>() {

        @Override
        public void storeUpdate(StoreEvent<GPClientViewport> se) {
            super.storeUpdate(se);
            ViewportGridFieldSet.this.saveButton.enable();
        }
    });
    this.add(createViewportFilter());
    this.add(this.generateGrid(), new FormData("100%"));
    ButtonBar buttonBar = new ButtonBar();
    Button addEntryButton = new Button(MapModuleConstants.INSTANCE.ViewportGridFieldSet_buttonAddViewportText(), AbstractImagePrototype.create(BasicWidgetResources.ICONS.done()), new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            ViewportGridFieldSet.this.store.add(ViewportUtility.generateViewportFromMap(map));
            viewportGrid.startEditing(store.getCount() - 1, 1);
            ViewportGridFieldSet.this.saveButton.enable();
        }
    });
    buttonBar.add(addEntryButton);
    this.deleteViewportButton = new Button(MapModuleConstants.INSTANCE.ViewportGridFieldSet_buttonDeleteViewportText(), AbstractImagePrototype.create(BasicWidgetResources.ICONS.delete()), new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            final List<GPClientViewport> viewportList = viewportGrid.getSelectionModel().getSelectedItems();
            if (viewportList != null) {
                GeoPlatformMessage.confirmMessage(MapModuleConstants.INSTANCE.ViewportGridFieldSet_confirmDeleteViewportTitleText(), MapModuleConstants.INSTANCE.ViewportGridFieldSet_confirmDeleteViewportBodyText(), new Listener<MessageBoxEvent>() {

                    @Override
                    public void handleEvent(MessageBoxEvent be) {
                        if (Dialog.YES.equals(be.getButtonClicked().getItemId())) {
                            for (GPClientViewport viewport : viewportList) {
                                store.remove(viewport);
                                ViewportGridFieldSet.this.saveButton.enable();
                            }
                        }
                    }
                });
            }
        }
    });
    deleteViewportButton.setEnabled(Boolean.FALSE);
    buttonBar.add(deleteViewportButton);
    this.gotoViewportButton = new Button(MapModuleConstants.INSTANCE.ViewportGridFieldSet_buttonGoToViewportText(), AbstractImagePrototype.create(BasicWidgetResources.ICONS.gotoXY()), new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            final List<GPClientViewport> viewportList = viewportGrid.getSelectionModel().getSelectedItems();
            if (viewportList != null && viewportList.size() == 1) {
                ViewportUtility.gotoViewportLocation(map, viewportList.get(0));
            } else {
                GeoPlatformMessage.alertMessage(MapModuleConstants.INSTANCE.ViewportGridFieldSet_singleSelectionAlertTitleText(), MapModuleConstants.INSTANCE.ViewportGridFieldSet_singleSelectionAlertBodyText());
            }
        }
    });
    gotoViewportButton.setEnabled(Boolean.FALSE);
    buttonBar.add(gotoViewportButton);
    this.setDefaultViewportButton = new Button(ButtonsConstants.INSTANCE.setDefautlText(), AbstractImagePrototype.create(BasicWidgetResources.ICONS.select()), new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            final List<GPClientViewport> viewportList = viewportGrid.getSelectionModel().getSelectedItems();
            if (viewportList != null && viewportList.size() == 1) {
                GPClientViewport selectedViewport = viewportList.get(0);
                for (GPClientViewport viewport : ViewportGridFieldSet.this.store.getModels()) {
                    if (viewport.isDefault()) {
                        viewport.set(ViewportEnum.IS_DEFAULT.toString(), Boolean.FALSE);
                        store.update(viewport);
                    } else if (selectedViewport.equals(viewport)) {
                        viewport.set(ViewportEnum.IS_DEFAULT.toString(), Boolean.TRUE);
                        store.update(viewport);
                    }
                }
            } else {
                GeoPlatformMessage.alertMessage(MapModuleConstants.INSTANCE.ViewportGridFieldSet_setDefaultViewportAlertTitleText(), MapModuleConstants.INSTANCE.ViewportGridFieldSet_singleSelectionAlertBodyText());
            }
        }
    });
    setDefaultViewportButton.setEnabled(Boolean.FALSE);
    buttonBar.add(setDefaultViewportButton);
    SaveViewportAction saveViewportAction = new SaveViewportAction(GPTrustedLevel.LOW, this.store);
    this.saveButton = new GPSecureButton(ButtonsConstants.INSTANCE.saveText(), AbstractImagePrototype.create(BasicWidgetResources.ICONS.save()), saveViewportAction);
    buttonBar.add(this.saveButton);
    this.add(buttonBar, new FormData("100%"));
}
Also used : FormData(com.extjs.gxt.ui.client.widget.layout.FormData) ButtonBar(com.extjs.gxt.ui.client.widget.button.ButtonBar) GPSecureButton(org.geosdi.geoplatform.gui.action.button.GPSecureButton) SaveViewportAction(org.geosdi.geoplatform.gui.client.action.viewport.SaveViewportAction) GPClientViewport(org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport) GPSecureButton(org.geosdi.geoplatform.gui.action.button.GPSecureButton) Button(com.extjs.gxt.ui.client.widget.button.Button)

Example 4 with GPClientViewport

use of org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport in project geo-platform by geosdi.

the class ViewportWidget method onCreateViewport.

@Override
public void onCreateViewport(List<GPLayerBean> layerList, String viewportName) {
    Bounds bounds = ViewportUtility.calculateMaxBound(layerList, map);
    Projection currentProjection = new Projection(GPCoordinateReferenceSystem.WGS_84.getCode());
    Projection destinationProjection = new Projection(map.getProjection());
    bounds.transform(currentProjection, destinationProjection);
    double zoom = map.getZoomForExtent(bounds, Boolean.FALSE);
    bounds.transform(destinationProjection, currentProjection);
    BBoxClientInfo bbox = ViewportUtility.generateBBOXFromBounds(bounds);
    this.viewportToAdd = new GPClientViewport(viewportName, MapModuleConstants.INSTANCE.ViewportUtility_newViewportDescriptionText(), bbox, zoom, Boolean.FALSE);
    this.show();
}
Also used : BBoxClientInfo(org.geosdi.geoplatform.gui.configuration.map.client.geometry.BBoxClientInfo) GPClientViewport(org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport) Bounds(org.gwtopenmaps.openlayers.client.Bounds) Projection(org.gwtopenmaps.openlayers.client.Projection)

Example 5 with GPClientViewport

use of org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport in project geo-platform by geosdi.

the class MapService method convertServerViewportToDTO.

private List<GPClientViewport> convertServerViewportToDTO(Collection<GPViewport> viewportCollection) {
    List<GPClientViewport> clientViewportList = Lists.<GPClientViewport>newArrayList();
    GPClientViewport clientViewport;
    GPBBox serverBBOX;
    BBoxClientInfo clientBBOX;
    if (viewportCollection != null) {
        for (GPViewport viewport : viewportCollection) {
            serverBBOX = viewport.getBbox();
            clientBBOX = new BBoxClientInfo(serverBBOX.getMinX(), serverBBOX.getMinY(), serverBBOX.getMaxX(), serverBBOX.getMaxY());
            clientViewport = new GPClientViewport(viewport.getName(), viewport.getDescription(), clientBBOX, viewport.getZoomLevel(), viewport.isIsDefault());
            clientViewportList.add(clientViewport);
        }
    }
    return clientViewportList;
}
Also used : BBoxClientInfo(org.geosdi.geoplatform.gui.configuration.map.client.geometry.BBoxClientInfo) GPViewport(org.geosdi.geoplatform.core.model.GPViewport) GPClientViewport(org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport) GPBBox(org.geosdi.geoplatform.core.model.GPBBox)

Aggregations

GPClientViewport (org.geosdi.geoplatform.gui.configuration.map.client.GPClientViewport)9 BBoxClientInfo (org.geosdi.geoplatform.gui.configuration.map.client.geometry.BBoxClientInfo)6 GPBBox (org.geosdi.geoplatform.core.model.GPBBox)3 GPViewport (org.geosdi.geoplatform.core.model.GPViewport)2 IGPAccountDetail (org.geosdi.geoplatform.gui.global.security.IGPAccountDetail)2 Bounds (org.gwtopenmaps.openlayers.client.Bounds)2 Projection (org.gwtopenmaps.openlayers.client.Projection)2 Button (com.extjs.gxt.ui.client.widget.button.Button)1 ButtonBar (com.extjs.gxt.ui.client.widget.button.ButtonBar)1 NumberField (com.extjs.gxt.ui.client.widget.form.NumberField)1 FormData (com.extjs.gxt.ui.client.widget.layout.FormData)1 GPMessage (org.geosdi.geoplatform.core.model.GPMessage)1 GPUser (org.geosdi.geoplatform.core.model.GPUser)1 GPSecureButton (org.geosdi.geoplatform.gui.action.button.GPSecureButton)1 SaveViewportAction (org.geosdi.geoplatform.gui.client.action.viewport.SaveViewportAction)1 GPLoginUserDetail (org.geosdi.geoplatform.gui.client.model.security.GPLoginUserDetail)1 GPSecureStringTextField (org.geosdi.geoplatform.gui.configuration.GPSecureStringTextField)1 GPClientMessage (org.geosdi.geoplatform.gui.impl.message.GPClientMessage)1 UserTreeOptions (org.geosdi.geoplatform.gui.impl.users.options.UserTreeOptions)1 IGPClientMessage (org.geosdi.geoplatform.gui.model.message.IGPClientMessage)1