private void addButton(Type type, AbstractImagePrototype icon) {
   ToggleButton button = new ToggleButton("", icon);
   button.setToggleGroup(TYPE_DATA);
   button.setData(TYPE_DATA, type);
   button.addSelectionListener(listener);
   buttons.add(button);
 }
 public PivotChartReportElement.Type getSelection() {
   for (ToggleButton button : buttons) {
     if (button.isPressed()) {
       return button.getData(TYPE_DATA);
     }
   }
   return PivotChartReportElement.Type.ClusteredBar;
 }
 private void stopPlayer() {
   if (playButton.isPressed()) {
     playButton.toggle(Boolean.FALSE);
     playSelectioListener.componentSelected(null);
     // This call produce the update in map
     applyFilterSelectionListener.componentSelected(null);
   }
 }
  public void setSelection(PivotChartReportElement.Type type) {
    if (type == null) {
      type = PivotChartReportElement.Type.ClusteredBar;
    }

    for (ToggleButton button : buttons) {
      if (type.equals(button.getData(TYPE_DATA))) {
        button.toggle(true);
      }
    }
  }
  /**
   * (non-Javadoc)
   *
   * @see
   *     com.extjs.gxt.ui.client.event.SelectionListener#componentSelected(com.extjs.gxt.ui.client.event.ComponentEvent)
   */
  @Override
  public void componentSelected(ButtonEvent ce) {
    ToggleButton button = (ToggleButton) ce.getSource();

    super.changeButtonState();

    if (button.isPressed()) {
      editorOberver.setButtonPressed(button);
      this.mapWidget.activateDrawPointFeature();
    } else {
      this.mapWidget.deactivateDrawPointFeature();
    }
  }
