javax.swing.undo.AbstractUndoableEdit Java Examples
The following examples show how to use
javax.swing.undo.AbstractUndoableEdit.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExperimentalMarkerSetNode.java From opensim-gui with Apache License 2.0 | 6 votes |
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(); }
Example #2
Source File: BringToFrontAction.java From openAGV with Apache License 2.0 | 6 votes |
@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); } }); }
Example #3
Source File: ModelInfoTreeUI.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
/** * 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(); }
Example #4
Source File: SendToBackAction.java From openAGV with Apache License 2.0 | 6 votes |
@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); } }); }
Example #5
Source File: ModelInfoTreeUI.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
/** * 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(); }
Example #6
Source File: ModelInfoTreeUI.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
/** * 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(); }
Example #7
Source File: ExplorerTopComponent.java From opensim-gui with Apache License 2.0 | 6 votes |
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(); } }); } }
Example #8
Source File: ExperimentalForceSetNode.java From opensim-gui with Apache License 2.0 | 6 votes |
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(); }
Example #9
Source File: ExperimentalForceSetNode.java From opensim-gui with Apache License 2.0 | 6 votes |
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(); }
Example #10
Source File: ModelVertex.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
/** * 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); } }); } }
Example #11
Source File: ExperimentalMarkerSetNode.java From opensim-gui with Apache License 2.0 | 6 votes |
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(); }
Example #12
Source File: MarkerAdapter.java From opensim-gui with Apache License 2.0 | 6 votes |
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); }
Example #13
Source File: MarkerAdapter.java From opensim-gui with Apache License 2.0 | 6 votes |
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); }
Example #14
Source File: OneBodyNode.java From opensim-gui with Apache License 2.0 | 6 votes |
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); } }
Example #15
Source File: ConnectionEditor.java From opensim-gui with Apache License 2.0 | 5 votes |
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); } }
Example #16
Source File: ViewDB.java From opensim-gui with Apache License 2.0 | 5 votes |
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); }
Example #17
Source File: MarkerAdapter.java From opensim-gui with Apache License 2.0 | 5 votes |
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); }
Example #18
Source File: ObjectNameEditor.java From opensim-gui with Apache License 2.0 | 5 votes |
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); } }
Example #19
Source File: PathPointAdapter.java From opensim-gui with Apache License 2.0 | 5 votes |
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); }
Example #20
Source File: QueryNode.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * 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); } }); }
Example #21
Source File: ModelInfoTreeUI.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * 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())); }
Example #22
Source File: UniqueKey.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * 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; } }); }
Example #23
Source File: UniqueKey.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * 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; }
Example #24
Source File: UniqueKey.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * 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; } }); }
Example #25
Source File: ModelVertex.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * 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); } }); }
Example #26
Source File: ModelVertex.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * 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; }
Example #27
Source File: ModelVertex.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * 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); } }); }
Example #28
Source File: EntityNode.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * 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); } }); } }
Example #29
Source File: Model.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * 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(); }
Example #30
Source File: ModelVertex.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * 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); } }); }