List of usage examples for javax.swing.undo UndoableEditSupport postEdit
public synchronized void postEdit(UndoableEdit e)
undoableEditHappened
in all listeners. From source file:com.projity.grouping.core.model.AssignmentNodeModel.java
public void objectChanged(ObjectEvent objectEvent) { if (objectEvent.getObject() instanceof Assignment) { Assignment assignment = ((Assignment) objectEvent.getObject()); if (assignment.isDefault()) return; if (assignment.getDocument(containsLeftObjects) == document) { //TODO check if it's correct if (objectEvent.isCreate()) { Object parentObject = containsLeftObjects ? assignment.getLeft() : assignment.getRight(); Node parent = search(parentObject); if (parent != null) { // the new assignment has to be added Node child = null; if (objectEvent.getInfo() != null && dataFactory instanceof Project) { //don't want a node shared by Projet and ResourcePool if (objectEvent.getInfo().getNode() != null) child = objectEvent.getInfo().getNode(); else child = NodeFactory.getInstance().createNode(assignment); } else { //search if assignment already exists in hierarchy for (Enumeration e = parent.children(); e.hasMoreElements();) { Node c = (Node) e.nextElement(); if (c.getImpl() == assignment) { child = c; break; }//from w w w .java2s. c o m } if (child == null) child = NodeFactory.getInstance().createNode(assignment); } int position = 0; for (Enumeration e = parent.children(); e.hasMoreElements(); position++) { if (!(((Node) e.nextElement()).getImpl() instanceof Assignment)) break; } add(parent, child, position, EVENT); if ((objectEvent.getInfo() == null || (objectEvent.getInfo() != null && objectEvent.getInfo().isUndo())) && dataFactory instanceof Project) { UndoableEditSupport undoableEditSupport = getUndoableEditSupport(); if (undoableEditSupport != null) { undoableEditSupport.postEdit(new AssignmentCreationEdit(child)); } } } } else if (objectEvent.isDelete()) { Node node = search(assignment); if (node != null) { remove(node, EVENT, false, false); if ((objectEvent.getInfo() == null || (objectEvent.getInfo() != null && objectEvent.getInfo().isUndo())) && dataFactory instanceof Project) { UndoableEditSupport undoableEditSupport = getUndoableEditSupport(); if (undoableEditSupport != null) { undoableEditSupport.postEdit(new AssignmentDeletionEdit(node)); } } } } else { //update } } } }
From source file:com.projity.pm.dependency.DependencyService.java
public void setFields(Dependency dependency, long lag, int type, Object eventSource) throws InvalidAssociationException { // if (eventSource != null) // dependency.getDocument().getObjectEventManager().fireUpdateEvent(eventSource,dependency); long oldLag = dependency.getLag(); int oldType = dependency.getDependencyType(); dependency.setLag(lag);/*from w ww . j a v a2 s.c om*/ dependency.setDependencyType(type); dependency.setDirty(true); UndoableEditSupport undoableEditSupport = getUndoableEditSupport(dependency); if (undoableEditSupport != null && !(eventSource instanceof UndoableEdit)) { undoableEditSupport.postEdit(new DependencySetFieldsEdit(dependency, oldLag, oldType, eventSource)); } }
From source file:com.projity.pm.dependency.DependencyService.java
public void remove(Dependency dependency, Object eventSource, boolean undo) { dependency.setDirty(true); //for setGroupDirty() dependency.getPredecessor().getSuccessorList().remove(dependency); dependency.getSuccessor().getPredecessorList().remove(dependency); updateSentinels(dependency);// w ww.j ava 2 s . c o m if (eventSource != null) dependency.fireDeleteEvent(eventSource); UndoableEditSupport undoableEditSupport = getUndoableEditSupport(dependency); if (undo && undoableEditSupport != null && !(eventSource instanceof UndoableEdit)) { undoableEditSupport.postEdit(new DependencyDeletionEdit(dependency, eventSource)); } }
From source file:com.projity.pm.dependency.DependencyService.java
public void connect(Dependency dependency, Object eventSource) { dependency.getPredecessor().getSuccessorList().add(dependency); dependency.getSuccessor().getPredecessorList().add(dependency); updateSentinels(dependency);// ww w . jav a 2 s .co m if (eventSource != null) { dependency.fireCreateEvent(eventSource); } dependency.setDirty(true); UndoableEditSupport undoableEditSupport = getUndoableEditSupport(dependency); if (undoableEditSupport != null && eventSource != null && !(eventSource instanceof UndoableEdit)) { undoableEditSupport.postEdit(new DependencyCreationEdit(dependency, eventSource)); } }
From source file:com.projity.pm.task.Project.java
public void saveCurrentToSnapshot(Object snapshotId, boolean entireProject, List selection, boolean undo) { if (entireProject) forTasks(new SnapshottableImpl.SaveCurrentToSnapshotClosure(snapshotId)); else/*www. ja v a 2 s. c om*/ CollectionUtils.forAllDo(selection, new SnapshottableImpl.SaveCurrentToSnapshotClosure(snapshotId)); fireBaselineChanged(this, null, (Integer) snapshotId, true); if (undo) { UndoableEditSupport undoableEditSupport = getUndoController().getEditSupport(); if (undoableEditSupport != null) { undoableEditSupport.postEdit(new SaveSnapshotEdit(this, snapshotId, entireProject, selection)); } } }
From source file:com.projity.pm.task.Project.java
public void clearSnapshot(final Object snapshotId, boolean entireProject, List selection, boolean undo) { Iterator i;// w w w.j a va2 s .co m if (entireProject) i = getTaskOutlineIterator(); else i = selection == null ? null : selection.iterator(); final Collection snapshotDetails; final boolean[] foundSnapshot = new boolean[1]; //no undo edit of there is no snapshot if (undo && i != null && i.hasNext()) { snapshotDetails = new ArrayList(); while (i.hasNext()) { NormalTask t = (NormalTask) i.next(); TaskBackup taskBackup = (TaskBackup) t.backupDetail(snapshotId); if (taskBackup.snapshot != null) foundSnapshot[0] = true; snapshotDetails.add(taskBackup); } } else snapshotDetails = null; if (entireProject) forTasks(new SnapshottableImpl.ClearSnapshotClosure(snapshotId)); else CollectionUtils.forAllDo(selection, new SnapshottableImpl.ClearSnapshotClosure(snapshotId)); // FieldEvent.fire(this, Configuration.getFieldFromId("Field.baseline" + snapshotId + "Cost"), null); fireBaselineChanged(this, null, (Integer) snapshotId, false); if (foundSnapshot[0]) { UndoableEditSupport undoableEditSupport = getUndoController().getEditSupport(); if (undoableEditSupport != null) { undoableEditSupport.postEdit( new ClearSnapshotEdit(this, snapshotId, entireProject, selection, snapshotDetails)); } } }