Example #1
0
  private void buildToolbar() {
    toolbar = new ToolBar();

    next = new Button();
    next.setIconStyle("icon-next");
    next.setText("Next " + NUMBER_OF_RESULTS + " Results");
    next.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            start += NUMBER_OF_RESULTS;
            if (start + NUMBER_OF_RESULTS > currentResults.getLength()) next.setEnabled(false);
            if (start > 0) prev.setEnabled(true);
            fillTable();
          }
        });

    prev = new Button();
    prev.setIconStyle("icon-previous");
    prev.setText("Previous " + NUMBER_OF_RESULTS + " Results");
    prev.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            start -= NUMBER_OF_RESULTS;
            if (start < 0) start = 0;
            if (start == 0) prev.setEnabled(false);
            if (start + NUMBER_OF_RESULTS < currentResults.getLength()) next.setEnabled(true);
            fillTable();
          }
        });

    toolbar.add(prev);
    toolbar.add(next);
  }
Example #2
0
  private void createButtons() {
    Button submitBtn = new Button("Submit");
    Button resetBtn = new Button("Reset");
    submitBtn.addSelectionListener(new FormSubmitListener(form));
    resetBtn.addSelectionListener(new FormResetListener(form));

    form.addButton(submitBtn);
    form.addButton(resetBtn);
    addBeforSubmitListener();
  }
  private LayoutContainer createContentContainer() {
    LayoutContainer contentContainer = new LayoutContainer();
    contentContainer.setBorders(false);
    contentContainer.setSize(340, 170);
    HBoxLayout tabbarContainerLayout = new HBoxLayout();
    tabbarContainerLayout.setHBoxLayoutAlign(HBoxLayoutAlign.TOP);
    contentContainer.setLayout(tabbarContainerLayout);

    LayoutContainer contentItemsContainer = new LayoutContainer();
    contentItemsContainer.setBorders(true);
    contentItemsContainer.setWidth(230);
    contentItemsContainer.setHeight(160);
    contentItemsContainer.setLayout(new FitLayout());
    contentItemsContainer.setStyleAttribute("backgroundColor", "white");
    // overflow-auto style is for IE hack.
    contentItemsContainer.addStyleName("overflow-auto");

    TreeStore<BeanModel> deviceContentTreeStore = new TreeStore<BeanModel>();
    deviceContentTree = TreePanelBuilder.buildDeviceContentTree(deviceContentTreeStore);
    contentItemsContainer.add(deviceContentTree);

    LayoutContainer buttonsContainer = new LayoutContainer();
    buttonsContainer.setSize(110, 160);
    buttonsContainer.setBorders(false);
    buttonsContainer.setLayout(new RowLayout(Orientation.VERTICAL));

    Button addCommandBtn = new Button("Add command");
    addCommandBtn.addSelectionListener(new AddCommandListener());

    Button addSensorBtn = new Button("Add sensor");
    addSensorBtn.addSelectionListener(new AddSensorListener());

    Button addSwitchBtn = new Button("Add switch");
    addSwitchBtn.addSelectionListener(new AddSwitchListener());

    Button addSliderBtn = new Button("Add slider");
    addSliderBtn.addSelectionListener(new AddSliderListener());

    Button deleteBtn = new Button("Delete");
    deleteBtn.addSelectionListener(new DeleteContentListener());

    buttonsContainer.add(addCommandBtn, new RowData(110, -1, new Margins(5)));
    buttonsContainer.add(addSensorBtn, new RowData(110, -1, new Margins(5)));
    buttonsContainer.add(addSwitchBtn, new RowData(110, -1, new Margins(5)));
    buttonsContainer.add(addSliderBtn, new RowData(110, -1, new Margins(5)));
    buttonsContainer.add(deleteBtn, new RowData(110, -1, new Margins(5)));

    contentContainer.add(contentItemsContainer);
    contentContainer.add(buttonsContainer);
    return contentContainer;
  }
Example #4
0
 private Button setOkButtonListener(
     SelectionListener<ButtonEvent> DialogOkBtnSelectionListenerImpl) {
   Button bntOk = getButtonById(Dialog.OK);
   bntOk.addSelectionListener(DialogOkBtnSelectionListenerImpl);
   bntOk.disable();
   return bntOk;
 }
 private Button createDeleteButton(final IViewContext<ICommonClientServiceAsync> context) {
   Button deleteButton = new Button(context.getMessage(Dict.BUTTON_DELETE));
   deleteButton.addSelectionListener(
       new SelectionListener<ButtonEvent>() {
         @Override
         public void componentSelected(ButtonEvent ce) {
           List<BaseEntityModel<T>> types = getSelectedItems();
           if (types.isEmpty()) {
             return;
           }
           final List<String> selectedTypeCodes = new ArrayList<String>();
           for (BaseEntityModel<T> model : types) {
             EntityType term = model.getBaseObject();
             selectedTypeCodes.add(term.getCode());
           }
           ConfirmationDialog confirmationDialog =
               new ConfirmationDialog(
                   context.getMessage(Dict.DELETE_CONFIRMATION_TITLE),
                   context.getMessage(
                       Dict.DELETE_CONFIRMATION_MESSAGE,
                       StringUtils.joinList(selectedTypeCodes))) {
                 @Override
                 protected void onYes() {
                   deleteEntityTypes(selectedTypeCodes, new RefreshCallback(viewContext));
                 }
               };
           confirmationDialog.show();
         }
       });
   return deleteButton;
 }
  public LatestVirtualReportItemsPanel() {
    setHeading("Virtual Level Monitoring");
    setLayout(new FitLayout());

    ToolBar toolBar = new ToolBar();
    Button reflesh = new Button("Refresh");
    reflesh.setIcon(IconHelper.createStyle("icon-email-add"));
    id = new TextField<String>();
    id.setFieldLabel("Virtual ID");
    id.setAllowBlank(false);
    toolBar.add(new LabelToolItem("Virtual ID: "));
    toolBar.add(id);
    toolBar.add(reflesh);
    setTopComponent(toolBar);
    reflesh.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            String virtualId = id.getValue();
            service = (MonitoringManagerWebServiceAsync) Registry.get("guiservice");
            service.getMonitoringResources(
                "virtual",
                virtualId,
                new AsyncCallback<List<MonitoringResource>>() {
                  public void onFailure(Throwable caught) {
                    Dispatcher.forwardEvent(MainEvents.Error, caught);
                  }

                  public void onSuccess(List<MonitoringResource> result) {
                    getVirtualStore().removeAll();
                    if (result.size() > 0) virtualStore.add(result);
                  }
                });
          }
        });

    virtualStore = new GroupingStore<MonitoringResource>();
    virtualStore.groupBy("resource_type");
    cm = new ColumnModel(OptimisResource.getColumnConfig());
    GroupingView view = new GroupingView();
    view.setShowGroupedColumn(true);
    view.setForceFit(true);
    view.setGroupRenderer(
        new GridGroupRenderer() {
          public String render(GroupColumnData data) {
            String f = cm.getColumnById(data.field).getHeader();
            String l = data.models.size() == 1 ? "Item" : "Items";
            return f + ": " + data.group + " (" + data.models.size() + " " + l + ")";
          }
        });

    virtualGrid = new Grid<MonitoringResource>(virtualStore, cm);
    virtualGrid.setTitle(" Service Resources ");
    virtualGrid.setView(view);
    virtualGrid.setBorders(true);
    virtualGrid.getView().setForceFit(true);
    add(virtualGrid);
  }
