KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ddloaders > client > ClientDataObject


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.ddloaders.client;
21
22 import java.awt.Component JavaDoc;
23 import java.awt.Dialog JavaDoc;
24 import java.awt.Image JavaDoc;
25 import java.awt.event.ActionEvent JavaDoc;
26 import java.awt.event.ActionListener JavaDoc;
27 import java.beans.PropertyChangeEvent JavaDoc;
28 import java.beans.PropertyChangeListener JavaDoc;
29 import java.io.IOException JavaDoc;
30 import java.util.ArrayList JavaDoc;
31 import java.util.Enumeration JavaDoc;
32 import java.util.List JavaDoc;
33 import java.util.Vector JavaDoc;
34 import javax.swing.JButton JavaDoc;
35 import javax.swing.event.ChangeEvent JavaDoc;
36 import javax.swing.event.ChangeListener JavaDoc;
37 import org.netbeans.api.java.project.JavaProjectConstants;
38 import org.netbeans.api.project.FileOwnerQuery;
39 import org.netbeans.api.project.Project;
40 import org.netbeans.api.project.ProjectUtils;
41 import org.netbeans.api.project.SourceGroup;
42 import org.netbeans.api.project.Sources;
43 import org.netbeans.api.xml.cookies.CheckXMLCookie;
44 import org.netbeans.api.xml.cookies.ValidateXMLCookie;
45 import org.netbeans.core.spi.multiview.MultiViewElement;
46 import org.netbeans.modules.j2ee.dd.api.client.AppClient;
47 import org.netbeans.modules.j2ee.dd.api.client.DDProvider;
48 import org.netbeans.modules.j2ee.dd.api.common.RootInterface;
49 import org.netbeans.modules.j2ee.dd.impl.client.ClientParseUtils;
50 import org.netbeans.modules.j2ee.dd.impl.client.AppClientProxy;
51 import org.netbeans.modules.j2ee.ddloaders.multiview.DDMultiViewDataObject;
52 import org.netbeans.modules.j2ee.ddloaders.web.DDDataObject;
53 import org.netbeans.modules.web.api.webmodule.WebModule;
54 import org.netbeans.modules.xml.multiview.DesignMultiViewDesc;
55 import org.netbeans.spi.xml.cookies.CheckXMLSupport;
56 import org.netbeans.spi.xml.cookies.DataObjectAdapters;
57 import org.netbeans.spi.xml.cookies.ValidateXMLSupport;
58 import org.openide.DialogDescriptor;
59 import org.openide.DialogDisplayer;
60 import org.openide.ErrorManager;
61 import org.openide.filesystems.FileAttributeEvent;
62 import org.openide.filesystems.FileChangeListener;
63 import org.openide.filesystems.FileEvent;
64 import org.openide.filesystems.FileObject;
65 import org.openide.filesystems.FileRenameEvent;
66 import org.openide.filesystems.FileUtil;
67 import org.openide.loaders.DataLoaderPool;
68 import org.openide.loaders.DataObjectExistsException;
69 import org.openide.loaders.OperationAdapter;
70 import org.openide.loaders.OperationEvent;
71 import org.openide.loaders.OperationListener;
72 import org.openide.util.HelpCtx;
73 import org.openide.util.NbBundle;
74 import org.openide.util.RequestProcessor;
75 import org.xml.sax.InputSource JavaDoc;
76 import org.xml.sax.SAXException JavaDoc;
77 import org.xml.sax.SAXParseException JavaDoc;
78
79 /**
80  *
81  * @author jungi
82  */

