getEdit()源码实例Demo

javax.swing.event.UndoableEditEvent#getEdit()源码实例Demo

下面列出了javax.swing.event.UndoableEditEvent#getEdit() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openAGV   文件: BezierLinerEditHandler.java
@Override
public void undoableEditHappened(UndoableEditEvent evt) {
  if (!(evt.getEdit() instanceof BezierLinerEdit)) {
    return;
  }
  BezierFigure owner = ((BezierLinerEdit) evt.getEdit()).getOwner();
  if (!(owner instanceof PathConnection)) {
    return;
  }

  PathConnection path = (PathConnection) owner;
  path.updateControlPoints();
  PathModel pathModel = path.getModel();
  pathModel.getPropertyPathControlPoints().markChanged();
  pathModel.propertiesChanged(path);
}
 
源代码2 项目: groovy   文件: TextUndoManager.java
public void undoableEditHappened(UndoableEditEvent uee) {
    UndoableEdit edit = uee.getEdit();
    boolean undoable = canUndo();

    long editTime = System.currentTimeMillis();

    if (firstModified == 0 ||
            editTime - compoundEdit.editedTime() > 700) {
        compoundEdit.end();
        compoundEdit = new StructuredEdit();
    }
    compoundEdit.addEdit(edit);

    firstModified = firstModified == 0 ?
            compoundEdit.editedTime() : firstModified;

    if (lastEdit() != compoundEdit) {
        boolean changed = hasChanged();
        addEdit(compoundEdit);
        firePropertyChangeEvent(UndoManager.UndoName, undoable, canUndo());
    }

}
 
源代码3 项目: netbeans   文件: UndoRedoSupport.java
@Override
public void undoableEditHappened(UndoableEditEvent e) {
    if (edit == null) {
        startNewEdit(e.getEdit());
        processDocumentChange();
        return;
    }
    //AbstractDocument.DefaultDocumentEvent event = (AbstractDocument.DefaultDocumentEvent) e.getEdit();
    UndoableEdit event = e.getEdit();
    if (event instanceof DocumentEvent) {
        if (((DocumentEvent)event).getType().equals(DocumentEvent.EventType.CHANGE)) {
            edit.addEdit(e.getEdit());
            return;
        }
    }
    int offsetChange = component.getCaretPosition() - lastOffset;
    int lengthChange = component.getDocument().getLength() - lastLength;

    if (Math.abs(offsetChange) == 1 && Math.abs(lengthChange) == 1) {
        lastOffset = component.getCaretPosition();
        lastLength = component.getDocument().getLength();
        addEdit(e.getEdit());
        processDocumentChange();
    } else {
        // last change consists of multiple chars, start new compound edit
        startNewEdit(e.getEdit());
    }
}
 
源代码4 项目: jeveassets   文件: CompoundUndoManager.java
@Override
public void undoableEditHappened(UndoableEditEvent e) {
	//  Start a new compound edit

	if (compoundEdit == null) {
		compoundEdit = startCompoundEdit(e.getEdit());
		return;
	}

	int offsetChange = textComponent.getCaretPosition() - lastOffset;
	int lengthChange = textComponent.getDocument().getLength() - lastLength;

	//  Check for an attribute change
	UndoableEdit edit = e.getEdit();
	if (edit instanceof AbstractDocument.DefaultDocumentEvent) {
		AbstractDocument.DefaultDocumentEvent event = (AbstractDocument.DefaultDocumentEvent) e.getEdit();
		if (event.getType().equals(DocumentEvent.EventType.CHANGE)) {
			if (offsetChange == 0) {
				compoundEdit.addEdit(e.getEdit());
				return;
			}
		}
	}

	//  Check for an incremental edit or backspace.
	//  The Change in Caret position and Document length should both be
	//  either 1 or -1.
	if (offsetChange == lengthChange
			&& Math.abs(offsetChange) == 1) {
		compoundEdit.addEdit(e.getEdit());
		lastOffset = textComponent.getCaretPosition();
		lastLength = textComponent.getDocument().getLength();
		return;
	}

	//  Not incremental edit, end previous edit and start a new one
	compoundEdit.end();
	compoundEdit = startCompoundEdit(e.getEdit());
}
 
