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

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

源代码1 项目: CQL   文件: ModelVertex.java
/**
 * Add a constraint to the set of constraints of which this node is a part
 *
 * @param con the constraint
 */
public void addConstraint(final ModelConstraint<F, GM, M, N, E> con) {
	final boolean added = _constraints.add(con);

	if (added) {
		getMModel().getGraphModel().postEdit(new AbstractUndoableEdit() {
			/**
			 *                
			 */
			private static final long serialVersionUID = 2332966369924855958L;

			@Override
			public void undo() {
				super.undo();
				_constraints.remove(con);
			}

			@Override
			public void redo() {
				super.redo();
				_constraints.add(con);
			}
		});
	}
}
 
源代码2 项目: CQL   文件: ModelInfoTreeUI.java
/**
 * Adds an entity and its attributes to the tree
 *
 * @param entity The entity to be added to the tree
 */
public void addNode(final N entity) {
	EasikGraphModel model = _theFrame.getMModel().getGraphModel();

	model.beginUpdate();
	_addEntity(entity);
	model.postEdit(new AbstractUndoableEdit() {
		private static final long serialVersionUID = -731839601016126887L;

		@Override
		public void undo() {
			super.undo();
			_removeEntity(entity);
		}

		@Override
		public void redo() {
			super.redo();
			_addEntity(entity);
		}
	});
	model.endUpdate();
}
 
源代码3 项目: CQL   文件: ModelInfoTreeUI.java
/**
 * Removes an entity from the tree. Undoable.
 *
 * @param toRemove Entity to be removed from the tree
 */
public void removeNode(final N toRemove) {
	EasikGraphModel model = _theFrame.getMModel().getGraphModel();

	model.beginUpdate();
	_removeEntity(toRemove);
	model.postEdit(new AbstractUndoableEdit() {
		private static final long serialVersionUID = 5641595793303538595L;

		@Override
		public void undo() {
			super.undo();
			_addEntity(toRemove);
		}

		@Override
		public void redo() {
			super.redo();
			_removeEntity(toRemove);
		}
	});
	model.endUpdate();
}
 
源代码4 项目: CQL   文件: ModelInfoTreeUI.java
/**
 * Remove a constraint from the info tree. This action will factor into the
 * Sketch's undo/redo history as a single action.
 *
 * @param constraint The constraint to remove
 * @since 2006-05-30 Vera Ranieri
 */
public void removeConstraint(final ModelConstraint<F, GM, M, N, E> constraint) {
	storeExpansion();

	EasikGraphModel model = _theFrame.getMModel().getGraphModel();

	model.beginUpdate();
	_removeConstraint(constraint);
	model.postEdit(new AbstractUndoableEdit() {
		private static final long serialVersionUID = -6234979876902120545L;

		@Override
		public void undo() {
			super.undo();
			_addConstraint(constraint);
		}

		@Override
		public void redo() {
			super.redo();
			_removeConstraint(constraint);
		}
	});
	model.endUpdate();
	revertExpansion();
}
 
源代码5 项目: openAGV   文件: BringToFrontAction.java
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
  final DrawingView view = getView();
  final LinkedList<Figure> figures = new LinkedList<>(view.getSelectedFigures());
  bringToFront(view, figures);
  fireUndoableEditHappened(new AbstractUndoableEdit() {
    @Override
    public String getPresentationName() {
      return ResourceBundleUtil.getBundle(TOOLBAR_PATH).getString("bringToFrontAction.undo.presentationName");
    }

    @Override
    public void redo()
        throws CannotRedoException {
      super.redo();
      BringToFrontAction.bringToFront(view, figures);
    }

    @Override
    public void undo()
        throws CannotUndoException {
      super.undo();
      SendToBackAction.sendToBack(view, figures);
    }
  });
}
 
