当前位置: 首页>>代码示例>>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;未经允许,请勿转载。