當前位置: 首頁>>代碼示例>>Java>>正文


Java CannotUndoException類代碼示例

本文整理匯總了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);
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:17,代碼來源:SystemStore.java

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

}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:BaseDocument.java

示例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);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:30,代碼來源:PropertiesOpen.java

示例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());
    
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:StableCompoundEditTest.java

示例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());
    
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:StableCompoundEditTest.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:DocumentTesting.java

示例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--;
  
}
 
開發者ID:oxygenxml,項目名稱:oxygen-git-plugin,代碼行數:12,代碼來源:UndoSupportInstaller.java

示例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);
	
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:20,代碼來源:PasteNetworkModel.java

示例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();
    }
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:24,代碼來源:LapTreeMVElement.java

示例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);
}
 
開發者ID:arodchen,項目名稱:MaxSim,代碼行數:20,代碼來源:DiagramScene.java

示例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();
}
 
開發者ID:ser316asu,項目名稱:Neukoelln_SER316,代碼行數:11,代碼來源:HTMLEditor.java

示例12: undo

import javax.swing.undo.CannotUndoException; //導入依賴的package包/類
@Override
public void undo() throws CannotUndoException {
    if (edit != null) {
        edit.end();
    }
    super.undo();
    edit = null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:UndoRedoSupport.java

示例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;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:BaseDocument.java

示例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;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:GuardedDocumentEvent.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:DocumentContent.java


注:本文中的javax.swing.undo.CannotUndoException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。