源代码6 项目: openAGV   文件: SendToBackAction.java
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
  final DrawingView view = getView();
  final LinkedList<Figure> figures = new LinkedList<>(view.getSelectedFigures());
  sendToBack(view, figures);
  fireUndoableEditHappened(new AbstractUndoableEdit() {
    @Override
    public String getPresentationName() {
      return ResourceBundleUtil.getBundle(TOOLBAR_PATH).getString("sendToBackAction.undo.presentationName");
    }

    @Override
    public void redo()
        throws CannotRedoException {
      super.redo();
      SendToBackAction.sendToBack(view, figures);
    }

    @Override
    public void undo()
        throws CannotUndoException {
      super.undo();
      BringToFrontAction.bringToFront(view, figures);
    }
  });
}
 
源代码7 项目: opensim-gui   文件: ExplorerTopComponent.java
public static void addUndoableEdit(AbstractUndoableEdit aUndoableEdit)
{
    instance.getUndoRedoManager().addEdit(aUndoableEdit);
    if (java.awt.EventQueue.isDispatchThread()) {
        getVisualizerTopComponent().requestActive();
    }
    else {
        SwingUtilities.invokeLater(new Runnable(){

        @Override
        public void run() {
            getVisualizerTopComponent().requestActive();
        }
    });
    }
 }
 
源代码8 项目: 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();
}
 
源代码9 项目: opensim-gui   文件: ExperimentalForceSetNode.java
void setForceScaleFactorUI(final double newFactor, boolean allowUndo)
{
    final double oldForceScaleFactor = getForceScaleFactor();
    if (allowUndo){
        AbstractUndoableEdit auEdit = new AbstractUndoableEdit(){
           @Override
           public void undo() throws CannotUndoException {
               super.undo();
               setForceScaleFactorUI(oldForceScaleFactor, false);
           }
           @Override
           public void redo() throws CannotRedoException {
               super.redo();
               setForceScaleFactorUI(newFactor, true);
           }
        };
        ExplorerTopComponent.addUndoableEdit(auEdit);
    }       
    motionDisplayer.setExperimentalForceScaleFactor(newFactor);
    
    refreshNode();
}
 
源代码10 项目: 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();
}
 
源代码11 项目: opensim-gui   文件: ExperimentalMarkerSetNode.java
void setMarkerRadiusUI(final double newRadius, boolean allowUndo)
{
    final double oldMarkerSize = getMarkerRadius();
    if (allowUndo){
        AbstractUndoableEdit auEdit = new AbstractUndoableEdit(){
           @Override
           public void undo() throws CannotUndoException {
               super.undo();
               setMarkerRadiusUI(oldMarkerSize, false);
           }
           @Override
           public void redo() throws CannotRedoException {
               super.redo();
               setMarkerRadiusUI(newRadius, false);
           }
        };
        ExplorerTopComponent.addUndoableEdit(auEdit);
    }       
    motionDisplayer.setExperimentalMarkerRadius(newRadius);
    
    refreshNode();
}
 
源代码12 项目: opensim-gui   文件: MarkerAdapter.java
private void setBodyName(final String bodyName, boolean enableUndo) {
    final String oldName = getBodyName();
    if (bodyName.equals(oldName)) return; // Nothing to do
    //marker.setParentFrameName(bodyName); 
    // The following line calls setParentFrame
    context.setBody(marker, model.getBodySet().get(bodyName), true);
    updateDisplay();
    if (enableUndo){
        AbstractUndoableEdit auEdit = new AbstractUndoableEdit(){
           public void undo() throws CannotUndoException {
               super.undo();
               setBodyName(oldName, false);
           }
           public void redo() throws CannotRedoException {
               super.redo();
               setBodyName(bodyName, true);
           }
        };
        ExplorerTopComponent.addUndoableEdit(auEdit);
    }
    SingleModelGuiElements guiElem = OpenSimDB.getInstance().getModelGuiElements(model);
    guiElem.setUnsavedChangesFlag(true);

}
 
