@Override public void collapse() { tree.addListener( Events.Collapse, new Listener<TreePanelEvent<ModelData>>() { @Override public void handleEvent(TreePanelEvent<ModelData> be) { if (be.getItem() instanceof FolderTreeNode) { IMementoSave mementoSave = MementoModuleInjector.MainInjector.getInstance().getMementoSave(); AbstractMementoOriginalProperties memento = mementoSave.copyOriginalProperties((GPBeanTreeModel) be.getItem()); ((FolderTreeNode) be.getItem()).setExpanded(Boolean.FALSE); mementoSave.putOriginalPropertiesInCache(memento); } } }); }
@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()); } } }); } } }); }