Esempio n. 1
0
 private boolean onArrowLeft(KeyboardEvent event) {
   if (noContentCheck()) return true;
   final int count = model.getRowCount();
   if (hotPointY < 0 || hotPointY >= count) {
     environment.hint(Hints.EMPTY_LINE);
     return true;
   }
   if (hotPointX < initialHotPointX) hotPointX = initialHotPointX;
   if (getColUnderPos(hotPointX) < 0) hotPointX = initialHotPointX;
   final int currentCol = getColUnderPos(hotPointX);
   final int currentColWidth = colWidth[currentCol];
   final int colStartPos = getColStartPos(currentCol);
   final TableCell c =
       new TableCell(
           hotPointX - colStartPos,
           cellShift,
           currentColWidth,
           appearance.getCellText(model, currentCol, hotPointY));
   if (!c.movePrev()) {
     if (currentCol <= 0) {
       environment.hint(Hints.TABLE_BEGIN_OF_ROW);
       return true;
     }
     final String prevColText = appearance.getCellText(model, currentCol - 1, hotPointY);
     final int prevColWidth = colWidth[currentCol - 1];
     final int prevColStartPos = getColStartPos(currentCol - 1);
     if (prevColText.length() > prevColWidth) {
       hotPointX = prevColStartPos + prevColWidth;
       cellShift = prevColText.length() - prevColWidth;
     } else {
       cellShift = 0;
       hotPointX = prevColStartPos + prevColText.length();
     }
     environment.hint(Hints.TABLE_END_OF_COL);
     environment.onAreaNewContent(this);
     environment.onAreaNewHotPoint(this);
     return true;
   }
   cellShift = c.shift;
   hotPointX = c.pos + colStartPos;
   if (c.pos == c.width) // Should never happen;
   environment.hint(Hints.TABLE_END_OF_COL);
   else environment.sayLetter(c.line.charAt(c.pos + c.shift));
   environment.onAreaNewContent(this);
   environment.onAreaNewHotPoint(this);
   return true;
 }
Esempio n. 2
0
 private boolean onArrowRight(KeyboardEvent event) {
   if (noContentCheck()) return true;
   final int count = model.getRowCount();
   if (hotPointY < 0 || hotPointY >= count) {
     environment.hint(Hints.EMPTY_LINE);
     return true;
   }
   // Checking that hot point not before proper line begin;
   if (hotPointX < initialHotPointX) hotPointX = initialHotPointX;
   if (getColUnderPos(hotPointX) < 0) hotPointX = initialHotPointX;
   final int currentCol = getColUnderPos(hotPointX);
   final int currentColWidth = colWidth[currentCol];
   final int colStartPos = getColStartPos(currentCol);
   final int nextColStartPos = colStartPos + colWidth[currentCol] + 1;
   final TableCell c =
       new TableCell(
           hotPointX - colStartPos,
           cellShift,
           currentColWidth,
           appearance.getCellText(model, currentCol, hotPointY));
   if (!c.moveNext()) {
     if (currentCol + 1 >= colWidth.length) {
       environment.hint(Hints.TABLE_END_OF_ROW);
       return true;
     }
     cellShift = 0;
     hotPointX = nextColStartPos;
     final String nextColText = appearance.getCellText(model, currentCol + 1, hotPointY);
     if (!nextColText.isEmpty()) environment.sayLetter(nextColText.charAt(0));
     else
       environment.hint(
           currentCol + 2 < colWidth.length ? Hints.TABLE_END_OF_COL : Hints.TABLE_END_OF_ROW);
     environment.onAreaNewContent(this);
     environment.onAreaNewHotPoint(this);
     return true;
   }
   cellShift = c.shift;
   hotPointX = c.pos + colStartPos;
   if (c.pos + c.shift >= c.line.length())
     environment.hint(
         currentCol + 1 < colWidth.length ? Hints.TABLE_END_OF_COL : Hints.TABLE_END_OF_ROW);
   else environment.sayLetter(c.line.charAt(c.pos + c.shift));
   environment.onAreaNewContent(this);
   environment.onAreaNewHotPoint(this);
   return true;
 }