源代码13 项目: opensim-gui   文件: MarkerAdapter.java
public void setLocation(final Vec3 newOffset, boolean enableUndo) {
    Vec3 rOffest = marker.get_location();
    final Vec3 oldOffset = new Vec3(rOffest);
    marker.set_location(newOffset);
    updateDisplay(); 
    if (enableUndo){
         AbstractUndoableEdit auEdit = new AbstractUndoableEdit(){
           public void undo() throws CannotUndoException {
               super.undo();
               setLocation(oldOffset, false);
           }
           public void redo() throws CannotRedoException {
               super.redo();
               setLocation(newOffset, true);
           }
        };
        ExplorerTopComponent.addUndoableEdit(auEdit);            
    }
    SingleModelGuiElements guiElem = OpenSimDB.getInstance().getModelGuiElements(model);
    guiElem.setUnsavedChangesFlag(true);
}
 
源代码14 项目: opensim-gui   文件: OneBodyNode.java
private void setCOMfromArray(final ArrayDouble newOffset, boolean enableUndo) {
    Body body = Body.safeDownCast(getOpenSimObject());
    Vec3 rOffest = body.get_mass_center();
    final ArrayDouble oldOffset = new ArrayDouble(3);
    for(int i=0; i<3; i++) oldOffset.set(i, rOffest.get(i));
    body.setMassCenter(newOffset.getAsVec3());
    Model model = body.getModel();
    UUID comUuid = ViewDB.getInstance().getModelVisualizationJson(model).getBodyRep(comp).getComObjectUUID();
    ViewDB.getInstance().setObjectTranslationInParentByUuid(comUuid, body.getMassCenter());
    refreshNode();
    if (enableUndo){
         AbstractUndoableEdit auEdit = new AbstractUndoableEdit(){
           public void undo() throws CannotUndoException {
               super.undo();
               setCOMfromArray(oldOffset, false);
           }
           public void redo() throws CannotRedoException {
               super.redo();
               setCOMfromArray(newOffset, true);
           }
        };
        ExplorerTopComponent.addUndoableEdit(auEdit);            
    }
}
 
源代码15 项目: CQL   文件: QueryNode.java
/**
 * Creates a new
 * EntityAttribute<ViewFrame,ViewGraphModel,View,QueryNode,View_Edge> and add
 * its to the list of attributes
 *
 * @param inAtt The
 *              EntityAttribute<ViewFrame,ViewGraphModel,View,QueryNode,View_Edge>
 *              to add to this EntityNode.
 */
@Override
public void addEntityAttribute(final EntityAttribute<ViewFrame, ViewGraphModel, View, QueryNode, View_Edge> inAtt) {
	_entityAttributes.add(inAtt);
	getAttributeNode().add(inAtt);
	_theModel.refresh();
	_theModel.getFrame().getInfoTreeUI().refreshTree(this);
	_theModel.getGraphModel().postEdit(new AbstractUndoableEdit() {
		/**
		 *            
		 */
		private static final long serialVersionUID = -8359488490185936367L;

		@Override
		public void undo() {
			super.undo();
			_entityAttributes.remove(inAtt);
			getAttributeNode().remove(inAtt);
			_theModel.refresh();
			_theModel.getFrame().getInfoTreeUI().refreshTree(QueryNode.this);
		}

		@Override
		public void redo() {
			super.redo();
			_entityAttributes.add(inAtt);
			getAttributeNode().add(inAtt);
			_theModel.refresh();
			_theModel.getFrame().getInfoTreeUI().refreshTree(QueryNode.this);
		}
	});
}
 
源代码16 项目: CQL   文件: EntityNode.java
/**
 * Add a constraint to the set of constraints of which this node is a part
 *
 * @param con the constraint
 */
