本文整理汇总了Java中javax.swing.undo.CannotUndoException类的典型用法代码示例。如果您正苦于以下问题:Java CannotUndoException类的具体用法?Java CannotUndoException怎么用?Java CannotUndoException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CannotUndoException类属于javax.swing.undo包,在下文中一共展示了CannotUndoException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: undo
import javax.swing.undo.CannotUndoException; //导入依赖的package包/类
@Override
public void undo() throws CannotUndoException {
super.undo();
try {
Set<QualName> deleted = new HashSet<>(this.newTexts.keySet());
deleted.removeAll(this.oldTexts.keySet());
doDeleteTexts(getResourceKind(), deleted);
if (this.oldProps != null) {
doPutProperties(this.oldProps);
}
doPutTexts(getResourceKind(), this.oldTexts);
} catch (IOException exc) {
throw new CannotUndoException();
}
notifyObservers(this);
}
示例2: undo
import javax.swing.undo.CannotUndoException; //导入依赖的package包/类
public @Override void undo() throws CannotUndoException {
atomicLockImpl ();
try {
TokenHierarchyControl<?> thcInactive = thcInactive();
try {
super.undo();
} finally {
if (thcInactive != null) {
thcInactive.setActive(true);
}
}
} finally {
atomicUnlockImpl ();
}
if (previousEdit != null) {
previousEdit.undo();
}
}
示例3: undo
import javax.swing.undo.CannotUndoException; //导入依赖的package包/类
/** Implements {@code UndoRedo}. Undo an edit. It finds a manager which next undo edit has the highest
* time stamp and makes undo on it.
* @exception CannotUndoException if it fails
*/
@Override
public synchronized void undo () throws CannotUndoException {
PropertiesEditorSupport.UndoRedoStampFlagManager chosenManager = (PropertiesEditorSupport.UndoRedoStampFlagManager)getNextUndo();
if (chosenManager == null) {
throw new CannotUndoException();
} else {
Object atomicFlag = chosenManager.getAtomicFlagOfEditToBeUndone();
if (atomicFlag == null) {// not linked with other edits as one atomic action
chosenManager.undo();
} else { // atomic undo compound from more edits in underlying managers
boolean undone;
do { // the atomic action can consists from more undo edits from same manager
undone = false;
for (Iterator<Manager> it = managers.iterator(); it.hasNext(); ) {
PropertiesEditorSupport.UndoRedoStampFlagManager manager = (PropertiesEditorSupport.UndoRedoStampFlagManager)it.next();
if(atomicFlag.equals(manager.getAtomicFlagOfEditToBeUndone())) {
manager.undo();
undone = true;
}
}
} while(undone);
}
}
}
示例4: testBasicFailUndo0
import javax.swing.undo.CannotUndoException; //导入依赖的package包/类
public void testBasicFailUndo0() throws Exception {
StableCompoundEdit cEdit = new StableCompoundEdit();
TestEdit e0 = new TestEdit(true);
TestEdit e1 = new TestEdit();
cEdit.addEdit(e0);
cEdit.addEdit(e1);
NbTestCase.assertFalse("Not ended yet", cEdit.canUndo());
NbTestCase.assertFalse("Not ended yet", cEdit.canRedo());
cEdit.end();
NbTestCase.assertTrue("Expected undoable", cEdit.canUndo());
NbTestCase.assertFalse("Expected non-redoable", cEdit.canRedo());
try {
cEdit.undo();
fail("Was expecting CannotUndoException exception.");
} catch (CannotUndoException ex) {
// Expected
}
NbTestCase.assertTrue("Expected undoable", cEdit.canUndo());
NbTestCase.assertFalse("Expected non-redoable", cEdit.canRedo());
NbTestCase.assertTrue("Expected undoable", e0.canUndo());
NbTestCase.assertFalse("Expected non-redoable", e0.canRedo());
NbTestCase.assertTrue("Expected undoable", e1.canUndo());
NbTestCase.assertFalse("Expected non-redoable", e1.canRedo());
}
示例5: testBasicFailUndo1
import javax.swing.undo.CannotUndoException; //导入依赖的package包/类
public void testBasicFailUndo1() throws Exception {
StableCompoundEdit cEdit = new StableCompoundEdit();
TestEdit e0 = new TestEdit();
TestEdit e1 = new TestEdit(true);
cEdit.addEdit(e0);
cEdit.addEdit(e1);
NbTestCase.assertFalse("Not ended yet", cEdit.canUndo());
NbTestCase.assertFalse("Not ended yet", cEdit.canRedo());
cEdit.end();
NbTestCase.assertTrue("Expected undoable", cEdit.canUndo());
NbTestCase.assertFalse("Expected non-redoable", cEdit.canRedo());
try {
cEdit.undo();
fail("Was expecting CannotUndoException exception.");
} catch (CannotUndoException ex) {
// Expected
}
NbTestCase.assertTrue("Expected undoable", cEdit.canUndo());
NbTestCase.assertFalse("Expected non-redoable", cEdit.canRedo());
NbTestCase.assertTrue("Expected undoable", e0.canUndo());
NbTestCase.assertFalse("Expected non-redoable", e0.canRedo());
NbTestCase.assertTrue("Expected undoable", e1.canUndo());
NbTestCase.assertFalse("Expected non-redoable", e1.canRedo());
}
示例6: undo
import javax.swing.undo.CannotUndoException; //导入依赖的package包/类
public static void undo(Context context, final int count) throws Exception {
final Document doc = getDocument(context);
final UndoManager undoManager = (UndoManager) doc.getProperty(UndoManager.class);
logUndoRedoOp(context, "UNDO", count);
invoke(context, new Runnable() {
@Override
public void run() {
try {
int cnt = count;
while (undoManager.canUndo() && --cnt >= 0) {
undoManager.undo();
}
} catch (CannotUndoException e) {
throw new IllegalStateException(e);
}
}
});
logPostUndoRedoOp(context, count);
}
示例7: undo
import javax.swing.undo.CannotUndoException; //导入依赖的package包/类
@Override
public void undo() {
if (!canUndo()) {
throw new CannotUndoException();
}
MyCompoundEdit u = edits.get(pointer);
u.undo();
pointer--;
}
示例8: undo
import javax.swing.undo.CannotUndoException; //导入依赖的package包/类
@Override
public void undo() throws CannotUndoException {
super.undo();
// --- Remove the added components --------------
HashSet<NetworkComponent> netComps2Remove = new HashSet<NetworkComponent>();
for (NetworkComponent networkComponentPasted : this.pastedNetworkModel.getNetworkComponents().values()) {
String netCompID = networkComponentPasted.getId();
NetworkComponent netCompRemove = this.graphController.getNetworkModel().getNetworkComponent(netCompID);
netComps2Remove.add(netCompRemove);
this.graphController.removeAgent(networkComponentPasted);
}
this.graphController.getNetworkModel().removeNetworkComponents(netComps2Remove);
NetworkModelNotification notification = new NetworkModelNotification(NetworkModelNotification.NETWORK_MODEL_Component_Removed);
notification.setInfoObject(netComps2Remove);
this.graphController.notifyObservers(notification);
}
示例9: undo
import javax.swing.undo.CannotUndoException; //导入依赖的package包/类
@Override
public void undo() throws CannotUndoException {
try {
ignore = true;
// take text from position - 1
String planText = history.get(position - 1);
// parse it
PoshParser parser = new PoshParser(new StringReader(planText));
PoshPlan plan = parser.parsePlan();
// synchronize with the editor tree
lapTree.synchronize(plan);
if (position > 0) {
--position;
}
} catch (ParseException ex) {
throw new CannotUndoException();
} finally {
ignore = false;
cs.fireChange();
}
}
示例10: undo
import javax.swing.undo.CannotUndoException; //导入依赖的package包/类
@Override
public void undo() throws CannotUndoException {
super.undo();
boolean b = scene.getUndoRedoEnabled();
scene.setUndoRedoEnabled(false);
scene.getModel().getViewChangedEvent().addListener(this);
scene.getModel().setData(oldModel);
scene.getModel().getViewChangedEvent().removeListener(this);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
scene.setScrollPosition(oldScrollPosition);
}
});
scene.setUndoRedoEnabled(b);
}
示例11: actionPerformed
import javax.swing.undo.CannotUndoException; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
try {
undo.undo();
} catch (CannotUndoException ex) {
System.out.println("Unable to undo: " + ex);
ex.printStackTrace();
}
update();
redoAction.update();
}
示例12: undo
import javax.swing.undo.CannotUndoException; //导入依赖的package包/类
@Override
public void undo() throws CannotUndoException {
if (edit != null) {
edit.end();
}
super.undo();
edit = null;
}
示例13: undoAtomicEdits
import javax.swing.undo.CannotUndoException; //导入依赖的package包/类
private void undoAtomicEdits() {
if (atomicEdits != null && atomicEdits.size() > 0) {
atomicEdits.end();
if (atomicEdits.canUndo()) {
atomicEdits.undo();
} else {
LOG.log(Level.WARNING,
"Cannot UNDO: " + atomicEdits.toString() + // NOI18N
" Edits: " + atomicEdits.getEdits(), // NOI18N
new CannotUndoException());
}
atomicEdits = null;
}
}
示例14: undo
import javax.swing.undo.CannotUndoException; //导入依赖的package包/类
public void undo() throws CannotUndoException {
GuardedDocument gdoc = (GuardedDocument)getDocument();
boolean origBreak = gdoc.breakGuarded;
gdoc.breakGuarded = true;
super.undo();
if (!origBreak) {
gdoc.breakGuarded = false;
}
}
示例15: undo
import javax.swing.undo.CannotUndoException; //导入依赖的package包/类
public @Override void undo() throws CannotUndoException {
super.undo();
if (debugUndo) {
/*DEBUG*/System.err.println("UNDO-" + dump()); // NOI18N
}
undoOrRedo(-length, true);
}