Esempio n. 3
0
 private void onNewHotPointY(boolean briefIntroduction) {
   final int count = model.getRowCount();
   hotPointX = hotPointY < count ? initialHotPointX : 0;
   cellShift = 0;
   environment.onAreaNewHotPoint(this);
   if (hotPointY < count)
     appearance.introduceRow(model, hotPointY, briefIntroduction ? INTRODUCTION_BRIEF : 0);
   else environment.hint(Hints.EMPTY_LINE);
 }
Esempio n. 4
0
 public TableArea(ControlEnvironment environment, TableModel model) {
   this.environment = environment;
   this.model = model;
   if (environment == null) throw new NullPointerException("environment may not be null");
   if (model == null) throw new NullPointerException("model may not be null");
   this.appearance = new DefaultTableAppearance(environment);
   this.initialHotPointX = appearance.getInitialHotPointX(model);
   //	refresh();
 }
Esempio n. 5
0
 public void refresh(boolean refreshModel) {
   if (model == null) {
     colWidth = null;
     cellShift = 0;
     hotPointX = 0;
     hotPointY = 0;
     environment.onAreaNewContent(this);
     environment.onAreaNewHotPoint(this);
     return;
   }
   if (refreshModel) model.refresh();
   final int colCount = model.getColCount();
   final int rowCount = model.getRowCount();
   if (colCount <= 0 || rowCount <= 0) {
     colWidth = null;
     cellShift = 0;
     hotPointX = 0;
     hotPointY = 0;
     environment.onAreaNewContent(this);
     environment.onAreaNewHotPoint(this);
     return;
   }
   initialHotPointX = appearance.getInitialHotPointX(model);
   colWidth = new int[colCount];
   int totalWidth = initialHotPointX;
   for (int i = 0; i < colCount; ++i) {
     final int width = appearance.getColWidth(model, i);
     colWidth[i] = width >= 1 ? width : 1;
     totalWidth += (colWidth[i] + 1);
   }
   if (hotPointY > rowCount) hotPointY = rowCount;
   if (hotPointY < rowCount && hotPointX >= totalWidth)
     hotPointX =
         totalWidth - 1; // totalWidth may not be zero as always we have at least one column here;
   if (hotPointY == rowCount) hotPointX = 0;
   environment.onAreaNewContent(this);
   environment.onAreaNewHotPoint(this);
 }
Esempio n. 6
0
 @Override
 public String getLine(int index) {
   if (noProperContent())
     return index <= 0 ? environment.staticStr(LangStatic.TABLE_NO_CONTENT) : "";
   if (index < 0 || index >= model.getRowCount()) return "";
   final int currentCol = getColUnderPos(hotPointX);
   String line = getStringOfLen(appearance.getRowPrefix(model, index), initialHotPointX, "", "");
   if (index != hotPointY || currentCol < 0) {
     for (int i = 0; i < model.getColCount(); ++i)
       line += getStringOfLen(appearance.getCellText(model, i, index), colWidth[i], ">", " ");
     return line;
   }
   if (currentCol > 0)
     for (int i = 0; i < currentCol; ++i)
       line += getStringOfLen(appearance.getCellText(model, i, index), colWidth[i], ">", " ");
   String currentColText = appearance.getCellText(model, currentCol, index);
   if (cellShift > 0 && cellShift < currentColText.length())
     currentColText = currentColText.substring(cellShift);
   line += getStringOfLen(currentColText, colWidth[currentCol], ">", " ");
   if (currentCol + 1 < colWidth.length)
     for (int i = currentCol + 1; i < colWidth.length; ++i)
       line += getStringOfLen(appearance.getCellText(model, i, index), colWidth[i], ">", " ");
   return line;
 }
Esempio n. 7
0
  public TableArea(
      ControlEnvironment environment,
      TableModel model,
      TableAppearance appearance,
      TableClickHandler clickHandler,
      String name) {
    this.environment = environment;
    this.model = model;
    this.appearance = appearance != null ? appearance : new DefaultTableAppearance(environment);
    this.name = name != null ? name : "";
    this.clickHandler = clickHandler;
    this.initialHotPointX = appearance.getInitialHotPointX(model);

    if (environment == null) throw new NullPointerException("environment may not be null");
    if (model == null) throw new NullPointerException("model may not be null");
    if (appearance == null) throw new NullPointerException("appearance may not be null");
    //	if (clickHandler == null)
    //	    throw new NullPointerException("clickHandler may not be null");
    if (name == null) throw new NullPointerException("name may not be null");
    //	refresh();
  }