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);
}
});
}
});
}
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());
}
});
}
});
}
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);
}
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;
}
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());
}
}
});
}
}
});
}
Aggregations