Example #7
0
  public SearchFormPanel() {

    ListStore<BeanModel> comboStore = new ListStore<BeanModel>();
    combo = new ComboBox<BeanModel>();
    combo.setStore(comboStore);
    combo.setFieldLabel("Asset type");
    combo.setDisplayField("name");
    combo.setTypeAhead(true);
    combo.setForceSelection(true);
    combo.setTriggerAction(ComboBox.TriggerAction.ALL);
    // combo.setWidth(150);
    combo.addSelectionChangedListener(
        new SelectionChangedListener<BeanModel>() {
          public void selectionChanged(SelectionChangedEvent<BeanModel> se) {
            prepareForm((MetaAsset) combo.getValue().getBean());
          }
        });

    Button btnSearch = new Button("Search");
    btnSearch.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          public void componentSelected(ButtonEvent be) {
            submitSearch();
          }
        });

    form = new FormPanel();
    form.setHeaderVisible(false);
    form.setBodyBorder(false);
    form.setScrollMode(Style.Scroll.AUTOY);
    // form.setWidth(300);

    HBoxLayout layout = new HBoxLayout();
    layout.setHBoxLayoutAlign(HBoxLayout.HBoxLayoutAlign.MIDDLE);
    ContentPanel topPanel = new ContentPanel(layout);
    topPanel.setHeaderVisible(false);
    topPanel.setFrame(true);
    topPanel.setHeight(40);
    topPanel.add(new Text("Asset type: "));
    HBoxLayoutData layoutData = new HBoxLayoutData(0, 2, 0, 2);
    topPanel.add(combo, layoutData);
    topPanel.add(btnSearch);

    setHeading("Advanced search");
    setLayout(new FitLayout());
    setFrame(true);
    setTopComponent(topPanel);
    add(form);

    /*
    addListener(Events.Expand, new Listener<BaseEvent>() {
    	public void handleEvent(BaseEvent be) {
    		initComponents(false);
    	}
    });*/
    initComponents(false);
  }
  public LatestPhysicalReportItemsPanel() {
    setHeading("Physical Level Monitoring");
    setLayout(new FitLayout());

    ToolBar toolBar = new ToolBar();
    ToolBar toolBarBottom = new ToolBar();
    Button reflesh = new Button("Refresh");
    reflesh.setIcon(IconHelper.createStyle("icon-email-add"));
    id = new TextField<String>();
    id.setFieldLabel("Physical ID");
    id.setAllowBlank(false);
    toolBar.add(new LabelToolItem("Physical ID: "));
    toolBar.add(id);
    toolBar.add(reflesh);
    setTopComponent(toolBar);
    lt = new LabelField("");
    setToolBar4Status("");
    toolBarBottom.add(lt);
    setBottomComponent(toolBarBottom);
    reflesh.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            setToolBar4Status("Loading data, please wait...");
            String physicalId = id.getValue();
            service = (MonitoringManagerWebServiceAsync) Registry.get("guiservice");
            service.getMonitoringResources(
                "physical",
                physicalId,
                new AsyncCallback<List<MonitoringResource>>() {
                  public void onFailure(Throwable caught) {
                    setToolBar4Status("Connection failed by loading data, please try again.");
                    Dispatcher.forwardEvent(MainEvents.Error, caught);
                  }

                  public void onSuccess(List<MonitoringResource> result) {
                    setToolBar4Status("");
                    getStore().removeAll();
                    if (result.size() > 0) {
                      store.add(result);
                    } else {
                      setToolBar4ErrorStatus("No data found.");
                    }
                  }
                });
          }
        });

    cm = new ColumnModel(OptimisResource.getColumnConfig());
    store = new ListStore<MonitoringResource>();
    grid = new Grid<MonitoringResource>(store, cm);
    grid.setTitle(" Physical Level Resources ");
    grid.setBorders(true);
    grid.getView().setForceFit(true);
    add(grid);
    setLayout(new FitLayout());
  }
Example #9
0
 public PersonForm() {
   saveButton.setEnabled(true);
   saveButton.addSelectionListener(
       new SelectionListener<ButtonEvent>() {
         @Override
         public void componentSelected(ButtonEvent ce) {
           savePerson();
         }
       });
   loadPerson();
 }
Example #10
0
 private Button buildNewToolRequestMenuItem() {
   Button newToolBtn = new Button(org.iplantc.core.tito.client.I18N.DISPLAY.requestNewTool());
   newToolBtn.setIcon(AbstractImagePrototype.create(Resources.ICONS.add()));
   newToolBtn.addSelectionListener(
       new SelectionListener<ButtonEvent>() {
         @Override
         public void componentSelected(ButtonEvent ce) {
           new NewToolRequestWindow().show();
         }
       });
   newToolBtn.setId(ID_BTN_NEW_TOOL_BTN);
   return newToolBtn;
 }
  @Override
  protected void createButtons() {

    ok = new Button("Si");
    ok.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          public void componentSelected(ButtonEvent ce) {
            hide();
            Dispatcher.forwardEvent(CentralEvents.ShowPanel, Eventi.MAIN);
            Dispatcher.forwardEvent(PubblicazioniEvents.ClearPanel, Eventi.MAIN);
          }
        });

    cancel = new Button("No");
    cancel.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          public void componentSelected(ButtonEvent ce) {
            hide();
          }
        });
    addButton(ok);
    addButton(cancel);
  }
  /** Inits the save and export buttons on applicationToolBar. */
  private void initSaveAndExportButtons() {
    saveButton = new Button();
    saveButton.setIcon(icons.saveIcon());
    saveButton.setToolTip("Save");
    saveButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            uiDesignerPresenter.saveUiDesignerLayout();
          }
        });

    exportButton = new Button();
    exportButton.setIcon(icons.exportAsZipIcon());
    exportButton.setToolTip("Export as zip");
    exportButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            if (!isExportedDataValid()) {
              MessageBox.info("Info", "Nothing to export.", null);
              return;
            }
            viewport.mask("Exporting, please wait.");
            UtilsProxy.exportFiles(
                IDUtil.currentID(),
                uiDesignerPresenter.getAllPanels(),
                new AsyncSuccessCallback<String>() {
                  @Override
                  public void onSuccess(String exportURL) {
                    viewport.unmask();
                    Window.open(exportURL, "_blank", "");
                  }
                });
          }
        });
  }
 /**
  * Creates the logout button for the user logout the application.
  *
  * @return the button
  */
 private Button createLogoutButton() {
   String currentUserName =
       (this.authority == null) ? "" : "(" + this.authority.getUsername() + ")";
   Button logoutButton = new Button();
   logoutButton.setIcon(icons.logout());
   logoutButton.setToolTip("Logout" + currentUserName);
   logoutButton.addSelectionListener(
       new SelectionListener<ButtonEvent>() {
         @Override
         public void componentSelected(ButtonEvent ce) {
           Window.open("j_security_logout", "_self", "");
         }
       });
   return logoutButton;
 }
