Package org.pentaho.aggdes.ui.model

Examples of org.pentaho.aggdes.ui.model.UIAggregate


        AggList list = (AggList) e.getSource();
        switch (e.getType()) {
        case AGGS_ADDED:
          try {
            for (int i = e.getIndex(); i < list.getSize(); i++) {
              UIAggregate newAgg = list.getAgg(i);
 
              XulTreeRow newRow = (XulTreeRow) document.createElement("treerow");
 
              XulTreeCell newCell = (XulTreeCell) document.createElement("treecell");
              newCell.setValue(newAgg.getEnabled());
              newRow.addCell(newCell);
 
              newCell = (XulTreeCell) document.createElement("treecell");
              newCell.setLabel(newAgg.isAlgoAgg() ? Messages.getString("agg_type_advisor") : Messages.getString("agg_type_custom"));
              newRow.addCell(newCell);
 
              newCell = (XulTreeCell) document.createElement("treecell");
              newCell.setLabel(newAgg.getName());
              newRow.addCell(newCell);
 
              newCell = (XulTreeCell) document.createElement("treecell");
              double rowCount = newAgg.estimateRowCount();
              if (rowCount == 0) {
                newCell.setLabel(ESTIMATE_UNKNOWN);
              } else {
                newCell.setLabel(format.format(rowCount));
              }
              newRow.addCell(newCell);
 
              newCell = (XulTreeCell) document.createElement("treecell");
              double space = newAgg.estimateSpace();
              if (space == 0) {
                newCell.setLabel(ESTIMATE_UNKNOWN);
              } else {
                newCell.setLabel(format.format(space));
              }
              newRow.addCell(newCell);
 
              aggTable.addTreeRow(newRow);
            }
            changeInAggregates();
           
          } catch (XulException xe) {
            logger.error("Error adding new row to Agg table", xe);
          }
          break;
       
          case AGG_ADDED:
            try {
              UIAggregate newAgg = list.getAgg(e.getIndex());

              XulTreeRow newRow = (XulTreeRow) document.createElement("treerow");

              XulTreeCell newCell = (XulTreeCell) document.createElement("treecell");
              newCell.setValue(newAgg.getEnabled());
              newRow.addCell(newCell);

              newCell = (XulTreeCell) document.createElement("treecell");
              newCell.setLabel(newAgg.isAlgoAgg() ? Messages.getString("agg_type_advisor") : Messages.getString("agg_type_custom"));
              newRow.addCell(newCell);

              newCell = (XulTreeCell) document.createElement("treecell");
              newCell.setLabel(newAgg.getName());
              newRow.addCell(newCell);

              newCell = (XulTreeCell) document.createElement("treecell");
              double rowCount = newAgg.estimateRowCount();
              if (rowCount == 0) {
                newCell.setLabel(ESTIMATE_UNKNOWN);
              } else {
                newCell.setLabel(format.format(rowCount));
              }
              newRow.addCell(newCell);

              newCell = (XulTreeCell) document.createElement("treecell");
              double space = newAgg.estimateSpace();
              if (space == 0) {
                newCell.setLabel(ESTIMATE_UNKNOWN);
              } else {
                newCell.setLabel(format.format(space));
              }
              newRow.addCell(newCell);

              aggTable.addTreeRow(newRow);

              changeInAggregates();
             
            } catch (XulException xe) {
              logger.error("Error adding new row to Agg table", xe);
            }
            break;
          case AGGS_CLEARED:
            aggTable.getRootChildren().removeAll();
            aggModel.setThinAgg(null);
            changeInAggregates();
            break;
          case AGG_REMOVED:
            aggTable.removeTreeRows(new int[] { e.getIndex() });
            aggTable.clearSelection();
            int[] tableSelection = aggTable.getSelectedRows();
            if (e.getIndex() < list.getSize()) {
              //we're single selection
              list.setSelectedIndex(e.getIndex());
            }
            //There's aready a selection listener on the table firing the same.
            UIAggregate tempAgg = list.getSelectedValue();
           
            aggModel.setThinAgg(list.getSelectedValue());
           
            changeInAggregates();
                       
            break;
          case SELECTION_CHANGED:
           
            if (aggTable.getSelectedRows().length > 0) {
              logger.info("Event index: " + e.getIndex() + " aggTable.selectedRow0: " + aggTable.getSelectedRows()[0]);
            }
            int[] rows = aggTable.getSelectedRows();
            if (aggTable.getSelectedRows().length > 0 && e.getIndex() == aggTable.getSelectedRows()[0]) {
              aggModel.setThinAgg(list.getSelectedValue());
            }
            //check to see if it's already selected, ignore if so
            int[] curSelection = aggTable.getSelectedRows();
//            if(curSelection.length > 0 && e.getIndex() == curSelection[0]){
//              logger.debug("already selected row");
//              break;
//            }
            logger.debug("selecting new row");
            aggTable.setSelectedRows(new int[] { e.getIndex() });
            aggModel.setThinAgg(list.getSelectedValue());
            break;
          case AGG_CHANGED:
            logger.debug("agg list controller responding to AGG_CHANGED event from aggList");
            int idx = e.getIndex();
            UIAggregate agg = list.getAgg(idx);
            aggTable.getRootChildren().getItem(idx).getRow().getCell(0).setValue(agg.getEnabled());
            aggTable.getRootChildren().getItem(idx).getRow().getCell(1).setLabel(
                agg.isAlgoAgg()
                ? Messages.getString("agg_type_advisor")
                : Messages.getString("agg_type_custom")
            );
            aggTable.getRootChildren().getItem(idx).getRow().getCell(2).setLabel(agg.getName());

            double rowCount = agg.estimateRowCount();
            if (rowCount == 0) {
              aggTable.getRootChildren().getItem(idx).getRow().getCell(3).setLabel(ESTIMATE_UNKNOWN);
            } else {
              aggTable.getRootChildren().getItem(idx).getRow().getCell(3).setLabel(format.format(rowCount));
            }

            double space = agg.estimateSpace();
            if (space == 0) {
              aggTable.getRootChildren().getItem(idx).getRow().getCell(4).setLabel(ESTIMATE_UNKNOWN);
            } else {
              aggTable.getRootChildren().getItem(idx).getRow().getCell(4).setLabel(format.format(space));
            }
View Full Code Here


    changeInAggregates();
  }

  public void addAgg() {
    try {
      UIAggregate newAgg = new UIAggregateImpl();
      aggNamingService.nameAggregate(newAgg, getAggList(), connectionModel.getSchema());
     
      newAgg.setOutput(outputService.generateDefaultOutput(newAgg));
     
      getAggList().addAgg(newAgg);
      getAggList().setSelectedIndex(getAggList().getSize() - 1);
    } catch (OutputValidationException e) {
      System.err.println("Failed to create output, skipping UIAggregate");
View Full Code Here

      getAggList().setSelectedIndex(idx);
    }
  }

  public void saveAggChange(int idx) {
    UIAggregate agg = getAggList().getAgg(idx);
    XulTree aggTable = (XulTree) document.getElementById("definedAggTable");
    XulTreeRow row = aggTable.getRootChildren().getItem(idx).getRow();
    agg.setEnabled((Boolean) row.getCell(0).getValue());

    // get row count estimate
    Aggregate algoAggregate = algorithm.createAggregate(connectionModel.getSchema(), agg.getAttributes());
    agg.setEstimateRowCount(algoAggregate.estimateRowCount());
    agg.setEstimateSpace(algoAggregate.estimateSpace());
    getAggList().aggChanged(agg);
    System.out.println("Saving agg, enabled? " + row.getCell(0).getValue());
   
  }
View Full Code Here

    eventSupport.removeListener(l);
  }

  public void removeAgg(int index) {
    if (0 <= index && index < list.size()) {
        UIAggregate old = list.remove(index);
      if(index == selectedIndex){
        this.setSelectedIndex(-1);
      }
      if (old != null) {
        fireEvent(new AggListEvent(this, AGG_REMOVED, index));
View Full Code Here

TOP

Related Classes of org.pentaho.aggdes.ui.model.UIAggregate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.