當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。