源代码5 项目: RipplePower   文件: ROCEditorListener.java
@Override
public void undoableEditHappened(UndoableEditEvent ev) {
	UndoableEdit edit = ev.getEdit();
	if (edit instanceof AbstractDocument.DefaultDocumentEvent && ((AbstractDocument.DefaultDocumentEvent) edit)
			.getType() == AbstractDocument.DefaultDocumentEvent.EventType.CHANGE) {
		return;
	}
	manager.addEdit(edit);
}
 
源代码6 项目: Pixelitor   文件: RepeatMenuItem.java
@Override
public void undoableEditHappened(UndoableEditEvent e) {
    PixelitorEdit edit = (PixelitorEdit) e.getEdit();

    if (edit == null) { // happens when all images are closed
        setEnabled(false);
        getAction().putValue(Action.NAME, "Repeat");
        return;
    }

    setEnabled(edit.canRepeat());
    getAction().putValue(Action.NAME, "Repeat " + edit.getPresentationName());
}
 
源代码7 项目: PIPE   文件: Contains.java
@Override
public boolean matches(Object argument) {
    UndoableEditEvent event = (UndoableEditEvent) argument;
    UndoableEdit edit = event.getEdit();

    return edit.equals(expectedEdit);
}
 
源代码8 项目: SikuliX1   文件: EditorUndoManager.java
@Override
public void undoableEditHappened(UndoableEditEvent e) {
   UndoableEdit edit=e.getEdit();
   if (edit instanceof AbstractDocument.DefaultDocumentEvent) {
      AbstractDocument.DefaultDocumentEvent event=(AbstractDocument.DefaultDocumentEvent)edit;
      int start=event.getOffset();
      int len=event.getLength();
      Debug.log(9, "undoableEditHappened " + start + "," + len);
      boolean isNeedStart=false;
      if(event.getType().equals(DocumentEvent.EventType.CHANGE) ||
         event.getType().equals(DocumentEvent.EventType.INSERT) ){
         try {
            String text=event.getDocument().getText(start, len);
            if (text.contains("\n"))
               isNeedStart=true;
         } catch (BadLocationException e1) {
           Debug.error(me + "undoableEditHappened: Problem getting text\n%s", e1.getMessage());
         }
      }

      if (current==null) {
         isNeedStart=true;
      }
      else if (lastEditName==null || !lastEditName.equals(edit.getPresentationName())) {
         isNeedStart=true;
      }

      while (pointer<edits.size()-1) {
         edits.remove(edits.size()-1);
         isNeedStart=true;
      }
      if (isNeedStart) {
         createCompoundEdit();
      }

      current.addEdit(edit);
      lastEditName=edit.getPresentationName();

      refreshControls();
   }
}
 
源代码9 项目: jpexs-decompiler   文件: CompoundUndoMan.java
/**
 * Whenever an UndoableEdit happens the edit will either be absorbed by the
 * current compound edit or a new compound edit will be started
 */
@Override
public void undoableEditHappened(UndoableEditEvent e) {
    //  Start a new compound edit

    if (compoundEdit == null) {
        compoundEdit = startCompoundEdit(e.getEdit());
        startCombine = false;
        updateDirty();
        return;
    }
    if (e.getEdit() instanceof DefaultDocumentEvent) {
        // Java 6 to 8
        AbstractDocument.DefaultDocumentEvent docEvt = (DefaultDocumentEvent) e.getEdit();

        int editLine = doc.getLineNumberAt(docEvt.getOffset());

        //  Check for an incremental edit or backspace.
        //  The Change in Caret position and Document length should both be
        //  either 1 or -1.
        if ((startCombine || Math.abs(docEvt.getLength()) == 1) && editLine == lastLine) {
            compoundEdit.addEdit(e.getEdit());
            startCombine = false;
            updateDirty();
            return;
        }

        //  Not incremental edit, end previous edit and start a new one
        lastLine = editLine;

    } else // Java 9: It seems that all the edits are wrapped and we cannot get line number!
    // See https://github.com/netroby/jdk9-dev/blob/master/jdk/src/java.desktop/share/classes/javax/swing/text/AbstractDocument.java#L279
    // AbstractDocument.DefaultDocumentEventUndoableWrapper docEvt = e.getEdit();
    {
        if (startCombine && !e.getEdit().isSignificant()) {
            compoundEdit.addEdit(e.getEdit());
            startCombine = false;
            updateDirty();
            return;
        }
    }

    compoundEdit.end();
    compoundEdit = startCompoundEdit(e.getEdit());

    updateDirty();
}
 
源代码评论
动弹
沙发等你来抢
 同类方法