@Override
public void addConstraint(
		final ModelConstraint<SketchFrame, SketchGraphModel, Sketch, EntityNode, SketchEdge> con) {
	final boolean added = _constraints.add(con);

	if (added) {
		getMModel().getGraphModel().postEdit(new AbstractUndoableEdit() {
			/**
			 *                
			 */
			private static final long serialVersionUID = 2332966369924855958L;

			@Override
			public void undo() {
				super.undo();
				_constraints.remove(con);
			}

			@Override
			public void redo() {
				super.redo();
				_constraints.add(con);
			}
		});
	}
}
 
源代码17 项目: CQL   文件: Model.java
/**
 * Adds a constraint to the sketch. This will register the constraint in the
 * constraint list, as well as adding a visual representation of the constraint
 * to the graph.
 *
 * @param c The constraint to be added.
 */
@SuppressWarnings("unchecked")
public void addConstraint(final ModelConstraint<F, GM, M, N, E> c) {
	// Push loading state
	_stateManager.pushState(new LoadingState<>((M) this));
	model.beginUpdate();
	_constraints.put(c.getID(), c);
	c.setVisible(c.isVisible());
	_Frame.getInfoTreeUI().addConstraint(c);
	model.postEdit(new AbstractUndoableEdit() {
		/**
		*            
		*/
		private static final long serialVersionUID = -4081680510909421247L;

		@Override
		public void undo() {
			super.undo();
			_constraints.remove(c.getID());
		}

		@Override
		public void redo() {
			super.redo();
			_constraints.put(c.getID(), c);
		}
	});
	model.endUpdate();

	// Pop state
	_stateManager.popState();
}
 
源代码18 项目: CQL   文件: ModelVertex.java
/**
 * Creates a new
 * EntityAttribute<SketchFrame,SketchGraphModel,Sketch,EntityNode,SketchEdge>
 * and add its to the list of attributes
 *
 * @param inAtt The
 *              EntityAttribute<SketchFrame,SketchGraphModel,Sketch,EntityNode,SketchEdge>
 *              to add to this EntityNode.
 */
public void addEntityAttribute(final EntityAttribute<F, GM, M, N, E> inAtt) {
	for (EntityAttribute<F, GM, M, N, E> ea : _entityAttributes) {
		if (inAtt.getName().equals(ea.getName())) {
			return;
		}
	}
	_entityAttributes.add(inAtt);
	getAttributeNode().add(inAtt);
	getMModel().refresh();
	getMModel().getFrame().getInfoTreeUI().refreshTree(this);
	getMModel().getGraphModel().postEdit(new AbstractUndoableEdit() {
		/**
		*            
		*/
		private static final long serialVersionUID = -8359488490185936367L;

		@Override
		public void undo() {
			super.undo();
			_entityAttributes.remove(inAtt);
			getAttributeNode().remove(inAtt);
			getMModel().refresh();
			getMModel().getFrame().getInfoTreeUI().refreshTree(ModelVertex.this);
		}

		@Override
		public void redo() {
			super.redo();
			_entityAttributes.add(inAtt);
			getAttributeNode().add(inAtt);
			getMModel().refresh();
			getMModel().getFrame().getInfoTreeUI().refreshTree(ModelVertex.this);
		}
	});
}
 
源代码19 项目: CQL   文件: ModelVertex.java
/**
 * Adds a unique key to the list
 *
 * @param inKey The key to be added
 */
public void addUniqueKey(final UniqueKey<F, GM, M, N, E> inKey) {
	_uniqueKeys.add(inKey);
	getKeyNode().add(inKey);
	getMModel().refresh();
	getMModel().getFrame().getInfoTreeUI().refreshTree(this);
	getMModel().getGraphModel().postEdit(new AbstractUndoableEdit() {
		/**
		*            
		*/
		private static final long serialVersionUID = 6892030054106524533L;

		@Override
		public void undo() {
			super.undo();
			_uniqueKeys.remove(inKey);
			getKeyNode().remove(inKey);
			getMModel().refresh();
			getMModel().getFrame().getInfoTreeUI().refreshTree(ModelVertex.this);
		}

		@Override
		public void redo() {
			super.redo();
			_uniqueKeys.add(inKey);
			getKeyNode().add(inKey);
			getMModel().refresh();
			getMModel().getFrame().getInfoTreeUI().refreshTree(ModelVertex.this);
		}
	});
}
 
