Esempio n. 1
0
 void setFormData(WObject.FormData formData) {
   if (!(formData.values.length == 0)) {
     List<String> attributes = new ArrayList<String>();
     attributes = new ArrayList<String>(Arrays.asList(formData.values[0].split(";")));
     if (attributes.size() == 6) {
       try {
         this.volume_ = Double.parseDouble(attributes.get(0));
       } catch (RuntimeException e) {
         this.volume_ = -1;
       }
       try {
         this.current_ = Double.parseDouble(attributes.get(1));
       } catch (RuntimeException e) {
         this.current_ = -1;
       }
       try {
         this.duration_ = Double.parseDouble(attributes.get(2));
       } catch (RuntimeException e) {
         this.duration_ = -1;
       }
       this.playing_ = attributes.get(3).equals("0");
       this.ended_ = attributes.get(4).equals("1");
       try {
         this.readyState_ = intToReadyState(Integer.parseInt(attributes.get(5)));
       } catch (RuntimeException e) {
         throw new WException(
             "WAbstractMedia: error parsing: " + formData.values[0] + ": " + e.toString());
       }
     } else {
       throw new WException("WAbstractMedia: error parsing: " + formData.values[0]);
     }
   }
 }
Esempio n. 2
0
 private void expand(int row, int column, int rowSpan, int columnSpan) {
   int newRowCount = Math.max(this.getRowCount(), row + rowSpan);
   int newColumnCount = Math.max(this.getColumnCount(), column + columnSpan);
   int extraRows = newRowCount - this.getRowCount();
   int extraColumns = newColumnCount - this.getColumnCount();
   if (extraColumns > 0) {
     for (int a_row = 0; a_row < this.getRowCount(); ++a_row) {
       {
         int insertPos = this.grid_.items_.get(a_row).size();
         for (int ii = 0; ii < (extraColumns); ++ii)
           this.grid_.items_.get(a_row).add(insertPos + ii, new Grid.Item());
       }
       ;
     }
     {
       int insertPos = this.grid_.columns_.size();
       for (int ii = 0; ii < (extraColumns); ++ii)
         this.grid_.columns_.add(insertPos + ii, new Grid.Section());
     }
     ;
   }
   if (extraRows > 0) {
     {
       int insertPos = this.grid_.items_.size();
       for (int ii = 0; ii < (extraRows); ++ii)
         this.grid_.items_.add(insertPos + ii, new ArrayList<Grid.Item>());
     }
     ;
     for (int i = 0; i < extraRows; ++i) {
       final List<Grid.Item> items =
           this.grid_.items_.get(this.grid_.items_.size() - extraRows + i);
       {
         int insertPos = items.size();
         for (int ii = 0; ii < (newColumnCount); ++ii) items.add(insertPos + ii, new Grid.Item());
       }
       ;
     }
     {
       int insertPos = this.grid_.rows_.size();
       for (int ii = 0; ii < (extraRows); ++ii)
         this.grid_.rows_.add(insertPos + ii, new Grid.Section());
     }
     ;
   }
 }
Esempio n. 3
0
 void getDomChanges(List<DomElement> result, WApplication app) {
   DomElement e = DomElement.getForUpdate(this, this.getDomElementType());
   if (!this.isStubbed() && this.flags_.get(BIT_GRID_CHANGED)) {
     DomElement newE = this.createDomElement(app);
     e.replaceWith(newE);
   } else {
     if (this.rowsChanged_ != null) {
       for (Iterator<WTableRow> i_it = this.rowsChanged_.iterator(); i_it.hasNext(); ) {
         WTableRow i = i_it.next();
         DomElement e2 = DomElement.getForUpdate(i, DomElementType.DomElement_TR);
         i.updateDom(e2, false);
         result.add(e2);
       }
       ;
       this.rowsChanged_ = null;
     }
     if (this.rowsAdded_ != 0) {
       DomElement etb =
           DomElement.getForUpdate(this.getId() + "tb", DomElementType.DomElement_TBODY);
       for (int i = 0; i < (int) this.rowsAdded_; ++i) {
         DomElement tr = this.createRow(this.getRowCount() - this.rowsAdded_ + i, true, app);
         etb.addChild(tr);
       }
       result.add(etb);
       this.rowsAdded_ = 0;
     }
     if (this.flags_.get(BIT_COLUMNS_CHANGED)) {
       for (int i = 0; i < this.columns_.size(); ++i) {
         DomElement e2 =
             DomElement.getForUpdate(this.columns_.get(i), DomElementType.DomElement_COL);
         this.columns_.get(i).updateDom(e2, false);
         result.add(e2);
       }
       this.flags_.clear(BIT_COLUMNS_CHANGED);
     }
     this.updateDom(e, false);
   }
   result.add(e);
 }