83 public class ClientDataObject extends DDMultiViewDataObject
84         implements DDChangeListener, ChangeListener JavaDoc, PropertyChangeListener JavaDoc {
85     
86     private transient AppClient appClient;
87     private transient FileObject srcRoots[];
88     private transient FileObjectObserver fileListener;
89     
90     /** List of updates to servlets that should be processed */
91     private Vector JavaDoc updates;
92     
93     private transient RequestProcessor.Task updateTask;
94     
95     /** Property name for documentDTD property */
96     public static final String JavaDoc PROP_DOCUMENT_DTD = "documentDTD"; // NOI18N
97

98     /** Creates a new instance of ClientDataObject */
99     public ClientDataObject(FileObject pf, ClientDataLoader loader) throws DataObjectExistsException {
100         super(pf, loader);
101         init(pf,loader);
102     }
103     
104     private void init(FileObject fo, ClientDataLoader loader) {
105         // added ValidateXMLCookie
106
InputSource JavaDoc in = DataObjectAdapters.inputSource(this);
107         CheckXMLCookie checkCookie = new CheckXMLSupport(in);
108         getCookieSet().add(checkCookie);
109         ValidateXMLCookie validateCookie = new ValidateXMLSupport(in);
110         getCookieSet().add(validateCookie);
111         
112         fileListener = new FileObjectObserver(fo);
113         
114         Project project = FileOwnerQuery.getOwner(getPrimaryFile());
115         if (project != null) {
116             Sources sources = ProjectUtils.getSources(project);
117             sources.addChangeListener(this);
118         }
119         refreshSourceFolders();
120         addPropertyChangeListener(this);
121     }
122     
123     private void refreshSourceFolders() {
124         ArrayList JavaDoc srcRootList = new ArrayList JavaDoc();
125         
126         Project project = FileOwnerQuery.getOwner(getPrimaryFile());
127         if (project != null) {
128             Sources sources = ProjectUtils.getSources(project);
129             SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
130             for (int i = 0; i < groups.length; i++) {
131                 if (WebModule.getWebModule(groups [i].getRootFolder()) != null) {
132                     srcRootList.add(groups [i].getRootFolder());
133                     DataLoaderPool.getDefault().removeOperationListener(operationListener); //avoid being added multiple times
134
DataLoaderPool.getDefault().addOperationListener(operationListener);
135                 }
136             }
137         }
138         srcRoots = (FileObject []) srcRootList.toArray(new FileObject [srcRootList.size()]);
139     }
140     
141     private String JavaDoc getPackageName(FileObject clazz) {
142         for (int i = 0; i < srcRoots.length; i++) {
143             String JavaDoc rp = FileUtil.getRelativePath(srcRoots [i], clazz);
144             if (rp != null) {
145                 if (clazz.getExt().length() > 0) {
146                     rp = rp.substring(0, rp.length() - clazz.getExt().length() - 1);
147                 }
148                 return rp.replace('/', '.');
149             }
150         }
151         return null;
152     }
153     
154     /**
155      * This methods gets called when object is changed
156      *
157      * @param evt - object that describes the change.
158      */

159     public void deploymentChange(DDChangeEvent evt) {
160         /*
161         // fix of #28542, don't add servlet, if it's already defined in DD
162         if (evt.getType() == DDChangeEvent.SERVLET_ADDED && servletDefined(evt.getNewValue())) {
163             return;
164         }
165          */

166         
167         synchronized (this) {
168             if (updates == null) {
169                 updates = new Vector JavaDoc();
170             }
171             updates.addElement(evt);
172         }
173         
174         // schedule processDDChangeEvent
175
if (updateTask == null) {
176             updateTask = RequestProcessor.getDefault().post(new Runnable JavaDoc() {
177                 public void run() {
178                     java.util.List JavaDoc changes = null;
179                     synchronized (ClientDataObject.this) {
180                         if (!ClientDataObject.this.isValid()) {
181                             return;
182                         }
183                         if (updates != null) {
184                             changes = updates;
185                             updates = null;
186                         }
187                     }
188                     if (changes != null) {
189                         showDDChangesDialog(changes);
190                     }
191                 }
192             }, 2000, Thread.MIN_PRIORITY);
193         } else {
194             updateTask.schedule(2000);
195         }
196     }
197     
198     /**
199      * Invoked when the target of the listener has changed its state.
200      *
201      *
202      * @param e a ChangeEvent object
203      */

204     public void stateChanged(ChangeEvent JavaDoc e) {
205         refreshSourceFolders ();
206     }
207     
208     /**
209      * This method gets called when a bound property is changed.
210      *
211      * @param evt A PropertyChangeEvent object describing the event source
212      * and the property that has changed.
213      */

214     public void propertyChange(PropertyChangeEvent JavaDoc evt) {
215         if (ClientDataObject.PROP_DOCUMENT_VALID.equals (evt.getPropertyName ())) {
216             ((ClientDataNode)getNodeDelegate()).iconChanged();
217         }
218     }
219     
220     protected String JavaDoc getPrefixMark() {
221         return "<application-client";
222     }
223
224     
225     /**
226      * MultiViewDesc for MultiView editor
227      */

228     protected DesignMultiViewDesc[] getMultiViewDesc() {
229         
230         return new DesignMultiViewDesc[] {};
231     }
232     
233         private class DesignMultiViewDescImpl extends DesignMultiViewDesc {
234             public MultiViewElement createElement() {
235                 return null;
236             }
237             public Image JavaDoc getIcon() {
238                 return null;
239             }
240             public String JavaDoc preferredID() {
241                 return null;
242             }
243         }
244     /**
245      *
246      *
247      * @throws IOException
248      */

249     protected void validateDocument() throws IOException JavaDoc {
250         // parse document without updating model
251
parseDocument(false);
252     }
253     
254     /**
255      *
256      *
257      * @throws IOException
258      */

259     protected void parseDocument() throws IOException JavaDoc {
260         if (appClient == null || ((AppClientProxy) appClient).getOriginal() == null) {
261             try {
262                 appClient = DDProvider.getDefault().getDDRoot(getPrimaryFile());
263             } catch (IOException JavaDoc e) {
264                 if (appClient == null) {
265                     appClient = new AppClientProxy(null, null);
266                 }
267             }
268         }
269         // update model with the document
270
parseDocument(true);
271     }
272     
273     /**
274      * Used to detect if data model has already been created or not.
275      * Method is called before switching to the design view from XML view when the document isn't parseable.
276      */

277     protected boolean isModelCreated() {
278         return (appClient!=null && ((org.netbeans.modules.j2ee.dd.impl.client.AppClientProxy)appClient).getOriginal()!=null);
279     }
280     
281     /**
282      * Returns true if xml file is parseable(data model can be created),
283      * Method is called before switching to the design view from XML view when the document isn't parseable.
284      */

285     protected boolean isDocumentParseable() {
286         return AppClient.STATE_INVALID_UNPARSABLE != getAppClient().getStatus();
287     }
288     
289     /**
290      * Returns model of the deployment descriptor
291      *
292      * @return the model
293      */

294     protected RootInterface getDDModel() {
295         return getAppClient();
296     }
297     
298     protected org.openide.nodes.Node createNodeDelegate () {
299         return new ClientDataNode(this);
300     }
301
302     
303     private void showDDChangesDialog(List JavaDoc changes) {
304         final JButton JavaDoc processButton;
305         final JButton JavaDoc processAllButton;
306         final JButton JavaDoc closeButton;
307         final DDChangesPanel connectionPanel;
308         final DialogDescriptor confirmChangesDescriptor;
309         final Dialog JavaDoc confirmChangesDialog[] = { null };
310         
311         processButton = new JButton JavaDoc(NbBundle.getMessage(DDDataObject.class, "LAB_processButton"));
312         processButton.setMnemonic(NbBundle.getMessage(DDDataObject.class, "LAB_processButton_Mnemonic").charAt(0));
313         processButton.setToolTipText(NbBundle.getMessage(DDDataObject.class, "ACS_processButtonA11yDesc"));
314         processAllButton = new JButton JavaDoc(NbBundle.getMessage(DDDataObject.class, "LAB_processAllButton"));
315         processAllButton.setMnemonic(NbBundle.getMessage(DDDataObject.class, "LAB_processAllButton_Mnemonic").charAt(0));
316         processAllButton.setToolTipText(NbBundle.getMessage(DDDataObject.class, "ACS_processAllButtonA11yDesc"));
317         closeButton = new JButton JavaDoc(NbBundle.getMessage(DDDataObject.class, "LAB_closeButton"));
318         closeButton.setMnemonic(NbBundle.getMessage(DDDataObject.class, "LAB_closeButton_Mnemonic").charAt(0));
319         closeButton.setToolTipText(NbBundle.getMessage(DDDataObject.class, "ACS_closeButtonA11yDesc"));
320         final Object JavaDoc [] options = new Object JavaDoc [] {
321             processButton,
322             processAllButton
323         };
324         final Object JavaDoc [] additionalOptions = new Object JavaDoc [] {
325             closeButton
326         };
327         WebModule wm = WebModule.getWebModule(getPrimaryFile());
328         String JavaDoc fsname=""; // NOI18N
329
if (wm!=null) {
330             fsname=wm.getContextPath();
331         }
332         String JavaDoc caption = NbBundle.getMessage(DDDataObject.class, "MSG_SynchronizeCaption", fsname);
333         connectionPanel = new DDChangesPanel(caption, processButton);
334         confirmChangesDescriptor = new DialogDescriptor(
335                 connectionPanel,
336                 NbBundle.getMessage(DDDataObject.class, "LAB_ConfirmDialog"),
337                 true,
338                 options,
339                 processButton,
340                 DialogDescriptor.RIGHT_ALIGN,
341                 HelpCtx.DEFAULT_HELP,
342                 new ActionListener JavaDoc() {
343             public void actionPerformed(ActionEvent JavaDoc e) {
344                 if (e.getSource() instanceof Component JavaDoc) {
345                     Component JavaDoc root;
346                     
347                     // hack to avoid multiple calls for disposed dialogs:
348
root = javax.swing.SwingUtilities.getRoot((Component JavaDoc)e.getSource());
349                     if (!root.isDisplayable()) {
350                         return;
351                     }
352                 }
353                 if (options[0].equals(e.getSource())) {
354                     int min = connectionPanel.changesList.getMinSelectionIndex();
355                     int max = connectionPanel.changesList.getMaxSelectionIndex();
356                     for (int i = max; i >= min; i--) {
357                         if (connectionPanel.changesList.isSelectedIndex(i)) {
358                             final DDChangeEvent ev = (DDChangeEvent)connectionPanel.listModel.getElementAt(i);
359                             processDDChangeEvent(ev);
360                             connectionPanel.listModel.removeElementAt(i);
361                         }
362                     }
363                     if (connectionPanel.listModel.isEmpty()) {
364                         confirmChangesDialog[0].setVisible(false);
365                     } else {
366                         processButton.setEnabled(false);
367                     }
368                 } else if (options[1].equals(e.getSource())) {
369                     Enumeration JavaDoc en = connectionPanel.listModel.elements();
370                     while (en.hasMoreElements()) {
371                         processDDChangeEvent((DDChangeEvent)en.nextElement());
372                     }
373                     confirmChangesDialog[0].setVisible(false);
374                     connectionPanel.setChanges(null);
375                 } else if (additionalOptions[0].equals(e.getSource())) {
376                     confirmChangesDialog[0].setVisible(false);
377                     connectionPanel.setChanges(null);
378                 }
379             }
380         }
381         );
382         confirmChangesDescriptor.setAdditionalOptions(additionalOptions);
383         
384         processButton.setEnabled(false);
385         processAllButton.requestFocus();
386         connectionPanel.setChanges(changes);
387         
388         try {
389             confirmChangesDialog[0] = DialogDisplayer.getDefault().createDialog(confirmChangesDescriptor);
390             confirmChangesDialog[0].setVisible(true);
391         } finally {
392             confirmChangesDialog[0].dispose();
393         }
394     }
395     
396     private void processDDChangeEvent(DDChangeEvent evt) {
397         System.err.println("ClientDataObject.processDDChangeEvent");
398         if (!isValid()) {
399             return;
400         }
401         
402         /*
403         if (evt.getType () == DDChangeEvent.SERVLET_ADDED) {
404             String clz = evt.getNewValue ();
405              
406             // new from template or copy of another servlet
407             String urimapping = "/servlet/"+clz; // NOI18N
408             createDefaultServletConfiguration (clz, urimapping);
409         }
410         else if (evt.getType () == DDChangeEvent.SERVLET_CHANGED) {
411             // update servlet-class in servlet element
412             String old = evt.getOldValue ();
413             if (old == null) {
414                 return;
415             }
416              
417             Servlet [] servlets = getAppClient ().getServlet ();
418             for (int i=0; i<servlets.length; i++) {
419                 if (old.equals (servlets[i].getServletClass ())) {
420                     servlets[i].setServletClass ((String)evt.getNewValue ());
421                 }
422             }
423         }
424         else if (evt.getType () == DDChangeEvent.SERVLET_DELETED) {
425             // delete servlet and matching servlet-mappings
426             String clz = evt.getNewValue ();
427             if (clz == null) {
428                 return;
429             }
430             WebApp wa = getAppClient ();
431             Servlet [] servlets = wa.getServlet ();
432             java.util.Vector servletNames = new java.util.Vector ();
433             for (int i=0; i<servlets.length; i++) {
434                 if (clz.equals (servlets[i].getServletClass ())) {
435                     servletNames.addElement (servlets[i].getServletName ());
436                     wa.removeServlet (servlets[i]);
437                 }
438             }
439             ServletMapping [] mappings = wa.getServletMapping ();
440             for (int i=0; i<mappings.length; i++) {
441                 if (servletNames.contains (mappings[i].getServletName ())) {
442                     wa.removeServletMapping (mappings[i]);
443                 }
444             }
445         }
446         else if (evt.getType () == DDChangeEvent.FILTER_CHANGED) {
447             String old = evt.getOldValue ();
448             if (old == null) {
449                 return;
450             }
451              
452             Filter [] filters = getAppClient ().getFilter ();
453             for (int i=0; i<filters.length; i++) {
454                 if (old.equals (filters[i].getFilterClass ())) {
455                     filters[i].setFilterClass ((String)evt.getNewValue ());
456                 }
457             }
458         }
459         else if (evt.getType () == DDChangeEvent.FILTER_DELETED) {
460             String clz = evt.getNewValue ();
461             if (clz == null) {
462                 return;
463             }
464              
465             WebApp wa = getAppClient ();
466             Filter [] filters = wa.getFilter ();
467             java.util.Vector filterNames = new java.util.Vector ();
468             for (int i=0; i<filters.length; i++) {
469                 if (clz.equals (filters[i].getFilterClass ())) {
470                     filterNames.addElement (filters[i].getFilterName ());
471                     wa.removeFilter (filters[i]);
472                 }
473             }
474             FilterMapping [] mappings = wa.getFilterMapping ();
475             for (int i=0; i<mappings.length; i++) {
476                 if (filterNames.contains (mappings[i].getFilterName ())) {
477                     wa.removeFilterMapping (mappings[i]);
478                 }
479             }
480         }
481         else if (evt.getType () == DDChangeEvent.LISTENER_CHANGED) {
482             String old = evt.getOldValue ();
483             if (old == null) {
484                 return;
485             }
486              
487             Listener [] listeners = getAppClient ().getListener ();
488             for (int i=0; i<listeners.length; i++) {
489                 if (old.equals (listeners[i].getListenerClass ())) {
490                     listeners[i].setListenerClass ((String)evt.getNewValue ());
491                 }
492             }
493         }
494         else if (evt.getType () == DDChangeEvent.LISTENER_DELETED) {
495             String clz = evt.getNewValue ();
496             if (clz == null) {
497                 return;
498             }
499              
500             WebApp wa = getAppClient ();
501             Listener [] listeners = wa.getListener ();
502             for (int i=0; i<listeners.length; i++) {
503                 if (clz.equals (listeners[i].getListenerClass ())) {
504                     wa.removeListener (listeners[i]);
505                     break;
506                 }
507             }
508         }
509         try {
510             writeModel(getAppClient());
511         } catch (IOException e) {
512             ErrorManager.getDefault().notify(e);
513         }
514              */

515     }
516     
517     private void parseDocument(boolean updateWebApp) throws IOException JavaDoc {
518         AppClientProxy webAppProxy = (AppClientProxy) appClient;
519         try {
520             // preparsing
521
SAXParseException JavaDoc error = ClientParseUtils.parse(new InputSource JavaDoc(createReader()));
522             setSaxError(error);
523
524             String JavaDoc version = ClientParseUtils.getVersion(new InputSource JavaDoc(createReader()));
525             // creating model
526
AppClientProxy app = new AppClientProxy(org.netbeans.modules.j2ee.dd.impl.common.DDUtils.createAppClient(
527                     createInputStream(), version), version);
528             if (updateWebApp) {
529                 String JavaDoc webAppProxyVersion = webAppProxy.getVersion() != null ? webAppProxy.getVersion().toString() : "";
530                 if (version.equals(webAppProxyVersion) && webAppProxy.getOriginal() != null) {
531                     appClient.merge(app, AppClient.MERGE_UPDATE);
532                 } else if (app.getOriginal() != null) {
533                     appClient = webAppProxy = app;
534                 }
535             }
536             webAppProxy.setStatus(error != null ? AppClient.STATE_INVALID_PARSABLE : AppClient.STATE_VALID);
537             webAppProxy.setError(error);
538         } catch (SAXException JavaDoc ex) {
539             webAppProxy.setStatus(AppClient.STATE_INVALID_UNPARSABLE);
540             if (ex instanceof SAXParseException JavaDoc) {
541                 webAppProxy.setError((SAXParseException JavaDoc) ex);
542             } else if (ex.getException() instanceof SAXParseException JavaDoc) {
543                 webAppProxy.setError((SAXParseException JavaDoc) ex.getException());
544             }
545             setSaxError(ex);
546         }
547     }
548
549     public AppClient getAppClient() {
550         if (appClient == null) {
551             try {
552                 appClient = createWebApp();
553             } catch (IOException JavaDoc ex) {
554                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
555             }
556         }
557         return appClient;
558     }
559
560     private AppClient createWebApp() throws java.io.IOException JavaDoc {
561         AppClient webApp = DDProvider.getDefault().getDDRoot(getPrimaryFile());
562         if (webApp != null) {
563             setSaxError(webApp.getError());
564         }
565         return webApp;
566     }
567
568     private OperationListener operationListener = new OperationAdapter() {
569         public void operationDelete(OperationEvent ev) {
570             FileObject fo = ev.getObject().getPrimaryFile();
571             String JavaDoc resourceName = getPackageName(fo);
572             if (resourceName != null && "java".equals(fo.getExt())) { //NOI18N
573
boolean foundElement=false;
574                 /*
575                 Servlet[] servlets = getAppClient().getServlet();
576                 for (int i=0;i<servlets.length;i++) {
577                     if (resourceName.equals(servlets[i].getServletClass())) {
578                         DDChangeEvent ddEvent = new DDChangeEvent(DDDataObject.this,DDDataObject.this,null,resourceName,DDChangeEvent.SERVLET_DELETED);
579                         deploymentChange (ddEvent);
580                         foundElement=true;
581                         break;
582                     }
583                 }
584                 if (foundElement) {
585                     return;
586                 }
587                 Filter[] filters = getAppClient().getFilter();
588                 for (int i=0;i<filters.length;i++) {
589                     if (resourceName.equals(filters[i].getFilterClass())) {
590                         DDChangeEvent ddEvent = new DDChangeEvent(DDDataObject.this,DDDataObject.this,null,resourceName,DDChangeEvent.FILTER_DELETED);
591                         deploymentChange (ddEvent);
592                         foundElement=true;
593                         break;
594                     }
595                 }
596                 if (foundElement) {
597                     return;
598                 }
599                 Listener[] listeners = getAppClient().getListener();
600                 for (int i=0;i<listeners.length;i++) {
601                     if (resourceName.equals(listeners[i].getListenerClass())) {
602                         DDChangeEvent ddEvent = new DDChangeEvent(DDDataObject.this,DDDataObject.this,null,resourceName,DDChangeEvent.LISTENER_DELETED);
603                         deploymentChange (ddEvent);
604                         break; // listener with that class should be only one
605                     }
606                 }
607                  */

608             }
609         }
610     };
611     
612     /** WeakListener for accepting external changes to web.xml
613      */

614     private class FileObjectObserver implements FileChangeListener {
615         FileObjectObserver(FileObject fo) {
616             fo.addFileChangeListener((FileChangeListener)org.openide.util.WeakListeners.create(
617                     FileChangeListener.class, this, fo));
618         }
619         
620         public void fileAttributeChanged(FileAttributeEvent fileAttributeEvent) {
621         }
622         
623         public void fileChanged(FileEvent fileEvent) {
624             /*
625            WebAppProxy appClient = (WebAppProxy) DDDataObject.this.getAppClient();
626            boolean needRewriting = true;
627            if (appClient!= null && appClient.isWriting()) { // change from outside
628                appClient.setWriting(false);
629                needRewriting=false;
630            }
631            if (isSavingDocument()) {// document is being saved
632                setSavingDocument(false);
633                needRewriting=false;
634            }
635            if (needRewriting) getEditorSupport().restartTimer();
636              */

637         }
638         
639         public void fileDataCreated(FileEvent fileEvent) {
640         }
641         
642         public void fileDeleted(FileEvent fileEvent) {
643         }
644         
645         public void fileFolderCreated(FileEvent fileEvent) {
646         }
647         
648         public void fileRenamed(FileRenameEvent fileRenameEvent) {
649         }
650     }
651     
652 }
653
Popular Tags