Example #6
0
  private Button createButton() {
    String confirm = getField().getAttribute("confirm", "false");
    String icon = getField().getAttribute("icon", "icsc-edit");
    String toggle = getField().getAttribute("toggle", "false");
    String toggleGroup = getField().getAttribute("toggleGroup", "");

    Button btn = null;
    if (Boolean.parseBoolean(toggle)) {
      btn = new ToggleButton(getField().getLabel());
      if (!toggleGroup.equals("")) {
        ((ToggleButton) btn).setToggleGroup(toggleGroup);
      }
    } else {
      if (confirm.toLowerCase().equals("false")) {
        btn = new gkButton(getField().getLabel(), false);
      } else {
        btn = new gkButton(getField().getLabel(), confirm);
      }
      ((gkButton) btn).setValue(getField().getValue());
    }
    // 为btn设定图片,在gul语法中设定icon="xxx",xxx可以是css文件中已定义好的选择器(如:icsc-edit)
    // 也可以是自定义的图片路径,若无设定,则默认使用icon="icsc-edit"
    btn.setIconStyle(icon);

    // 如果 <field type='btn'>..</field>有子節點,是為menu,進行建立menu動作
    if (getField().getWidgets().size() > 0) {
      attachWidget(btn);
    }
    return btn;
  }
  private ContentPanel createStandard() {
    ContentPanel panel = new SamplePanel();
    panel.setHeading("Standard");

    ToolBar toolBar = new ToolBar();

    Button btn = new Button("Cool", IconHelper.createStyle("add16"));
    toolBar.add(btn);
    Menu menu = new Menu();
    menu.add(new MenuItem("Ribbons are cool"));
    btn.setMenu(menu);
    toolBar.add(new SeparatorToolItem());

    btn = new Button("Cut", IconHelper.createStyle("add16"));
    menu = new Menu();
    menu.add(new MenuItem("Copy me"));
    toolBar.add(btn);

    btn = new Button("Copy", IconHelper.createStyle("add16"));
    toolBar.add(btn);

    btn = new Button("Paste", IconHelper.createStyle("add16"));
    toolBar.add(btn);
    menu = new Menu();
    menu.add(new MenuItem("Ribbons are cool"));
    btn.setMenu(menu);
    toolBar.add(new SeparatorToolItem());

    ToggleButton toggleBtn = new ToggleButton("Format");
    toggleBtn.toggle(true);
    toolBar.add(toggleBtn);

    panel.setTopComponent(toolBar);

    return panel;
  }
 /**
  * Creates the button that can convert to ui designer view.
  *
  * @return the toggle button
  */
 private ToggleButton createUDButton() {
   final ToggleButton udButton = new ToggleButton();
   udButton.setToolTip("UI Designer");
   udButton.setIcon(icons.udIcon());
   udButton.addSelectionListener(
       new SelectionListener<ButtonEvent>() {
         public void componentSelected(ButtonEvent ce) {
           if (!udButton.isPressed()) {
             udButton.toggle(true);
           } else {
             modelerContainer.remove(buildingModelerView);
             modelerContainer.add(uiDesignerView);
             Cookies.setCookie(Constants.CURRETN_ROLE, Role.ROLE_DESIGNER);
             modelerContainer.layout();
           }
         }
       });
   udButton.setToggleGroup("modeler-switch");
   if (Role.ROLE_DESIGNER.equals(Cookies.getCookie(Constants.CURRETN_ROLE))) {
     udButton.toggle(true);
   }
   return udButton;
 }
  /**
   * Set up and get a button bar with buttons to expand or collapse the tree.
   *
   * @return
   */
  public ToolBar getButtonsBar() {
    ButtonBar toolbar = new ButtonBar();
    toolbar.setAlignment(HorizontalAlignment.CENTER);

    pieButton = new ToggleButton("Pie Chart");
    pieButton.setToggleGroup("chartType");
    IconSupplier.forceIcon(pieButton, IconSupplier.getPieChartIconName());
    pieButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {
            chartType = PIE_CHART;
            redoChart();
          }
        });

    barButton = new ToggleButton("Bar Graph");
    barButton.setToggleGroup("chartType");
    IconSupplier.forceIcon(barButton, IconSupplier.getBarChartIconName());
    barButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {
            chartType = BAR_CHART;
            redoChart();
          }
        });

    if (chartType == BAR_CHART) barButton.toggle(true);
    else pieButton.toggle(true);

    valueCombo =
        FieldFactory.getModelDataComboField(
            "valueBox",
            "",
            100,
            "Select the value to chart.",
            getValueComboStore(),
            "value",
            "description");
    valueCombo.enable();
    setValueCombo();
    valueCombo.addSelectionChangedListener(
        new SelectionChangedListener<ModelData>() {

          @Override
          public void selectionChanged(SelectionChangedEvent<ModelData> se) {
            if (se.getSelectedItem() != null && se.getSelectedItem().get("value") != null) {
              valueCol = se.getSelectedItem().get("value").toString();
              valueLabel = se.getSelectedItem().get("description").toString();
              redoChart();
            }
          }
        });

    groupCombo =
        FieldFactory.getModelDataComboField(
            "valueBox",
            "",
            100,
            "Select the value to chart.",
            getGroupComboStore(),
            "value",
            "description");
    groupCombo.enable();
    setGroupCombo();
    groupCombo.addSelectionChangedListener(
        new SelectionChangedListener<ModelData>() {

          @Override
          public void selectionChanged(SelectionChangedEvent<ModelData> se) {
            if (se.getSelectedItem() != null && se.getSelectedItem().get("value") != null) {
              groupCol = se.getSelectedItem().get("value").toString();
              groupLabel = se.getSelectedItem().get("description").toString();
              labelCol = groupCol;
              textCol = groupCol;
              redoChart();
            }
          }
        });

    toolbar.add(pieButton);
    toolbar.add(barButton);
    toolbar.add(new SeparatorToolItem());
    toolbar.add(new Html("Chart"));
    toolbar.add(valueCombo);
    toolbar.add(new Html("By"));
    toolbar.add(groupCombo);

    return toolbar;
  }
 public void setChartType(int chartType) {
   this.chartType = chartType;
   if (chartType == PIE_CHART && pieButton != null) pieButton.toggle(true);
   if (chartType == BAR_CHART && barButton != null) barButton.toggle(true);
   if (chart != null) redoChart(); // 	 Only do this now if we already have a chart
 }
  private void createViewsButtons(ToolBar calendarToolbar) {
    final ToggleButton oneDay = new ToggleButton("<b>" + HarvesterUI.CONSTANTS.oneDay() + "</b>");
    final ToggleButton threeDay =
        new ToggleButton("<b>" + HarvesterUI.CONSTANTS.threeDay() + "</b>");
    final ToggleButton week = new ToggleButton("<b>" + HarvesterUI.CONSTANTS.week() + "</b>");
    final ToggleButton month = new ToggleButton("<b>" + HarvesterUI.CONSTANTS.month() + "</b>");
    month.toggle();

    oneDay.addListener(
        Events.OnClick,
        new Listener<ButtonEvent>() {
          public void handleEvent(ButtonEvent ce) {
            threeDay.toggle(false);
            week.toggle(false);
            month.toggle(false);
            oneDay.toggle(true);
            calendar.setView(CalendarViews.DAY, 1);
          }
        });

    threeDay.addListener(
        Events.OnClick,
        new Listener<ButtonEvent>() {
          public void handleEvent(ButtonEvent ce) {
            threeDay.toggle(true);
            week.toggle(false);
            month.toggle(false);
            oneDay.toggle(false);
            calendar.setView(CalendarViews.DAY, 3);
          }
        });

    week.addListener(
        Events.OnClick,
        new Listener<ButtonEvent>() {
          public void handleEvent(ButtonEvent ce) {
            threeDay.toggle(false);
            week.toggle(true);
            month.toggle(false);
            oneDay.toggle(false);
            calendar.setView(CalendarViews.DAY, 7);
          }
        });

    month.addListener(
        Events.OnClick,
        new Listener<ButtonEvent>() {
          public void handleEvent(ButtonEvent ce) {
            threeDay.toggle(false);
            week.toggle(false);
            month.toggle(true);
            oneDay.toggle(false);
            calendar.setView(CalendarViews.MONTH);
          }
        });

    calendarToolbar.add(oneDay);
    calendarToolbar.add(threeDay);
    calendarToolbar.add(week);
    calendarToolbar.add(month);
  }
