| Home >> All >> org >> bdgp >> apps >> dagedit >> [ datamodel Javadoc ] |
Source code: org/bdgp/apps/dagedit/datamodel/DEEdit.java
1 package org.bdgp.apps.dagedit.datamodel; 2 3 import org.bdgp.swing.NamedCompoundEdit; 4 import org.bdgp.apps.dagedit.gui.Controller; 5 import org.bdgp.apps.dagedit.gui.event.*; 6 import javax.swing.tree.TreePath; 7 import java.io.Serializable; 8 9 public class DEEdit extends NamedCompoundEdit implements Serializable { 10 11 HistoryItem item; 12 Controller controller; 13 TreePath [] oldSelection; 14 TreePath [] newSelection; 15 16 public DEEdit(String name, Controller controller) { 17 super(name); 18 this.controller = controller; 19 } 20 21 public void setHistoryItem(HistoryItem item) { 22 this.item = item; 23 controller.getHistory().addItem(item); 24 } 25 26 public void setSelections(TreePath [] oldSelection, 27 TreePath [] newSelection) { 28 setSelections(oldSelection, newSelection, true); 29 } 30 31 public void setSelections(TreePath [] oldSelection, 32 TreePath [] newSelection, 33 boolean doSelect) { 34 this.oldSelection = oldSelection; 35 this.newSelection = newSelection; 36 if (doSelect && newSelection != null) 37 controller.fireTermSelect(new DETermSelectEvent(this, 38 newSelection)); 39 } 40 41 public void undo() { 42 super.undo(); 43 controller.getHistory().removeItem(item); 44 controller.fireReload(new DETermReloadEvent(this)); 45 if (oldSelection != null) 46 controller.fireTermSelect(new DETermSelectEvent(this, 47 oldSelection)); 48 } 49 50 public void redo() { 51 super.redo(); 52 controller.getHistory().addItem(item); 53 controller.fireReload(new DETermReloadEvent(this)); 54 if (newSelection != null) 55 controller.fireTermSelect(new DETermSelectEvent(this, 56 newSelection)); 57 } 58 }