Пример #1
0
 /** re-executes the command for the additional character added above. */
 public void commitPending() {
   if (overwrite) overwrittenText += run.overwriteText(pending, offset + insertedChars.length);
   else run.insertText(pending, offset + insertedChars.length);
   char old[] = insertedChars;
   insertedChars = new char[old.length + 1];
   System.arraycopy(old, 0, insertedChars, 0, old.length);
   insertedChars[insertedChars.length - 1] = pending.toCharArray()[0];
   pending = null;
 }
Пример #2
0
  /**
   * This class removes a range in the model starting from a given TextRun and offset and
   * terminating at another TextRun and offset location. Removing the range in the model may result
   * in the merging of 2 or more pieces of the model. After this edit is applied, the resulting
   * location in the merged model may be obtained. This location should be used for subsequent
   * insertions.
   *
   * @since 3.1
   */
  public RemoveRange(TextRun begin, int so, TextRun end, int eo) {
    if (begin == end) {
      clipBeginning = new RemoveText(begin, so, eo);
    } else {
      List remove = ModelUtil.getModelSpan(begin, so, end, eo);

      removed = new ModelElement[remove.size()];
      removedFrom = new Container[removed.length];

      for (int i = remove.size() - 1; i >= 0; i--) {
        removed[i] = (ModelElement) remove.get(i);
        removedFrom[i] = removed[i].getContainer();
      }

      if (so > 0) clipBeginning = new RemoveText(begin, so, begin.size());
      if (eo < end.size()) clipEnding = new RemoveText(end, 0, eo);
    }
  }
Пример #3
0
 public void rollback() {
   if (overwrite) {
     run.overwriteText(overwrittenText, offset);
     overwrittenText = null;
   } else run.removeRange(offset, insertedChars.length);
 }
Пример #4
0
 public void reapply() {
   if (overwrite) overwrittenText = run.overwriteText(new String(insertedChars), offset);
   else run.insertText(new String(insertedChars), offset);
 }
Пример #5
0
 /** @see org.eclipse.gef.commands.Command#execute() */
 public void apply() {
   if (overwrite) overwrittenText = run.overwriteText(pending, offset);
   else run.insertText(pending, offset);
   insertedChars = pending.toCharArray();
   pending = null;
 }