源代码20 项目: CQL   文件: ModelVertex.java
/**
 * Removes a constraint from the set of constraints this node believes to be in
 *
 * @param con the constraint
 * @return true if removed
 */
public boolean removeConstraint(final ModelConstraint<F, GM, M, N, E> con) {
	final boolean removed = _constraints.remove(con);
	final EntityAttribute<F, GM, M, N, E> ea = getHiddenAttribute(con);

	_hiddenAttributes.remove(ea);

	if (removed) {
		getMModel().getGraphModel().postEdit(new AbstractUndoableEdit() {
			/**
			 *                
			 */
			private static final long serialVersionUID = 6399404906957760505L;

			@Override
			public void undo() {
				super.undo();
				_constraints.add(con);
				_hiddenAttributes.add(ea);
			}

			@Override
			public void redo() {
				super.redo();
				_constraints.remove(con);
				_hiddenAttributes.remove(ea);
			}
		});
	}
	return removed;
}
 
源代码21 项目: CQL   文件: ModelVertex.java
/**
 * Removes a unique key from the list
 *
 * @param inKey The unique key to be removed
 */
public void removeUniqueKey(final UniqueKey<F, GM, M, N, E> inKey) {
	final int keyPos = _uniqueKeys.indexOf(inKey);
	final int nodePos = getKeyNode().getIndex(inKey);

	_uniqueKeys.remove(inKey);
	getKeyNode().remove(inKey);
	getMModel().refresh();
	getMModel().getFrame().getInfoTreeUI().refreshTree(this);
	getMModel().getGraphModel().postEdit(new AbstractUndoableEdit() {
		/**
		 *            
		 */
		private static final long serialVersionUID = 2520426386166974414L;

		@Override
		public void undo() {
			super.undo();
			_uniqueKeys.add(keyPos, inKey);
			getKeyNode().insert(inKey, nodePos);
			getMModel().refresh();
			getMModel().getFrame().getInfoTreeUI().refreshTree(ModelVertex.this);
		}

		@Override
		public void redo() {
			super.redo();
			_uniqueKeys.remove(inKey);
			getKeyNode().remove(inKey);
			getMModel().refresh();
			getMModel().getFrame().getInfoTreeUI().refreshTree(ModelVertex.this);
		}
	});
}
 
源代码22 项目: CQL   文件: UniqueKey.java
/**
 * Sets the elements involved in this unique key to the unique-indexable
 * attributes/edges contained in the passed-in collection (set, list, etc.).
 * Note that this collection will be added to a set, so duplicate
 * EntityAttribute values will be ignored. Also note that the order of the
 * attributes will be preserved.
 *
 * @param elems Collection of UniqueIndexable-implementing objects
 */
public void setElements(final Collection<UniqueIndexable> elems) {
	final LinkedHashSet<UniqueIndexable> oldElements = _elements;

	_elements = new LinkedHashSet<>(elems);

	final LinkedHashSet<UniqueIndexable> newElements = _elements;

	_parent.getMModel().getGraphModel().postEdit(new AbstractUndoableEdit() {
		/**
		 *            
		 */
		private static final long serialVersionUID = -6780658287050089538L;

		@Override
		public void undo() {
			super.undo();

			_elements = oldElements;
		}

		@Override
		public void redo() {
			super.redo();

			_elements = newElements;
		}
	});
}
 
