1 26 package org.objectweb.util.explorer.core.dnd.lib; 27 28 import java.util.HashMap ; 29 import java.util.List ; 30 import java.util.Map ; 31 import java.util.Vector ; 32 33 import org.objectweb.util.explorer.core.common.api.Description; 34 import org.objectweb.util.explorer.core.dnd.api.DnDDescription; 35 import org.objectweb.util.explorer.core.dnd.api.DnDDescriptions; 36 37 45 public class BasicDnDDescriptions 46 implements DnDDescriptions 47 { 48 49 55 56 protected Map dropActions_; 57 58 64 67 public BasicDnDDescriptions(){ 68 dropActions_ = new HashMap (); 69 } 70 71 77 80 protected void addDescription(DnDDescription dndDesc, List l){ 81 if(dndDesc!=null && !"".equals(dndDesc.getLabel().trim())){ 82 l.add("[" + dndDesc.getType() + "] " + dndDesc.getLabel()); 83 } 84 } 85 86 protected String getDnDDescription(DnDDescription dndDesc){ 87 if(dndDesc!=null){ 88 return dndDesc.toString(); 89 } 90 return "null"; 91 } 92 93 99 102 public String getDescriptionType() { 103 return Description.DND_DESCRIPTION; 104 } 105 106 109 public boolean isEmpty() { 110 return dropActions_.isEmpty(); 111 } 112 113 119 122 public void addDropAction(DnDDescription dndDesc) { 123 if (dndDesc!=null && !dndDesc.isEmpty() 124 && (DnDDescription.MOVE_ACTION.equals(dndDesc.getType()) 125 || DnDDescription.COPY_ACTION.equals(dndDesc.getType()) 126 || DnDDescription.LINK_ACTION.equals(dndDesc.getType()))){ 127 dropActions_.put(dndDesc.getType(), dndDesc); 128 } 129 } 130 131 134 public DnDDescription getDropAction(String actionType) { 135 return (DnDDescription)dropActions_.get(actionType); 136 } 137 138 141 public String [] getActionsDescription() { 142 Vector l = new Vector (); 143 addDescription(getDropAction(DnDDescription.MOVE_ACTION),l); 144 addDescription(getDropAction(DnDDescription.COPY_ACTION),l); 145 addDescription(getDropAction(DnDDescription.LINK_ACTION),l); 146 return (String [])l.toArray(new String [l.size()]); 147 } 148 149 155 159 public boolean equals(Object o){ 160 if(o!=null && o instanceof BasicDnDDescription) 161 return equals((BasicDnDDescription)o); 162 return false; 163 } 164 165 168 public String toString(){ 169 StringBuffer buf = new StringBuffer (); 170 buf.append("BasicDnDDescriptions[dropActions=["); 171 buf.append("move=" + getDnDDescription(getDropAction(DnDDescription.MOVE_ACTION)) + ", "); 172 buf.append("copy=" + getDnDDescription(getDropAction(DnDDescription.COPY_ACTION)) + ", "); 173 buf.append("link=" + getDnDDescription(getDropAction(DnDDescription.LINK_ACTION))); 174 buf.append("]]"); 175 return buf.toString(); 176 } 177 178 } 179 180 | Popular Tags |