Exemplo n.º 1
0
  @Test
  public void checkAutoFill() {
    // Arrange
    TreeGridView view = new TreeGridView();

    // Act
    view.setAutoFill(true);

    // Assert
    Assert.assertTrue(view.isAutoFill());
  }
Exemplo n.º 2
0
  private void createMainGrid() {
    store = new TreeStore<ModelData>();

    mainDataGrid =
        new TreeGrid<DataContainer>(store, createColumnModel()) {
          @Override
          protected void onRender(Element parent, int index) {
            super.onRender(parent, index);
            if (HarvesterUI.UTIL_MANAGER
                .getLoggedUserName()
                .equals(HarvesterUI.CONSTANTS.anonymous())) {
              mainDataGrid.removeAllListeners();
            }

            DeferredCommand.addCommand(
                new Command() {
                  public void execute() {
                    browseFilterPanel.setExpanded(false);
                    viewDsInfoPanel.setExpanded(false);
                  }
                });
          }
        };

    mainDataGrid.setAutoExpand(true);
    //        mainDataGrid.getTreeView().setBufferEnabled(false);
    mainDataGrid.setTrackMouseOver(false);
    mainDataGrid.setExpandOnFilter(true);
    mainDataGrid.setId("MainDataGrid01");
    //        mainDataGrid.setStateId("MainDataGridStateID01");
    mainDataGrid.setColumnLines(true);
    mainDataGrid.getView().setEmptyText(HarvesterUI.CONSTANTS.noDataAvailable());
    mainDataGrid.setStripeRows(true);
    //        mainDataGrid.setStateful(true);
    mainDataGrid.setColumnReordering(true);
    mainDataGrid.disableTextSelection(false);
    mainDataGrid.setSelectionModel(mainGridSelectionModel);
    mainDataGrid.addPlugin(mainGridSelectionModel);
    mainDataGrid
        .getSelectionModel()
        .addSelectionChangedListener(
            new SelectionChangedListener<DataContainer>() {
              @Override
              public void selectionChanged(SelectionChangedEvent<DataContainer> se) {
                if (se.getSelectedItem() != null) {
                  selectedItemIndex = mainDataGrid.getStore().indexOf(se.getSelectedItem());
                  if (se.getSelectedItem() instanceof AggregatorUI) {
                    overviewGridAggregatorOperations.showButtons(topToolbar);
                    overviewGridDataSetOperations.hideButtons(topToolbar);
                    overviewGridDataProviderOperations.hideButtons(topToolbar);
                  } else if (se.getSelectedItem() instanceof DataProviderUI) {
                    DataProviderUI dataProviderUI = (DataProviderUI) se.getSelectedItem();
                    if (dataProviderUI.getDataSourceUIList().size() == 1) {
                      overviewGridDataSetOperations.showButtons(topToolbar);
                      overviewGridDataProviderOperations.showButtons(topToolbar);
                      overviewGridAggregatorOperations.hideButtons(topToolbar);
                      editPanelInfo(dataProviderUI.getDataSourceUIList().get(0));
                    } else {
                      overviewGridDataProviderOperations.showButtons(topToolbar);
                      overviewGridDataSetOperations.hideButtons(topToolbar);
                      overviewGridAggregatorOperations.hideButtons(topToolbar);
                    }
                  } else if (se.getSelectedItem() instanceof DataSourceUI) {
                    overviewGridDataSetOperations.showButtons(topToolbar);
                    overviewGridAggregatorOperations.hideButtons(topToolbar);
                    overviewGridDataProviderOperations.hideButtons(topToolbar);
                    editPanelInfo((DataSourceUI) se.getSelectedItem());
                  }
                } else {
                  emptyDataSetPanel();
                  overviewGridDataSetOperations.hideButtons(topToolbar);
                  overviewGridAggregatorOperations.hideButtons(topToolbar);
                  overviewGridDataProviderOperations.hideButtons(topToolbar);
                }
              }
            });

    //        mainDataGrid.addListener(Events.Attach, new Listener<GridEvent<BaseTreeModel>>() {
    //            public void handleEvent(GridEvent<BaseTreeModel> be) {
    //                reloadMainData();
    //            }
    //        });

    // Comparator
    final MainGridDefaultComparator mainGridDefaultComparator = new MainGridDefaultComparator();
    store.setStoreSorter(
        new StoreSorter<ModelData>() {
          @Override
          public int compare(Store<ModelData> store, ModelData m1, ModelData m2, String property) {
            return mainGridDefaultComparator.compareMainGridItem(store, m1, m2, property);
          }
        });

    TreeGridView mainGridViewConfig = new TreeGridView();
    mainGridViewConfig.setViewConfig(
        new GridViewConfig() {
          @Override
          public String getRowStyle(ModelData model, int rowIndex, ListStore<ModelData> ds) {
            if (HarvesterUI.getProjectType().equals("EUDML")) {
              if (model instanceof DataProviderUI) {
                if (((DataProviderUI) model).getDataSourceUIList().size() == 1) {
                  return "ULTRA_LIGHT_ORANGE";
                } else if (((DataProviderUI) model).getDataSourceUIList().size() > 1)
                  return "LIGHT_ORANGE";
                return "WHITE";
              }
              return "WHITE";
            } else {
              if (model instanceof AggregatorUI) {
                return "AGGREGATOR_STYLE";
              } else if (model instanceof DataProviderUI) {
                if (((DataProviderUI) model).getDataSourceUIList().size() == 1) {
                  return "DP_SINGLE_DS_STYLE";
                } else if (((DataProviderUI) model).getDataSourceUIList().size() > 1)
                  return "DP_MANY_DS_STYLE";
                return "WHITE";
              }
              return "WHITE";
            }
          }
        });
    mainGridViewConfig.setForceFit(true);
    mainDataGrid.setView(mainGridViewConfig);

    mainDataGrid.setIconProvider(
        new ModelIconProvider<DataContainer>() {
          public AbstractImagePrototype getIcon(DataContainer model) {
            if (model instanceof AggregatorUI) {
              return HarvesterUI.ICONS.aggregator_icon();
            } else if (model instanceof DataProviderUI) {
              return HarvesterUI.ICONS.data_provider_icon();
            } else if (model instanceof DataSourceUI) {
              return HarvesterUI.ICONS.data_set_icon();
            }
            return null;
          }
        });

    OverviewGridContextMenus overviewGridContextMenus = new OverviewGridContextMenus(mainDataGrid);
    overviewGridContextMenus.createTreeContextMenu();

    overviewGridDataSetOperations = new OverviewGridDataSetOperations(mainDataGrid);
    overviewGridAggregatorOperations = new OverviewGridAggregatorOperations(mainDataGrid);
    overviewGridDataProviderOperations = new OverviewGridDataProviderOperations(mainDataGrid);

    BorderLayoutData data = new BorderLayoutData(Style.LayoutRegion.CENTER);
    mainGridPanel.add(mainDataGrid, data);
  }