源代码23 项目: CQL   文件: UniqueKey.java
/**
 * Returns a UniqueIndexable element from the element list, if it contains it.
 * Note that this might make the unique key invalid (0 elements) or a duplicate
 * of another key: you must take care to call UniqueKey.cleanup(node) after
 * finished removing all elements from the node to fix up the element list.
 *
 * @param elem the UniqueIndexable-implementing object to remove
 * @return true if the element existed and was removed, false if the element did
 *         not exist
 */
public boolean removeElement(final UniqueIndexable elem) {
	final boolean ret = _elements.remove(elem);

	if (ret) {
		_parent.getMModel().getGraphModel().postEdit(new AbstractUndoableEdit() {
			/**
			 *                
			 */
			private static final long serialVersionUID = 8689047282879320151L;

			@Override
			public void undo() {
				super.undo();
				_elements.add(elem);
			}

			@Override
			public void redo() {
				super.redo();
				_elements.remove(elem);
			}
		});
	}

	return ret;
}
 
源代码24 项目: CQL   文件: UniqueKey.java
/**
 * Sets the key name to the name described in <it>inName</it>
 * 
 * @param inName The name of this attribute
 */
public void setKeyName(final String inName) {
	final String oldName = _keyName;

	_keyName = inName;

	_parent.getMModel().getGraphModel().postEdit(new AbstractUndoableEdit() {
		/**
		 *            
		 */
		private static final long serialVersionUID = 3728325633310707957L;

		@Override
		public void undo() {
			super.undo();

			_keyName = oldName;
		}

		@Override
		public void redo() {
			super.redo();

			_keyName = inName;
		}
	});
}
 
源代码25 项目: CQL   文件: ModelInfoTreeUI.java
/**
 * Add a constraint to the info tree. This action will factor into the Sketch's
 * undo/redo history as a single action.
 *
 * @param constraint The constraint to add
 * @since 2006-05-30 Vera Ranieri
 */
public void addConstraint(final ModelConstraint<F, GM, M, N, E> constraint) {
	EasikGraphModel model = _theFrame.getMModel().getGraphModel();

	model.beginUpdate();
	_addConstraint(constraint);
	model.postEdit(new AbstractUndoableEdit() {
		private static final long serialVersionUID = -6225673569024807131L;

		@Override
		public void undo() {
			super.undo();
			_removeConstraint(constraint);
		}

		@Override
		public void redo() {
			super.redo();
			_addConstraint(constraint);
		}
	});
	model.endUpdate();

	DefaultMutableTreeNode node = constraint.getTreeNode();

	_infoTree.scrollPathToVisible(new TreePath(node.getPath()));
}
 
源代码26 项目: opensim-gui   文件: ViewDB.java
public void dragSelectedObjects(final OpenSimObject clickedObject, final double dragVector[], boolean supportUndo) {
   DragObjectsEvent evnt = new DragObjectsEvent(clickedObject, dragVector);
   //System.out.println("drg vec"+dragVector[0]+" "+dragVector[1]+" "+dragVector[2]);
   // undo is a drag in the opposite direction!
   AbstractUndoableEdit auEdit = new AbstractUndoableEdit(){
        public boolean canUndo() {
            return true;
        }
        public boolean canRedo() {
            return true;
        }
        public void undo() throws CannotUndoException {
            super.undo();
            final double[] negativeDrag=new double[3];
            for(int i=0;i<3;i++) negativeDrag[i]=-dragVector[i];
            dragSelectedObjects(clickedObject, negativeDrag, false);
        }
        public void redo() throws CannotRedoException {
            super.redo();
            dragSelectedObjects(clickedObject, dragVector, true);
        }

        @Override
        public String getRedoPresentationName() {
            return "Redo Drag object(s)";
         }

        @Override
        public String getUndoPresentationName() {
            return "Undo Drag object(s)";
        }
        
    };
   if (supportUndo)
     ExplorerTopComponent.addUndoableEdit(auEdit);
   setChanged();  
   notifyObservers(evnt);
}
 
