类javax.swing.undo.CannotUndoException源码实例Demo

下面列出了怎么用javax.swing.undo.CannotUndoException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: netbeans   文件: DocumentTesting.java
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);
}
 
源代码2 项目: opensim-gui   文件: ExperimentalMarkerSetNode.java
void setColorUI(final Color color, boolean allowUndo) {
    final Color oldColor = getColor();
    if (allowUndo){
        AbstractUndoableEdit auEdit = new AbstractUndoableEdit(){
            @Override
           public void undo() throws CannotUndoException {
               super.undo();
               setColorUI(oldColor, false);
           }
            @Override
           public void redo() throws CannotRedoException {
               super.redo();
               setColorUI(color, true);
           }
        };
        ExplorerTopComponent.addUndoableEdit(auEdit);
    }
    motionDisplayer.setDefaultExperimentalMarkerColor(color);
    
    refreshNode();
}
 
源代码3 项目: opensim-gui   文件: ExperimentalForceSetNode.java
void setColorUI(final Color color, boolean allowUndo) {
    final Color oldColor = getColor();
    if (allowUndo){
        AbstractUndoableEdit auEdit = new AbstractUndoableEdit(){
            @Override
           public void undo() throws CannotUndoException {
               super.undo();
               setColorUI(oldColor, false);
           }
            @Override
           public void redo() throws CannotRedoException {
               super.redo();
               setColorUI(color, true);
           }
        };
        ExplorerTopComponent.addUndoableEdit(auEdit);
    }
    motionDisplayer.setDefaultForceColor(color);
    
    refreshNode();
}
 
源代码4 项目: snap-desktop   文件: VectorDataFigureEditor.java
@Override
public void deleteFigures(boolean performDelete, Figure... figures) {
    Debug.trace("VectorDataFigureEditor.deleteFigures " + performDelete + ", " + figures.length);
    if (vectorDataNode != null) {
        List<SimpleFeature> simpleFeatures = toSimpleFeatureList(figures);
        vectorDataNode.getFeatureCollection().removeAll(simpleFeatures);
        getUndoContext().postEdit(new FigureDeleteEdit(this, performDelete, figures) {
            @Override
            public void undo() throws CannotUndoException {
                super.undo();
                vectorDataNode.getFeatureCollection().addAll(simpleFeatures);
            }

            @Override
            public void redo() throws CannotRedoException {
                super.redo();
                vectorDataNode.getFeatureCollection().removeAll(simpleFeatures);
            }
        });
    } else {
        // warn
        super.deleteFigures(performDelete, figures);
    }
}
 
源代码5 项目: energy2d   文件: UndoEditBlob.java
@Override
public void undo() throws CannotUndoException {
	super.undo();
	int n = blob.getPointCount();
	for (int i = 0; i < n; i++) {
		Point2D.Float pi = blob.getPoint(i);
		newPoints.add(new Point2D.Float(pi.x, pi.y));
	}
	blob.setPoints(oldPoints);
	view.getModel().refreshPowerArray();
	view.getModel().refreshTemperatureBoundaryArray();
	view.getModel().refreshMaterialPropertyArrays();
	if (view.isViewFactorLinesOn())
		view.getModel().generateViewFactorMesh();
	view.setSelectedManipulable(selectedManipulable);
	view.repaint();
}
 
源代码6 项目: openjdk-8   文件: DiagramScene.java
@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() {

        public void run() {
            scene.setScrollPosition(oldScrollPosition);
        }
    });

    scene.setUndoRedoEnabled(b);
}
 
源代码7 项目: energy2d   文件: UndoEditPolygon.java
@Override
public void undo() throws CannotUndoException {
	super.undo();
	int n = polygon.getVertexCount();
	for (int i = 0; i < n; i++) {
		Point2D.Float pi = polygon.getVertex(i);
		newPoints.add(new Point2D.Float(pi.x, pi.y));
	}
	polygon.setVertices(oldPoints);
	view.getModel().refreshPowerArray();
	view.getModel().refreshTemperatureBoundaryArray();
	view.getModel().refreshMaterialPropertyArrays();
	if (view.isViewFactorLinesOn())
		view.getModel().generateViewFactorMesh();
	view.setSelectedManipulable(selectedManipulable);
	view.repaint();
}
 
源代码8 项目: Pixelitor   文件: NewLayerEdit.java
@Override
public void undo() throws CannotUndoException {
    super.undo();

    comp.deleteLayer(newLayer, false);
    comp.setActiveLayer(activeLayerBefore);

    viewModeBefore.activate(comp, activeLayerBefore);
}
 
