Search in sources :

Example 1 with GPClientCommand

use of org.geosdi.geoplatform.gui.command.api.GPClientCommand in project geo-platform by geosdi.

the class GPTreeMenuLoader method loadMenu.

@Override
public void loadMenu() {
    this.tree.addListener(Events.Render, new Listener() {

        @Override
        public void handleEvent(BaseEvent be) {
            ClientCommandDispatcher.getInstance().execute(new GPClientCommand<GetCompositeMenuResponse>() {

                private static final long serialVersionUID = 2887781730841655720L;

                {
                    super.setCommandRequest(new GetCompositeMenuRequest());
                }

                @Override
                public void onCommandSuccess(GetCompositeMenuResponse response) {
                    storeRepository.setMenuCompositeStore(response.getResult());
                    bus.fireEvent(new GPTreeMenuActivatorEvent());
                }

                @Override
                public void onCommandFailure(Throwable exception) {
                    /**
                     * For now a sout to print the exception. We
                     * don't notify to user the error, the
                     * Application must use the base TreeMenu
                     * prepared with Menu Item for GeoPlatform Info.
                     */
                    logger.log(Level.WARNING, "TreeLayer Dynamic Menu Loading Error : " + exception);
                }
            });
        }
    });
}
Also used : Listener(com.extjs.gxt.ui.client.event.Listener) BaseEvent(com.extjs.gxt.ui.client.event.BaseEvent) GetCompositeMenuRequest(org.geosdi.geoplatform.gui.client.command.GetCompositeMenuRequest) GetCompositeMenuResponse(org.geosdi.geoplatform.gui.client.command.GetCompositeMenuResponse) GPTreeMenuActivatorEvent(org.geosdi.geoplatform.gui.client.widget.tree.menu.activator.puregwt.event.GPTreeMenuActivatorEvent) GPClientCommand(org.geosdi.geoplatform.gui.command.api.GPClientCommand)

Example 2 with GPClientCommand

use of org.geosdi.geoplatform.gui.command.api.GPClientCommand in project geo-platform by geosdi.

the class SelectFeatureButtonProvider method get.

@Override
public Button get() {
    return new Button("Get 100 Features", new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            bus.fireEvent(FeatureSelectionWidgetHandler.DISABLE_QUERY_BUTTON_EVENT);
            getAllFeatureRequest.setServerUrl(layerSchemaBinder.getLayerSchemaDTO().getScope());
            getAllFeatureRequest.setTypeName(layerSchemaBinder.getLayerSchemaDTO().getTypeName());
            getAllFeatureRequest.setMaxFeatures(100);
            ClientCommandDispatcher.getInstance().execute(new GPClientCommand<GetAllFeatureResponse>() {

                private static final long serialVersionUID = 9028489214099941178L;

                {
                    super.setCommandRequest(getAllFeatureRequest);
                }

                @Override
                public void onCommandSuccess(GetAllFeatureResponse response) {
                    if (!response.getResult().isFeaturesLoaded()) {
                        String errorMessage = "Error on WFS GetFeature request";
                        GeoPlatformMessage.errorMessage("GetFeture Service Error", errorMessage + " - " + response.getResult().getErrorMessage());
                        LayoutManager.getInstance().getStatusMap().setStatus(errorMessage + " for " + layerSchemaBinder.getLayerSchemaDTO().getTypeName() + " layer.", SearchStatus.EnumSearchStatus.STATUS_SEARCH_ERROR.toString());
                    } else {
                        List<FeatureDetail> instances = Lists.<FeatureDetail>newArrayListWithCapacity(response.getResult().getFeatures().size());
                        for (FeatureDTO feature : GPSharedUtils.safeList(response.getResult().getFeatures())) {
                            Map<String, String> attributes = feature.getAttributes().getAttributesMap();
                            FeatureDetail featureDetail = new FeatureDetail(attributes, feature);
                            instances.add(featureDetail);
                        }
                        FeatureInstancesEvent e = new FeatureInstancesEvent();
                        e.setInstances(instances);
                        bus.fireEvent(e);
                    }
                    bus.fireEvent(FeatureSelectionWidgetHandler.ENABLE_QUERY_BUTTON_EVENT);
                }

                @Override
                public void onCommandFailure(Throwable exception) {
                    String errorMessage = "Error on WFS GetFeature request";
                    GeoPlatformMessage.errorMessage("GetFeture Service Error", errorMessage + " - " + exception.getMessage());
                    LayoutManager.getInstance().getStatusMap().setStatus(errorMessage + " for " + layerSchemaBinder.getLayerSchemaDTO().getTypeName() + " layer.", SearchStatus.EnumSearchStatus.STATUS_SEARCH_ERROR.toString());
                }
            });
        }
    });
}
Also used : GetAllFeatureResponse(org.geosdi.geoplatform.gui.client.command.wfst.basic.GetAllFeatureResponse) GPClientCommand(org.geosdi.geoplatform.gui.command.api.GPClientCommand) FeatureInstancesEvent(org.geosdi.geoplatform.gui.client.puregwt.wfs.event.FeatureInstancesEvent) FeatureDetail(org.geosdi.geoplatform.gui.client.model.wfs.FeatureDetail) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) FeatureDTO(org.geosdi.geoplatform.connector.wfs.response.FeatureDTO)

