当前位置: 首页>>代码示例>>Java>>正文


Java UndoableEditEvent.getEdit方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:22,代码来源:GraphEditorTab.java

示例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
        }
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:17,代码来源:GraphTab.java

示例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());
    }

}
 
开发者ID:apache,项目名称:groovy,代码行数:24,代码来源:TextUndoManager.java

示例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());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:UndoRedoSupport.java

示例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);
			}
		}
	}
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:41,代码来源:UndoSupportInstaller.java

示例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);
}
 
开发者ID:vedun-z,项目名称:difftool,代码行数:9,代码来源:DiffPanel.java

示例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());
  }
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:29,代码来源:SPDataSourceTypeTest.java

示例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);
}
 
开发者ID:cping,项目名称:RipplePower,代码行数:10,代码来源:ROCEditorListener.java

示例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());
}
 
开发者ID:jindrapetrik,项目名称:jpexs-decompiler,代码行数:34,代码来源:CompoundUndoMan.java

示例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();
        }
    }
}
 
开发者ID:xjtu3c,项目名称:GranuleJ,代码行数:37,代码来源:UndoManager.java

示例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);
    }        
}
 
开发者ID:OpenIndex,项目名称:OpenIndex-SHEF,代码行数:15,代码来源:CompoundUndoManager.java

示例12: undoableEditHappened

import javax.swing.event.UndoableEditEvent; //导入方法依赖的package包/类
public void undoableEditHappened(UndoableEditEvent e)
{
    UndoableEdit edit = e.getEdit();
    if(undoer != null)
    {
        undoer.addEdit(edit);
        updateActions();
    }
}
 
开发者ID:OpenIndex,项目名称:OpenIndex-SHEF,代码行数:10,代码来源:TextEditPopupManager.java

示例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);
        }
    }
}
 
开发者ID:foxerfly,项目名称:Joeffice,代码行数:35,代码来源:TextUndoManager.java

示例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);
}
 
开发者ID:sarahtattersall,项目名称:PIPE,代码行数:8,代码来源:Contains.java

示例15: undoableEditHappened

import javax.swing.event.UndoableEditEvent; //导入方法依赖的package包/类
public void undoableEditHappened(UndoableEditEvent e) {
          super.addEdit(e.getEdit());
}
 
开发者ID:Compalg,项目名称:compalg,代码行数:4,代码来源:MyUndoRedoManager.java


注:本文中的javax.swing.event.UndoableEditEvent.getEdit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。