Example #1
0
  public GridControl(Object[] objects) {

    listGrid = new ListGrid();
    listGrid.setFields(getFields());
    toolStrip = new ToolStrip();
    this.addMember(toolStrip);
    this.addMember(listGrid);

    com.smartgwt.client.widgets.events.ClickHandler tsbStateHandler =
        new com.smartgwt.client.widgets.events.ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            Object objectSource = event.getSource();
            ttsbuttonClick(objectSource);
          }
        };
    tsbAdd =
        ClientUtils.createTSButton(
            "[SKIN]/actions/add.png",
            tsbStateHandler,
            SelectionType.BUTTON,
            "Add Object",
            "selection",
            toolStrip);
    tsbAdd.setSelected(false);

    tsbEdit =
        ClientUtils.createTSButton(
            "[SKIN]/actions/edit.png",
            tsbStateHandler,
            SelectionType.BUTTON,
            "Edit Object",
            "selection",
            toolStrip);
    tsbEdit.setSelected(false);

    tsbDelete =
        ClientUtils.createTSButton(
            "[SKIN]/actions/remove.png",
            tsbStateHandler,
            SelectionType.BUTTON,
            "Remove Object",
            "selection",
            toolStrip);
    tsbDelete.setSelected(false);

    listGrid.addDoubleClickHandler(
        new DoubleClickHandler() {
          @Override
          public void onDoubleClick(DoubleClickEvent event) {
            addEdit(listGrid.getSelectedRecord());
          }
        });
    if (objects != null)
      for (Object dscProp : objects) {
        Record record = new Record();
        setDataValue(dscProp, record);
        listGrid.addData(record);
      }
  }
  /**
   * Get view panel.
   *
   * @return The viewPanel Canvas
   */
  public Canvas getViewPanel() {
    VLayout layout = new VLayout(5);
    layout.setPadding(5);

    MapWidget mapWidget = new MapWidget("mapGuwWmsCountries", "appGuw");
    final RibbonTabLayout ribbon = new RibbonTabLayout(mapWidget, "appGuw", "guwRibbon1");
    ribbon.setSize("100%", "120px");

    ToolStrip toolStrip = new ToolStrip();
    toolStrip.setWidth100();
    ToolStripButton btn1 = new ToolStripButton("Toggle group title");
    btn1.addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            ribbon.getRibbonBar(0).setShowGroupTitles(!ribbon.getRibbonBar(0).isShowGroupTitles());
          }
        });
    toolStrip.addButton(btn1);
    layout.addMember(toolStrip);
    layout.addMember(ribbon);
    layout.addMember(mapWidget);
    return layout;
  }
  public void build(DataSource entityDataSource, DataSource... additionalDataSources) {
    VLayout leftVerticalLayout = new VLayout();
    leftVerticalLayout.setID("customerLeftVerticalLayout");
    leftVerticalLayout.setHeight100();
    leftVerticalLayout.setWidth("50%");
    leftVerticalLayout.setShowResizeBar(true);

    listDisplay =
        new DynamicEntityListView(
            BLCMain.getMessageManager().getString("customerListTitle"),
            entityDataSource,
            false,
            false);
    leftVerticalLayout.addMember(listDisplay);

    dynamicFormDisplay =
        new DynamicFormView(
            BLCMain.getMessageManager().getString("customerDetailsTitle"), entityDataSource);
    dynamicFormDisplay.setWidth("50%");
    ToolStrip toolbar = dynamicFormDisplay.getToolbar();
    toolbar.addFill();
    Label label = new Label();
    label.setContents(BLCMain.getMessageManager().getString("resetPasswordPrompt"));
    label.setWrap(false);
    toolbar.addMember(label);

    updateLoginButton = new ToolStripButton();
    updateLoginButton.setIcon(
        GWT.getModuleBaseURL() + "sc/skins/Enterprise/images/headerIcons/settings.png");
    updateLoginButton.setDisabled(true);
    toolbar.addButton(updateLoginButton);
    toolbar.addSpacer(6);

    addMember(leftVerticalLayout);
    addMember(dynamicFormDisplay);
  }
  public Canvas getViewPanel() {

    VLayout layout = new VLayout(15);
    layout.setWidth(650);
    layout.setAutoHeight();

    final ListGrid countryGrid = new ListGrid();
    countryGrid.setLeaveScrollbarGap(true);
    countryGrid.setCanFreezeFields(false);
    countryGrid.setCanGroupBy(false);
    countryGrid.setWidth100();
    countryGrid.setHeight(224);
    countryGrid.setDataSource(CountryXmlDS.getInstance());
    countryGrid.setAutoFetchData(true);

    // allow users to add formula and summary fields
    // accessible in the grid header context menu
    countryGrid.setCanAddFormulaFields(true);
    countryGrid.setCanAddSummaryFields(true);

    ListGridField countryCodeField = new ListGridField("countryCode", "Flag", 50);
    countryCodeField.setAlign(Alignment.CENTER);
    countryCodeField.setType(ListGridFieldType.IMAGE);
    countryCodeField.setImageURLPrefix("flags/16/");
    countryCodeField.setImageURLSuffix(".png");
    countryCodeField.setCanSort(false);

    ListGridField nameField = new ListGridField("countryName", "Country");
    ListGridField capitalField = new ListGridField("capital", "Capital");

    ListGridField populationField = new ListGridField("population", "Population");
    populationField.setCellFormatter(
        new CellFormatter() {
          public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
            if (value == null) return null;
            try {
              NumberFormat nf = NumberFormat.getFormat("0,000");
              return nf.format(((Number) value).longValue());
            } catch (Exception e) {
              return value.toString();
            }
          }
        });

    ListGridField areaField = new ListGridField("area", "Area (km²)");
    areaField.setType(ListGridFieldType.INTEGER);
    areaField.setCellFormatter(
        new CellFormatter() {
          public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
            if (value == null) return null;
            String val = null;
            try {
              NumberFormat nf = NumberFormat.getFormat("0,000");
              val = nf.format(((Number) value).longValue());
            } catch (Exception e) {
              return value.toString();
            }
            return val + "km&sup2";
          }
        });
    countryGrid.setFields(countryCodeField, nameField, capitalField, populationField, areaField);

    ToolStripButton formulaButton =
        new ToolStripButton("Formula Builder", "crystal/oo/sc_insertformula.png");
    formulaButton.setAutoFit(true);
    formulaButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            countryGrid.addFormulaField();
          }
        });

    ToolStripButton summaryBuilder =
        new ToolStripButton("Summary Builder", "crystal/16/apps/tooloptions.png");
    summaryBuilder.setAutoFit(true);
    summaryBuilder.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            countryGrid.addSummaryField();
          }
        });

    ToolStripButton savePreference = new ToolStripButton("Persist State", "silk/database_gear.png");
    savePreference.setAutoFit(true);
    savePreference.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            String viewState = countryGrid.getViewState();
            Offline.put("exampleState", viewState);
            SC.say("Preferences persisted.");
          }
        });

    // toolstrip to attach to the country grid
    ToolStrip countryGridToolStrip = new ToolStrip();
    countryGridToolStrip.setWidth100();
    countryGridToolStrip.addFill();
    countryGridToolStrip.addButton(formulaButton);
    countryGridToolStrip.addButton(summaryBuilder);
    countryGridToolStrip.addSeparator();
    countryGridToolStrip.addButton(savePreference);

    VLayout countryGridLayout = new VLayout(0);
    countryGridLayout.setWidth(650);
    countryGridLayout.addMember(countryGridToolStrip);
    countryGridLayout.addMember(countryGrid);
    layout.addMember(countryGridLayout);

    final String previouslySavedState = (String) Offline.get("exampleState");
    if (previouslySavedState != null) {
      countryGrid.addDrawHandler(
          new DrawHandler() {
            @Override
            public void onDraw(DrawEvent event) {
              // restore any previously saved view state for this grid
              countryGrid.setViewState(previouslySavedState);
            }
          });
    }

    return layout;
  }
  public UserPermissionView(Boolean canReorder, Boolean canEdit) {
    setHeight100();
    setWidth100();
    setBackgroundColor("#eaeaea");
    setOverflow(Overflow.AUTO);

    HStack hStack = new HStack(10);
    hStack.setID("userPermissionHStack");

    hStack.setHeight("45%");
    hStack.setWidth100();
    hStack.setBackgroundColor("#eaeaea");
    hStack.setAlign(Alignment.CENTER);

    VLayout stack = new VLayout();
    stack.setID("userPermissionVerticalLayout");
    stack.setHeight100();
    stack.setWidth100();

    toolBar = new ToolStrip();
    toolBar.setHeight(30);
    toolBar.setWidth100();
    toolBar.setMinWidth(300);
    toolBar.addSpacer(6);
    addButton = new ToolStripButton();
    addButton.setTitle(BLCMain.getMessageManager().getString("addTitle"));
    addButton.setIcon(GWT.getModuleBaseURL() + "sc/skins/Enterprise/images/actions/add.png");
    addButton.setDisabled(true);
    toolBar.addButton(addButton);
    removeButton = new ToolStripButton();
    removeButton.setTitle(BLCMain.getMessageManager().getString("removeTitle"));
    removeButton.setIcon(GWT.getModuleBaseURL() + "sc/skins/Enterprise/images/actions/remove.png");
    removeButton.setDisabled(true);
    toolBar.addButton(removeButton);
    toolBar.addSpacer(6);
    toolBar.setDisabled(false);
    toolBar.addFill();
    stack.addMember(toolBar);

    grid = new ListGrid();
    grid.setAutoFetchData(false);
    grid.setShowHeader(true);
    grid.setShowHeaderContextMenu(false);
    grid.setPreventDuplicates(true);
    grid.setCanReorderRecords(canReorder);
    grid.setDisabled(true);
    grid.setCanSort(false);
    grid.setCellPadding(5);
    grid.setCanEdit(canEdit);
    grid.setEditEvent(ListGridEditEvent.DOUBLECLICK);
    grid.setEditByCell(true);
    grid.setAutoSaveEdits(true);
    grid.setSaveByCell(true);
    grid.setAlternateRecordStyles(true);
    grid.setCanGroupBy(false);
    if (!canEdit) {
      grid.setAlternateBodyStyleName("editRowDisabled");
    }
    stack.addMember(grid);

    hStack.addMember(stack);
    hStack.setOverflow(Overflow.AUTO);

    addMember(hStack);
  }
  public TabCalendar() {
    try {
      setTitle(CallCenter.constants.menuCalendar());
      setCanClose(true);

      datasource = DataSource.get("CalSecDS");

      mainLayout = new VLayout(5);
      mainLayout.setWidth100();
      mainLayout.setHeight100();
      mainLayout.setMargin(5);

      searchForm = new DynamicForm();
      searchForm.setAutoFocus(true);
      searchForm.setWidth(780);
      searchForm.setTitleWidth(300);
      searchForm.setNumCols(4);
      mainLayout.addMember(searchForm);

      calendarStateItem = new ComboBoxItem();
      calendarStateItem.setTitle(CallCenter.constants.type());
      calendarStateItem.setWidth(300);
      calendarStateItem.setName("calendar_state_id");
      calendarStateItem.setValueMap(ClientMapUtil.getInstance().getCalendarStates());
      calendarStateItem.setAddUnknownValues(false);

      secCalendarTypeItem = new ComboBoxItem();
      secCalendarTypeItem.setTitle(CallCenter.constants.moonPhase());
      secCalendarTypeItem.setWidth(300);
      secCalendarTypeItem.setName("calendar_event_id");
      secCalendarTypeItem.setValueMap(ClientMapUtil.getInstance().getSecCalendarTypes());
      secCalendarTypeItem.setAddUnknownValues(false);

      calendarDayItem = new DateItem();
      calendarDayItem.setTitle(CallCenter.constants.date());
      calendarDayItem.setWidth(300);
      calendarDayItem.setValue(new Date());
      calendarDayItem.setName("calendar_day");
      calendarDayItem.setHint(CallCenter.constants.choose());

      descriptionItem = new TextItem();
      descriptionItem.setTitle(CallCenter.constants.description());
      descriptionItem.setName("calendar_description");
      descriptionItem.setWidth(300);

      commentItem = new TextItem();
      commentItem.setTitle(CallCenter.constants.comment());
      commentItem.setName("calendar_comment");
      commentItem.setWidth(300);

      byCalendarDayItem = new CheckboxItem();
      byCalendarDayItem.setTitle(CallCenter.constants.searchByDate());
      byCalendarDayItem.setWidth(300);
      byCalendarDayItem.setName("buCalDaySearch");
      byCalendarDayItem.setValue(false);

      searchForm.setFields(
          calendarStateItem,
          secCalendarTypeItem,
          descriptionItem,
          commentItem,
          byCalendarDayItem,
          calendarDayItem);

      HLayout buttonLayout = new HLayout(5);
      buttonLayout.setWidth(780);
      buttonLayout.setHeight(30);
      buttonLayout.setAlign(Alignment.RIGHT);

      clearButton = new IButton();
      clearButton.setTitle(CallCenter.constants.clear());

      findButton = new IButton();
      findButton.setTitle(CallCenter.constants.find());

      buttonLayout.setMembers(findButton, clearButton);
      mainLayout.addMember(buttonLayout);

      ToolStrip toolStrip = new ToolStrip();
      toolStrip.setWidth(780);
      toolStrip.setPadding(5);
      mainLayout.addMember(toolStrip);

      addBtn = new ToolStripButton(CallCenter.constants.add(), "addIcon.png");
      addBtn.setLayoutAlign(Alignment.LEFT);
      addBtn.setWidth(50);
      toolStrip.addButton(addBtn);

      editBtn = new ToolStripButton(CallCenter.constants.modify(), "editIcon.png");
      editBtn.setLayoutAlign(Alignment.LEFT);
      editBtn.setWidth(50);
      toolStrip.addButton(editBtn);

      disableBtn = new ToolStripButton(CallCenter.constants.disable(), "deleteIcon.png");
      disableBtn.setLayoutAlign(Alignment.LEFT);
      disableBtn.setWidth(50);
      toolStrip.addButton(disableBtn);

      activateBtn = new ToolStripButton(CallCenter.constants.enable(), "restoreIcon.gif");
      activateBtn.setLayoutAlign(Alignment.LEFT);
      activateBtn.setWidth(50);
      toolStrip.addButton(activateBtn);

      toolStrip.addSeparator();

      copyBtn = new ToolStripButton(CallCenter.constants.copy(), "copy.png");
      copyBtn.setLayoutAlign(Alignment.LEFT);
      copyBtn.setWidth(50);
      toolStrip.addButton(copyBtn);

      listGrid =
          new ListGrid() {
            protected String getCellCSSText(ListGridRecord record, int rowNum, int colNum) {
              ListGridRecord countryRecord = (ListGridRecord) record;
              if (countryRecord == null) {
                return super.getCellCSSText(record, rowNum, colNum);
              }
              Integer deleted = countryRecord.getAttributeAsInt("deleted");
              if (deleted != null && !deleted.equals(0)) {
                return "color:red;";
              } else {
                return super.getCellCSSText(record, rowNum, colNum);
              }
            };
          };

      listGrid.setWidth(780);
      listGrid.setHeight(260);
      listGrid.setAlternateRecordStyles(true);
      listGrid.setDataSource(datasource);
      listGrid.setAutoFetchData(false);
      listGrid.setShowFilterEditor(false);
      listGrid.setCanEdit(false);
      listGrid.setCanRemoveRecords(false);
      listGrid.setFetchOperation("searchAllSecularCalendars");
      listGrid.setShowRowNumbers(true);
      listGrid.setCanHover(true);
      listGrid.setShowHover(true);
      listGrid.setShowHoverComponents(true);

      datasource.getField("calendar_day").setTitle(CallCenter.constants.date());
      datasource.getField("event").setTitle(CallCenter.constants.moonPhase());
      datasource.getField("state").setTitle(CallCenter.constants.type());
      datasource.getField("sun_rise").setTitle(CallCenter.constants.order());
      datasource.getField("calendar_description").setTitle(CallCenter.constants.description());

      datasource.getField("calendar_comment").setTitle(CallCenter.constants.comment());
      datasource.getField("rec_date").setTitle(CallCenter.constants.recDate());
      datasource.getField("rec_user").setTitle(CallCenter.constants.recUser());
      datasource.getField("upd_date").setTitle(CallCenter.constants.updDate());
      datasource.getField("upd_user").setTitle(CallCenter.constants.updUser());

      ListGridField calendar_day =
          new ListGridField("calendar_day", CallCenter.constants.date(), 150);
      ListGridField event = new ListGridField("event", CallCenter.constants.moonPhase(), 150);
      ListGridField state = new ListGridField("state", CallCenter.constants.type(), 80);
      ListGridField sun_rise = new ListGridField("sun_rise", CallCenter.constants.sunRise(), 100);
      ListGridField calendar_description =
          new ListGridField("calendar_description", CallCenter.constants.description(), 250);

      calendar_day.setAlign(Alignment.LEFT);
      event.setAlign(Alignment.LEFT);
      state.setAlign(Alignment.CENTER);
      sun_rise.setAlign(Alignment.CENTER);

      listGrid.setFields(calendar_day, event, state, sun_rise, calendar_description);

      mainLayout.addMember(listGrid);
      findButton.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              search();
            }
          });
      clearButton.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              calendarStateItem.clearValue();
              secCalendarTypeItem.clearValue();
              calendarDayItem.clearValue();
              descriptionItem.clearValue();
              commentItem.clearValue();
            }
          });
      addBtn.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              DlgAddEditSecCalendar dlgEditSecCalendar =
                  new DlgAddEditSecCalendar(listGrid, null, false);
              dlgEditSecCalendar.show();
            }
          });

      editBtn.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              ListGridRecord listGridRecord = listGrid.getSelectedRecord();
              if (listGridRecord == null) {
                SC.say(CallCenter.constants.pleaseSelrecord());
                return;
              }
              DlgAddEditSecCalendar dlgEditSecCalendar =
                  new DlgAddEditSecCalendar(listGrid, listGridRecord, false);
              dlgEditSecCalendar.show();
            }
          });

      copyBtn.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              ListGridRecord listGridRecord = listGrid.getSelectedRecord();
              if (listGridRecord == null) {
                SC.say(CallCenter.constants.pleaseSelrecord());
                return;
              }
              DlgAddEditSecCalendar dlgEditSecCalendar =
                  new DlgAddEditSecCalendar(listGrid, listGridRecord, true);
              dlgEditSecCalendar.show();
            }
          });

      disableBtn.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              ListGridRecord listGridRecord = listGrid.getSelectedRecord();
              if (listGridRecord == null) {
                SC.say(CallCenter.constants.pleaseSelrecord());
                return;
              }
              Integer deleted = listGridRecord.getAttributeAsInt("deleted");
              if (!deleted.equals(0)) {
                SC.say(CallCenter.constants.recordAlrDisabled());
                return;
              }
              final Integer calendar_id = listGridRecord.getAttributeAsInt("calendar_id");
              SC.ask(
                  CallCenter.constants.askForDisable(),
                  new BooleanCallback() {
                    @Override
                    public void execute(Boolean value) {
                      if (value) {
                        changeStatus(calendar_id, 1);
                      }
                    }
                  });
            }
          });
      activateBtn.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              ListGridRecord listGridRecord = listGrid.getSelectedRecord();
              if (listGridRecord == null) {
                SC.say(CallCenter.constants.pleaseSelrecord());
                return;
              }
              Integer deleted = listGridRecord.getAttributeAsInt("deleted");
              if (deleted.equals(0)) {
                SC.say(CallCenter.constants.recordAlrEnabled());
                return;
              }
              final Integer calendar_id = listGridRecord.getAttributeAsInt("calendar_id");
              SC.ask(
                  CallCenter.constants.askForEnable(),
                  new BooleanCallback() {
                    @Override
                    public void execute(Boolean value) {
                      if (value) {
                        changeStatus(calendar_id, 0);
                      }
                    }
                  });
            }
          });

      TabSet tabSet = new TabSet();
      tabSet.setWidth(780);
      Tab tabDetViewer = new Tab(CallCenter.constants.view());
      final DetailViewer detailViewer = new DetailViewer();
      detailViewer.setDataSource(datasource);
      detailViewer.setWidth(750);
      tabDetViewer.setPane(detailViewer);

      listGrid.addRecordClickHandler(
          new RecordClickHandler() {
            public void onRecordClick(RecordClickEvent event) {
              detailViewer.viewSelectedData(listGrid);
            }
          });

      listGrid.addRecordDoubleClickHandler(
          new RecordDoubleClickHandler() {
            @Override
            public void onRecordDoubleClick(RecordDoubleClickEvent event) {
              ListGridRecord listGridRecord = listGrid.getSelectedRecord();
              if (listGridRecord == null) {
                SC.say(CallCenter.constants.pleaseSelrecord());
                return;
              }
              DlgAddEditSecCalendar dlgEditSecCalendar =
                  new DlgAddEditSecCalendar(listGrid, listGridRecord, false);
              dlgEditSecCalendar.show();
            }
          });

      tabSet.setTabs(tabDetViewer);
      mainLayout.addMember(tabSet);
      setPane(mainLayout);
    } catch (Exception e) {
      e.printStackTrace();
      SC.say(e.getMessage().toString());
    }
  }
