本文整理匯總了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);
}