@Override
 public void show() {
   super.show();
   this.loadDataToDisplay();
   GPLayerTreeModel layerElement =
       (GPLayerTreeModel) treePanel.getSelectionModel().getSelectedItem();
   String timeFilter = layerElement.getTimeFilter();
   String variableTimeFilter = layerElement.getVariableTimeFilter();
   if (variableTimeFilter != null) {
     try {
       String[] variableTimeFilterSplitted = timeFilter.split("/");
       int integerTimeFilter = Integer.parseInt(variableTimeFilterSplitted[0]);
       this.startFilterNumberField.setValue(integerTimeFilter);
       this.dimensionRadioGroup.setValue(this.variableDimensionRadio);
       if (variableTimeFilterSplitted.length > 1) {
         integerTimeFilter = Integer.parseInt(variableTimeFilterSplitted[1]);
         this.endFilterNumberField.setValue(integerTimeFilter);
       }
     } catch (NumberFormatException nfe) {
     }
   } else if (timeFilter != null) {
     String[] timeFilterSplitted = timeFilter.split("/");
     this.startDimensionComboBox.setValue(new DimensionData(timeFilterSplitted[0]));
     if (timeFilterSplitted.length > 1) {
       this.endDimensionComboBox.enable();
       this.endDimensionComboBox.setValue(new DimensionData(timeFilterSplitted[1]));
     }
     this.dimensionRadioGroup.setValue(this.fixedDimensionRadio);
   }
 }
 @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());
                          }
                        }
                      });
            }
          }
        });
  }
  private void loadDataToDisplay() {
    final GetLayerDimensionRequest getLayerDimensionRequest =
        GWT.<GetLayerDimensionRequest>create(GetLayerDimensionRequest.class);

    final GPLayerTreeModel layerSelected =
        (GPLayerTreeModel) treePanel.getSelectionModel().getSelectedItem();
    getLayerDimensionRequest.setLayerName(layerSelected.getName());

    ClientCommandDispatcher.getInstance()
        .execute(
            new GPClientCommand<GetLayerDimensionResponse>() {
              private static final long serialVersionUID = 4372276287420606744L;

              {
                super.setCommandRequest(getLayerDimensionRequest);
              }

              @Override
              public void onCommandSuccess(GetLayerDimensionResponse response) {
                List<String> dimensionList =
                    Lists.<String>newArrayList(response.getResult().split(","));
                dimensionSizeLabel.setHtml(
                    LayerModuleMessages.INSTANCE.LayerTimeFilterWidget_dimensionSizeHTMLMessage(
                        dimensionList.size()));
                dimensionSizeLabel.setStyleAttribute("font-size", "1.3em");
                dimensionSizeLabel.setStyleAttribute("text-align", "right");
                startStore.removeAll();
                endStore.removeAll();
                for (String dimension : GPSharedUtils.safeList(dimensionList)) {
                  startStore.add(new DimensionData(dimension));
                }
                if (!dimensionList.isEmpty()) {
                  slider.setMaxValue(dimensionList.size());
                  slider.setMinValue(0);
                  endFilterNumberField.setValue(0);
                  if (layerSelected.getTimeFilter() != null) {
                    String[] timeFilterSplitted = layerSelected.getTimeFilter().split("/");
                    int startDimensionPosition = Integer.parseInt(timeFilterSplitted[0]);
                    slider.setValue(startStore.getModels().size() - startDimensionPosition - 1);
                    startFilterNumberField.setValue(startDimensionPosition);
                    if (timeFilterSplitted.length > 1) {
                      int endDimensionPosition = Integer.parseInt(timeFilterSplitted[1]);
                      endFilterNumberField.setValue(endDimensionPosition);
                    }
                  } else {
                    startFilterNumberField.setValue(dimensionList.size() - 1);
                  }
                }
              }

              @Override
              public void onCommandFailure(Throwable exception) {
                if (exception.getCause() instanceof GPSessionTimeout) {
                  GPHandlerManager.fireEvent(new GPLoginEvent(null));
                } else {
                  GeoPlatformMessage.errorMessage(
                      LayerModuleConstants.INSTANCE
                          .LayerTimeFilterWidget_timeFilterErrorTitleText(),
                      WindowsConstants.INSTANCE.errorMakingConnectionBodyText());
                  LayoutManager.getInstance()
                      .getStatusMap()
                      .setStatus(
                          LayerModuleConstants.INSTANCE
                              .LayerTimeFilterWidget_statusTimeFilterErrorLoadingText(),
                          SearchStatus.EnumSearchStatus.STATUS_NO_SEARCH.toString());
                  System.out.println(
                      "Error Loading Time Filter: "
                          + exception.toString()
                          + " data: "
                          + exception.getMessage());
                }
              }
            });
  }