Example #12
0
  private ContentPanel getGeneralSection() {
    if (generalSectionPanel == null) {

      final ManagementServiceAsync managementService = Registry.get(PIGE.MANAGEMENT_SERVICE);
      generalSectionPanel = new ContentPanel();
      generalSectionPanel.setHeaderVisible(false);
      generalSectionPanel.setLayout(new RowLayout(Orientation.VERTICAL));
      generalSectionPanel.setBorders(false);

      ToolBar buttonBar = new ToolBar();
      generalSectionPanel.setTopComponent(buttonBar);
      Button updateConfigsBtn = new Button(messages.update());
      updateConfigsBtn.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.saveIcon()));
      buttonBar.add(updateConfigsBtn);
      updateConfigsBtn.addSelectionListener(
          new SelectionListener<ButtonEvent>() {

            @Override
            public void componentSelected(ButtonEvent event) {
              ServerConfigs sc = new ServerConfigs();
              sc.setValue(
                  ServerConfigs.ATT_MAINTENANCE_MODE_ACTIVATED,
                  maintenanceModeActivated.toString());
              sc.setValue(ServerConfigs.ATT_MAINTENANCE_MODE_INFO, mmInfoArea.getValue());
              sc.setValue(ServerConfigs.ATT_EMAIL_ENABLED, emailServiceEnabled.toString());
              sc.setValue(ServerConfigs.LOAN_TERM_VERIFICATOR_ENABLED, ltvEnabled.toString());
              sc.setValue(ServerConfigs.MAINTENANCE_RECALL_SERVICE_ENABLED, mrsEnabled.toString());
              managementService.setConfigurations(
                  sc,
                  new AsyncCallback() {

                    @Override
                    public void onSuccess(Object o) {
                      PIGE.setServerOperationModeStatus();
                      StatusBar statusBar = Registry.get(AppWidgets.APP_STATUS_BAR);
                      statusBar.setTimedText(messages.updateSuccessful());
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                      PIGE.handleException(caught);
                    }
                  });
            }
          });

      Html generatTitle = new Html(messages.general());
      generatTitle.addStyleName("pige-management-section-title");
      generalSectionPanel.add(generatTitle, new RowData(1, 25, new Margins(3)));
      LayoutContainer maintenancePanel = new LayoutContainer();
      maintenancePanel.setWidth(1);
      maintenancePanel.setBorders(false);
      maintenancePanel.setLayout(new RowLayout(Orientation.VERTICAL));

      // Maintenance mode
      Html maintenanceTitle = new Html(messages.maintenanceMode());
      maintenanceTitle.addStyleName("pige-management-topic-title");
      maintenancePanel.add(maintenanceTitle, new RowData(1, 20));
      Html maintenanceModeText = new Html(messages.maintenanceModeText());
      maintenancePanel.add(maintenanceModeText, new RowData(1, -1));
      LayoutContainer maintenanceConfigPanel = new LayoutContainer();
      maintenanceConfigPanel.setLayout(new RowLayout(Orientation.HORIZONTAL));
      maintenancePanel.add(maintenanceConfigPanel, new RowData(1, 75));
      mmInfoArea = new TextArea();
      mmActivatedBtn = new ToggleButton(messages.activated());
      mmActivatedBtn.setSize(75, 22);
      mmActivatedBtn.setStyleAttribute("padding", "0px 0px 0px 0px");
      mmActivatedBtn.setToggleGroup("mm-state");
      mmDeactivatedBtn = new ToggleButton(messages.deactivated());
      mmDeactivatedBtn.setSize(75, 22);
      mmDeactivatedBtn.setStyleAttribute("padding", "0px 0px 0px 0px");
      mmDeactivatedBtn.setToggleGroup("mm-state");
      Listener mmButtonListener =
          new Listener<ButtonEvent>() {

            @Override
            public void handleEvent(ButtonEvent event) {
              if (mmActivatedBtn.isPressed()) {
                maintenanceModeActivated = Boolean.TRUE;
              } else {
                maintenanceModeActivated = Boolean.FALSE;
              }
            }
          };
      mmActivatedBtn.addListener(Events.Toggle, mmButtonListener);
      mmDeactivatedBtn.addListener(Events.Toggle, mmButtonListener);
      LayoutContainer buttonPanel = new LayoutContainer();
      buttonPanel.setLayout(new RowLayout(Orientation.VERTICAL));
      buttonPanel.add(mmActivatedBtn);
      buttonPanel.add(mmDeactivatedBtn);
      maintenanceConfigPanel.add(buttonPanel, new RowData(100, 1, new Margins(3)));
      maintenanceConfigPanel.add(mmInfoArea, new RowData(1, 1));
      generalSectionPanel.add(maintenancePanel, new RowData(1, -1, new Margins(5)));

      // Email
      LayoutContainer emailServicePanel = new LayoutContainer();
      emailServicePanel.setWidth(1);
      emailServicePanel.setBorders(false);
      emailServicePanel.setLayout(new RowLayout(Orientation.VERTICAL));
      Html emailServiceTitle = new Html(messages.emailService());
      emailServiceTitle.addStyleName("pige-management-topic-title");
      emailServicePanel.add(emailServiceTitle, new RowData(1, 20));
      Html emailServiceText = new Html(messages.emailServiceText());
      emailServicePanel.add(emailServiceText, new RowData(1, -1));
      LayoutContainer emailServiceConfigPanel = new LayoutContainer();
      emailServiceConfigPanel.setLayout(new RowLayout(Orientation.HORIZONTAL));
      emailServicePanel.add(emailServiceConfigPanel, new RowData(1, 75));
      emailEnabledBtn = new ToggleButton(messages.activated());
      emailEnabledBtn.setSize(75, 22);
      emailEnabledBtn.setStyleAttribute("padding", "0px 0px 0px 0px");
      emailEnabledBtn.setToggleGroup("email-service-state");
      emailDisabledBtn = new ToggleButton(messages.deactivated());
      emailDisabledBtn.setSize(75, 22);
      emailDisabledBtn.setStyleAttribute("padding", "0px 0px 0px 0px");
      emailDisabledBtn.setToggleGroup("email-service-state");
      Listener emailServiceButtonListener =
          new Listener<ButtonEvent>() {

            @Override
            public void handleEvent(ButtonEvent event) {
              if (emailEnabledBtn.isPressed()) {
                emailServiceEnabled = Boolean.TRUE;
              } else {
                emailServiceEnabled = Boolean.FALSE;
              }
            }
          };
      emailEnabledBtn.addListener(Events.Toggle, emailServiceButtonListener);
      emailDisabledBtn.addListener(Events.Toggle, emailServiceButtonListener);
      buttonPanel = new LayoutContainer();
      buttonPanel.setLayout(new RowLayout(Orientation.VERTICAL));
      buttonPanel.add(emailEnabledBtn);
      buttonPanel.add(emailDisabledBtn);
      emailServiceConfigPanel.add(buttonPanel, new RowData(100, 1, new Margins(3)));
      generalSectionPanel.add(emailServicePanel, new RowData(1, -1, new Margins(5)));

      // Vérificateur d'échéance des emprunts
      LayoutContainer ltvServicePanel = new LayoutContainer();
      ltvServicePanel.setWidth(1);
      ltvServicePanel.setBorders(false);
      ltvServicePanel.setLayout(new RowLayout(Orientation.VERTICAL));
      Html ltvTitle = new Html(messages.loanTermVerification());
      ltvTitle.addStyleName("pige-management-topic-title");
      ltvServicePanel.add(ltvTitle, new RowData(1, 20));
      Html ltvText = new Html(messages.loanTermVerificationText());
      ltvServicePanel.add(ltvText, new RowData(1, -1));
      LayoutContainer ltvConfigPanel = new LayoutContainer();
      ltvConfigPanel.setLayout(new RowLayout(Orientation.HORIZONTAL));
      ltvServicePanel.add(ltvConfigPanel, new RowData(1, 75));
      ltvEnabledBtn = new ToggleButton(messages.activated());
      ltvEnabledBtn.setSize(75, 22);
      ltvEnabledBtn.setStyleAttribute("padding", "0px 0px 0px 0px");
      ltvEnabledBtn.setToggleGroup("ltv-state");
      ltvDisabledBtn = new ToggleButton(messages.deactivated());
      ltvDisabledBtn.setSize(75, 22);
      ltvDisabledBtn.setStyleAttribute("padding", "0px 0px 0px 0px");
      ltvDisabledBtn.setToggleGroup("ltv-state");
      Listener ltvButtonListener =
          new Listener<ButtonEvent>() {

            @Override
            public void handleEvent(ButtonEvent event) {
              if (ltvEnabledBtn.isPressed()) {
                ltvEnabled = Boolean.TRUE;
              } else {
                ltvEnabled = Boolean.FALSE;
              }
            }
          };
      ltvEnabledBtn.addListener(Events.Toggle, ltvButtonListener);
      ltvDisabledBtn.addListener(Events.Toggle, ltvButtonListener);
      buttonPanel = new LayoutContainer();
      buttonPanel.setLayout(new RowLayout(Orientation.VERTICAL));
      buttonPanel.add(ltvEnabledBtn);
      buttonPanel.add(ltvDisabledBtn);
      ltvConfigPanel.add(buttonPanel, new RowData(100, 1, new Margins(3)));
      generalSectionPanel.add(ltvServicePanel, new RowData(1, -1, new Margins(5)));

      // Service de rappel des maintenances.
      LayoutContainer mrsServicePanel = new LayoutContainer();
      mrsServicePanel.setWidth(1);
      mrsServicePanel.setBorders(false);
      mrsServicePanel.setLayout(new RowLayout(Orientation.VERTICAL));
      Html mrsTitle = new Html(messages.maintenanceRecalLService());
      mrsTitle.addStyleName("pige-management-topic-title");
      mrsServicePanel.add(mrsTitle, new RowData(1, 20));
      Html mrsText = new Html(messages.maintenanceRecalLServiceTxt());
      mrsServicePanel.add(mrsText, new RowData(1, -1));
      LayoutContainer mrsConfigPanel = new LayoutContainer();
      mrsConfigPanel.setLayout(new RowLayout(Orientation.HORIZONTAL));
      mrsServicePanel.add(mrsConfigPanel, new RowData(1, 75));
      mrsEnabledBtn = new ToggleButton(messages.activated());
      mrsEnabledBtn.setSize(75, 22);
      mrsEnabledBtn.setStyleAttribute("padding", "0px 0px 0px 0px");
      mrsEnabledBtn.setToggleGroup("mrs-state");
      mrsDisabledBtn = new ToggleButton(messages.deactivated());
      mrsDisabledBtn.setSize(75, 22);
      mrsDisabledBtn.setStyleAttribute("padding", "0px 0px 0px 0px");
      mrsDisabledBtn.setToggleGroup("mrs-state");
      Listener mrsButtonListener =
          new Listener<ButtonEvent>() {

            @Override
            public void handleEvent(ButtonEvent event) {
              if (mrsEnabledBtn.isPressed()) {
                mrsEnabled = Boolean.TRUE;
              } else {
                mrsEnabled = Boolean.FALSE;
              }
            }
          };
      mrsEnabledBtn.addListener(Events.Toggle, mrsButtonListener);
      mrsDisabledBtn.addListener(Events.Toggle, mrsButtonListener);
      buttonPanel = new LayoutContainer();
      buttonPanel.setLayout(new RowLayout(Orientation.VERTICAL));
      buttonPanel.add(mrsEnabledBtn);
      buttonPanel.add(mrsDisabledBtn);
      mrsConfigPanel.add(buttonPanel, new RowData(100, 1, new Margins(3)));
      generalSectionPanel.add(mrsServicePanel, new RowData(1, -1, new Margins(5)));
    }
    return generalSectionPanel;
  }
  @Override
  public void addComponent() {
    this.dimensionRadioGroup = new RadioGroup();
    this.dimensionRadioGroup.setFieldLabel(
        LayerModuleConstants.INSTANCE.LayerTimeFilterWidget_dimensionRadioLabelText());
    fixedDimensionRadio.setBoxLabel(
        LayerModuleConstants.INSTANCE.LayerTimeFilterWidget_fixedDimensionRadioLabelText());
    fixedDimensionRadio.setHideLabel(Boolean.TRUE);
    this.dimensionRadioGroup.add(fixedDimensionRadio);
    variableDimensionRadio.setBoxLabel(
        LayerModuleConstants.INSTANCE.LayerTimeFilterWidget_variableDimensionRadioLabelText());
    variableDimensionRadio.setHideLabel(Boolean.TRUE);
    this.dimensionRadioGroup.add(variableDimensionRadio);
    this.fixedDimensionContainer.setVisible(Boolean.FALSE);
    this.variableDimensionContainer.setVisible(Boolean.FALSE);
    this.fixedDimensionRadio.addListener(
        Events.Change,
        new Listener<FieldEvent>() {
          @Override
          public void handleEvent(FieldEvent fe) {
            if (fixedDimensionRadio.getValue()) {
              fixedDimensionContainer.setVisible(Boolean.TRUE);
              variableDimensionContainer.setVisible(Boolean.FALSE);
            }
          }
        });
    this.variableDimensionRadio.addListener(
        Events.Change,
        new Listener<FieldEvent>() {
          @Override
          public void handleEvent(FieldEvent fe) {
            if (variableDimensionRadio.getValue()) {
              variableDimensionContainer.setVisible(Boolean.TRUE);
              fixedDimensionContainer.setVisible(Boolean.FALSE);
            }
          }
        });

    this.startStore = new ListStore<DimensionData>();
    this.startDimensionComboBox = new ComboBox<DimensionData>();
    this.startDimensionComboBox.setFieldLabel(
        LayerModuleConstants.INSTANCE.LayerTimeFilterWidget_startDimensionComboLabelText());
    this.startDimensionComboBox.setStore(this.startStore);
    this.startDimensionComboBox.setDisplayField(DimensionData.DIMENSION_KEY);
    this.startDimensionComboBox.setEditable(Boolean.FALSE);
    this.startDimensionComboBox.addSelectionChangedListener(
        new SelectionChangedListener<DimensionData>() {
          @Override
          public void selectionChanged(SelectionChangedEvent<DimensionData> se) {
            if (se.getSelectedItem() != null) {
              endStore.removeAll();
              int indexStart = startStore.getModels().indexOf(se.getSelectedItem()) + 1;
              //                    System.out.println("Sublist start: " + indexStart);
              //                    System.out.println("Sublist end: " +
              // (startStore.getModels().size() - 1));
              if (indexStart < startStore.getModels().size()) {
                endDimensionComboBox.enable();
                endStore.add(
                    startStore
                        .getModels()
                        .subList(
                            startStore.indexOf(se.getSelectedItem()) + 1,
                            startStore.getModels().size()));
              } else {
                endDimensionComboBox.disable();
              }
            }
          }
        });
    this.endStore = new ListStore<DimensionData>();
    this.endDimensionComboBox = new ComboBox<DimensionData>();
    this.endDimensionComboBox.setFieldLabel(
        LayerModuleConstants.INSTANCE.LayerTimeFilterWidget_endDimensionComboLabelText());
    this.endDimensionComboBox.setStore(this.endStore);
    this.endDimensionComboBox.setDisplayField(DimensionData.DIMENSION_KEY);
    this.endDimensionComboBox.disable();
    this.endDimensionComboBox.setEditable(Boolean.FALSE);
    dimensionSizeLabel = new Label();
    dimensionSizeLabel.setStyleAttribute("font-size", "12px");
    this.startFilterNumberField = new NumberField();
    this.startFilterNumberField.setFireChangeEventOnSetValue(Boolean.TRUE);
    this.startFilterNumberField.addListener(
        Events.Change,
        new Listener<BaseEvent>() {
          @Override
          public void handleEvent(BaseEvent be) {
            if (checkStartFieldValue()) {
              int fromFilter = startFilterNumberField.getValue().intValue();
              int position = startStore.getModels().size() - fromFilter - 1;
              String tooltip =
                  (String) startStore.getModels().get(position).get(DimensionData.DIMENSION_KEY);
              //                            startStore.getModels().size() - fromFilter - 1).get(
              startFilterNumberField.setToolTip(tooltip);
              startTimeLabel.setHtml(tooltip);
              slider.setValue(position);
            } else {
              startTimeLabel.setHtml("");
              startFilterNumberField.setToolTip("");
            }
          }
        });
    startTimeLabel = new Label();
    startTimeLabel.setStyleAttribute("font-size", "1.3em");
    this.startFilterNumberField.setSize(50, 30);
    this.endFilterNumberField = new NumberField();
    this.endFilterNumberField.setFireChangeEventOnSetValue(Boolean.TRUE);
    endTimeLabel = new Label();
    endTimeLabel.setStyleAttribute("font-size", "1.3em");
    this.endFilterNumberField.addListener(
        Events.Change,
        new Listener<BaseEvent>() {
          @Override
          public void handleEvent(BaseEvent be) {
            if (checkEndFieldValue()) {
              int endFilter = endFilterNumberField.getValue().intValue();
              String tooltip =
                  (String) startStore.getModels().get(endFilter).get(DimensionData.DIMENSION_KEY);
              //                            startStore.getModels().size() - endFilter - 1).
              endFilterNumberField.setToolTip(tooltip);
              endTimeLabel.setHtml(tooltip);
            } else {
              endTimeLabel.setHtml("");
              endFilterNumberField.setToolTip("");
            }
          }
        });
    this.endFilterNumberField.setSize(50, 30);
    FormPanel panel = new FormPanel();
    panel.setHeaderVisible(Boolean.FALSE);
    panel.setFrame(Boolean.TRUE);
    panel.setBorders(Boolean.FALSE);
    panel.setHeight(WIDGET_HEIGHT - 67);
    panel.add(this.dimensionRadioGroup);
    panel.setStyleAttribute("background-color", "white");
    this.variableDimensionContainer.add(dimensionSizeLabel, new FormData("100%"));

    Portal portal = new Portal(3);
    portal.setBorders(false);
    portal.setColumnWidth(0, .20);
    portal.setColumnWidth(1, .60);
    portal.setColumnWidth(2, .20);

    Portlet portlet = new Portlet();
    portlet.setLayout(new FitLayout());
    portlet.setHeaderVisible(false);
    portlet.setSize(50, 30);
    portlet.add(this.startFilterNumberField);
    portal.add(portlet, 0);
    portlet = new Portlet(new CenterLayout());
    portlet.setHeaderVisible(false);
    portlet.setSize(100, 30);
    this.rangeCheckBox = new CheckBox();
    rangeCheckBox.setValue(true);
    rangeCheckBox.setBoxLabel("range");
    portlet.add(rangeCheckBox);
    portlet.setBorders(false);
    portal.add(portlet, 1);
    portlet = new Portlet();
    portlet.setHeaderVisible(false);
    portlet.setSize(50, 30);
    portlet.add(this.endFilterNumberField);
    portal.add(portlet, 2);

    this.variableDimensionContainer.add(portal, new FormData("99%"));
    //
    this.slider =
        new Slider() {
          @Override
          public void setValue(int value) {
            super.setValue(value);
            super.setMessage("" + (startStore.getModels().size() - value));
          }
        };
    slider.setIncrement(1);
    this.variableDimensionContainer.add(slider, new FormData("98%"));

    this.fixedDimensionContainer.add(this.startDimensionComboBox);
    this.fixedDimensionContainer.add(this.endDimensionComboBox);
    panel.add(this.fixedDimensionContainer, new FormData("100%"));
    panel.add(this.variableDimensionContainer, new FormData("100%"));
    super.add(panel);
    this.playSelectioListener =
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            //                System.out.println("Play button status: ");
            if (!playButton.isPressed()) {
              playButton.setText(ButtonsConstants.INSTANCE.playText());
              playButton.setIcon(AbstractImagePrototype.create(LayerResources.ICONS.playTime()));
              animationTimer.cancel();
            } else {
              Number startValueNumber = startFilterNumberField.getValue();
              if (startValueNumber == null) {
                GeoPlatformMessage.alertMessage(
                    LayerModuleConstants.INSTANCE
                        .LayerTimeFilterWidget_timeFilterWarningTitleText(),
                    LayerModuleConstants.INSTANCE
                        .LayerTimeFilterWidget_timeFilterWarningBodyText());
              } else {
                slider.setValue(startStore.getModels().size() - startValueNumber.intValue() - 1);
                playButton.setIcon(AbstractImagePrototype.create(LayerResources.ICONS.pauseTime()));
                playButton.setText(ButtonsConstants.INSTANCE.pauseText());
                playTimeFilter();
              }
            }
          }
        };
    playButton.addSelectionListener(playSelectioListener);
    playButton.setHeight(30);
    super.addButton(playButton);

    Button apply = new Button(ButtonsConstants.INSTANCE.applyText());
    this.applyFilterSelectionListener =
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            GPLayerTreeModel layerSelected =
                (GPLayerTreeModel) treePanel.getSelectionModel().getSelectedItem();
            IMementoSave mementoSave =
                MementoModuleInjector.MainInjector.getInstance().getMementoSave();
            AbstractMementoOriginalProperties memento =
                mementoSave.copyOriginalProperties(layerSelected);
            String layerName;
            if (layerSelected.getAlias() != null
                && layerSelected.getAlias().indexOf(LAYER_TIME_DELIMITER) != -1) {
              layerName =
                  layerSelected
                      .getAlias()
                      .substring(0, layerSelected.getAlias().indexOf(LAYER_TIME_DELIMITER));
            } else {
              layerName = layerSelected.getLabel();
            }
            if (fixedDimensionRadio.getValue()) {
              String timeFilter =
                  (String) startDimensionComboBox.getValue().get(DimensionData.DIMENSION_KEY);
              if (endDimensionComboBox.getValue() != null) {
                timeFilter +=
                    "/" + (String) endDimensionComboBox.getValue().get(DimensionData.DIMENSION_KEY);
              }
              layerSelected.setTimeFilter(timeFilter);
              layerSelected.setVariableTimeFilter(null);
              layerSelected.setAlias(
                  layerName + LAYER_TIME_DELIMITER + layerSelected.getTimeFilter() + "]");
              WidgetPropertiesHandlerManager.fireEvent(labelEvent);
            } else {
              if ((rangeCheckBox.getValue() && !checkEndFieldValue()) || !checkStartFieldValue()) {
                GeoPlatformMessage.errorMessage(
                    LayerModuleConstants.INSTANCE.LayerTimeFilterWidget_timeFilterErrorTitleText(),
                    LayerModuleConstants.INSTANCE.LayerTimeFilterWidget_timeFilterErrorBodyText());
                return;
              } else {
                int fromFilter = slider.getValue();
                String timeFilter = "" + (startStore.getModels().size() - fromFilter - 1);
                String variableTimeFilter =
                    (String)
                        startStore.getModels().get(fromFilter).get(DimensionData.DIMENSION_KEY);
                if (rangeCheckBox.getValue() && playButton.isPressed()) {
                  fromFilter =
                      startStore.getModels().size()
                          - startFilterNumberField.getValue().intValue()
                          - 1;
                  timeFilter = "" + startFilterNumberField.getValue().intValue();
                  variableTimeFilter =
                      (String)
                          startStore.getModels().get(fromFilter).get(DimensionData.DIMENSION_KEY);
                  //
                  int toFilter = slider.getValue();
                  timeFilter += "/" + (startStore.getModels().size() - slider.getValue() - 1);
                  variableTimeFilter +=
                      "/"
                          + (String)
                              startStore.getModels().get(toFilter).get(DimensionData.DIMENSION_KEY);
                } // This is usefull when press Apply button to show all the elements in range
                else if (rangeCheckBox.getValue() && endFilterNumberField.getValue() != null) {
                  fromFilter =
                      startStore.getModels().size()
                          - startFilterNumberField.getValue().intValue()
                          - 1;
                  timeFilter = "" + startFilterNumberField.getValue().intValue();
                  variableTimeFilter =
                      (String)
                          startStore.getModels().get(fromFilter).get(DimensionData.DIMENSION_KEY);
                  //
                  int toFilter =
                      startStore.getModels().size()
                          - endFilterNumberField.getValue().intValue()
                          - 1;
                  timeFilter += "/" + endFilterNumberField.getValue().intValue();
                  variableTimeFilter +=
                      "/"
                          + (String)
                              startStore.getModels().get(toFilter).get(DimensionData.DIMENSION_KEY);
                }
                layerSelected.setTimeFilter(timeFilter);
                layerSelected.setVariableTimeFilter(variableTimeFilter);
                layerSelected.setAlias(
                    layerName + LAYER_TIME_DELIMITER + layerSelected.getVariableTimeFilter() + "]");
                WidgetPropertiesHandlerManager.fireEvent(labelEvent);
                slider.setMessage(variableTimeFilter);
                GeoPlatformMessage.infoMessage(
                    LayerModuleConstants.INSTANCE
                        .LayerTimeFilterWidget_timeFilterMessageTitleText(),
                    LayerModuleMessages.INSTANCE.LayerTimeFilterWidget_layerStatusShowedMessage(
                        timeFilter));
              }
            }
            mementoSave.putOriginalPropertiesInCache(memento);
            timeFilterLayerMapEvent.setLayerBean(layerSelected);
            GPHandlerManager.fireEvent(timeFilterLayerMapEvent);
            treePanel.refresh(layerSelected);
          }
        };

    apply.addSelectionListener(applyFilterSelectionListener);

    super.addButton(apply);
    Button close =
        new Button(
            ButtonsConstants.INSTANCE.closeText(),
            new SelectionListener<ButtonEvent>() {
              @Override
              public void componentSelected(ButtonEvent ce) {
                startFilterNumberField.clear();
                startTimeLabel.setHtml("");
                endTimeLabel.setHtml("");
                endFilterNumberField.clear();
                hide();
              }
            });

    super.addButton(close);
  }