源代码27 项目: opensim-gui   文件: MarkerAdapter.java
private void setName(final String newName, boolean enableUndo) {
    final String oldName = getName();
    if (newName.equals(oldName)) return; // Nothing to do
    marker.setName(newName);
    
    
    ExplorerTopComponent.getDefault().requestActive();
    if (enableUndo){
        AbstractUndoableEdit auEdit = new AbstractUndoableEdit(){
           public void undo() throws CannotUndoException {
               super.undo();
               setName(oldName, false);
           }
           public void redo() throws CannotRedoException {
               super.redo();
               setName(newName, true);
           }
        };
        ExplorerTopComponent.addUndoableEdit(auEdit);
    }
    OpenSimDB.getInstance().getModelGuiElements(model).updateMarkerNames();
    Vector<OpenSimObject> objs = new Vector<OpenSimObject>(1);
    objs.add(marker);
    ObjectsRenamedEvent evnt = new ObjectsRenamedEvent(this, model, objs);
    OpenSimDB.getInstance().setChanged();
    OpenSimDB.getInstance().notifyObservers(evnt);
    SingleModelGuiElements guiElem = OpenSimDB.getInstance().getModelGuiElements(model);
    guiElem.setUnsavedChangesFlag(true);
}
 
源代码28 项目: opensim-gui   文件: ObjectNameEditor.java
private void handleNameChange(final String oldValue, final String v, boolean supportUndo) {
    ViewDB.getInstance().updateModelDisplay(model);
    Vector<OpenSimObject> objs = new Vector<OpenSimObject>(1);
    objs.add(obj);
    ObjectsRenamedEvent evnt = new ObjectsRenamedEvent(this, model, objs);
    OpenSimDB.getInstance().setChanged();
    OpenSimDB.getInstance().notifyObservers(evnt);
    node.refreshNode();
    if (supportUndo) {
        AbstractUndoableEdit auEdit = new AbstractUndoableEdit() {

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

            @Override
            public void redo() throws CannotRedoException {
                super.redo();
                setName(v, true);
            }
            @Override
            public String getRedoPresentationName() {
                return "Redo name change";
            }
            @Override
            public String getUndoPresentationName() {
                return "Undo name change";
            }
        };
        ExplorerTopComponent.addUndoableEdit(auEdit);
    }
}
 
源代码29 项目: opensim-gui   文件: PathPointAdapter.java
public void setLocation(final Vec3 newLocation, boolean enableUndo) {
    GeometryPath currentPath = GeometryPath.safeDownCast(pathpoint.getOwner());
    boolean hasWrapping = currentPath.getWrapSet().getSize()>0;
    final Vec3 oldLocation = new Vec3(pathpoint.get_location());
    //System.out.println("oldLocation:"+oldLocation.get(1));
    context.cacheModelAndState();
    context.setLocation(pathpoint, newLocation);
    try {
        context.restoreStateFromCachedModel();
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
    //System.out.println("newLocation:"+newLocation.get(1));
    if (!hasWrapping)
        updateDisplay(); 
    else{
       ViewDB.getInstance().updatePathDisplay(pathpoint.getModel(), currentPath, 0, -1);
       ViewDB.getInstance().updateModelDisplay(model);
    }
    if (enableUndo){
         AbstractUndoableEdit auEdit = new AbstractUndoableEdit(){
           public void undo() throws CannotUndoException {
               super.undo();
               setLocation(oldLocation, false);
               //System.out.println("after undo oldLocation:"+oldLocation.get(1));
           }
           public void redo() throws CannotRedoException {
               super.redo();
               setLocation(newLocation, true);
           }
        };
        ExplorerTopComponent.addUndoableEdit(auEdit);
    }
    SingleModelGuiElements guiElem = OpenSimDB.getInstance().getModelGuiElements(model);
    guiElem.setUnsavedChangesFlag(true);
}
 
源代码30 项目: 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);
        }
    }
 
 类所在包
 同包方法