源代码9 项目: openAGV   文件: UndoRedoManager.java
/**
 * Redoes the last undone edit event.
 * The UndoRedoManager ignores all incoming UndoableEdit events,
 * while redo is in progress.
 */
@Override
public void redo()
    throws CannotUndoException {
  undoOrRedoInProgress = true;

  try {
    super.redo();
  }
  finally {
    undoOrRedoInProgress = false;
    updateActions();
  }
}
 
源代码10 项目: niftyeditor   文件: RedoCommand.java
@Override
public void perform() throws Exception {
    try{
        manager.redo();
    }catch(CannotUndoException ex){
        ex.printStackTrace(); 
    }
}
 
源代码11 项目: Pixelitor   文件: SubPathStartEdit.java
@Override
public void undo() throws CannotUndoException {
    super.undo();

    boolean noMoreLeft = path.deleteLastSubPath();
    assert wasFirstSP == noMoreLeft;
    if (noMoreLeft) {
        Tools.PEN.removePath();
    }
    path.setBuildState(NO_INTERACTION);
    comp.repaint();
}
 
源代码12 项目: netbeans   文件: StableCompoundEditTest.java
@Override
public void undo() throws CannotUndoException {
    if (fireException) {
        throw new CannotUndoException();
    }
    super.undo();
}
 
源代码13 项目: tracker   文件: PencilControl.java
@Override
public void redo() throws CannotUndoException {
  super.redo();
  scene.getDrawings().add(drawing);
  setSelectedScene(scene);
  goToScene(scene);
  trackerPanel.repaint();
}
 
源代码14 项目: energy2d   文件: UndoFlipManipulable.java
@Override
public void undo() throws CannotUndoException {
	super.undo();
	if (selectedManipulable instanceof Part) {
		Shape shape = selectedManipulable.getShape();
		if (shape instanceof TransformableShape) {
			TransformableShape s = (TransformableShape) shape;
			switch (flipDirection) {
			case 0:
				s.flipX();
				break;
			case 1:
				s.flipY();
				break;
			}
			if (s instanceof Blob2D) {
				((Blob2D) s).update();
			}
			model.refreshPowerArray();
			model.refreshTemperatureBoundaryArray();
			model.refreshMaterialPropertyArrays();
			if (view.isViewFactorLinesOn())
				model.generateViewFactorMesh();
		}
	}
	view.setSelectedManipulable(selectedManipulable);
	view.repaint();
}
 
源代码15 项目: java-swing-tips   文件: MainPanel.java
@Override public void actionPerformed(ActionEvent e) {
  try {
    undoManager.undo();
  } catch (CannotUndoException ex) {
    Toolkit.getDefaultToolkit().beep();
  }
}
 
源代码16 项目: opensim-gui   文件: ConnectionEditor.java
private void handleConnectionChange(final String oldValue, final String v, boolean supportUndo) {

        try {
            context.setSocketConnecteePath(connector, v);
         } catch (IOException iae) {
                 new JOptionPane(iae.getMessage(), 
                     JOptionPane.ERROR_MESSAGE).createDialog(null, "Error").setVisible(true);
                 return; // change failed, no harm done

        }
        handleConnectionChangeCommon();
        
        if (supportUndo) {
            AbstractUndoableEdit auEdit = new AbstractUndoableEdit() {

                @Override
                public void undo() throws CannotUndoException {
                    super.undo();
                    setConnectedToPathAndPropagateChange(oldValue, false);
                }

                @Override
                public String getUndoPresentationName() {
                    return "Undo "+connector.getName()+" change";
                }

                @Override
                public void redo() throws CannotRedoException {
                    super.redo();
                    setConnectedToPathAndPropagateChange(v, true);
                }
                 @Override
                public String getRedoPresentationName() {
                    return "Redo "+connector.getName()+" change";
                }
           };
            ExplorerTopComponent.addUndoableEdit(auEdit);
        }
    }
 
/**
 * Undoes a change.
 *
 * @exception CannotUndoException if the change cannot be undone
 */
public void undo() throws CannotUndoException {
    super.undo();
    MutableAttributeSet as = (MutableAttributeSet)element.getAttributes();
    as.removeAttributes(as);
    as.addAttributes(copy);
}
 
源代码18 项目: MeteoInfo   文件: FrmMain.java
private void jButton_ZoomUndoActionPerformed(ActionEvent evt) {
    try {
        zoomUndoManager.undo();
    } catch (CannotUndoException cre) {
    }
    this.refreshZoomUndoRedo();
}
 
