本文整理汇总了Java中javax.swing.event.UndoableEditEvent.getEdit方法的典型用法代码示例。如果您正苦于以下问题:Java UndoableEditEvent.getEdit方法的具体用法?Java UndoableEditEvent.getEdit怎么用?Java UndoableEditEvent.getEdit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.event.UndoableEditEvent
的用法示例。
在下文中一共展示了UndoableEditEvent.getEdit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: undoableEditHappened
import javax.swing.event.UndoableEditEvent; //导入方法依赖的package包/类
@Override
public void undoableEditHappened(UndoableEditEvent e) {
boolean relevant = true;
// only process edits that really changed anything
if (GraphEditorTab.this.refreshing || getJGraph().isModelRefreshing()) {
relevant = false;
} else if (e.getEdit() instanceof GraphLayoutCacheChange) {
GraphModelChange edit = (GraphModelChange) e.getEdit();
Object[] inserted = edit.getInserted();
Object[] removed = edit.getRemoved();
Object[] changed = edit.getChanged();
relevant =
inserted != null && inserted.length > 0 || removed != null && removed.length > 0
|| changed != null && changed.length > 0;
}
if (relevant) {
super.undoableEditHappened(e);
setDirty(isMinor(e.getEdit()));
updateHistoryButtons();
}
}
示例2: undoableEditHappened
import javax.swing.event.UndoableEditEvent; //导入方法依赖的package包/类
@Override
public void undoableEditHappened(UndoableEditEvent e) {
if (e.getEdit() instanceof GraphModelEdit) {
try {
getJModel().syncGraph();
AspectGraph graph = getJModel().getGraph();
// we need to clone the graph to properly freeze the next layout change
AspectGraph graphClone = graph.clone();
graphClone.setFixed();
getSimulatorModel().doAddGraph(getResourceKind(), graphClone, true);
getPropertiesPanel().setProperties(getJModel().getProperties());
} catch (IOException e1) {
// do nothing
}
}
}
示例3: undoableEditHappened
import javax.swing.event.UndoableEditEvent; //导入方法依赖的package包/类
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());
}
}
示例4: undoableEditHappened
import javax.swing.event.UndoableEditEvent; //导入方法依赖的package包/类
@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());
}
}
示例5: undoableEditHappened
import javax.swing.event.UndoableEditEvent; //导入方法依赖的package包/类
@Override
public void undoableEditHappened(UndoableEditEvent e) {
UndoableEdit edit = e.getEdit();
if (edit instanceof AbstractDocument.DefaultDocumentEvent) {
try {
AbstractDocument.DefaultDocumentEvent event = (AbstractDocument.DefaultDocumentEvent) edit;
int start = event.getOffset();
int len = event.getLength();
String text = "";
if ("addition".equals(edit.getPresentationName())) {
text = event.getDocument().getText(start, len);
}
boolean isNeedStart = false;
if (current == null
|| lastEditName == null
|| !lastEditName.equals(edit.getPresentationName())
|| text.contains("\n") && !"deletion".equals(edit.getPresentationName())
|| Math.abs(lastOffset - start) > 1) {
isNeedStart = true;
}
while (pointer < edits.size() - 1) {
edits.remove(edits.size() - 1);
isNeedStart = true;
}
if (isNeedStart) {
createCompoundEdit();
}
current.addEdit(edit);
lastEditName = edit.getPresentationName();
lastOffset = start;
} catch (BadLocationException e1) {
if (logger.isDebugEnabled()) {
logger.debug(e1, e1);
}
}
}
}
示例6: undoableEditHappened
import javax.swing.event.UndoableEditEvent; //导入方法依赖的package包/类
@Override
public void undoableEditHappened(UndoableEditEvent e) {
AbstractDocument.DefaultDocumentEvent event =
(AbstractDocument.DefaultDocumentEvent) e.getEdit();
if (!event.getType().equals(DocumentEvent.EventType.CHANGE))
super.undoableEditHappened(e);
}
示例7: testUndoAndRedo
import javax.swing.event.UndoableEditEvent; //导入方法依赖的package包/类
public void testUndoAndRedo() throws Exception {
final JDBCDataSourceType dsType = new JDBCDataSourceType();
class TestUndoableEditListener implements UndoableEditListener {
private int editCount = 0;
public void undoableEditHappened(UndoableEditEvent e) {
editCount++;
UndoableEdit edit = e.getEdit();
assertTrue(edit.canUndo());
assertEquals("hello", dsType.getProperty("Test"));
edit.undo();
assertTrue(edit.canRedo());
assertNull(dsType.getProperty("Test"));
edit.redo();
assertTrue(edit.canUndo());
assertEquals("hello", dsType.getProperty("Test"));
}
public int getEditCount() {
return editCount;
}
}
TestUndoableEditListener undoableEditListener = new TestUndoableEditListener();
dsType.addUndoableEditListener(undoableEditListener);
dsType.putProperty("Test", "hello");
assertEquals(1, undoableEditListener.getEditCount());
}
示例8: undoableEditHappened
import javax.swing.event.UndoableEditEvent; //导入方法依赖的package包/类
@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);
}
示例9: undoableEditHappened
import javax.swing.event.UndoableEditEvent; //导入方法依赖的package包/类
/**
* 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
AbstractDocument.DefaultDocumentEvent docEvt = (DefaultDocumentEvent) e.getEdit();
if (compoundEdit == null) {
compoundEdit = startCompoundEdit(e.getEdit());
startCombine = false;
return;
}
int editLine = ((SyntaxDocument)docEvt.getDocument()).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;
return;
}
// Not incremental edit, end previous edit and start a new one
lastLine = editLine;
compoundEdit.end();
compoundEdit = startCompoundEdit(e.getEdit());
}
示例10: undoableEditHappened
import javax.swing.event.UndoableEditEvent; //导入方法依赖的package包/类
public void undoableEditHappened(UndoableEditEvent e) {
UndoableEdit edit=e.getEdit();
if (edit instanceof AbstractDocument.DefaultDocumentEvent) {
try {
AbstractDocument.DefaultDocumentEvent event=(AbstractDocument.DefaultDocumentEvent)edit;
int start=event.getOffset();
int len=event.getLength();
String text=event.getDocument().getText(start, len);
boolean isNeedStart=false;
if (current==null) {
isNeedStart=true;
}
else if (text.contains("\n")) {
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();
} catch (BadLocationException e1) {
e1.printStackTrace();
}
}
}
示例11: undoableEditHappened
import javax.swing.event.UndoableEditEvent; //导入方法依赖的package包/类
public void undoableEditHappened(UndoableEditEvent evt)
{
UndoableEdit edit = evt.getEdit();
if(compoundEdit != null)
{
//System.out.println("adding to compound");
compoundEdit.addEdit(edit);
}
else
{
undoer.addEdit(edit);
updateUndo(document);
}
}
示例12: undoableEditHappened
import javax.swing.event.UndoableEditEvent; //导入方法依赖的package包/类
public void undoableEditHappened(UndoableEditEvent e)
{
UndoableEdit edit = e.getEdit();
if(undoer != null)
{
undoer.addEdit(edit);
updateActions();
}
}
示例13: undoableEditHappened
import javax.swing.event.UndoableEditEvent; //导入方法依赖的package包/类
@Override
public void undoableEditHappened(UndoableEditEvent e) {
UndoableEdit edit = e.getEdit();
if (edit instanceof AbstractDocument.DefaultDocumentEvent) {
try {
AbstractDocument.DefaultDocumentEvent event = (AbstractDocument.DefaultDocumentEvent) edit;
int start = event.getOffset();
int len = event.getLength();
String text = event.getDocument().getText(start, len);
boolean isNeedStart = false;
if (current == null) {
isNeedStart = true;
} else if (text.contains("\n")) {
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);
super.undoableEditHappened(e);
lastEditName = edit.getPresentationName();
} catch (BadLocationException e1) {
Exceptions.printStackTrace(e1);
}
}
}
示例14: matches
import javax.swing.event.UndoableEditEvent; //导入方法依赖的package包/类
@Override
public boolean matches(Object argument) {
UndoableEditEvent event = (UndoableEditEvent) argument;
UndoableEdit edit = event.getEdit();
return edit.equals(expectedEdit);
}
示例15: undoableEditHappened
import javax.swing.event.UndoableEditEvent; //导入方法依赖的package包/类
public void undoableEditHappened(UndoableEditEvent e) {
super.addEdit(e.getEdit());
}