Esempio n. 4
0
 /**
  * Move a table column from its original position to a new position.
  *
  * <p>The table expands automatically when the <code>to</code> column is beyond the current table
  * dimensions.
  *
  * <p>
  *
  * @see WTable#moveRow(int from, int to)
  */
 public void moveColumn(int from, int to) {
   if (from < 0 || from >= (int) this.columns_.size()) {
     logger.error(
         new StringWriter()
             .append("moveColumn: the from index is not a valid column index.")
             .toString());
     return;
   }
   WTableColumn from_tc = this.getColumnAt(from);
   this.columns_.remove(from_tc);
   if (to > (int) this.columns_.size()) {
     this.getColumnAt(to);
   }
   this.columns_.add(0 + to, from_tc);
   for (int i = 0; i < this.rows_.size(); i++) {
     List<WTableRow.TableData> cells = this.rows_.get(i).cells_;
     WTableRow.TableData cell = cells.get(from);
     cells.remove(0 + from);
     cells.add(0 + to, cell);
   }
   this.flags_.set(BIT_GRID_CHANGED);
   this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml));
 }
 static void decodeTouches(String str, List<Touch> result) {
   if (str.length() == 0) {
     return;
   }
   List<String> s = new ArrayList<String>();
   s = new ArrayList<String>(Arrays.asList(str.split(";")));
   if (s.size() % 9 != 0) {
     logger.error(
         new StringWriter()
             .append("Could not parse touches array '")
             .append(str)
             .append("'")
             .toString());
     return;
   }
   try {
     for (int i = 0; i < s.size(); i += 9) {
       result.add(
           new Touch(
               asUInt(s.get(i + 0)),
               asInt(s.get(i + 1)),
               asInt(s.get(i + 2)),
               asInt(s.get(i + 3)),
               asInt(s.get(i + 4)),
               asInt(s.get(i + 5)),
               asInt(s.get(i + 6)),
               asInt(s.get(i + 7)),
               asInt(s.get(i + 8))));
     }
   } catch (NumberFormatException ee) {
     logger.error(
         new StringWriter()
             .append("Could not parse touches array '")
             .append(str)
             .append("'")
             .toString());
     return;
   }
 }
Esempio n. 6
0
 void getDomChanges(List<DomElement> result, WApplication app) {
   if (this.mediaId_.length() != 0) {
     DomElement media = DomElement.getForUpdate(this.mediaId_, DomElementType.DomElement_DIV);
     this.updateMediaDom(media, false);
     if (this.sourcesChanged_) {
       for (int i = 0; i < this.sourcesRendered_; ++i) {
         media.callJavaScript(
             "Wt3_2_3.remove('" + this.mediaId_ + "s" + String.valueOf(i) + "');", true);
       }
       this.sourcesRendered_ = 0;
       for (int i = 0; i < this.sources_.size(); ++i) {
         DomElement src = DomElement.createNew(DomElementType.DomElement_SOURCE);
         src.setId(this.mediaId_ + "s" + String.valueOf(i));
         this.renderSource(src, this.sources_.get(i), i + 1 >= this.sources_.size());
         media.addChild(src);
       }
       this.sourcesRendered_ = this.sources_.size();
       this.sourcesChanged_ = false;
       media.callJavaScript(this.getJsMediaRef() + ".load();");
     }
     result.add(media);
   }
   super.getDomChanges(result, app);
 }