| Home >> All >> org >> bdgp >> apps >> dagedit >> [ datamodel Javadoc ] |
Source code: org/bdgp/apps/dagedit/datamodel/TermMacroHistoryItem.java
1 package org.bdgp.apps.dagedit.datamodel; 2 3 import java.util.*; 4 import javax.swing.tree.*; 5 6 public class TermMacroHistoryItem extends HistoryItem { 7 8 protected Vector historyItems = new Vector(); 9 protected String description; 10 protected Vector rels; 11 protected Term result; 12 13 public TermMacroHistoryItem(String description) { 14 this.type = MACRO; 15 this.description = description; 16 rels = new Vector(); 17 } 18 19 public void setTarget(Term target) { 20 this.target = target; 21 } 22 23 public void setResult(Term term) { 24 result = term; 25 } 26 27 public Term getResult() { 28 return result; 29 } 30 31 public Vector getSources() { 32 return rels; 33 } 34 35 public void setSources(TreePath [] paths) { 36 for(int i=0; i < paths.length; i++) { 37 TermRelationship tr = (TermRelationship) paths[i]. 38 getLastPathComponent(); 39 rels.addElement(tr); 40 } 41 } 42 43 public void setSources(Vector rels) { 44 this.rels = rels; 45 } 46 47 public String getDescription() { 48 return description; 49 } 50 51 public int getHistoryItemCount() { 52 return historyItems.size(); 53 } 54 55 public HistoryItem getHistoryItemAt(int index) { 56 return (HistoryItem) historyItems.elementAt(index); 57 } 58 59 public void setHistoryItems(Vector items) { 60 this.historyItems = items; 61 } 62 63 public void addHistoryItem(HistoryItem item) { 64 historyItems.addElement(item); 65 } 66 67 public void removeHistoryItem(HistoryItem item) { 68 historyItems.removeElement(item); 69 } 70 71 public Vector getTouchedNodes() { 72 Vector touched = new Vector(); 73 for(int i=0; i < historyItems.size(); i++) { 74 HistoryItem item = (HistoryItem) historyItems.elementAt(i); 75 Vector sub = item.getTouchedNodes(); 76 for(int j=0; j < sub.size(); j++) { 77 Term node = (Term) sub.elementAt(j); 78 if (!touched.contains(node)) 79 touched.addElement(node); 80 } 81 } 82 return touched; 83 } 84 85 public String toString() { 86 return (description != null ? description+" (macro)": "unnamed macro"); 87 } 88 }