Example #14
0
  private Button buildSearchButton() {
    Button searchBtn = new Button();
    searchBtn.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {
            search(filter.getValue());
          }
        });

    searchBtn.setId(ID_SEARCH_BTN);
    searchBtn.setIcon(AbstractImagePrototype.create(Resources.ICONS.search()));
    return searchBtn;
  }
 /**
  * Creates the button to pop up the account management window.
  *
  * @return the button
  */
 private Button createAccountManageButton() {
   Button accountManageBtn = new Button();
   accountManageBtn.setToolTip("Account management");
   accountManageBtn.setIcon(icons.userIcon());
   accountManageBtn.addSelectionListener(
       new SelectionListener<ButtonEvent>() {
         public void componentSelected(ButtonEvent ce) {
           AsyncServiceFactory.getUserRPCServiceAsync()
               .getUserId(
                   new AsyncSuccessCallback<Long>() {
                     public void onSuccess(Long currentUserId) {
                       new AccountManageWindow(currentUserId);
                     }
                   });
         }
       });
   return accountManageBtn;
 }
  private HorizontalPanel getSearchPanel() {
    HorizontalPanel searchBox = new HorizontalPanel();
    TextField<String> msisdnField = new TextField<String>();
    msisdnField.setFieldLabel("MSISDN");
    msisdnField.setWidth(200);
    msisdnField.setEmptyText("Enter MSISDN");
    Button searchButton = new Button("Search");
    searchBox.setShadow(true);
    searchBox.setSpacing(5);
    searchBox.add(msisdnField);
    searchBox.add(searchButton);
    searchBox.setHorizontalAlign(HorizontalAlignment.CENTER);
    searchButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {}
        });
    return searchBox;
  }
 /**
  * Creates the button that can pop up the testOnline dialog.
  *
  * @return the button
  */
 private Button createOnLineTestBtn() {
   final Button showDemoBtn = new Button();
   showDemoBtn.setToolTip("Test UI online in your panel. ");
   showDemoBtn.setIcon(icons.onLineTestIcon());
   showDemoBtn.addSelectionListener(
       new SelectionListener<ButtonEvent>() {
         public void componentSelected(ButtonEvent ce) {
           UtilsProxy.getOnTestLineURL(
               new AsyncSuccessCallback<String>() {
                 @Override
                 public void onSuccess(String result) {
                   Dialog dialog = new Dialog();
                   dialog.setHideOnButtonClick(true);
                   dialog.setButtonAlign(HorizontalAlignment.CENTER);
                   dialog.setClosable(false);
                   dialog.setBodyBorder(false);
                   dialog.setHeading("Test UI Online");
                   dialog.setWidth(310);
                   dialog.setAutoHeight(true);
                   Text text = new Text();
                   text.setWidth("100%");
                   text.setStyleAttribute("backgroundColor", "CCD9E8");
                   text.setText(
                       "To test your UI without installing any Controller or deploying configuration, "
                           + "type the following URL into your panel setting as Controller URL :");
                   TextField<String> url = new TextField<String>();
                   url.setWidth("100%");
                   url.setValue(result);
                   url.setReadOnly(true);
                   dialog.add(text);
                   dialog.add(url);
                   dialog.show();
                 }
               });
         }
       });
   return showDemoBtn;
 }
  private ToolBar createCalendarToolbar() {
    ToolBar calendarToolbar = new ToolBar();

    currentMonthAndYear = new Button();
    DateTimeFormat formatter = DateTimeFormat.getFormat("MMMM yyyy");
    String result = formatter.format(calendar.getDate());
    currentMonthAndYear.setText(result);
    currentMonthAndYear.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            dpDialog.show();
            dpDialog.center();
          }
        });

    Button today = new Button("<b>" + HarvesterUI.CONSTANTS.today() + "</b>");
    today.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            ((DatePicker) dpDialog.getItem(0)).setValue(new Date());
            //                DateTimeFormat formatter = DateTimeFormat.getFormat("MMMM yyyy");
            //                String result = formatter.format(calendar.getDate());
            //                currentMonthAndYear.setText(result);
            //                calendarTaskManager.updateScheduleTasks();
          }
        });

    Button yearLeft = new Button("<b>" + "<<" + "</b>");
    yearLeft.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            DateWrapper dw = new DateWrapper(calendar.getDate());
            ((DatePicker) dpDialog.getItem(0)).setValue(dw.addMonths(-1).asDate());
            //                DateTimeFormat formatter = DateTimeFormat.getFormat("MMMM yyyy");
            //                String result = formatter.format(calendar.getDate());
            //                currentMonthAndYear.setText(result);
            //                calendarTaskManager.updateScheduleTasks();
          }
        });

    Button yearRight = new Button("<b>" + ">>" + "</b>");
    yearRight.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            DateWrapper dw = new DateWrapper(calendar.getDate());
            ((DatePicker) dpDialog.getItem(0)).setValue(dw.addMonths(1).asDate());
            //                DateTimeFormat formatter = DateTimeFormat.getFormat("MMMM yyyy");
            //                String result = formatter.format(calendar.getDate());
            //                currentMonthAndYear.setText(result);
            //                calendarTaskManager.updateScheduleTasks();
          }
        });

    calendarToolbar.add(today);
    calendarToolbar.add(new SeparatorToolItem());
    calendarToolbar.add(yearLeft);
    calendarToolbar.add(currentMonthAndYear);
    calendarToolbar.add(yearRight);
    calendarToolbar.add(new SeparatorToolItem());

    calendarToolbar.add(new FillToolItem());
    createViewsButtons(calendarToolbar);

    return calendarToolbar;
  }
  @Override
  protected void onRender(Element parent, int index) {

    super.onRender(parent, index);

    setLayout(new CenterLayout());

    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

    configs.add(sm.getColumn());

    ColumnConfig column = new ColumnConfig();
    column.setId("ragioneSociale");
    column.setHeader("Ragione Sociale");
    column.setWidth(120);

    TextField<String> text = new TextField<String>();
    // text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    configs.add(column);

    column = new ColumnConfig();
    column.setId("cognome");
    column.setHeader("Cognome");
    column.setWidth(120);

    text = new TextField<String>();
    // text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    configs.add(column);

    column = new ColumnConfig();
    column.setId("nome");
    column.setHeader("Nome");
    column.setWidth(120);

    text = new TextField<String>();
    // text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    configs.add(column);

    column = new ColumnConfig();
    column.setId("cf");
    column.setHeader("Codice Fiscale");
    column.setWidth(120);

    text = new TextField<String>();
    // text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    configs.add(column);

    column = new ColumnConfig();
    column.setId("piva");
    column.setHeader("Partita IVA");
    column.setWidth(120);

    text = new TextField<String>();
    text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    configs.add(column);

    column = new ColumnConfig();
    column.setId("denominazione");
    column.setHeader("Denominazione");
    column.setWidth(120);

    text = new TextField<String>();
    text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    configs.add(column);

    caricaDati();

    ColumnModel cm = new ColumnModel(configs);

    ContentPanel cp = new ContentPanel();
    cp.setHeading("Anagrafica aziende");
    cp.setFrame(true);
    // cp.setIcon(Resources.ICONS.table());
    cp.setSize(Consts.LarghezzaFinestra, Consts.AltezzaFinestra);
    cp.setLayout(new FitLayout());

    final EditorGrid<BeanModel> grid = new EditorGrid<BeanModel>(store, cm);
    grid.setSelectionModel(sm);
    grid.setAutoExpandColumn("nome");
    grid.setBorders(true);
    grid.setClicksToEdit(EditorGrid.ClicksToEdit.TWO);
    cp.add(grid);

    ToolBar toolBar = new ToolBar();
    Button addButton = new Button("Aggiungi azienda");
    addButton.setIcon(
        IconHelper.create(
            "/resources/grafica/x16/add2.png", Consts.ICON_WIDTH_SMALL, Consts.ICON_HEIGHT_SMALL));
    addButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {
            BeanModelFactory factory = BeanModelLookup.get().getFactory(Azienda.class);
            Azienda azienda =
                new Azienda(
                    "NuovoNome",
                    "NuovoCognome",
                    "nuovaRS",
                    "nuovoCF",
                    "nuovaPIVA",
                    "NuovaDenominazione");
            BeanModel model = factory.createModel(azienda);

            grid.stopEditing();
            aziende.add(azienda);
            store.insert(model, 0);
            grid.startEditing(store.indexOf(model), 0);
          }
        });
    toolBar.add(addButton);
    toolBar.add(new SeparatorToolItem());

    Button remove = new Button("Rimuovi selezionati");
    remove.setIcon(
        IconHelper.create(
            "/resources/grafica/x16/delete2.png",
            Consts.ICON_WIDTH_SMALL,
            Consts.ICON_HEIGHT_SMALL));
    remove.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {
            if (!(sm.getSelectedItems()).isEmpty()) {
              MessageBox.confirm(
                  "Confirm",
                  "Sei sicuro di voler eliminare gli elemtni selezionati?",
                  cancellazione);
            } else {
              MessageBox.alert("Errore", "Selezionare uno o più elementi", cancellazione);
            }
          }
          // conferma per l'eliminazione
          final Listener<MessageBoxEvent> cancellazione =
              new Listener<MessageBoxEvent>() {

                @Override
                public void handleEvent(MessageBoxEvent ce) {
                  Button btn = ce.getButtonClicked();
                  if (btn.getText().equals("Yes")) {
                    List<BeanModel> modelsDaRimuovere = sm.getSelectedItems();
                    ArrayList<Azienda> aziendeDaRimuovere = new ArrayList();
                    if (modelsDaRimuovere != null) {
                      Iterator it = modelsDaRimuovere.iterator();
                      while (it.hasNext()) {
                        Object model = it.next();
                        store.remove((BeanModel) model);
                        Azienda azienda = ((BeanModel) model).getBean();
                        aziendeDaRimuovere.add(azienda);
                        aziende.remove(azienda);
                      }
                      cancellaDati(aziendeDaRimuovere);
                    }
                  }
                }
              };
        });
    toolBar.add(remove);
    cp.setTopComponent(toolBar);

    ToolBar statusBar = new ToolBar();
    status.setWidth(350);
    statusBar.add(status);
    cp.setBottomComponent(statusBar);
    cp.setButtonAlign(HorizontalAlignment.CENTER);

    Button resetButton =
        new Button(
            "Reset",
            new SelectionListener<ButtonEvent>() {

              @Override
              public void componentSelected(ButtonEvent ce) {
                store.rejectChanges();
              }
            });
    resetButton.setIcon(
        IconHelper.create(
            "/resources/grafica/x16/undo.png", Consts.ICON_WIDTH_SMALL, Consts.ICON_HEIGHT_SMALL));
    cp.addButton(resetButton);

    Button saveButton =
        new Button(
            "Save",
            new SelectionListener<ButtonEvent>() {

              @Override
              public void componentSelected(ButtonEvent ce) {
                store.commitChanges();
                salvaDati(aziende);
              }
            });
    saveButton.setIcon(
        IconHelper.create(
            "/resources/grafica/x16/save.png", Consts.ICON_WIDTH_SMALL, Consts.ICON_HEIGHT_SMALL));
    cp.addButton(saveButton);

    add(cp);
  }
  private FormPanel createForm() {
    final FormPanel panel = new FormPanel();
    panel.setLabelWidth(100);
    panel.setHeaderVisible(false);

    TextField<String> code = new TextField<String>();
    code.setName("containerNo");
    code.setFieldLabel("集装箱号");
    code.setAllowBlank(false);
    panel.add(code);

    final ComboBox<BeanModel> size = new ComboBox<BeanModel>();
    size.setTabIndex(9);
    size.setName("size");
    size.setForceSelection(true);
    size.setEmptyText("请选择...");
    size.setDisplayField("size");
    size.setFieldLabel("尺寸");
    size.setStore(containerSizeStore);
    size.setTypeAhead(true);
    size.setTriggerAction(TriggerAction.ALL);
    size.setAllowBlank(false);
    panel.add(size);

    size.addListener(
        Events.Blur,
        new Listener<FieldEvent>() {
          @Override
          public void handleEvent(FieldEvent be) {
            formBindings.getModel().set("valentNum", size.getValue().get("valentNum"));
          }
        });

    ComboBox<BeanModel> type = new ComboBox<BeanModel>();
    type.setTabIndex(9);
    type.setName("type");
    type.setForceSelection(true);
    type.setEmptyText("请选择...");
    type.setDisplayField("code");
    type.setFieldLabel("类型");
    type.setStore(ironChestStore);
    type.setTypeAhead(true);
    type.setTriggerAction(TriggerAction.ALL);
    panel.add(type);

    ComboBox<BeanModel> bracket = new ComboBox<BeanModel>();
    bracket.setTabIndex(9);
    bracket.setName("bracket");
    bracket.setForceSelection(true);
    bracket.setEmptyText("请选择...");
    bracket.setDisplayField("code");
    bracket.setFieldLabel("车架编号");
    bracket.setStore(bracketStore);
    bracket.setTypeAhead(true);
    bracket.setTriggerAction(TriggerAction.ALL);
    panel.add(bracket);

    formBindings = new FormBinding(panel, true);

    formBindings
        .getBinding(size)
        .setConverter(
            new Converter() {
              @Override
              public Object convertFieldValue(Object value) {
                if (value == null) {
                  return null;
                }
                return ((BeanModel) value).get("code").toString();
              }

              @Override
              public Object convertModelValue(Object value) {
                if (value != null) {
                  return containerSizeStore.findModel("code", (String) value);
                } else {
                  return null;
                }
              }
            });
    formBindings
        .getBinding(type)
        .setConverter(
            new Converter() {
              @Override
              public Object convertFieldValue(Object value) {
                if (value == null) {
                  return null;
                }
                return ((BeanModel) value).get("code").toString();
              }

              @Override
              public Object convertModelValue(Object value) {
                if (value != null) {
                  return ironChestStore.findModel("code", (String) value);
                } else {
                  return null;
                }
              }
            });
    formBindings
        .getBinding(bracket)
        .setConverter(
            new Converter() {
              @Override
              public Object convertFieldValue(Object value) {
                if (value == null) {
                  return null;
                }
                return ((BeanModel) value).get("code").toString();
              }

              @Override
              public Object convertModelValue(Object value) {
                if (value != null) {
                  return bracketStore.findModel("code", (String) value);
                } else {
                  return null;
                }
              }
            });

    formBindings.setStore((Store<BeanModel>) grid.getStore());

    panel.setReadOnly(true);

    panel.setButtonAlign(HorizontalAlignment.CENTER);

    saveButton = new Button("保存");
    saveButton.setVisible(false);
    saveButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            if (!panel.isValid()) return;
            save();
          }
        });
    panel.addButton(saveButton);

    cancelButton = new Button("取消");
    cancelButton.setVisible(false);
    cancelButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            resetState();
          }
        });
    panel.addButton(cancelButton);

    updateButton = new Button("更新");
    updateButton.disable();
    updateButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            if (!panel.isValid()) return;
            update();
          }
        });
    panel.addButton(updateButton);

    resetButton = new Button("取消");
    resetButton.disable();
    resetButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            store.rejectChanges();
            resetState();
          }
        });
    panel.addButton(resetButton);

    panel.setBorders(false);
    panel.setBodyBorder(false);

    return panel;
  }
  private void createForm() {
    FormLayout layout = new FormLayout();
    layout.setLabelAlign(LabelAlign.TOP);
    fp.setLayout(layout);
    fp.setFrame(false);
    fp.setHeaderVisible(false);
    fp.setAutoWidth(true);
    fp.setBodyBorder(true);
    fp.setButtonAlign(HorizontalAlignment.CENTER);

    eMail = new TextField<String>();
    eMail.setFieldLabel("E-mail address"); // ID
    eMail.setValue("*****@*****.**");
    eMail.setAllowBlank(false);

    eMail.setRegex("^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$");
    fp.add(eMail);

    pass = new TextField<String>();
    pass.setPassword(true);
    pass.setValue("pass");
    pass.setFieldLabel("Password");
    fp.add(pass);

    fp.addButton(loginButton);
    fp.addButton(newAccountButton);

    loginButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {

            ArrayList eventData = new ArrayList();
            if (!eMail.isValid()) {
              eventData = new ArrayList();
              eventData.add("e-mail is invalid!");
              Dispatcher.get().dispatch(MainEvents.login, eventData);
              return;
            } else if (eMail.getValue() == null) {
              eventData = new ArrayList();
              eventData.add("Please enter your e-mail address!");
              Dispatcher.get().dispatch(MainEvents.login, eventData);
              return;
            } else if (pass.getValue() == null) {
              eventData = new ArrayList();
              eventData.add("Please enter the password!");
              Dispatcher.get().dispatch(MainEvents.login, eventData);
              return;
            } else service = (ServiceManagerWebServiceAsync) Registry.get("guiservice");

            String email = eMail.getValue();
            String password = pass.getValue();
            service.loginUser(
                email,
                password,
                new AsyncCallback<ArrayList<Object>>() {
                  public void onFailure(Throwable caught) {
                    System.out.println("loginUser: error");
                  }

                  public void onSuccess(ArrayList<Object> result) {
                    System.out.println("loginUser: success; result.get(0) = \n" + result.get(0));
                    System.out.println("loginUser: session_id = \n" + result.get(1));
                    session_id = (String) result.get(1);
                    ArrayList eventData = new ArrayList();
                    if (!result
                        .get(0)
                        .equals(
                            "User/pass are wrong! Please correct input data or register an account")) {
                      eventData.add("Please select the option");
                      eventData.add(result.get(0));
                      Dispatcher.get().dispatch(MainEvents.login, eventData);
                      fp.remove(eMail);
                      fp.remove(pass);
                      fp.clear();
                      remove(fp);
                      FormLayout layout = new FormLayout();
                      layout.setLabelAlign(LabelAlign.TOP);
                      fp = new FormPanel();
                      fp.setLayout(layout);
                      fp.setFrame(false);
                      fp.setHeaderVisible(false);
                      fp.setAutoWidth(true);
                      fp.setBodyBorder(true);
                      fp.setButtonAlign(HorizontalAlignment.CENTER);
                      fp.addText((String) result.get(0));
                      fp.addButton(logoutButton);
                      add(fp);
                    } else {
                      eventData.add("You need to log in");
                      eventData.add(result.get(0));
                      Dispatcher.get().dispatch(MainEvents.newAccount, eventData);
                    }

                    layout(true);
                  }
                });
          }
        });

    logoutButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            fp.clear();
            remove(fp);
            FormLayout layout = new FormLayout();
            layout.setLabelAlign(LabelAlign.TOP);
            fp = new FormPanel();
            fp.setLayout(layout);
            fp.setFrame(false);
            fp.setHeaderVisible(false);
            fp.setAutoWidth(true);
            fp.setBodyBorder(true);
            fp.setButtonAlign(HorizontalAlignment.CENTER);

            fp.add(eMail);
            fp.add(pass);
            fp.addButton(loginButton);
            fp.addButton(newAccountButton);
            add(fp);

            layout(true);

            ArrayList eventData = new ArrayList();
            eventData.add("You are logged out!");
            eventData.add("You are logged out, " + eMail.getValue() + "!");
            Dispatcher.get().dispatch(MainEvents.logout, eventData);

            service.logoutUser(
                session_id,
                eMail.getValue(),
                new AsyncCallback<Boolean>() {
                  public void onFailure(Throwable caught) {
                    System.out.println("logoutUser: error");
                  }

                  public void onSuccess(Boolean result) {
                    System.out.println("logoutUser: success");
                  }
                });
          }
        });

    newAccountButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            ArrayList eventData = new ArrayList();
            eventData.add("Please select the option");
            Dispatcher.get().dispatch(MainEvents.newAccount, eventData);
          }
        });

    /*
    skipButton.addSelectionListener(new SelectionListener<ButtonEvent>() {
    	@Override
    	public void componentSelected(ButtonEvent ce) {
    		ArrayList eventData = new ArrayList();
    		eventData.add("Please select the option");
    		Dispatcher.get().dispatch(MainEvents.login, eventData);
    	}

    });
    */
    this.add(fp);
  }
  @Override
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FitLayout());

    containerSizeStore = getContainerSizeStore();
    ironChestStore = getIronChestStore();
    bracketStore = getBracketStore();

    ContentPanel content = new ContentPanel();
    content.setHeaderVisible(false);
    content.setBodyBorder(false);
    content.setLayout(new RowLayout(Orientation.VERTICAL));

    LayoutContainer frame1 = new LayoutContainer();
    frame1.setStyleAttribute("padding", "10px");
    frame1.setStyleAttribute("backgroundColor", "#dfe8f6");
    frame1.setLayout(new BorderLayout());

    grid = createGrid();
    grid.getSelectionModel()
        .addListener(
            Events.SelectionChange,
            new Listener<SelectionChangedEvent<BeanModel>>() {
              public void handleEvent(SelectionChangedEvent<BeanModel> be) {
                store.rejectChanges();
                resetState();
              }
            });

    formPanel = createForm();

    BorderLayoutData westData = new BorderLayoutData(LayoutRegion.WEST, 305);
    BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);

    frame1.add(grid, westData);
    frame1.add(formPanel, centerData);

    content.add(frame1);

    LayoutContainer frame2 = new LayoutContainer();
    frame2.setStyleAttribute("backgroundColor", "#dfe8f6");
    frame2.setLayout(new RowLayout(Orientation.HORIZONTAL));

    RowData data1 = new RowData(.45, 1);
    data1.setMargins(new Margins(10));
    RowData data2 = new RowData(.55, 1);
    data2.setMargins(new Margins(10));
    frame2.add(createTypeGrid(), data1);
    frame2.add(createBracketGrid(), data2);

    RowData data = new RowData(1, 0.5);
    content.add(frame1, data);
    content.add(frame2, data);

    // 添加工具栏
    ToolBar toolBar = new ToolBar();

    addButton = new Button("添加", Resources.ICONS.add());
    addButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            beanModel = beanModelFactory.createModel(new Container());
            formPanel.reset();
            formBindings.bind(beanModel);
            formBindings.addListener(
                Events.Bind,
                new Listener<BindingEvent>() {
                  @Override
                  public void handleEvent(BindingEvent be) {
                    formBindings
                        .getModel()
                        .set("customsDeclarationHeadId", selectedCustomsDeclarationHead.getId());
                    for (Field<?> field : formPanel.getFields()) {
                      field.clearInvalid();
                    }
                    formBindings.removeAllListeners();
                  }
                });
            formPanel.setReadOnly(false);
            formPanel.getFields().get(0).focus();
            saveButton.setVisible(true);
            cancelButton.setVisible(true);
            updateButton.setVisible(false);
            resetButton.setVisible(false);
            addButton.disable();
          }
        });
    toolBar.add(addButton);

    toolBar.add(new SeparatorToolItem());

    editButton = new Button("修改", Resources.ICONS.edit());
    editButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            if (grid.getSelectionModel().getSelection().size() > 0) {
              formBindings.bind((BeanModel) grid.getSelectionModel().getSelection().get(0));
              formPanel.setReadOnly(false);
              updateButton.enable();
              resetButton.enable();
              editButton.disable();
            } else {
              formBindings.unbind();
            }
          }
        });
    toolBar.add(editButton);

    toolBar.add(new SeparatorToolItem());

    deleteButton = new Button("删除", Resources.ICONS.delete());
    toolBar.add(deleteButton);
    deleteButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            MessageBox.confirm(
                "确认",
                "确定要删除选中的条目吗?",
                new Listener<MessageBoxEvent>() {
                  @Override
                  public void handleEvent(MessageBoxEvent be) {
                    if (be.getButtonClicked().getText() == GXT.MESSAGES.messageBox_yes()) {
                      delete();
                    }
                  }
                });
          }
        });

    if (permitedEnterprise != null) {
      if (permitedEnterprise.getCanAdd()) {
        addButton.enable();
      } else {
        addButton.disable();
      }
      if (permitedEnterprise.getCanUpdate()) {
        editButton.enable();
      } else {
        editButton.disable();
      }
      if (permitedEnterprise.getCanDelete()) {
        deleteButton.enable();
      } else {
        deleteButton.disable();
      }
    }

    content.setTopComponent(toolBar);
    add(content);
  }
  protected void onRender(Element target, int index) {
    super.onRender(target, index);

    final FitLayout fl = new FitLayout();

    LayoutContainer layoutContainer = new LayoutContainer();
    layoutContainer.setBorders(false);
    layoutContainer.setLayout(fl);

    VerticalPanel vp = new VerticalPanel();
    vp.setSpacing(3);

    ContentPanel cpGrid = new ContentPanel();
    cpGrid.setHeaderVisible(true);
    cpGrid.setHeading("Lista Dipendenti.");
    cpGrid.setBorders(false);
    cpGrid.setFrame(true);
    cpGrid.setHeight((h - 65));
    cpGrid.setWidth(w - 250);
    cpGrid.setScrollMode(Scroll.AUTO);
    cpGrid.setLayout(new FitLayout());
    cpGrid.setButtonAlign(HorizontalAlignment.CENTER);
    Resizable r = new Resizable(cpGrid);

    btnPrint = new Button();
    btnPrint.setEnabled(true);
    btnPrint.setIcon(AbstractImagePrototype.create(MyImages.INSTANCE.print24()));
    btnPrint.setIconAlign(IconAlign.TOP);
    btnPrint.setToolTip("Stampa");
    btnPrint.setSize(26, 26);
    btnPrint.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {
            SessionManagementService.Util.getInstance()
                .setDatiReportCostiDip(
                    "RIEP.COSTI",
                    store.getModels(),
                    new AsyncCallback<Boolean>() {

                      @Override
                      public void onFailure(Throwable caught) {
                        Window.alert("Error on setNomeReport()");
                      }

                      @Override
                      public void onSuccess(Boolean result) {
                        if (result) fp.submit();
                        else
                          Window.alert(
                              "Problemi durante il settaggio dei parametri in Sessione (http)");
                      }
                    });
          }
        });

    btnAdd = new Button();
    btnAdd.setStyleAttribute("padding-left", "2px");
    btnAdd.setIcon(AbstractImagePrototype.create(MyImages.INSTANCE.add()));
    btnAdd.setIconAlign(IconAlign.TOP);
    btnAdd.setSize(26, 26);
    btnAdd.setToolTip("Nuova Offerta");
    btnAdd.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            RiepilogoCostiDipendentiModel am =
                new RiepilogoCostiDipendentiModel(
                    0, 0, "", "0.00", "", "0", "0.00", "0.00", "0.00", "0.00", "0.00", "0.00", "",
                    "", "");

            gridRiepilogo.stopEditing();
            store.insert(am, 0);
            gridRiepilogo.startEditing(store.indexOf(am), 0);
          }
        });

    btnConfirm = new Button();
    btnConfirm.setEnabled(true);
    btnConfirm.setIcon(AbstractImagePrototype.create(MyImages.INSTANCE.confirm()));
    btnConfirm.setIconAlign(IconAlign.TOP);
    btnConfirm.setToolTip("Conferma modifiche");
    btnConfirm.setSize(26, 26);
    btnConfirm.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {

            RiepilogoCostiDipendentiModel c = new RiepilogoCostiDipendentiModel();

            for (Record record : store.getModifiedRecords()) {

              c = (RiepilogoCostiDipendentiModel) record.getModel();

              AdministrationService.Util.getInstance()
                  .editDatiCostiAzienda(
                      c,
                      new AsyncCallback<Boolean>() {

                        @Override
                        public void onFailure(Throwable caught) {
                          Window.alert("Errore di connessione on insertNewOffertaWithRda();");
                        }

                        @Override
                        public void onSuccess(Boolean result) {
                          if (result) {
                            caricaTabellaDati();
                          } else {
                            Window.alert(
                                "error: Impossibile effettuare l'inserimento/modifica dei dati!");
                          }
                        }
                      });
            }
          }
        });

    if ((ruolo.compareTo("PM") == 0)) {
      btnConfirm.disable();
      btnAdd.disable();
    }

    smplcmbxSede = new SimpleComboBox<String>();
    smplcmbxSede.setFieldLabel("Sede");
    smplcmbxSede.setWidth(65);
    smplcmbxSede.setEmptyText("Sede..");
    smplcmbxSede.setAllowBlank(false);
    smplcmbxSede.add("T");
    smplcmbxSede.add("B");
    smplcmbxSede.setStyleAttribute("padding-left", "2px");
    smplcmbxSede.addListener(
        Events.Select,
        new Listener<BaseEvent>() {
          @Override
          public void handleEvent(BaseEvent be) {
            caricaTabellaDati();
          }
        });

    // caricaTabellaDati();

    cm = new ColumnModel(createColumns());
    gridRiepilogo = new EditorGrid<RiepilogoCostiDipendentiModel>(store, cm);
    gridRiepilogo.setBorders(false);
    gridRiepilogo.setColumnLines(true);
    gridRiepilogo.setStripeRows(true);
    gridRiepilogo.setItemId("grid");
    gridRiepilogo.setSelectionModel(csm);

    fp.setMethod(FormPanel.METHOD_POST);
    fp.setAction(url);
    fp.addSubmitCompleteHandler(new FormSubmitCompleteHandler());
    fp.add(btnPrint);
    ContentPanel cp = new ContentPanel();
    cp.setHeaderVisible(false);
    cp.add(fp);

    ToolBar tlBar = new ToolBar();
    tlBar.add(smplcmbxSede);
    tlBar.add(btnAdd);
    tlBar.add(btnConfirm);
    tlBar.add(new SeparatorToolItem());
    tlBar.add(cp);

    cpGrid.setTopComponent(tlBar);
    cpGrid.add(gridRiepilogo);

    layoutContainer.add(cpGrid, new FitData(3, 3, 3, 3));

    add(layoutContainer);
  }
  private void initialize(BillTypeManager billTypeManager, ServiceLocations serviceLocations) {
    FormData formData = new FormData("-20");

    matchingField = new MatchingItemsControl();
    Widget storeField = createStoreField();
    Widget billTypeField = createBillTypeField(billTypeManager);
    Widget costField = createCostField();
    Widget notesField = createNotesField();
    Widget dateField = createDateField();

    Button okButton = new Button("OK");

    okButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            if (isSplit) {
              submitSplitPurchase();
            } else {
              if (isValid()) {
                submitPurchase();
              } else {
                Window.alert("Not valid");
              }
            }
          }
        });

    Button cancelButton = new Button("Cancel");

    cancelButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            finishPurchase();
          }
        });

    submitWithMatchesButton = new Button("Submit With Matches");

    submitWithMatchesButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            sendPurchase();
          }
        });

    submitWithMatchesButton.setVisible(false);

    Button splitButton = new Button("Split");
    splitButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            toggleSplit();
          }
        });

    VerticalPanel labelPanel = new VerticalPanel();
    VerticalPanel controlPanel = new VerticalPanel();
    labelPanel.add(new Label("Store"));
    labelPanel.add(new Label("Cost"));
    labelPanel.add(new Label("Date"));
    labelPanel.add(new Label("Bill Type"));
    labelPanel.add(new Label("Note"));
    controlPanel.add(storeField);
    controlPanel.add(costField);
    controlPanel.add(dateField);
    controlPanel.add(billTypeField);
    controlPanel.add(notesField);

    fieldPanel = new Grid(5, 2);

    fieldPanel.setText(0, 0, "Store:");
    fieldPanel.setWidget(0, 1, storeField);

    fieldPanel.setText(1, 0, "Cost:");
    fieldPanel.setWidget(1, 1, costField);

    fieldPanel.setText(2, 0, "Date:");
    fieldPanel.setWidget(2, 1, dateField);

    fieldPanel.setText(3, 0, "Bill Type:");
    fieldPanel.setWidget(3, 1, billTypeField);

    fieldPanel.setText(4, 0, "Note:");
    fieldPanel.setWidget(4, 1, notesField);

    HorizontalPanel buttonPanel = new HorizontalPanel();

    buttonPanel.add(okButton);
    buttonPanel.add(cancelButton);

    add(splitButton);
    add(fieldPanel);
    add(matchingField);
    add(submitWithMatchesButton);
    add(buttonPanel);
  }
  @Override
  public Widget asWidget() {

    // show window
    window.setSize(400, 310);
    window.setPlain(true);
    window.setModal(true);
    window.setClosable(false);
    window.setResizable(false);
    window.setHeading(AppController.Lang.AddNew(AppController.Lang.RunValue().toLowerCase()));
    window.setLayout(new FitLayout());

    // form
    final FormData formData = new FormData("-20");
    FormPanel simple = new FormPanel();
    simple.setHeaderVisible(false);
    simple.setFrame(true);
    simple.setAutoWidth(true);
    simple.setLabelWidth(100);
    // run
    cbName.setDisplayField("n");
    cbName.setFieldLabel(AppController.Lang.Run());
    cbName.setStore(storeName);
    cbName.setEnabled(false);
    cbName.setMinLength(Constants.LIMIT_NAME_MIN);
    cbName.setMaxLength(Constants.LIMIT_NAME_MAX);
    cbName.setAllowBlank(false);
    cbName.setTriggerAction(TriggerAction.ALL);
    simple.add(cbName, formData);
    // date
    final DateField tfDate = CommonUtils.getDateField(date);
    simple.add(tfDate, formData);
    // time
    final TimeSelectFieldView tfTime = new TimeSelectFieldView(0, null);
    tfTime.setFieldLabel(AppController.Lang.Time());
    simple.add(tfTime);

    // duration
    final MySpinnerField tfDuration = CommonUtils.getDurationSpinner();
    simple.add(tfDuration, formData);
    // pulse
    final SpinnerField tfPulse = CommonUtils.getPulseSpinner();
    simple.add(tfPulse, formData);
    // pulse max
    final SpinnerField tfPulseMax = CommonUtils.getPulseSpinner();
    tfPulseMax.setFieldLabel(AppController.Lang.MaxPulse());
    simple.add(tfPulseMax, formData);
    // calories
    final SpinnerField tfCalories = CommonUtils.getCaloriesSpinner();
    simple.add(tfCalories, formData);

    // info
    final TextArea tfInfo = new TextArea();
    tfInfo.setPreventScrollbars(true);
    tfInfo.setFieldLabel(AppController.Lang.Info());
    simple.add(tfInfo, formData);

    // buttons eventhandler
    Button btnAdd = new Button(AppController.Lang.Add());
    btnAdd.setScale(ButtonScale.MEDIUM);
    btnAdd.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @SuppressWarnings("deprecation")
          @Override
          public void componentSelected(ButtonEvent ce) {
            try {
              // return model
              if (handler != null) {

                final int pulse = (int) tfPulse.getValue().doubleValue();
                final int pulseMax = (int) tfPulseMax.getValue().doubleValue();
                final int calories = (int) tfCalories.getValue().doubleValue();
                // date and time
                Date date = tfDate.getValue();
                final double time = CommonUtils.getTimeToSeconds(tfTime.getValue());
                date.setHours((int) (time / 3600));
                date.setMinutes((int) ((time % 3600) / 60));
                date = CommonUtils.trimDateToDatabase(date, false);
                final String info = tfInfo.getValue();
                final long duration = tfDuration.getValue().intValue();

                RunValueModel value = new RunValueModel();
                value.setCalories(calories);
                value.setDate(date);
                value.setDuration(duration);
                value.setInfo(info);
                value.setPulse(pulse);
                value.setPulseMax(pulseMax);

                // get run
                RunModel run = null;
                // if no values
                if (cbName.getValue() == null) {
                  final String str = cbName.getRawValue();
                  run = new RunModel(0L, str);
                }
                // if user typed new value
                else if (!cbName.getRawValue().equals(cbName.getValue().getNameClient())) {
                  final String str = cbName.getRawValue();
                  run = new RunModel(0L, str);
                }
                // value selected from list
                else {
                  run = cbName.getValue();
                }

                handler.newValue(run, value);
              }

            } catch (Exception e) {
              Motiver.showException(e);
            }
          }
        });
    simple.addButton(btnAdd);
    Button btnCancel = new Button(AppController.Lang.Cancel());
    btnCancel.setScale(ButtonScale.MEDIUM);
    // hide window
    btnCancel.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            handler.cancel();
          }
        });
    simple.addButton(btnCancel);
    simple.setButtonAlign(HorizontalAlignment.CENTER);
    FormButtonBinding binding = new FormButtonBinding(simple);
    binding.addButton(btnAdd);
    window.add(simple);

    window.show();

    return this;
  }