Example 3 with GPClientCommand

use of org.geosdi.geoplatform.gui.command.api.GPClientCommand in project geo-platform by geosdi.

the class GPProjectSearchPanel method createStore.

@Override
public void createStore() {
    super.toolBar = new GPPagingToolBar(super.getPageSize());
    super.proxy = new RpcProxy<PagingLoadResult<GPClientProject>>() {

        @Override
        protected void load(final Object loadConfig, final AsyncCallback<PagingLoadResult<GPClientProject>> callback) {
            final SearchProjectsRequest searchProjectsRequest = GWT.<SearchProjectsRequest>create(SearchProjectsRequest.class);
            searchProjectsRequest.setConfig((PagingLoadConfig) loadConfig);
            searchProjectsRequest.setSearchText(searchText);
            searchProjectsRequest.setImageURL(create(ICONS.gpProject()).getHTML());
            ClientCommandDispatcher.getInstance().execute(new GPClientCommand<SearchProjectsResponse>() {

                private static final long serialVersionUID = 3109256773218160485L;

                {
                    super.setCommandRequest(searchProjectsRequest);
                }

                @Override
                public void onCommandSuccess(SearchProjectsResponse response) {
                    callback.onSuccess(response.getResult());
                    toolBar.enable();
                }

                @Override
                public void onCommandFailure(Throwable caught) {
                    clearWidgetElements();
                    try {
                        throw caught;
                    } catch (GeoPlatformException e) {
                        if (caught.getCause() instanceof GPSessionTimeout) {
                            GPHandlerManager.fireEvent(new GPLoginEvent(null));
                        } else {
                            setSearchStatus(STATUS_NO_SEARCH, INSTANCE.STATUS_MESSAGE_NOT_SEARCH());
                        }
                    } catch (Throwable e) {
                        LayoutManager.getInstance().getStatusMap().setStatus(LayerModuleConstants.INSTANCE.GPProjectManagementWidget_headingText(), STATUS_NO_SEARCH.toString());
                    }
                }
            });
        }
    };
    super.loader = new BasePagingLoader<PagingLoadResult<ModelData>>(proxy);
    super.loader.setRemoteSort(false);
    super.store = new ListStore<GPClientProject>(loader);
    super.store.setMonitorChanges(true);
    super.toolBar.bind(loader);
}
Also used : GPClientProject(org.geosdi.geoplatform.gui.client.model.projects.GPClientProject) SearchProjectsRequest(org.geosdi.geoplatform.gui.client.command.layer.basic.SearchProjectsRequest) SearchProjectsResponse(org.geosdi.geoplatform.gui.client.command.layer.basic.SearchProjectsResponse) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GPClientCommand(org.geosdi.geoplatform.gui.command.api.GPClientCommand) GPLoginEvent(org.geosdi.geoplatform.gui.impl.map.event.GPLoginEvent) GPPagingToolBar(org.geosdi.geoplatform.gui.client.widget.grid.pagination.GPPagingToolBar) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Example 4 with GPClientCommand

use of org.geosdi.geoplatform.gui.command.api.GPClientCommand in project geo-platform by geosdi.

the class GPPublisherWidget method getFinalizePublishButton.

