1 19 20 package org.netbeans.modules.xml.schema.abe; 21 22 import java.awt.dnd.DropTarget ; 23 import java.awt.dnd.DropTargetDragEvent ; 24 import java.awt.dnd.DropTargetDropEvent ; 25 import java.awt.dnd.DropTargetEvent ; 26 import java.awt.dnd.DropTargetListener ; 27 import java.awt.event.ComponentEvent ; 28 import java.awt.event.ComponentListener ; 29 import java.awt.event.ContainerEvent ; 30 import java.awt.event.ContainerListener ; 31 import java.awt.event.HierarchyEvent ; 32 import java.awt.event.HierarchyListener ; 33 import java.beans.PropertyChangeEvent ; 34 import java.beans.PropertyChangeListener ; 35 import javax.swing.JPanel ; 36 import javax.swing.event.AncestorEvent ; 37 import javax.swing.event.AncestorListener ; 38 import org.netbeans.modules.xml.axi.AXIComponent; 39 import org.netbeans.modules.xml.schema.abe.nodes.ABEAbstractNode; 40 import org.netbeans.modules.xml.xam.ui.XAMUtils; 41 42 47 public abstract class ABEBaseDropPanel extends JPanel { 48 protected static final long serialVersionUID = 7526472295622776147L; 49 protected InstanceUIContext context; 50 protected boolean firstTimeRename = false; 51 55 public ABEBaseDropPanel(InstanceUIContext context) { 56 super(); 57 this.context = context; 58 this.context.addPropertyChangeListener(new PropertyChangeListener (){ 59 public void propertyChange(PropertyChangeEvent evt) { 60 if(evt.getPropertyName().equals(InstanceDesignConstants. 61 PROP_SHUTDOWN)){ 62 ABEBaseDropPanel.this.context.removePropertyChangeListener(this); 63 } 64 } 65 }); 66 initialize(); 67 } 68 69 70 public boolean isWritable(){ 71 return XAMUtils.isWritable(context.getAXIModel()); 72 } 73 74 78 private void initialize() { 79 setDropTarget( 82 new DropTarget (this, 83 new DropTargetListener () { 84 public void dragEnter(DropTargetDragEvent event) { 85 if(!isWritable()) 86 return; 87 setActive(true); 88 ABEBaseDropPanel.this.dragEnter(event); 89 } 90 91 public void dragExit(DropTargetEvent event) { 92 if(!isWritable()) 93 return; 94 setActive(false); 95 ABEBaseDropPanel.this.dragExit(event); 96 } 97 98 public void dragOver(DropTargetDragEvent event) { 99 if(!isWritable()) 100 return; 101 ABEBaseDropPanel.this.dragOver(event); 102 } 103 104 public void drop(DropTargetDropEvent event) { 105 if(!isWritable()) 106 return; 107 setActive(false); 108 ABEBaseDropPanel.this.drop(event); 109 } 110 111 public void dropActionChanged(DropTargetDragEvent event) { 112 if(!isWritable()) 113 return; 114 ABEBaseDropPanel.this.dropActionChanged(event); 115 } 116 }) 117 ); 118 119 } 120 121 122 123 124 128 132 public boolean isActive() { 133 return active; 134 } 135 136 137 141 public void setActive(boolean value) { 142 if (value!=active) { 143 boolean oldValue=active; 144 active=value; 145 146 handleActive(value); 147 firePropertyChange(PROP_ACTIVE,oldValue,active); 148 } 149 } 150 151 152 156 protected void handleActive(boolean value) { 157 } 159 160 161 165 public void dragEnter(DropTargetDragEvent event) { 166 event.rejectDrag(); 167 } 169 170 171 175 public void dragExit(DropTargetEvent event) { 176 } 178 179 180 184 public void dragOver(DropTargetDragEvent event) { 185 event.rejectDrag(); 186 } 188 189 190 194 public void drop(DropTargetDropEvent event) { 195 event.rejectDrop(); 196 } 198 199 200 204 public void dropActionChanged(DropTargetDragEvent event) { 205 event.rejectDrag(); 206 } 208 209 public ABEAbstractNode getNBNode(){ 210 return null; 211 } 212 213 public AXIComponent getAXIComponent(){ 214 return null; 215 } 216 217 218 public abstract void accept(UIVisitor visitor); 219 220 221 boolean selected; 222 public void setSelected(boolean selected){ 223 if(selected == this.selected) 224 return; 225 firePropertyChange(PROP_SELECTED, this.selected, selected); 226 this.selected = selected; 227 } 228 229 public void removeNotify() { 230 super.removeNotify(); 231 firePropertyChange(PROP_COMPONENT_REMOVED, " ", this); 232 } 233 234 public ABEBaseDropPanel getUIComponentFor(AXIComponent axiComponent){ 235 if(getAXIComponent() == axiComponent) 236 return this; 237 return null; 238 } 239 240 241 public ABEBaseDropPanel getChildUIComponentFor(AXIComponent axiComponent){ 242 return null; 243 } 244 245 246 public InstanceUIContext getContext(){ 247 return this.context; 248 } 249 250 254 public static final String PROP_ACTIVE="active"; 255 public static final String PROP_SELECTED="SELECTED"; 256 public static final String PROP_COMPONENT_REMOVED="COMPONENT_REMOVED"; 257 258 259 260 261 265 private boolean active; 266 } 267 | Popular Tags |