1 19 package org.netbeans.modules.j2ee.sun.share.config.ui; 20 21 import java.awt.*; 22 import java.awt.event.*; 23 import java.beans.*; 24 import java.io.IOException ; 25 import java.io.ObjectInput ; 26 import java.io.ObjectOutput ; 27 import java.io.OptionalDataException ; 28 import java.io.Serializable ; 29 import java.text.MessageFormat ; 30 import java.util.*; 31 import javax.swing.border.LineBorder ; 32 import javax.swing.event.ChangeListener ; 33 import javax.swing.event.ListSelectionEvent ; 34 import javax.swing.event.ListSelectionListener ; 35 import javax.swing.*; 36 import javax.swing.table.TableColumn ; 37 import javax.swing.undo.CannotRedoException ; 38 import javax.swing.undo.CannotUndoException ; 39 40 import org.openide.actions.PopupAction; 41 43 import org.openide.actions.FindAction; 44 import org.openide.cookies.CloseCookie; 46 import org.openide.cookies.OpenCookie; 47 import org.openide.cookies.SaveCookie; 48 import org.openide.explorer.ExplorerManager; 49 50 import org.openide.filesystems.FileObject; 51 import org.openide.filesystems.FileStateInvalidException; 52 import org.openide.loaders.MultiDataObject; 53 import org.openide.loaders.FileEntry; 54 import org.openide.loaders.DataObject; 55 import org.openide.loaders.OpenSupport; 56 import org.openide.NotifyDescriptor; 57 import org.openide.text.CloneableEditorSupport; 58 import org.openide.util.actions.CallbackSystemAction; 59 import org.openide.util.actions.SystemAction; 60 import org.openide.util.*; 61 import org.openide.windows.*; 62 import org.openide.util.Utilities; 63 import org.openide.nodes.*; 64 import org.openide.util.WeakListeners; 65 66 67 73 public abstract class PanelView extends TopComponent implements PanelFocusCookie { 74 75 private Node root; 76 79 transient NodeSelectedListener nodeListener = null; 80 81 82 transient private ExplorerManager manager; 83 84 transient PropertyChangeListener wlpc; 85 86 transient VetoableChangeListener wlvc; 87 88 protected ResourceBundle bundle; 89 90 91 94 public PanelView() { 95 nodeListener = new NodeSelectedListener(); 97 bundle = NbBundle.getBundle(PanelView.class); 98 } 99 100 104 public Node getRoot() { 105 return root; 106 } 107 108 public void setRoot(Node r){ 109 root = r; 110 } 111 112 116 131 133 145 149 abstract public void showSelection(Node[] nodes) ; 150 151 156 157 public boolean setManagerExploredContextAndSelection(Node value, Node[] nodes) { 158 try{ 159 getExplorerManager().setExploredContextAndSelection(value, nodes); 160 } 161 catch (PropertyVetoException e) { 162 return false; 163 } 164 return true; 165 } 166 170 171 public boolean setManagerSelection(Node[] nodes) { 172 try{ 173 getExplorerManager().setSelectedNodes(nodes); 174 } 175 catch (PropertyVetoException e) { 176 return false; 177 } 178 return true; 179 } 180 186 protected boolean selectionAccept(Node[] nodes) { 187 return true; 188 } 189 190 194 public void open(){ 195 } 196 203 public boolean canClose(){ 204 return true; 205 } 206 218 public boolean setFocusOn(String panelViewNameHint, String panelNameHint, Object focusObject){ 219 if (panelViewNameHint !=null && panelViewNameHint.equals(getName())) 220 return true; 221 return false; 222 } 223 224 225 230 public String getResourceString(String key) { 231 return bundle.getString(key); 232 } 233 234 237 public void addNotify() { 238 super.addNotify(); 239 240 242 243 ExplorerManager newManager = ExplorerManager.find(this); 244 245 if (newManager != manager) { 246 if (manager != null) { 247 manager.removeVetoableChangeListener(wlvc); 248 manager.removePropertyChangeListener(wlpc); 249 } 250 251 manager = newManager; 252 253 manager.addVetoableChangeListener(wlvc = WeakListeners.vetoableChange(nodeListener, manager)); 254 manager.addPropertyChangeListener(wlpc = WeakListeners.propertyChange(nodeListener, manager)); 255 256 } 257 258 } 259 260 264 265 public ExplorerManager getExplorerManager() { 266 return manager; 267 } 268 269 class NodeSelectedListener implements VetoableChangeListener,PropertyChangeListener { 270 271 public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException { 272 if (evt.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) { 273 if (!selectionAccept((Node[])evt.getNewValue())) { 274 throw new PropertyVetoException("", evt); } 276 } 277 } 278 279 public void propertyChange(PropertyChangeEvent evt) { 280 if (!ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) 281 return; 282 Node[] selectedNodes = getExplorerManager().getSelectedNodes(); 283 showSelection(selectedNodes); 284 285 } 286 } 287 } 288 289 | Popular Tags |