@Override
public Button getFinalizePublishButton() {
    if (super.finishButton == null) {
        super.finishButton = new Button(ButtonsConstants.INSTANCE.addOnTreeText(), AbstractImagePrototype.create(BasicWidgetResources.ICONS.done()));
        super.finishButton.addSelectionListener(new SelectionListener<ButtonEvent>() {

            @Override
            public void componentSelected(ButtonEvent ce) {
                if (tree.getSelectionModel().getSelectedItem() instanceof AbstractFolderTreeNode) {
                    // expander.checkNodeState();
                    List<String> layersName = Lists.<String>newArrayList();
                    for (PreviewLayer layer : layerList) {
                        layersName.add(layer.getTitle());
                    }
                    publishLayerRequest.setLayerList(layersName);
                    String workspaceName = getSelectedWorkspace();
                    if (GPSharedUtils.isEmpty(workspaceName)) {
                        IGPAccountDetail accountDetail = Registry.get(UserSessionEnum.ACCOUNT_DETAIL_IN_SESSION.name());
                        workspaceName = accountDetail.getUsername();
                    }
                    logger.info("**** Selected workspace: " + workspaceName);
                    publishLayerRequest.setWorkspace(workspaceName);
                    ClientCommandDispatcher.getInstance().execute(new GPClientCommand<PublishLayerPreviewResponse>() {

                        private static final long serialVersionUID = -7646291858544319457L;

                        {
                            super.setCommandRequest(publishLayerRequest);
                        }

                        @Override
                        public void onCommandSuccess(final PublishLayerPreviewResponse response) {
                            PublisherProgressBar.getInstance().show(PublisherWidgetConstants.INSTANCE.EPSGTablePanel_processingDataProgressBarText());
                            Timer t = new Timer() {

                                public void run() {
                                    LayerHandlerManager.fireEvent(new AddRasterFromPublisherEvent(layerList));
                                    reset();
                                    logger.info("Response: " + response);
                                    LayoutManager.getInstance().getStatusMap().setStatus(PublisherWidgetConstants.INSTANCE.GPPublisherWidget_statusShapePublishedSuccesfullyText(), EnumSearchStatus.STATUS_SEARCH.toString());
                                    PublisherProgressBar.getInstance().hide();
                                }
                            };
                            // Schedule the timer to run once in 5 seconds.
                            t.schedule(5000);
                        }

                        @Override
                        public void onCommandFailure(Throwable exception) {
                            if (exception.getCause() instanceof GPSessionTimeout) {
                                GPHandlerManager.fireEvent(new GPLoginEvent(publishShapePreviewEvent));
                            } else if (exception.getCause() instanceof GPReloadURLException) {
                                GeoPlatformMessage.errorMessage(PublisherWidgetConstants.INSTANCE.GPPublisherWidget_errorReloadClusterTitleText(), PublisherWidgetMessages.INSTANCE.GPPublisherWidget_errorReloadClusterBodyMessage(exception.getCause().getMessage()));
                                LayoutManager.getInstance().getStatusMap().setStatus(PublisherWidgetConstants.INSTANCE.statusErrorShapePublishingText(), EnumSearchStatus.STATUS_NO_SEARCH.toString());
                                System.out.println("Error Publishing previewed shape: " + exception.toString() + " data: " + exception.getMessage());
                            } else {
                                GeoPlatformMessage.errorMessage(PublisherWidgetConstants.INSTANCE.errorPublishingText(), WindowsConstants.INSTANCE.errorMakingConnectionBodyText());
                                LayoutManager.getInstance().getStatusMap().setStatus(PublisherWidgetConstants.INSTANCE.statusErrorShapePublishingText(), EnumSearchStatus.STATUS_NO_SEARCH.toString());
                                System.out.println("Error Publishing previewed shape: " + exception.toString() + " data: " + exception.getMessage());
                            }
                        }
                    });
                } else {
                    GeoPlatformMessage.alertMessage(PublisherWidgetConstants.INSTANCE.GPPublisherWidget_shapePreviewTitleText(), WindowsConstants.INSTANCE.warningLayerInToFolderText());
                }
            }
        });
        super.finishButton.disable();
    }
    return super.finishButton;
}
Also used : IGPAccountDetail(org.geosdi.geoplatform.gui.global.security.IGPAccountDetail) AbstractFolderTreeNode(org.geosdi.geoplatform.gui.model.tree.AbstractFolderTreeNode) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GPClientCommand(org.geosdi.geoplatform.gui.command.api.GPClientCommand) GPLoginEvent(org.geosdi.geoplatform.gui.impl.map.event.GPLoginEvent) PublishLayerPreviewResponse(org.geosdi.geoplatform.gui.client.command.publish.basic.PublishLayerPreviewResponse) GPReloadURLException(org.geosdi.geoplatform.gui.utility.GPReloadURLException) Timer(com.google.gwt.user.client.Timer) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) PreviewLayer(org.geosdi.geoplatform.gui.client.model.PreviewLayer) List(java.util.List) AddRasterFromPublisherEvent(org.geosdi.geoplatform.gui.client.widget.tree.store.puregwt.event.AddRasterFromPublisherEvent)

Example 5 with GPClientCommand

use of org.geosdi.geoplatform.gui.command.api.GPClientCommand in project geo-platform by geosdi.

the class GPTreeBeforeExapand method beforeExpand.