Example #26
0
 /**
  * Creates a new button with the given text and specified selection listener.
  *
  * @param text the button's text
  * @param listener the selection listener
  */
 public Button(String text, SelectionListener<ButtonEvent> listener) {
   this(text);
   addSelectionListener(listener);
 }
Example #27
0
 /**
  * Creates a new button with the given text, iconStyle and specified selection listener.
  *
  * @param text the button text
  * @param icon the icon
  * @param listener the selection listener
  */
 public Button(String text, AbstractImagePrototype icon, SelectionListener<ButtonEvent> listener) {
   this(text, icon);
   addSelectionListener(listener);
 }
    CreateFormIntervalliOre() {

      setLabelWidth(30);
      setFrame(true);
      setButtonAlign(HorizontalAlignment.CENTER);
      setHeading("Dettaglio Ore.");
      setHeaderVisible(false);
      setWidth(700);
      setHeight(95);
      setStyleAttribute("padding-left", "10px");
      setStyleAttribute("padding-top", "10px");
      setBorders(false);

      Date retVal = null;
      try {
        retVal = DateTimeFormat.getFormat("dd-MM-yyyy").parse(01 + "-" + 03 + "-" + 2013);
      } catch (Exception e) {
        retVal = null;
      }

      giornoRiferimento.setValue(new Date());
      giornoRiferimento.setMinValue(retVal);
      giornoRiferimento.setItemId("data");
      dtfldGiorno.setValue(giornoRiferimento.getValue());

      ListStore<PersonaleModel> store = new ListStore<PersonaleModel>();
      cmbxDipendente.setStore(store);
      cmbxDipendente.setFieldLabel("Dipendente");
      cmbxDipendente.setEnabled(true);
      cmbxDipendente.setEmptyText("Selezionare il dipendente..");
      cmbxDipendente.setEditable(false);
      cmbxDipendente.setVisible(true);
      cmbxDipendente.setTriggerAction(TriggerAction.ALL);
      cmbxDipendente.setAllowBlank(false);
      cmbxDipendente.setDisplayField("nomeCompleto");
      cmbxDipendente.addListener(
          Events.OnClick,
          new Listener<BaseEvent>() {
            @Override
            public void handleEvent(BaseEvent be) {
              getAllDipendenti();
            }
          });

      ButtonBar buttonBarTop = new ButtonBar();
      buttonBarTop.setAlignment(HorizontalAlignment.CENTER);
      buttonBarTop.setStyleAttribute("padding-bottom", "5px");
      buttonBarTop.setBorders(false);
      buttonBarTop.setWidth(570);
      buttonBarTop.setItemId("buttonBar");

      // buttonBarTop.add(btnPrev);
      buttonBarTop.add(giornoRiferimento);
      buttonBarTop.add(cmbxDipendente);
      buttonBarTop.add(btnSend);
      // buttonBarTop.add(btnNext);

      btnInviaCommenti.setIcon(AbstractImagePrototype.create(MyImages.INSTANCE.escl1()));
      btnInviaCommenti.setToolTip("Segnala eventuali problemi o anomalie.");
      btnInviaCommenti.setSize(26, 26);
      btnInviaCommenti.setIconAlign(IconAlign.TOP);
      btnInviaCommenti.addSelectionListener(
          new SelectionListener<ButtonEvent>() {
            @Override
            public void componentSelected(ButtonEvent ce) {
              Dialog d = new DialogInvioCommenti(txtfldUsername.getValue().toString(), new Date());
              d.show();
            }
          });

      btnRiepilogoCommesse.setEnabled(true);
      btnRiepilogoCommesse.setSize(26, 26);
      btnRiepilogoCommesse.setIcon(AbstractImagePrototype.create(MyImages.INSTANCE.riep_comm()));
      btnRiepilogoCommesse.setToolTip("Riepilogo Commesse");
      btnRiepilogoCommesse.addSelectionListener(
          new SelectionListener<ButtonEvent>() {

            @Override
            public void componentSelected(ButtonEvent ce) {
              /*Dialog d= new Dialog();
              d.setHeaderVisible(true);
              d.setHeading("Riepilogo dettagliato (Commesse).");
              d.setSize(550, 605);
              d.add(new PanelRiepilogoGiornalieroCommesse(txtfldUsername.getValue().toString(), giornoRiferimento.getValue()));
              d.setButtons("");
              d.show();*/
              Date data = dtfldGiorno.getValue();
              Dialog d = new Dialog();
              d.setHeaderVisible(true);
              d.setConstrain(false);
              d.setHeading("Riepilogo dettagliato (Commesse).");
              d.setSize(1500, 650);
              d.add(
                  new PanelRiepilogoMeseGiornalieroCommesseHorizontal(
                      0,
                      txtfldUsername.getValue().toString(),
                      data,
                      "0.00",
                      "0.00",
                      "0.00",
                      "0.00"));
              d.setButtons("");
              d.show();
            }
          });

      frm.setHeaderVisible(false);
      frm.setBorders(false);
      frm.setItemId("formPanel");
      frm.setWidth(1060);
      frm.setHeight(890);
      frm.setStyleAttribute("padding-left", "0px");
      frm.setStyleAttribute("padding-top", "0px");
      frm.setScrollMode(Scroll.AUTO);

      main.setLayout(new ColumnLayout());
      main.setBorders(false);
      main.setStyleAttribute("margin-top", "-10px");
      main.setItemId("main");

      left.setStyleAttribute("padding-left", "10px");
      FormLayout layout = new FormLayout();
      left.setLayout(layout);
      left.setItemId("left");

      right.setStyleAttribute("padding-left", "30px");
      layout = new FormLayout();
      right.setLayout(layout);
      right.setItemId("right");

      ButtonBar btnBarOperazioni = new ButtonBar();
      btnBarOperazioni.setHeight(28);
      btnBarOperazioni.setAlignment(HorizontalAlignment.LEFT);
      btnBarOperazioni.setBorders(false);
      btnBarOperazioni.add(btnRiepilogoCommesse);
      btnBarOperazioni.add(btnInviaCommenti);
      btnBarOperazioni.add(btnConferma);

      left.add(btnBarOperazioni);
      left.add(buttonBarTop);

      main.add(left);
      frm.add(main);
      frm.layout(true);
      add(frm);

      btnSend.setSize(26, 26);
      btnSend.setIcon(AbstractImagePrototype.create(MyImages.INSTANCE.reload()));
      btnSend.setToolTip("Carica Dati");
      btnSend.addSelectionListener(
          new SelectionListener<ButtonEvent>() {
            @Override
            public void componentSelected(ButtonEvent ce) {
              txtfldUsername.setValue(
                  cmbxDipendente
                      .getValue()
                      .get("username")
                      .toString()); // setto il valore globale dell'username per il caricamento dei
                                    // vari fieldset
              dtfldGiorno.setValue(
                  giornoRiferimento
                      .getValue()); // setto il valore globale della data con la data selezionata
              reloadFoglioOre();
            }
          });

      // btnConferma.setSize(46, 46);
      btnConferma.setIcon(AbstractImagePrototype.create(MyImages.INSTANCE.saveLittle()));
      btnConferma.setIconAlign(IconAlign.TOP);
      btnConferma.setToolTip("Conferma");
      btnConferma.setSize(26, 26);
      btnConferma.addSelectionListener(
          new SelectionListener<ButtonEvent>() {

            @Override
            public void componentSelected(ButtonEvent ce) {

              if (frm.isValid()) {
                String username = new String();
                Date giorno = new Date();
                DateField dtfld = new DateField();

                username = cmbxDipendente.getValue().get("username");
                List<IntervalliCommesseModel> intervalliC =
                    new ArrayList<IntervalliCommesseModel>();

                FldsetIntervalliCommesse fldSetIntervalliC;
                LayoutContainer lc = new LayoutContainer();
                LayoutContainer lcR = new LayoutContainer();
                ButtonBar bttnBar = new ButtonBar();

                lc = (LayoutContainer) frm.getItemByItemId("main");
                // Intervalli IU
                lc = (LayoutContainer) lc.getItemByItemId("left");

                // Data
                bttnBar = (ButtonBar) lc.getItemByItemId("buttonBar");
                dtfld = (DateField) bttnBar.getItemByItemId("data");
                giorno = dtfld.getValue();

                // Intervalli Comm
                fldSetIntervalliC =
                    (FldsetIntervalliCommesse) lc.getItemByItemId("fldSetIntervalliC");
                if (fldSetIntervalliC.getItemCount() > 1)
                  intervalliC = elaboraIntervalliC(fldSetIntervalliC);

                // Giustificativi
                lcR = (LayoutContainer) frm.getItemByItemId("main");
                lcR = (LayoutContainer) lcR.getItemByItemId("right");

                // txtfldOreTotali=fldSetGiustificativi.txtfldOreTotEffettive;

                AdministrationService.Util.getInstance()
                    .insertFoglioOreGiorno(
                        username,
                        giorno,
                        intervalliC,
                        new AsyncCallback<Boolean>() {

                          @Override
                          public void onFailure(Throwable caught) {
                            Window.alert("Errore di connessione on insertFoglioOreGiorno()!");
                          }

                          @Override
                          public void onSuccess(Boolean result) {
                            if (result) {
                              Window.alert("Caricamento avvenuto con successo.");
                              reloadFoglioOre();
                            } else {
                              Window.alert("error: Impossibile salvare i dati!");
                            }
                          }
                        });
              }
            }
          });
    }
Example #29
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);
  }