public void invoke(Object source, mxEventObject evt) { if (isEnabled()) { beforeUndo((mxUndoableEdit) evt.getProperty("edit")); } } };
public void invoke(Object source, mxEventObject evt) { if (isEnabled()) { cellsMoved((Object[]) evt.getProperty("cells"), (Point) evt .getProperty("location")); } } };
/** * */ protected Collection<Object> getCellsForChanges( List<mxUndoableChange> changes) { Set<Object> result = new HashSet<Object>(); Iterator<mxUndoableChange> it = changes.iterator(); while (it.hasNext()) { mxUndoableChange change = it.next(); if (change instanceof mxRootChange) { return new HashSet<Object>(); } else { result.addAll(getCellsForChange(change)); } } return result; }
/** * */ protected void beforeUndo(mxUndoableEdit edit) { Collection<Object> cells = getCellsForChanges(edit.getChanges()); mxIGraphModel model = getGraph().getModel(); if (isBubbling()) { Object[] tmp = mxGraphModel.getParents(model, cells.toArray()); while (tmp.length > 0) { cells.addAll(Arrays.asList(tmp)); tmp = mxGraphModel.getParents(model, tmp); } } layoutCells(mxUtils.sortCells(cells, false).toArray()); }
/** * */ protected void layoutCells(Object[] cells) { if (cells.length > 0) { // Invokes the layouts while removing duplicates mxIGraphModel model = getGraph().getModel(); model.beginUpdate(); try { for (int i = 0; i < cells.length; i++) { if (cells[i] != model.getRoot()) { executeLayout(getLayout(cells[i]), cells[i]); } } fireEvent(new mxEventObject(mxEvent.LAYOUT_CELLS, "cells", cells)); } finally { model.endUpdate(); } } }
/** * */ protected void cellsMoved(Object[] cells, Point location) { if (cells != null && location != null) { mxIGraphModel model = getGraph().getModel(); // Checks if a layout exists to take care of the moving for (int i = 0; i < cells.length; i++) { mxIGraphLayout layout = getLayout(model.getParent(cells[i])); if (layout != null) { layout.moveCell(cells[i], location.x, location.y); } } } }
mxIGraphModel model = getGraph().getModel(); Set<Object> result = new HashSet<Object>();
/** * */ protected void beforeUndo(mxUndoableEdit edit) { Collection<Object> cells = getCellsForChanges(edit.getChanges()); mxIGraphModel model = getGraph().getModel(); if (isBubbling()) { Object[] tmp = mxGraphModel.getParents(model, cells.toArray()); while (tmp.length > 0) { cells.addAll(Arrays.asList(tmp)); tmp = mxGraphModel.getParents(model, tmp); } } layoutCells(mxUtils.sortCells(cells, false).toArray()); }
/** * */ protected void layoutCells(Object[] cells) { if (cells.length > 0) { // Invokes the layouts while removing duplicates mxIGraphModel model = getGraph().getModel(); model.beginUpdate(); try { for (int i = 0; i < cells.length; i++) { if (cells[i] != model.getRoot()) { executeLayout(getLayout(cells[i]), cells[i]); } } fireEvent(new mxEventObject(mxEvent.LAYOUT_CELLS, "cells", cells)); } finally { model.endUpdate(); } } }
/** * */ protected void cellsMoved(Object[] cells, Point location) { if (cells != null && location != null) { mxIGraphModel model = getGraph().getModel(); // Checks if a layout exists to take care of the moving for (int i = 0; i < cells.length; i++) { mxIGraphLayout layout = getLayout(model.getParent(cells[i])); if (layout != null) { layout.moveCell(cells[i], location.x, location.y); } } } }
mxIGraphModel model = getGraph().getModel(); Set<Object> result = new HashSet<Object>();
public void invoke(Object source, mxEventObject evt) { if (isEnabled()) { beforeUndo((mxUndoableEdit) evt.getProperty("edit")); } } };
public void invoke(Object source, mxEventObject evt) { if (isEnabled()) { cellsMoved((Object[]) evt.getProperty("cells"), (Point) evt .getProperty("location")); } } };
/** * */ protected Collection<Object> getCellsForChanges( List<mxUndoableChange> changes) { Set<Object> result = new HashSet<Object>(); Iterator<mxUndoableChange> it = changes.iterator(); while (it.hasNext()) { mxUndoableChange change = it.next(); if (change instanceof mxRootChange) { return new HashSet<Object>(); } else { result.addAll(getCellsForChange(change)); } } return result; }