@Override
public void beforeExpand() {
    tree.addListener(Events.BeforeExpand, new Listener<TreePanelEvent<ModelData>>() {

        @Override
        public void handleEvent(TreePanelEvent<ModelData> be) {
            if ((be.getItem() instanceof FolderTreeNode) && (!((FolderTreeNode) be.getItem()).isLoaded()) && (((FolderTreeNode) be.getItem()).getId() != null)) {
                final FolderTreeNode parentFolder = (FolderTreeNode) be.getItem();
                parentFolder.setLoading(Boolean.TRUE);
                LayoutManager.getInstance().getStatusMap().setBusy(LayerModuleConstants.INSTANCE.statusLoadingTreeElementsText());
                loadFolderElementsRequest.setFolderID(parentFolder.getId());
                ClientCommandDispatcher.getInstance().execute(new GPClientCommand<LoadFolderElementsResponse>() {

                    private static final long serialVersionUID = 3109256773218160485L;

                    {
                        super.setCommandRequest(loadFolderElementsRequest);
                    }

                    @Override
                    public void onCommandSuccess(LoadFolderElementsResponse response) {
                        treeBuilder.insertElementsOnTree(parentFolder, response.getResult());
                        LayoutManager.getInstance().getStatusMap().setStatus(LayerModuleConstants.INSTANCE.statusSuccessLoadingTreeElementsText(), SearchStatus.EnumSearchStatus.STATUS_SEARCH.toString());
                    }

                    @Override
                    public void onCommandFailure(Throwable caught) {
                        if (caught.getCause() instanceof GPSessionTimeout) {
                            GPHandlerManager.fireEvent(new GPLoginEvent(new GPExpandTreeNodeEvent(parentFolder)));
                        } else {
                            parentFolder.setLoading(Boolean.FALSE);
                            GeoPlatformMessage.errorMessage(LayerModuleConstants.INSTANCE.errorLoadingTitleText(), WindowsConstants.INSTANCE.errorMakingConnectionBodyText());
                            LayoutManager.getInstance().getStatusMap().setStatus(LayerModuleConstants.INSTANCE.statusErrorLoadingTreeElementsText(), SearchStatus.EnumSearchStatus.STATUS_NO_SEARCH.toString());
                            System.out.println("Error loading tree elements: " + caught.toString() + " data: " + caught.getMessage());
                        }
                    }
                });
            }
        }
    });
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData) TreePanelEvent(com.extjs.gxt.ui.client.event.TreePanelEvent) GPExpandTreeNodeEvent(org.geosdi.geoplatform.gui.client.puregwt.timeout.event.GPExpandTreeNodeEvent) FolderTreeNode(org.geosdi.geoplatform.gui.client.model.FolderTreeNode) LoadFolderElementsResponse(org.geosdi.geoplatform.gui.client.command.layer.basic.LoadFolderElementsResponse) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GPClientCommand(org.geosdi.geoplatform.gui.command.api.GPClientCommand) GPLoginEvent(org.geosdi.geoplatform.gui.impl.map.event.GPLoginEvent)

Aggregations

GPClientCommand (org.geosdi.geoplatform.gui.command.api.GPClientCommand)8 ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)5 Button (com.extjs.gxt.ui.client.widget.button.Button)4 GPLoginEvent (org.geosdi.geoplatform.gui.impl.map.event.GPLoginEvent)3 GPSessionTimeout (org.geosdi.geoplatform.gui.utility.GPSessionTimeout)3 List (java.util.List)2 FeatureDTO (org.geosdi.geoplatform.connector.wfs.response.FeatureDTO)2 FeatureDetail (org.geosdi.geoplatform.gui.client.model.wfs.FeatureDetail)2 FeatureInstancesEvent (org.geosdi.geoplatform.gui.client.puregwt.wfs.event.FeatureInstancesEvent)2 ModelData (com.extjs.gxt.ui.client.data.ModelData)1 BaseEvent (com.extjs.gxt.ui.client.event.BaseEvent)1 Listener (com.extjs.gxt.ui.client.event.Listener)1 TreePanelEvent (com.extjs.gxt.ui.client.event.TreePanelEvent)1 ListStore (com.extjs.gxt.ui.client.store.ListStore)1 SimpleComboValue (com.extjs.gxt.ui.client.widget.form.SimpleComboValue)1 Timer (com.google.gwt.user.client.Timer)1 QueryDTO (org.geosdi.geoplatform.connector.wfs.response.QueryDTO)1 QueryRestrictionDTO (org.geosdi.geoplatform.connector.wfs.response.QueryRestrictionDTO)1 GetCompositeMenuRequest (org.geosdi.geoplatform.gui.client.command.GetCompositeMenuRequest)1 GetCompositeMenuResponse (org.geosdi.geoplatform.gui.client.command.GetCompositeMenuResponse)1