源代码19 项目: energy2d   文件: UndoRotateManipulable.java
@Override
public void undo() throws CannotUndoException {
	super.undo();
	if (selectedManipulable instanceof Part) {
		Shape shape = selectedManipulable.getShape();
		if (shape instanceof TransformableShape) {
			TransformableShape s = (TransformableShape) shape;
			s.rotateBy(-rotationAngle);
			if (s instanceof Blob2D) {
				((Blob2D) s).update();
			}
			model.refreshPowerArray();
			model.refreshTemperatureBoundaryArray();
			model.refreshMaterialPropertyArrays();
			if (view.isViewFactorLinesOn())
				model.generateViewFactorMesh();
		}
	} else if (selectedManipulable instanceof Particle) {
	} else if (selectedManipulable instanceof Fan) {
	} else if (selectedManipulable instanceof HeatFluxSensor) {
		HeatFluxSensor heatFluxSensor = (HeatFluxSensor) selectedManipulable;
		newAngle = heatFluxSensor.getAngle();
		heatFluxSensor.setAngle(oldAngle);
	}
	view.setSelectedManipulable(selectedManipulable);
	view.repaint();
}
 
源代码20 项目: Robot-Overlord-App   文件: ActionEntityRemove.java
@Override
public void undo() throws CannotUndoException {
	super.undo();
	ro.getWorld().addChild(entity);
	ro.updateEntityTree();
	ro.pickEntity(entity);
}
 
源代码21 项目: osp   文件: LauncherUndo.java
public void redo() throws CannotUndoException {
  super.redo();
  launcher.postEdits = false;
  launcher.open(args);
  launcher.refreshGUI();
  launcher.postEdits = true;
}
 
源代码22 项目: jdk8u60   文件: DefaultStyledDocument.java
/**
 * Undoes a change.
 *
 * @exception CannotUndoException if the change cannot be undone
 */
public void undo() throws CannotUndoException {
    super.undo();
    MutableAttributeSet as = (MutableAttributeSet)element.getAttributes();
    as.removeAttributes(as);
    as.addAttributes(copy);
}
 
源代码23 项目: JDKSourceCode1.8   文件: DefaultStyledDocument.java
/**
 * Undoes a change.
 *
 * @exception CannotUndoException if the change cannot be undone
 */
public void undo() throws CannotUndoException {
    super.undo();
    MutableAttributeSet as = (MutableAttributeSet)element.getAttributes();
    as.removeAttributes(as);
    as.addAttributes(copy);
}
 
源代码24 项目: niftyeditor   文件: EditAttributeCommand.java
@Override
public void undo() throws CannotUndoException {
    super.undo();
    if(toBeEdited == null){
        
        this.editor.getElementEditor().setAttribute(attribute, oldValue);
    }else{
       
        this.editor.getElementEditor(toBeEdited).setAttribute(attribute, oldValue);
    }
    
}
 
源代码25 项目: Pixelitor   文件: AddAnchorPointEdit.java
@Override
public void undo() throws CannotUndoException {
    super.undo();

    subPath.deleteLast();

    comp.repaint();
}
 
源代码26 项目: SikuliX1   文件: EditorUndoManager.java
@Override
public void undo() throws CannotUndoException {
   if (!canUndo()) {
      throw new CannotUndoException();
   }

   MyCompoundEdit u=edits.get(pointer);
   u.undo();
   pointer--;

   refreshControls();
}
 
源代码27 项目: openjdk-jdk8u-backup   文件: GapContent.java
public void undo() throws CannotUndoException {
    super.undo();
    try {
        // Get the Positions in the range being removed.
        posRefs = getPositionsInRange(null, offset, length);
        string = getString(offset, length);
        remove(offset, length);
    } catch (BadLocationException bl) {
      throw new CannotUndoException();
    }
}
 
源代码28 项目: openjdk-jdk8u   文件: GapContent.java
public void undo() throws CannotUndoException {
    super.undo();
    try {
        insertString(offset, string);
        // Update the Positions that were in the range removed.
        if(posRefs != null) {
            updateUndoPositions(posRefs, offset, length);
            posRefs = null;
        }
        string = null;
    } catch (BadLocationException bl) {
      throw new CannotUndoException();
    }
}
 
源代码29 项目: gameserver   文件: MyUndoManager.java
@Override
public synchronized void undo() throws CannotUndoException {
	super.undo();
	for ( UndoRedoListener listener: list ) {
		listener.redoHappened();
	}
}
 
源代码30 项目: jdk8u-jdk   文件: DefaultStyledDocument.java
/**
 * Undoes a change.
 *
 * @exception CannotUndoException if the change cannot be undone
 */
public void undo() throws CannotUndoException {
    super.undo();
    MutableAttributeSet as = (MutableAttributeSet)element.getAttributes();
    as.removeAttributes(as);
    as.addAttributes(copy);
}
 
 类所在包
 类方法
 同包方法