本文整理汇总了Java中javax.swing.event.UndoableEditEvent类的典型用法代码示例。如果您正苦于以下问题:Java UndoableEditEvent类的具体用法?Java UndoableEditEvent怎么用?Java UndoableEditEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UndoableEditEvent类属于javax.swing.event包,在下文中一共展示了UndoableEditEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: endCompoundEdit
import javax.swing.event.UndoableEditEvent; //导入依赖的package包/类
public CompoundEdit endCompoundEdit(boolean commit) {
if (compoundEdit != null) {
t("ending compound edit: "+commit); // NOI18N
compoundEdit.end();
if (commit && undoRedoRecording && compoundEdit.isSignificant()) {
if (!formModifiedLogged) {
Logger logger = Logger.getLogger("org.netbeans.ui.metrics.form"); // NOI18N
LogRecord rec = new LogRecord(Level.INFO, "USG_FORM_MODIFIED"); // NOI18N
rec.setLoggerName(logger.getName());
logger.log(rec);
formModifiedLogged = true;
}
getUndoRedoManager().undoableEditHappened(
new UndoableEditEvent(this, compoundEdit));
}
CompoundEdit edit = compoundEdit;
compoundEdit = null;
return edit;
}
return null;
}
示例2: doUndoRedoTest
import javax.swing.event.UndoableEditEvent; //导入依赖的package包/类
private void doUndoRedoTest(UndoRedo.Manager ur) {
assertFalse("Nothing to undo", ur.canUndo());
ur.addChangeListener(this);
MyEdit me = new MyEdit();
ur.undoableEditHappened(new UndoableEditEvent(this, me));
assertChange("One change");
assertTrue("Can undo now", ur.canUndo());
ur.undo();
assertFalse("Cannot undo", ur.canUndo());
assertChange("Snd change");
assertTrue("But redo", ur.canRedo());
ur.redo();
assertChange("Third change");
assertEquals("One undo", 1, me.undo);
assertEquals("One redo", 1, me.redo);
}
示例3: createTab
import javax.swing.event.UndoableEditEvent; //导入依赖的package包/类
private void createTab()
{
jep=new JEditorPane();
jsp=new JScrollPane(jep);
panes.add(jsp);
jep.setContentType("text/plain");
typeOFileLabel.setText("Plain Text File");
editorPanes.add(jep);
new CaretMonitor(jep, caretPosLabel);
jep.addCaretListener(this);
jep.getDocument().addUndoableEditListener((UndoableEditEvent uee) -> {
undo.addEdit(uee.getEdit()); });
tabbedPane.addTab("*Tab "+(ct+1),jsp);
tabbedPane.setSelectedIndex(ct);
tabbedPane.setTabComponentAt(ct,new ButtonTabComponent(tabbedPane));
ct++;
setToolbar();
}
示例4: undoableEditHappened
import javax.swing.event.UndoableEditEvent; //导入依赖的package包/类
public void undoableEditHappened(UndoableEditEvent e) {
//Remember the edit and update the menus
undo.addEdit(e.getEdit());
//undoAction.updateUndoState();
//redoAction.updateRedoState();
if (undo.canUndo()) {
TEdit.setEnabled("Undo",true);
TEdit.putValue("Undo", undo.getUndoPresentationName());
} else {
TEdit.setEnabled("Undo",false);
TEdit.putValue("Undo", "Undo");
}
if (undo.canRedo()) {
TEdit.setEnabled("Redo",true);
TEdit.putValue("Redo",undo.getRedoPresentationName());
} else {
TEdit.setEnabled("Redo",false);
TEdit.putValue("Redo","Redo");
}
}
示例5: 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();
}
}
示例6: 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
}
}
}
示例7: undoableEditHappened
import javax.swing.event.UndoableEditEvent; //导入依赖的package包/类
public void undoableEditHappened(UndoableEditEvent e) {
// Remember the edit and update the menus
undo.addEdit(e.getEdit());
if (undo.canUndo()) {
((BrowserMDIFrame)internalFrame.getParentFrame()).actionUndo.setEnabled(true);
} else {
((BrowserMDIFrame)internalFrame.getParentFrame()).actionUndo.setEnabled(false);
}
if (undo.canRedo()) {
((BrowserMDIFrame)internalFrame.getParentFrame()).actionRedo.setEnabled(true);
} else {
((BrowserMDIFrame)internalFrame.getParentFrame()).actionRedo.setEnabled(false);
}
/*
* internalFrame.getParentFrame(). undoAction.updateUndoState();
* redoAction.updateRedoState();
*/
}
示例8: XMLTextEditor
import javax.swing.event.UndoableEditEvent; //导入依赖的package包/类
/** Creates a new instance of XMLEditorPane */
public XMLTextEditor() {
super();
XMLEditorKit kit = new XMLEditorKit();
setEditorKitForContentType(XMLEditorKit.XML_MIME_TYPE, kit);
setContentType(XMLEditorKit.XML_MIME_TYPE);
setBackground(Color.white);
//setFont(new Font("Monospaced", Font.PLAIN, 12));
// add undoable edit
undoManager = new UndoManager();
UndoableEditListener undoableEditHandler = new UndoableEditListener() {
public void undoableEditHappened(UndoableEditEvent e) {
undoManager.addEdit(e.getEdit());
}
};
getDocument().addUndoableEditListener(undoableEditHandler);
}
示例9: SemanticAnnotation
import javax.swing.event.UndoableEditEvent; //导入依赖的package包/类
/** Creates new form SemanticAnnotation */
public SemanticAnnotation(String inputFile) {
this.inputFile = inputFile;
initComponents();
readInputFile();
spinner.setValue(0);
selectButton.doClick();
splitPane.setDividerLocation(0.5);
outText.getDocument().addUndoableEditListener(
new UndoableEditListener() {
public void undoableEditHappened(UndoableEditEvent e) {
undoManager.addEdit(e.getEdit());
}
});
}
示例10: updateFrame
import javax.swing.event.UndoableEditEvent; //导入依赖的package包/类
/**
* Updates the frame that is represented by the specified element to
* refer to the specified URL.
*
* @param el the element
* @param url the new url
*/
private void updateFrame(Element el, URL url)
{
try
{
writeLock();
DefaultDocumentEvent ev =
new DefaultDocumentEvent(el.getStartOffset(), 1,
DocumentEvent.EventType.CHANGE);
AttributeSet elAtts = el.getAttributes();
AttributeSet copy = elAtts.copyAttributes();
MutableAttributeSet matts = (MutableAttributeSet) elAtts;
ev.addEdit(new AttributeUndoableEdit(el, copy, false));
matts.removeAttribute(HTML.Attribute.SRC);
matts.addAttribute(HTML.Attribute.SRC, url.toString());
ev.end();
fireChangedUpdate(ev);
fireUndoableEditUpdate(new UndoableEditEvent(this, ev));
}
finally
{
writeUnlock();
}
}
示例11: putPropertyImpl
import javax.swing.event.UndoableEditEvent; //导入依赖的package包/类
/**
* Modifies the value of the named property, firing a change event if the
* new value differs from the pre-existing one.
*
* @param javaPropName
* The name of the JavaBeans property you are modifying. If the
* change does not correspond with a bean property, or you want
* to suppress the property change event, this parameter should
* be null.
* @param plPropName
* The name of PL.INI the property to set/update (this is also
* the key in the in-memory properties map)
* @param propValue
* The new value for the property
*/
private void putPropertyImpl(String javaPropName, String plPropName, String propValue) {
String oldValue = properties.get(plPropName);
properties.put(plPropName, propValue);
classLoader = getClassLoaderFromCache(); // in case this changes the classpath
if (javaPropName != null) {
firePropertyChange(javaPropName, oldValue, propValue);
}
if ((oldValue == null && propValue != null) || (oldValue != null && !oldValue.equals(propValue))) {
UndoableEdit edit = new UndoablePropertyEdit(plPropName, oldValue, propValue, this);
for (int i = undoableEditListeners.size() -1; i >= 0; i--) {
undoableEditListeners.get(i).undoableEditHappened(new UndoableEditEvent(this, edit));
}
}
}
示例12: testUndoOnSetters
import javax.swing.event.UndoableEditEvent; //导入依赖的package包/类
/**
* The setters on the DSType uses a different method to set properties than the
* one used in testUndoAndRedo. This confirms that the setters do create undo and
* redo edits.
*/
public void testUndoOnSetters() throws Exception {
final JDBCDataSourceType dsType = new JDBCDataSourceType();
class TestUndoableEditListener implements UndoableEditListener {
private int editCount = 0;
public void undoableEditHappened(UndoableEditEvent e) {
editCount++;
}
public int getEditCount() {
return editCount;
}
}
TestUndoableEditListener undoableEditListener = new TestUndoableEditListener();
dsType.addUndoableEditListener(undoableEditListener);
dsType.setComment("comment");
dsType.setDDLGeneratorClass("class");
dsType.setName("name");
assertEquals(3, undoableEditListener.getEditCount());
}
示例13: undoableEditHappened
import javax.swing.event.UndoableEditEvent; //导入依赖的package包/类
public void undoableEditHappened(UndoableEditEvent e) {
IApplication app = getSession().getApplication();
SquirrelPreferences prefs = app.getSquirrelPreferences();
if (fileOpened || fileSaved) {
if (prefs.getWarnForUnsavedFileEdits()) {
unsavedEdits = true;
}
getActiveSessionTabWidget().setUnsavedEdits(true);
ActionCollection actions =
getSession().getApplication().getActionCollection();
actions.enableAction(FileSaveAction.class, true);
} else if (prefs.getWarnForUnsavedBufferEdits()) {
unsavedEdits = true;
}
}
示例14: 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());
}
}
示例15: movementFinished
import javax.swing.event.UndoableEditEvent; //导入依赖的package包/类
/**
*
* @param widget
*/
@Override
public void movementFinished(Widget widget) {
if (widget instanceof TitleWidget) {
widget = ((TitleWidget) widget).parent;
}
String n = (String) findObject(widget);
WorkspaceObject obj = ws.getActiveLayer().getObjectById(n);
if (obj != null) {
obj.setLoc(new org.vap.core.model.micro.Point(widget.getLocation()));
}
MyAbstractUndoableEdit myAbstractUndoableEdit = new MyAbstractUndoableEdit(widget);
manager.undoableEditHappened(new UndoableEditEvent(widget, myAbstractUndoableEdit));
//XXX: Savable support
file.makeDirty();
}