Uploaded image for project: 'Keikai'
  1. Keikai
  2. KEIKAI-396

Provide a developer-friendly way to access a cell's precedents and dependents



    • New Feature
    • Resolution: Done
    • Normal
    • 5.6.0
    • None
    • None
    • Security Level: Jimmy
    • None


      Current state

      Keikai's internal model already tracks a cell's precedents and dependents. (cells which formulas are dependent on the target cells, and cells which values are used by the target cell).

      However, in the current API, they are not very easy to retrieve and use.

       Currently, accessing these cells require accessing internal values and building the Ref object manually, and access the internal DependencyTable:

                      prevRef = ref;
                      ref = new RefImpl(spreadsheet.getBook().getBookName(), spreadsheet.getSelectedSheetName(), e.getRow(), e.getColumn());
                      SBook book = spreadsheet.getSBook();
      		DependencyTable dt = ((AbstractBookSeriesAdv) book.getBookSeries()).getDependencyTable();
      		Set<Ref> dependents = dt.getDependents(ref);
      		Set<Ref> precedents = ((DependencyTableImpl)dt).getDirectPrecedents(ref);
      		if(precedents != null) {
      			for (Ref pre : precedents) {
      				Clients.log("precedent: " + pre);
      				if(RefType.CELL.equals(pre.getType())) {
      					Range depRange = Ranges.range(spreadsheet.getSelectedSheet(), pre.getRow(), pre.getColumn());
      					CellOperationUtil.applyBorder(depRange, ApplyBorderType.FULL, typePre, colorPre);
      				if(RefType.AREA.equals(pre.getType())) {
      					Range depRange = Ranges.range(spreadsheet.getSelectedSheet(), pre.getRow(), pre.getColumn(), pre.getLastRow(), pre.getLastColumn());
      					CellOperationUtil.applyBorder(depRange, ApplyBorderType.FULL, typePre, colorPre);
      		if(dependents != null) {
      			for (Ref dep : dependents) {
      				Clients.log("dependent: " + dep);
      				if(RefType.CELL.equals(dep.getType()) || RefType.AREA.equals(dep.getType())) {
      					Range depRange = Ranges.range(spreadsheet.getSelectedSheet(), dep.getRow(), dep.getColumn());
      					CellOperationUtil.applyBorder(depRange, ApplyBorderType.FULL, typeDep, colorDep);
      				if(RefType.AREA.equals(dep.getType())) {
      					Range depRange = Ranges.range(spreadsheet.getSelectedSheet(), dep.getRow(), dep.getColumn(), dep.getLastRow(), dep.getLastColumn());
      					CellOperationUtil.applyBorder(depRange, ApplyBorderType.FULL, typePre, colorPre);


      Expected Result

      An easy API to retrieve a collection of cells for precedents and dependents.

      Could be a Utility similar to Ranges, or a method on an exisiting object.

      The goal would be to retrieve a collections of Range object such as:

      Set<Range> dependents = DependencyUtil.getDependents(Range targetRange);
      for(Range range : dependents){
       // do range operations such as setting BG or border, or display the entries in a listbox, etc.


        Issue Links



              henrichen henrichen
              MDuchemin MDuchemin
              0 Vote for this issue
              2 Start watching this issue