Example #7
0
  public PZoneChange() {
    restrictedEdits = DocFlow.user_obj.getZoneConfiguration().getRestricted_edits();
    CHARCOUNT = DocFlow.user_obj.getZoneConfiguration().getCharcount();
    tsMain = new ToolStrip();
    tsMain.setWidth100();
    HashMap<String, String> listSqls = new HashMap<String, String>();
    listSqls.put("" + ClSelection.T_REGION, "" + ClSelection.T_REGION);
    listSqls.put("" + ClSelection.T_CUST_TYPE, "" + ClSelection.T_CUST_TYPE);
    dsZoneDS = DocFlow.getDataSource("ZoneDS");
    dsCustomer = DocFlow.getDataSource("CustomerDS");
    miSearch = new ToolStripButton("Search");
    tiNewZone = new TextItem("newzone", "New Zone");
    biSaveData = new ButtonItem("saveData", "Change Zone");

    tiNewZone.addKeyPressHandler(
        new KeyPressHandler() {

          @Override
          public void onKeyPress(KeyPressEvent event) {
            newZoneKeyPressed(event);
          }
        });
    VLayout vl = new VLayout();

    dmCriteria = new DynamicForm();
    dmCriteria.setNumCols(4);
    dmCriteria.setHeight("8%");
    dmCriteria.setTitleOrientation(TitleOrientation.TOP);
    siCustomerType = new SelectItem("custypeid", "Customer Type");
    siZones = new SelectItem("zones", "Zones");
    siZones.setValueField("zone");
    siZones.setAutoFetchData(false);
    siZones.setDisplayField("zone");
    siZones.setOptionDataSource(dsZoneDS);

    tsMain.setHeight("15");
    vl.addMember(tsMain);
    tsMain.addButton(miSearch);
    vl.addMember(dmCriteria);
    lgCustomers = new ListGrid();
    lgCustomers.setDataSource(dsCustomer);
    lgCustomers.setAutoFetchData(false);
    lgCustomers.setShowResizeBar(false);
    lgCustomers.setCanDragRecordsOut(true);
    lgCustomers.setDragDataAction(DragDataAction.COPY);
    lgCustomers.setHeight100();
    lgCustomers.setHeight100();

    DataSource dsSelectedData = new DataSource();
    dsSelectedData.setClientOnly(true);

    DataSourceIntegerField dsfcusid = new DataSourceIntegerField("cusid", "Customer ID");
    dsfcusid.setPrimaryKey(true);

    DataSourceTextField dsZone = new DataSourceTextField("zone", "Zone");
    dsSelectedData.setFields(dsfcusid, dsZone);

    lgZoneCustomers = new ListGrid();
    lgZoneCustomers.setDataSource(dsSelectedData);
    lgZoneCustomers.setAutoFetchData(false);
    lgZoneCustomers.setCanAcceptDroppedRecords(true);
    lgZoneCustomers.setCanRemoveRecords(true);
    lgZoneCustomers.setAutoFetchData(false);
    lgZoneCustomers.setPreventDuplicates(true);
    lgZoneCustomers.setHeight100();
    lgZoneCustomers.setWidth100();

    HStack hStack = new HStack(10);
    hStack.setWidth100();
    hStack.setHeight100();
    hStack.setShowEdges(true);

    VStack vStack = new VStack();
    vStack.setHeight100();
    vStack.setWidth("60%");
    vStack.addMember(lgCustomers);
    hStack.addMember(vStack);
    TransferImgButton arrowImg = new TransferImgButton(TransferImgButton.RIGHT);
    arrowImg.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            lgZoneCustomers.transferSelectedData(lgCustomers);
          }
        });

    TransferImgButton arrowImgLeft = new TransferImgButton(TransferImgButton.LEFT);
    arrowImgLeft.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            lgZoneCustomers.removeSelectedData();
          }
        });
    hStack.addMember(arrowImg);
    hStack.addMember(arrowImgLeft);
    VStack vStack2 = new VStack();
    vStack2.setHeight100();
    vStack2.setWidth("40%");
    vStack2.addMember(lgZoneCustomers);
    hStack.addMember(vStack2);

    miSearch.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            search();
          }
        });

    lgCustomers.addClickHandler(
        new com.smartgwt.client.widgets.events.ClickHandler() {

          @Override
          public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {}
        });

    vl.addMember(hStack);

    this.addMember(vl);
    DocFlow.docFlowService.getListTypesForDocument(
        listSqls,
        -1,
        new AsyncCallback<HashMap<String, ArrayList<ClSelectionItem>>>() {

          @Override
          public void onFailure(Throwable caught) {
            setResults(null);
          }

          @Override
          public void onSuccess(HashMap<String, ArrayList<ClSelectionItem>> result) {

            setResults(result);
          }
        });
  }
  public TabBillingComps() {
    try {

      setTitle(CallCenterBK.constants.billingComps());
      setCanClose(true);

      billingCompsDS = DataSource.get("BillingCompsDS");

      mainLayout = new VLayout(5);
      mainLayout.setWidth100();
      mainLayout.setHeight100();
      mainLayout.setMargin(5);

      searchForm = new DynamicForm();
      searchForm.setAutoFocus(true);
      searchForm.setWidth(830);
      searchForm.setTitleWidth(250);
      searchForm.setNumCols(4);
      mainLayout.addMember(searchForm);

      billingCompNameItem = new TextItem();
      billingCompNameItem.setTitle(CallCenterBK.constants.companyName());
      billingCompNameItem.setWidth(250);
      billingCompNameItem.setName("billingCompNameItem");

      phoneIndexItem = new TextItem();
      phoneIndexItem.setTitle(CallCenterBK.constants.index());
      phoneIndexItem.setWidth(250);
      phoneIndexItem.setName("phoneIndexItem");

      hasCalcItem = new SelectItem();
      hasCalcItem.setTitle(CallCenterBK.constants.hasCalculation());
      hasCalcItem.setWidth(250);
      hasCalcItem.setName("hasCalcItem");
      hasCalcItem.setDefaultToFirstOption(true);
      hasCalcItem.setValueMap(ClientMapUtil.getInstance().getHasCalculations());

      operatorItem = new SelectItem();
      operatorItem.setTitle(CallCenterBK.constants.operator());
      operatorItem.setWidth(200);
      operatorItem.setName("operator_src");
      operatorItem.setDefaultToFirstOption(true);
      ClientUtils.fillCombo(
          operatorItem, "OperatorsDS", "searchOperators", "operator_src", "operator_src_descr");

      searchForm.setFields(billingCompNameItem, phoneIndexItem, hasCalcItem, operatorItem);

      HLayout buttonLayout = new HLayout(5);
      buttonLayout.setWidth(830);
      buttonLayout.setHeight(30);
      buttonLayout.setAlign(Alignment.RIGHT);

      clearButton = new IButton();
      clearButton.setTitle(CallCenterBK.constants.clear());

      findButton = new IButton();
      findButton.setTitle(CallCenterBK.constants.find());

      buttonLayout.setMembers(findButton, clearButton);
      mainLayout.addMember(buttonLayout);

      ToolStrip toolStrip = new ToolStrip();
      toolStrip.setWidth100();
      toolStrip.setPadding(5);
      mainLayout.addMember(toolStrip);

      addBtn = new ToolStripButton(CallCenterBK.constants.add(), "addIcon.png");
      addBtn.setLayoutAlign(Alignment.LEFT);
      addBtn.setWidth(50);
      toolStrip.addButton(addBtn);

      editBtn = new ToolStripButton(CallCenterBK.constants.modify(), "editIcon.png");
      editBtn.setLayoutAlign(Alignment.LEFT);
      editBtn.setWidth(50);
      toolStrip.addButton(editBtn);

      deleteBtn = new ToolStripButton(CallCenterBK.constants.disable(), "deleteIcon.png");
      deleteBtn.setLayoutAlign(Alignment.LEFT);
      deleteBtn.setWidth(50);
      toolStrip.addButton(deleteBtn);

      toolStrip.addSeparator();

      billingCompBillByDayBtn =
          new ToolStripButton(CallCenterBK.constants.telCombBillByDay(), "billing.png");
      billingCompBillByDayBtn.setLayoutAlign(Alignment.LEFT);
      billingCompBillByDayBtn.setWidth(50);
      toolStrip.addButton(billingCompBillByDayBtn);

      billingCompBillByMonthBtn =
          new ToolStripButton(CallCenterBK.constants.telCombBillByMonth(), "billing.png");
      billingCompBillByMonthBtn.setLayoutAlign(Alignment.LEFT);
      billingCompBillByMonthBtn.setWidth(50);
      toolStrip.addButton(billingCompBillByMonthBtn);

      billingCompsGrid = new ListGrid();

      billingCompsGrid.setWidth100();
      billingCompsGrid.setHeight100();
      billingCompsGrid.setAlternateRecordStyles(true);
      billingCompsGrid.setDataSource(billingCompsDS);
      billingCompsGrid.setAutoFetchData(false);
      billingCompsGrid.setShowFilterEditor(false);
      billingCompsGrid.setCanEdit(false);
      billingCompsGrid.setCanRemoveRecords(false);
      billingCompsGrid.setFetchOperation("searchAllBillingComps");
      billingCompsGrid.setShowRowNumbers(true);
      billingCompsGrid.setCanHover(true);
      billingCompsGrid.setShowHover(true);
      billingCompsGrid.setShowHoverComponents(true);
      billingCompsGrid.setWrapCells(true);
      billingCompsGrid.setFixedRecordHeights(false);
      billingCompsGrid.setCanDragSelectText(true);

      ListGridField billing_company_name =
          new ListGridField("billing_company_name", CallCenterBK.constants.companyName());

      ListGridField our_percent =
          new ListGridField("our_percent", CallCenterBK.constants.ourPercent(), 150);

      ListGridField has_calculation_descr =
          new ListGridField("has_calculation_descr", CallCenterBK.constants.hasCalculation(), 150);

      ListGridField call_price =
          new ListGridField("call_price", CallCenterBK.constants.callPrice(), 150);

      our_percent.setAlign(Alignment.CENTER);
      has_calculation_descr.setAlign(Alignment.CENTER);
      call_price.setAlign(Alignment.CENTER);

      billingCompsGrid.setFields(
          billing_company_name, our_percent, has_calculation_descr, call_price);

      mainLayout.addMember(billingCompsGrid);
      findButton.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              search();
            }
          });

      billingCompNameItem.addKeyPressHandler(
          new KeyPressHandler() {
            @Override
            public void onKeyPress(KeyPressEvent event) {
              if (event.getKeyName().equals("Enter")) {
                search();
              }
            }
          });

      phoneIndexItem.addKeyPressHandler(
          new KeyPressHandler() {
            @Override
            public void onKeyPress(KeyPressEvent event) {
              if (event.getKeyName().equals("Enter")) {
                search();
              }
            }
          });

      clearButton.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              billingCompNameItem.clearValue();
            }
          });

      addBtn.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              DlgAddEditBillingComps dlgAddEditBillingComp =
                  new DlgAddEditBillingComps(billingCompsGrid, null);
              dlgAddEditBillingComp.show();
            }
          });

      editBtn.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              ListGridRecord listGridRecord = billingCompsGrid.getSelectedRecord();

              if (listGridRecord == null) {
                SC.say(CallCenterBK.constants.pleaseSelrecord());
                return;
              }

              DlgAddEditBillingComps dlgAddEditBillingComp =
                  new DlgAddEditBillingComps(billingCompsGrid, listGridRecord);
              dlgAddEditBillingComp.show();
            }
          });
      deleteBtn.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              final ListGridRecord listGridRecord = billingCompsGrid.getSelectedRecord();
              if (listGridRecord == null) {
                SC.say(CallCenterBK.constants.pleaseSelrecord());
                return;
              }
              SC.ask(
                  CallCenterBK.constants.askForDisable(),
                  new BooleanCallback() {
                    @Override
                    public void execute(Boolean value) {
                      if (value) {
                        delete(listGridRecord);
                      }
                    }
                  });
            }
          });

      billingCompsGrid.addRecordDoubleClickHandler(
          new RecordDoubleClickHandler() {
            @Override
            public void onRecordDoubleClick(RecordDoubleClickEvent event) {
              ListGridRecord listGridRecord = billingCompsGrid.getSelectedRecord();
              DlgAddEditBillingComps dlgAddEditBillingComp =
                  new DlgAddEditBillingComps(billingCompsGrid, listGridRecord);
              dlgAddEditBillingComp.show();
            }
          });

      billingCompBillByDayBtn.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {

              final ListGridRecord listGridRecord = billingCompsGrid.getSelectedRecord();
              if (listGridRecord == null) {
                SC.say(CallCenterBK.constants.pleaseSelrecord());
                return;
              }
              Integer billing_company_id = listGridRecord.getAttributeAsInt("billing_company_id");
              getBillingCompBillByDay(billing_company_id);
            }
          });
      billingCompBillByMonthBtn.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {

              final ListGridRecord listGridRecord = billingCompsGrid.getSelectedRecord();
              if (listGridRecord == null) {
                SC.say(CallCenterBK.constants.pleaseSelrecord());
                return;
              }
              Integer billing_company_id = listGridRecord.getAttributeAsInt("billing_company_id");
              getBillingCompBillByMonth(billing_company_id);
            }
          });

      setPane(mainLayout);
    } catch (Exception e) {
      SC.say(e.toString());
    }
  }