This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 72441
Collapse All | Expand All

(-)arch.xml (+6 lines)
Lines 1073-1078 Link Here
1073
       Please note that the latter is not part of any public APIs and you need implementation dependency to make use of it.
1073
       Please note that the latter is not part of any public APIs and you need implementation dependency to make use of it.
1074
     </p>
1074
     </p>
1075
    </api>
1075
    </api>
1076
    <api group="layer" name="J2SELogicalViewProvider" type="export" category="official">
1077
     <p>
1078
       "Projects/org-netbeans-modules-java-j2seproject/Nodes" folder's content is used to construct the project's child nodes.
1079
       It's content is expected to be <code>NodeFactory</code> instances.
1080
     </p>
1081
    </api>
1076
1082
1077
 </answer>
1083
 </answer>
1078
1084
(-)nbproject/project.properties (-1 / +1 lines)
Lines 15-21 Link Here
15
# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
15
# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
16
# Microsystems, Inc. All Rights Reserved.
16
# Microsystems, Inc. All Rights Reserved.
17
17
18
spec.version.base=1.7.0
18
spec.version.base=1.8.0
19
19
20
javadoc.arch=${basedir}/arch.xml
20
javadoc.arch=${basedir}/arch.xml
21
21
(-)src/org/netbeans/modules/java/j2seproject/ui/J2SELogicalViewProvider.java (-365 / +15 lines)
Lines 24-37 Link Here
24
import java.beans.PropertyChangeEvent;
24
import java.beans.PropertyChangeEvent;
25
import java.beans.PropertyChangeListener;
25
import java.beans.PropertyChangeListener;
26
import java.io.CharConversionException;
26
import java.io.CharConversionException;
27
import java.io.File;
28
import java.io.IOException;
27
import java.io.IOException;
29
import java.net.URI;
30
import java.net.URL;
31
import java.util.ArrayList;
28
import java.util.ArrayList;
32
import java.util.Arrays;
29
import java.util.Arrays;
33
import java.util.Collection;
30
import java.util.Collection;
34
import java.util.Collections;
35
import java.util.HashMap;
31
import java.util.HashMap;
36
import java.util.HashSet;
32
import java.util.HashSet;
37
import java.util.Iterator;
33
import java.util.Iterator;
Lines 42-48 Link Here
42
import javax.swing.AbstractAction;
38
import javax.swing.AbstractAction;
43
import javax.swing.Action;
39
import javax.swing.Action;
44
import javax.swing.JSeparator;
40
import javax.swing.JSeparator;
45
import javax.swing.SwingUtilities;
46
import javax.swing.event.ChangeEvent;
41
import javax.swing.event.ChangeEvent;
47
import javax.swing.event.ChangeListener;
42
import javax.swing.event.ChangeListener;
48
import org.netbeans.api.java.platform.JavaPlatform;
43
import org.netbeans.api.java.platform.JavaPlatform;
Lines 54-82 Link Here
54
import org.netbeans.api.project.SourceGroup;
49
import org.netbeans.api.project.SourceGroup;
55
import org.netbeans.api.project.Sources;
50
import org.netbeans.api.project.Sources;
56
import org.netbeans.modules.java.j2seproject.J2SEProjectUtil;
51
import org.netbeans.modules.java.j2seproject.J2SEProjectUtil;
57
import org.netbeans.modules.java.j2seproject.ui.customizer.CustomizerLibraries;
58
import org.netbeans.modules.java.j2seproject.ui.customizer.CustomizerProviderImpl;
59
import org.netbeans.modules.java.j2seproject.ui.customizer.J2SEProjectProperties;
52
import org.netbeans.modules.java.j2seproject.ui.customizer.J2SEProjectProperties;
60
import org.netbeans.modules.java.j2seproject.J2SEProject;
53
import org.netbeans.modules.java.j2seproject.J2SEProject;
61
import org.netbeans.modules.java.j2seproject.SourceRoots;
54
import org.netbeans.modules.java.j2seproject.SourceRoots;
62
import org.netbeans.modules.java.j2seproject.UpdateHelper;
55
import org.netbeans.modules.java.j2seproject.UpdateHelper;
63
import org.netbeans.modules.java.j2seproject.wsclient.J2SEProjectWebServicesClientSupport;
64
import org.netbeans.spi.java.project.support.ui.BrokenReferencesSupport;
56
import org.netbeans.spi.java.project.support.ui.BrokenReferencesSupport;
65
import org.netbeans.spi.java.project.support.ui.PackageView;
57
import org.netbeans.spi.java.project.support.ui.PackageView;
66
import org.netbeans.spi.project.ActionProvider;
58
import org.netbeans.spi.project.ActionProvider;
67
import org.netbeans.spi.project.SubprojectProvider;
59
import org.netbeans.spi.project.SubprojectProvider;
68
import org.netbeans.spi.project.support.ant.AntProjectHelper;
69
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
60
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
70
import org.netbeans.spi.project.support.ant.ReferenceHelper;
61
import org.netbeans.spi.project.support.ant.ReferenceHelper;
71
import org.netbeans.spi.project.ui.LogicalViewProvider;
62
import org.netbeans.spi.project.ui.LogicalViewProvider;
72
import org.netbeans.spi.project.ui.support.CommonProjectActions;
63
import org.netbeans.spi.project.ui.support.CommonProjectActions;
64
import org.netbeans.spi.project.ui.support.NodeFactorySupport;
73
import org.netbeans.spi.project.ui.support.DefaultProjectOperations;
65
import org.netbeans.spi.project.ui.support.DefaultProjectOperations;
74
import org.netbeans.spi.project.ui.support.ProjectSensitiveActions;
66
import org.netbeans.spi.project.ui.support.ProjectSensitiveActions;
75
import org.openide.ErrorManager;
67
import org.openide.ErrorManager;
76
import org.openide.actions.FindAction;
68
import org.openide.actions.FindAction;
77
import org.openide.actions.ToolsAction;
69
import org.openide.actions.ToolsAction;
78
import org.openide.filesystems.FileChangeAdapter;
79
import org.openide.filesystems.FileEvent;
80
import org.openide.filesystems.FileObject;
70
import org.openide.filesystems.FileObject;
81
import org.openide.filesystems.FileStateInvalidException;
71
import org.openide.filesystems.FileStateInvalidException;
82
import org.openide.filesystems.FileStatusEvent;
72
import org.openide.filesystems.FileStatusEvent;
Lines 90-97 Link Here
90
import org.openide.loaders.FolderLookup;
80
import org.openide.loaders.FolderLookup;
91
import org.openide.modules.SpecificationVersion;
81
import org.openide.modules.SpecificationVersion;
92
import org.openide.nodes.AbstractNode;
82
import org.openide.nodes.AbstractNode;
93
import org.openide.nodes.Children;
94
import org.openide.nodes.FilterNode;
95
import org.openide.nodes.Node;
83
import org.openide.nodes.Node;
96
import org.openide.util.HelpCtx;
84
import org.openide.util.HelpCtx;
97
import org.openide.util.Lookup;
85
import org.openide.util.Lookup;
Lines 102-109 Link Here
102
import org.openide.util.actions.SystemAction;
90
import org.openide.util.actions.SystemAction;
103
import org.openide.util.lookup.Lookups;
91
import org.openide.util.lookup.Lookups;
104
import org.openide.xml.XMLUtil;
92
import org.openide.xml.XMLUtil;
105
import org.netbeans.modules.websvc.api.client.WebServicesClientSupport;
106
import org.netbeans.modules.websvc.api.client.WebServicesClientView;
107
93
108
/**
94
/**
109
 * Support for creating logical views.
95
 * Support for creating logical views.
Lines 119-127 Link Here
119
    private final SubprojectProvider spp;
105
    private final SubprojectProvider spp;
120
    private final ReferenceHelper resolver;
106
    private final ReferenceHelper resolver;
121
    private List changeListeners;
107
    private List changeListeners;
122
123
    // Web service client
124
    private static final Object KEY_SERVICE_REFS = "serviceRefs"; // NOI18N
125
    
108
    
126
    public J2SELogicalViewProvider(J2SEProject project, UpdateHelper helper, PropertyEvaluator evaluator, SubprojectProvider spp, ReferenceHelper resolver) {
109
    public J2SELogicalViewProvider(J2SEProject project, UpdateHelper helper, PropertyEvaluator evaluator, SubprojectProvider spp, ReferenceHelper resolver) {
127
        this.project = project;
110
        this.project = project;
Lines 139-144 Link Here
139
        return new J2SELogicalViewRootNode();
122
        return new J2SELogicalViewRootNode();
140
    }
123
    }
141
    
124
    
125
    public PropertyEvaluator getEvaluator() {
126
        return evaluator;
127
    }
128
    
129
    public ReferenceHelper getRefHelper() {
130
        return resolver;
131
    }
132
    
133
    public UpdateHelper getUpdateHelper() {
134
        return helper;
135
    }
136
    
142
    public Node findPath(Node root, Object target) {
137
    public Node findPath(Node root, Object target) {
143
        Project project = (Project) root.getLookup().lookup(Project.class);
138
        Project project = (Project) root.getLookup().lookup(Project.class);
144
        if (project == null) {
139
        if (project == null) {
Lines 284-290 Link Here
284
        // icon badging <<<
279
        // icon badging <<<
285
        
280
        
286
        public J2SELogicalViewRootNode() {
281
        public J2SELogicalViewRootNode() {
287
            super(new LogicalViewChildren(project, evaluator, helper, resolver), Lookups.singleton(project));
282
            super(NodeFactorySupport.createCompositeChildren(project, "Projects/org-netbeans-modules-java-j2seproject/Nodes"), 
283
                  Lookups.singleton(project));
288
            setIconBaseWithExtension("org/netbeans/modules/java/j2seproject/ui/resources/j2seProject.gif");
284
            setIconBaseWithExtension("org/netbeans/modules/java/j2seproject/ui/resources/j2seProject.gif");
289
            super.setName( ProjectUtils.getInformation( project ).getDisplayName() );
285
            super.setName( ProjectUtils.getInformation( project ).getDisplayName() );
290
            if (hasBrokenLinks()) {
286
            if (hasBrokenLinks()) {
Lines 650-1001 Link Here
650
            
646
            
651
        }
647
        }
652
        
648
        
653
    }
654
    
655
    private static final class LogicalViewChildren extends Children.Keys/*<SourceGroup>*/ implements ChangeListener {
656
        
657
        private static final Object LIBRARIES = "Libs"; //NOI18N
658
        private static final Object TEST_LIBRARIES = "TestLibs"; //NOI18N
659
        private static final String WSDL_FOLDER=J2SEProjectWebServicesClientSupport.WSDL_FOLDER;
660
        
661
        private final Project project;
662
        private final PropertyEvaluator evaluator;
663
        private final UpdateHelper helper;
664
        private final ReferenceHelper resolver;
665
        private final SourceRoots testSources;
666
            
667
        private final WsdlCreationListener wsdlListener;
668
        private final MetaInfListener metaInfListener;
669
        private FileObject wsdlFolder;
670
                
671
        public LogicalViewChildren(J2SEProject project, PropertyEvaluator evaluator, UpdateHelper helper, ReferenceHelper resolver) {
672
            this.project = project;
673
            this.evaluator = evaluator;
674
            this.helper = helper;
675
            this.resolver = resolver;
676
            this.testSources = project.getTestSourceRoots();
677
            this.metaInfListener = new MetaInfListener();
678
            this.wsdlListener = new WsdlCreationListener();
679
        }
680
        
681
        protected void addNotify() {
682
            super.addNotify();
683
            getSources().addChangeListener(this);
684
            
685
            AntProjectHelper projectHelper = helper.getAntProjectHelper();
686
            String prop = evaluator.getProperty("meta.inf.dir"); //NOI18N
687
            if (prop!=null) {
688
                FileObject metaInf = projectHelper.resolveFileObject(prop);
689
                if (metaInf!=null) metaInf.addFileChangeListener(metaInfListener);
690
            }
691
            prop = evaluator.getProperty("src.dir"); //NOI18N
692
            if (prop!=null) {
693
                FileObject srcDir = projectHelper.resolveFileObject(prop);
694
                if (srcDir!=null) srcDir.addFileChangeListener(metaInfListener);
695
            }
696
            
697
            //XXX: Not very nice, the wsdlFolder should be hold by this class because it listens on it            
698
            WebServicesClientSupport wsClientSupportImpl = WebServicesClientSupport.getWebServicesClientSupport(project.getProjectDirectory());
699
            try {
700
                if (wsClientSupportImpl != null) {
701
                    wsdlFolder = wsClientSupportImpl.getWsdlFolder(false);
702
                }
703
            } catch (IOException ex) {
704
                ErrorManager.getDefault().notify(ex);
705
            }
706
            if (wsdlFolder != null) {
707
                wsdlFolder.addFileChangeListener(wsdlListener);
708
            }
709
            setKeys(getKeys());
710
        }
711
        
712
        protected void removeNotify() {
713
            setKeys(Collections.EMPTY_SET);
714
            getSources().removeChangeListener(this);
715
            
716
            AntProjectHelper projectHelper = helper.getAntProjectHelper();
717
            String prop = evaluator.getProperty("meta.inf.dir"); //NOI18N
718
            if (prop!=null) {
719
                FileObject metaInf = projectHelper.resolveFileObject(prop);
720
                if (metaInf!=null) metaInf.addFileChangeListener(metaInfListener);
721
            }
722
            prop = evaluator.getProperty("src.dir"); //NOI18N
723
            if (prop!=null) {
724
                FileObject srcDir = projectHelper.resolveFileObject(prop);
725
                if (srcDir!=null) srcDir.removeFileChangeListener(metaInfListener);
726
            }
727
            if (wsdlFolder != null) {
728
                wsdlFolder.removeFileChangeListener(wsdlListener);
729
            }
730
731
            super.removeNotify();
732
        }
733
        
734
        protected Node[] createNodes(Object key) {
735
            Node[] result;
736
            if (key == LIBRARIES) {
737
                //Libraries Node
738
                result = new Node[] {
739
                    new LibrariesNode(NbBundle.getMessage(J2SELogicalViewProvider.class,"CTL_LibrariesNode"),
740
                        project, evaluator, helper, resolver, J2SEProjectProperties.RUN_CLASSPATH,
741
                        new String[] {J2SEProjectProperties.BUILD_CLASSES_DIR},
742
                        "platform.active", // NOI18N
743
                        new Action[] {
744
                            LibrariesNode.createAddProjectAction(project, J2SEProjectProperties.JAVAC_CLASSPATH),
745
                            LibrariesNode.createAddLibraryAction(project, J2SEProjectProperties.JAVAC_CLASSPATH),
746
                            LibrariesNode.createAddFolderAction(project, J2SEProjectProperties.JAVAC_CLASSPATH),
747
                            null,
748
                            new PreselectPropertiesAction(project, "Libraries", CustomizerLibraries.COMPILE), // NOI18N
749
                        }
750
                    ),
751
                };
752
            } else if (key == TEST_LIBRARIES) {
753
                result = new Node[] {
754
                    new LibrariesNode(NbBundle.getMessage(J2SELogicalViewProvider.class,"CTL_TestLibrariesNode"),
755
                        project, evaluator, helper, resolver, J2SEProjectProperties.RUN_TEST_CLASSPATH,
756
                        new String[] {
757
                            J2SEProjectProperties.BUILD_TEST_CLASSES_DIR,
758
                            J2SEProjectProperties.JAVAC_CLASSPATH,
759
                            J2SEProjectProperties.BUILD_CLASSES_DIR,
760
                        },
761
                        null,
762
                        new Action[] {
763
                            LibrariesNode.createAddProjectAction(project, J2SEProjectProperties.JAVAC_TEST_CLASSPATH),
764
                            LibrariesNode.createAddLibraryAction(project, J2SEProjectProperties.JAVAC_TEST_CLASSPATH),
765
                            LibrariesNode.createAddFolderAction(project, J2SEProjectProperties.JAVAC_TEST_CLASSPATH),
766
                            null,
767
                            new PreselectPropertiesAction(project, "Libraries", CustomizerLibraries.COMPILE_TESTS), // NOI18N
768
                        }
769
                    ),
770
                };
771
            }
772
            // else if (key instanceof SourceGroup) {
773
            else if (key instanceof SourceGroupKey) {
774
                //Source root
775
                result = new Node[] {new PackageViewFilterNode(((SourceGroupKey) key).group, project)};
776
777
            } else if (key == KEY_SERVICE_REFS) {
778
                result = null;
779
                FileObject clientRoot = project.getProjectDirectory();
780
                WebServicesClientView clientView = WebServicesClientView.getWebServicesClientView(clientRoot);
781
                if (clientView != null) {
782
                    WebServicesClientSupport wss = WebServicesClientSupport.getWebServicesClientSupport(clientRoot);
783
                    if (wss!=null) {
784
                        FileObject wsdlFolder = wss.getWsdlFolder();
785
                        if (wsdlFolder!=null) {
786
                            FileObject[] children = wsdlFolder.getChildren();
787
                            boolean foundWsdl = false;
788
                            for (int i=0;i<children.length;i++) {
789
                                if (children[i].getExt().equalsIgnoreCase(WSDL_FOLDER)) { //NOI18N
790
                                    foundWsdl=true;
791
                                    break;
792
                                }
793
                            }
794
                            if (foundWsdl) {
795
                                result = new Node[] {clientView.createWebServiceClientView(wsdlFolder)};
796
                            }
797
                        }
798
                    }
799
                }
800
            } else {
801
                assert false : "Unknown key type";  //NOI18N
802
                result = new Node[0];
803
            }
804
            return result;
805
        }
806
        
807
        public void stateChanged(ChangeEvent e) {
808
            // setKeys(getKeys());
809
            // The caller holds ProjectManager.mutex() read lock
810
            SwingUtilities.invokeLater(new Runnable() {
811
                public void run() {
812
                    setKeys(getKeys());
813
                }
814
            });
815
        }
816
        
817
        // Private methods -----------------------------------------------------
818
        
819
        private Collection getKeys() {
820
            //#60800, #61584 - when the project is deleted externally do not try to create children, the source groups
821
            //are not valid
822
            if (this.project.getProjectDirectory() == null || !this.project.getProjectDirectory().isValid()) {
823
                return Collections.EMPTY_LIST;
824
            }
825
            Sources sources = getSources();
826
            SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
827
            
828
            List result =  new ArrayList(groups.length);
829
            for( int i = 0; i < groups.length; i++ ) {
830
                result.add(new SourceGroupKey(groups[i]));
831
            }
832
            result.add(LIBRARIES);
833
            URL[] testRoots = this.testSources.getRootURLs();
834
            boolean addTestSources = false;
835
            for (int i = 0; i < testRoots.length; i++) {
836
                File f = new File(URI.create(testRoots[i].toExternalForm()));
837
                if (f.exists()) {
838
                    addTestSources = true;
839
                    break;
840
                }
841
            }
842
            if (addTestSources) {
843
                result.add(TEST_LIBRARIES);
844
            }
845
            
846
            result.add(KEY_SERVICE_REFS);
847
848
            return result;
849
        }
850
        
851
        private Sources getSources() {
852
            return ProjectUtils.getSources(project);
853
        }
854
        
855
        private static class SourceGroupKey {
856
            
857
            public final SourceGroup group;
858
            public final FileObject fileObject;
859
            
860
            SourceGroupKey(SourceGroup group) {
861
                this.group = group;
862
                this.fileObject = group.getRootFolder();
863
            }
864
            
865
            public int hashCode() {
866
                return fileObject.hashCode();
867
            }
868
            
869
            public boolean equals(Object obj) {
870
                if (!(obj instanceof SourceGroupKey)) {
871
                    return false;
872
                } else {
873
                    SourceGroupKey otherKey = (SourceGroupKey) obj;
874
                    String thisDisplayName = this.group.getDisplayName();
875
                    String otherDisplayName = otherKey.group.getDisplayName();
876
                    // XXX what is the operator binding order supposed to be here??
877
                    return fileObject.equals(otherKey.fileObject) &&
878
                            thisDisplayName == null ? otherDisplayName == null : thisDisplayName.equals(otherDisplayName);
879
                }
880
            }
881
            
882
        }
883
        
884
        private final class WsdlCreationListener extends FileChangeAdapter {
885
            
886
            public void fileDataCreated (FileEvent fe) {
887
                if (WSDL_FOLDER.equalsIgnoreCase(fe.getFile().getExt())) {
888
                    SwingUtilities.invokeLater(new Runnable() {
889
                        public void run() {
890
                            refreshKey(KEY_SERVICE_REFS);
891
                        }
892
                    });
893
                }
894
            }
895
            
896
            public void fileDeleted (FileEvent fe) {
897
                if (WSDL_FOLDER.equalsIgnoreCase(fe.getFile().getExt())) {
898
                    SwingUtilities.invokeLater(new Runnable() {
899
                        public void run() {
900
                            refreshKey(KEY_SERVICE_REFS);
901
                        }
902
                    });
903
                } else if (fe.getFile().isFolder() && WSDL_FOLDER.equals(fe.getFile().getName())) {
904
                    SwingUtilities.invokeLater(new Runnable() {
905
                        public void run() {
906
                            refreshKey(KEY_SERVICE_REFS);
907
                        }
908
                    });
909
                }
910
            }
911
        }
912
        
913
        private final class MetaInfListener extends FileChangeAdapter {
914
            
915
            public void fileFolderCreated (FileEvent fe) {
916
                if (fe.getFile().isFolder() && WSDL_FOLDER.equals(fe.getFile().getName())) {
917
                    fe.getFile().addFileChangeListener(wsdlListener);
918
                } else if (fe.getFile().isFolder() && "META-INF".equals(fe.getFile().getName())) { //NOI18N
919
                    fe.getFile().addFileChangeListener(metaInfListener);
920
                }
921
            }
922
923
            public void fileDeleted (FileEvent fe) {
924
                if (fe.getFile().isFolder() && WSDL_FOLDER.equals(fe.getFile().getName())) {
925
                    fe.getFile().removeFileChangeListener(wsdlListener);
926
                    SwingUtilities.invokeLater(new Runnable() {
927
                        public void run() {
928
                            refreshKey(KEY_SERVICE_REFS);
929
                        }
930
                    });
931
                } else if (fe.getFile().isFolder() && "META-INF".equals(fe.getFile().getName())) { //NOI18N
932
                    fe.getFile().removeFileChangeListener(metaInfListener);
933
                }
934
            }
935
        }
936
    }
937
                
938
    /** Yet another cool filter node just to add properties action
939
     */
940
    private static class PackageViewFilterNode extends FilterNode {
941
        
942
        private String nodeName;
943
        private Project project;
944
        
945
        Action[] actions;
946
        
947
        public PackageViewFilterNode(SourceGroup sourceGroup, Project project) {
948
            super(PackageView.createPackageView(sourceGroup));
949
            this.project = project;
950
            this.nodeName = "Sources";
951
        }
952
        
953
        
954
        public Action[] getActions(boolean context) {
955
            if (!context) {
956
                if (actions == null) {
957
                    Action superActions[] = super.getActions(context);
958
                    actions = new Action[superActions.length + 2];
959
                    System.arraycopy(superActions, 0, actions, 0, superActions.length);
960
                    actions[superActions.length] = null;
961
                    actions[superActions.length + 1] = new PreselectPropertiesAction(project, nodeName);
962
                }
963
                return actions;
964
            } else {
965
                return super.getActions(context);
966
            }
967
        }
968
        
969
    }
970
    
971
    
972
    /** The special properties action
973
     */
974
    private static class PreselectPropertiesAction extends AbstractAction {
975
        
976
        private final Project project;
977
        private final String nodeName;
978
        private final String panelName;
979
        
980
        public PreselectPropertiesAction(Project project, String nodeName) {
981
            this(project, nodeName, null);
982
        }
983
        
984
        public PreselectPropertiesAction(Project project, String nodeName, String panelName) {
985
            super(NbBundle.getMessage(J2SELogicalViewProvider.class, "LBL_Properties_Action"));
986
            this.project = project;
987
            this.nodeName = nodeName;
988
            this.panelName = panelName;
989
        }
990
        
991
        public void actionPerformed(ActionEvent e) {
992
            // J2SECustomizerProvider cp = (J2SECustomizerProvider) project.getLookup().lookup(J2SECustomizerProvider.class);
993
            CustomizerProviderImpl cp = (CustomizerProviderImpl) project.getLookup().lookup(CustomizerProviderImpl.class);
994
            if (cp != null) {
995
                cp.showCustomizer(nodeName, panelName);
996
            }
997
            
998
        }
999
    }
649
    }
1000
    
650
    
1001
}
651
}
(-)src/org/netbeans/modules/java/j2seproject/ui/LibrariesNodeFactory.java (+186 lines)
Added Link Here
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.java.j2seproject.ui;
21
22
import java.beans.PropertyChangeEvent;
23
import java.beans.PropertyChangeListener;
24
import java.io.File;
25
import java.net.URI;
26
import java.net.URL;
27
import java.util.ArrayList;
28
import java.util.Iterator;
29
import java.util.List;
30
import javax.swing.Action;
31
import javax.swing.SwingUtilities;
32
import javax.swing.event.ChangeEvent;
33
import javax.swing.event.ChangeListener;
34
import org.netbeans.api.project.Project;
35
import org.netbeans.modules.java.j2seproject.J2SEProject;
36
import org.netbeans.modules.java.j2seproject.SourceRoots;
37
import org.netbeans.modules.java.j2seproject.UpdateHelper;
38
import org.netbeans.modules.java.j2seproject.ui.customizer.CustomizerLibraries;
39
import org.netbeans.modules.java.j2seproject.ui.customizer.J2SEProjectProperties;
40
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
41
import org.netbeans.spi.project.support.ant.ReferenceHelper;
42
import org.netbeans.spi.project.ui.support.NodeFactory;
43
import org.netbeans.spi.project.ui.support.NodeList;
44
import org.openide.nodes.Node;
45
import org.openide.util.NbBundle;
46
47
/**
48
 *
49
 * @author mkleint
50
 */
51
public final class LibrariesNodeFactory implements NodeFactory {
52
    
53
    /** Creates a new instance of LibrariesNodeFactory */
54
    public LibrariesNodeFactory() {
55
    }
56
57
    public NodeList createNodes(Project p) {
58
        J2SEProject project = (J2SEProject)p.getLookup().lookup(J2SEProject.class);
59
        assert project != null;
60
        return new LibrariesNodeList(project);
61
    }
62
63
    public Node findPath(Project p, Node root, Object target) {
64
        return null;
65
    }
66
    
67
    private static class LibrariesNodeList implements NodeList, PropertyChangeListener {
68
        private static final Object LIBRARIES = "Libs"; //NOI18N
69
        private static final Object TEST_LIBRARIES = "TestLibs"; //NOI18N
70
71
        private SourceRoots testSources;
72
        private J2SEProject project;
73
        private ArrayList listeners = new ArrayList();
74
75
        private PropertyEvaluator evaluator;
76
        private UpdateHelper helper;
77
        private ReferenceHelper resolver;
78
        
79
        LibrariesNodeList(J2SEProject proj) {
80
            project = proj;
81
            testSources = project.getTestSourceRoots();
82
            J2SELogicalViewProvider logView = (J2SELogicalViewProvider)project.getLookup().lookup(J2SELogicalViewProvider.class);
83
            assert logView != null;
84
            evaluator = logView.getEvaluator();
85
            helper = logView.getUpdateHelper();
86
            resolver = logView.getRefHelper();
87
        }
88
        
89
        public List keys() {
90
            List result = new ArrayList();
91
            result.add(LIBRARIES);
92
            URL[] testRoots = testSources.getRootURLs();
93
            boolean addTestSources = false;
94
            for (int i = 0; i < testRoots.length; i++) {
95
                File f = new File(URI.create(testRoots[i].toExternalForm()));
96
                if (f.exists()) {
97
                    addTestSources = true;
98
                    break;
99
                }
100
            }
101
            if (addTestSources) {
102
                result.add(TEST_LIBRARIES);
103
            }
104
            return result;
105
        }
106
107
        public synchronized void addChangeListener(ChangeListener l) {
108
            listeners.add(l);
109
        }
110
111
        public synchronized void removeChangeListener(ChangeListener l) {
112
            listeners.remove(l);
113
        }
114
        
115
        private void fireChange() {
116
            ArrayList list = new ArrayList();
117
            synchronized (this) {
118
                list.addAll(listeners);
119
            }
120
            Iterator it = list.iterator();
121
            while (it.hasNext()) {
122
                ChangeListener elem = (ChangeListener) it.next();
123
                elem.stateChanged(new ChangeEvent( this ));
124
            }
125
        }
126
127
        public Node node(Object key) {
128
            if (key == LIBRARIES) {
129
                //Libraries Node
130
                return  
131
                    new LibrariesNode(NbBundle.getMessage(J2SELogicalViewProvider.class,"CTL_LibrariesNode"),
132
                        project, evaluator, helper, resolver, J2SEProjectProperties.RUN_CLASSPATH,
133
                        new String[] {J2SEProjectProperties.BUILD_CLASSES_DIR},
134
                        "platform.active", // NOI18N
135
                        new Action[] {
136
                            LibrariesNode.createAddProjectAction(project, J2SEProjectProperties.JAVAC_CLASSPATH),
137
                            LibrariesNode.createAddLibraryAction(project, J2SEProjectProperties.JAVAC_CLASSPATH),
138
                            LibrariesNode.createAddFolderAction(project, J2SEProjectProperties.JAVAC_CLASSPATH),
139
                            null,
140
                            new SourceNodeFactory.PreselectPropertiesAction(project, "Libraries", CustomizerLibraries.COMPILE), // NOI18N
141
                        }
142
                    );
143
            } else if (key == TEST_LIBRARIES) {
144
                return  
145
                    new LibrariesNode(NbBundle.getMessage(J2SELogicalViewProvider.class,"CTL_TestLibrariesNode"),
146
                        project, evaluator, helper, resolver, J2SEProjectProperties.RUN_TEST_CLASSPATH,
147
                        new String[] {
148
                            J2SEProjectProperties.BUILD_TEST_CLASSES_DIR,
149
                            J2SEProjectProperties.JAVAC_CLASSPATH,
150
                            J2SEProjectProperties.BUILD_CLASSES_DIR,
151
                        },
152
                        null,
153
                        new Action[] {
154
                            LibrariesNode.createAddProjectAction(project, J2SEProjectProperties.JAVAC_TEST_CLASSPATH),
155
                            LibrariesNode.createAddLibraryAction(project, J2SEProjectProperties.JAVAC_TEST_CLASSPATH),
156
                            LibrariesNode.createAddFolderAction(project, J2SEProjectProperties.JAVAC_TEST_CLASSPATH),
157
                            null,
158
                            new SourceNodeFactory.PreselectPropertiesAction(project, "Libraries", CustomizerLibraries.COMPILE_TESTS), // NOI18N
159
                        }
160
                    );
161
            }
162
            assert false: "No node for key: " + key;
163
            return null;
164
            
165
        }
166
167
        public void addNotify() {
168
            testSources.addPropertyChangeListener(this);
169
        }
170
171
        public void removeNotify() {
172
            testSources.removePropertyChangeListener(this);
173
        }
174
175
        public void propertyChange(PropertyChangeEvent evt) {
176
            // The caller holds ProjectManager.mutex() read lock
177
            SwingUtilities.invokeLater(new Runnable() {
178
                public void run() {
179
                    fireChange();
180
                }
181
            });
182
        }
183
        
184
    }
185
    
186
}
(-)src/org/netbeans/modules/java/j2seproject/ui/SourceNodeFactory.java (+234 lines)
Added Link Here
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.java.j2seproject.ui;
21
22
import java.awt.event.ActionEvent;
23
import java.util.ArrayList;
24
import java.util.Collections;
25
import java.util.Iterator;
26
import java.util.List;
27
import javax.swing.AbstractAction;
28
import javax.swing.Action;
29
import javax.swing.SwingUtilities;
30
import javax.swing.event.ChangeEvent;
31
import javax.swing.event.ChangeListener;
32
import org.netbeans.api.java.project.JavaProjectConstants;
33
import org.netbeans.api.project.Project;
34
import org.netbeans.api.project.ProjectUtils;
35
import org.netbeans.api.project.SourceGroup;
36
import org.netbeans.api.project.Sources;
37
import org.netbeans.modules.java.j2seproject.J2SEProject;
38
import org.netbeans.modules.java.j2seproject.ui.customizer.CustomizerProviderImpl;
39
import org.netbeans.spi.java.project.support.ui.PackageView;
40
import org.netbeans.spi.project.ui.support.NodeFactorySupport;
41
import org.netbeans.spi.project.ui.support.NodeFactory;
42
import org.netbeans.spi.project.ui.support.NodeList;
43
import org.openide.filesystems.FileObject;
44
import org.openide.nodes.FilterNode;
45
import org.openide.nodes.Node;
46
import org.openide.util.NbBundle;
47
48
/**
49
 *
50
 * @author mkleint
51
 */
52
public final class SourceNodeFactory implements NodeFactory {
53
    public SourceNodeFactory() {
54
    }
55
    
56
    public NodeList createNodes(Project p) {
57
        J2SEProject project = (J2SEProject)p.getLookup().lookup(J2SEProject.class);
58
        assert project != null;
59
        return new SourcesNodeList(project);
60
    }
61
    
62
    public Node findPath(Project p, Node root, Object target) {
63
        return null;
64
    }
65
    
66
    private static class SourcesNodeList implements NodeList, ChangeListener {
67
        
68
        private J2SEProject project;
69
        
70
        private List listeners = new ArrayList();
71
        
72
        public SourcesNodeList(J2SEProject proj) {
73
            project = proj;
74
        }
75
        
76
        public List keys() {
77
            if (this.project.getProjectDirectory() == null || !this.project.getProjectDirectory().isValid()) {
78
                return Collections.EMPTY_LIST;
79
            }
80
            Sources sources = getSources();
81
            SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
82
            
83
            List result =  new ArrayList(groups.length);
84
            for( int i = 0; i < groups.length; i++ ) {
85
                result.add(new SourceGroupKey(groups[i]));
86
            }
87
            return result;
88
        }
89
        
90
        public synchronized void addChangeListener(ChangeListener l) {
91
            listeners.add(l);
92
        }
93
        
94
        public synchronized void removeChangeListener(ChangeListener l) {
95
            listeners.remove(l);
96
        }
97
        
98
        private void fireChange() {
99
            ArrayList list = new ArrayList();
100
            synchronized (this) {
101
                list.addAll(listeners);
102
            }
103
            Iterator it = list.iterator();
104
            while (it.hasNext()) {
105
                ChangeListener elem = (ChangeListener) it.next();
106
                elem.stateChanged(new ChangeEvent( this ));
107
            }
108
        }
109
        
110
        public Node node(Object key) {
111
            if (key instanceof SourceGroupKey) {
112
                //Source root
113
                return new PackageViewFilterNode(((SourceGroupKey) key).group, project);
114
            }
115
            return null;
116
        }
117
        
118
        public void addNotify() {
119
            getSources().addChangeListener(this);
120
        }
121
        
122
        public void removeNotify() {
123
            getSources().removeChangeListener(this);
124
        }
125
        
126
        public void stateChanged(ChangeEvent e) {
127
            // setKeys(getKeys());
128
            // The caller holds ProjectManager.mutex() read lock
129
            SwingUtilities.invokeLater(new Runnable() {
130
                public void run() {
131
                    fireChange();
132
                }
133
            });
134
        }
135
        
136
        private Sources getSources() {
137
            return ProjectUtils.getSources(project);
138
        }
139
        
140
    }
141
    
142
    private static class SourceGroupKey {
143
        
144
        public final SourceGroup group;
145
        public final FileObject fileObject;
146
        
147
        SourceGroupKey(SourceGroup group) {
148
            this.group = group;
149
            this.fileObject = group.getRootFolder();
150
        }
151
        
152
        public int hashCode() {
153
            return fileObject.hashCode();
154
        }
155
        
156
        public boolean equals(Object obj) {
157
            if (!(obj instanceof SourceGroupKey)) {
158
                return false;
159
            } else {
160
                SourceGroupKey otherKey = (SourceGroupKey) obj;
161
                String thisDisplayName = this.group.getDisplayName();
162
                String otherDisplayName = otherKey.group.getDisplayName();
163
                // XXX what is the operator binding order supposed to be here??
164
                return fileObject.equals(otherKey.fileObject) &&
165
                        thisDisplayName == null ? otherDisplayName == null : thisDisplayName.equals(otherDisplayName);
166
            }
167
        }
168
        
169
    }
170
    
171
    /** Yet another cool filter node just to add properties action
172
     */
173
    private static class PackageViewFilterNode extends FilterNode {
174
        
175
        private String nodeName;
176
        private Project project;
177
        
178
        Action[] actions;
179
        
180
        public PackageViewFilterNode(SourceGroup sourceGroup, Project project) {
181
            super(PackageView.createPackageView(sourceGroup));
182
            this.project = project;
183
            this.nodeName = "Sources";
184
        }
185
        
186
        
187
        public Action[] getActions(boolean context) {
188
            if (!context) {
189
                if (actions == null) {
190
                    Action superActions[] = super.getActions(context);
191
                    actions = new Action[superActions.length + 2];
192
                    System.arraycopy(superActions, 0, actions, 0, superActions.length);
193
                    actions[superActions.length] = null;
194
                    actions[superActions.length + 1] = new PreselectPropertiesAction(project, nodeName);
195
                }
196
                return actions;
197
            } else {
198
                return super.getActions(context);
199
            }
200
        }
201
        
202
    }
203
    
204
    
205
    /** The special properties action
206
     */
207
    static class PreselectPropertiesAction extends AbstractAction {
208
        
209
        private final Project project;
210
        private final String nodeName;
211
        private final String panelName;
212
        
213
        public PreselectPropertiesAction(Project project, String nodeName) {
214
            this(project, nodeName, null);
215
        }
216
        
217
        public PreselectPropertiesAction(Project project, String nodeName, String panelName) {
218
            super(NbBundle.getMessage(J2SELogicalViewProvider.class, "LBL_Properties_Action"));
219
            this.project = project;
220
            this.nodeName = nodeName;
221
            this.panelName = panelName;
222
        }
223
        
224
        public void actionPerformed(ActionEvent e) {
225
            // J2SECustomizerProvider cp = (J2SECustomizerProvider) project.getLookup().lookup(J2SECustomizerProvider.class);
226
            CustomizerProviderImpl cp = (CustomizerProviderImpl) project.getLookup().lookup(CustomizerProviderImpl.class);
227
            if (cp != null) {
228
                cp.showCustomizer(nodeName, panelName);
229
            }
230
            
231
        }
232
    }
233
    
234
}
(-)src/org/netbeans/modules/java/j2seproject/ui/resources/layer.xml (+8 lines)
Lines 108-113 Link Here
108
                    </file>
108
                    </file>
109
                </folder>
109
                </folder>
110
            </folder>
110
            </folder>
111
            <folder name="Nodes">
112
                <file name="org.netbeans.modules.java.j2seproject.ui.SourceNodeFactory.instance"/>
113
                <attr name="org.netbeans.modules.java.j2seproject.ui.SourceNodeFactory.instance/org.netbeans.modules.java.j2seproject.ui.LibrariesNodeFactory.instance" boolvalue="true"/>
114
                <file name="org.netbeans.modules.java.j2seproject.ui.LibrariesNodeFactory.instance"/>
115
                <attr name="org.netbeans.modules.java.j2seproject.ui.LibrariesNodeFactory.instance/org.netbeans.modules.java.j2seproject.wsclient.WebServicesNodeFactory.instance" boolvalue="true"/>
116
                <file name="org.netbeans.modules.java.j2seproject.wsclient.WebServicesNodeFactory.instance"/>
117
                
118
            </folder>
111
        </folder>
119
        </folder>
112
    </folder>
120
    </folder>
113
</filesystem>
121
</filesystem>
(-)src/org/netbeans/modules/java/j2seproject/wsclient/WebServicesNodeFactory.java (+246 lines)
Added Link Here
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.java.j2seproject.wsclient;
21
22
import java.io.IOException;
23
import java.util.ArrayList;
24
import java.util.Collections;
25
import java.util.Iterator;
26
import java.util.List;
27
import javax.swing.SwingUtilities;
28
import javax.swing.event.ChangeEvent;
29
import javax.swing.event.ChangeListener;
30
import org.netbeans.api.project.Project;
31
import org.netbeans.modules.java.j2seproject.J2SEProject;
32
import org.netbeans.modules.java.j2seproject.UpdateHelper;
33
import org.netbeans.modules.java.j2seproject.ui.J2SELogicalViewProvider;
34
import org.netbeans.modules.websvc.api.client.WebServicesClientSupport;
35
import org.netbeans.modules.websvc.api.client.WebServicesClientView;
36
import org.netbeans.spi.project.support.ant.AntProjectHelper;
37
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
38
import org.netbeans.spi.project.support.ant.ReferenceHelper;
39
import org.netbeans.spi.project.ui.support.NodeFactory;
40
import org.netbeans.spi.project.ui.support.NodeList;
41
import org.openide.ErrorManager;
42
import org.openide.filesystems.FileChangeAdapter;
43
import org.openide.filesystems.FileEvent;
44
import org.openide.filesystems.FileObject;
45
import org.openide.nodes.Node;
46
47
/**
48
 *
49
 * @author mkleint
50
 */
51
public class WebServicesNodeFactory implements NodeFactory {
52
    
53
    /** Creates a new instance of WebServicesNodeFactory */
54
    public WebServicesNodeFactory() {
55
    }
56
    
57
    public NodeList createNodes(Project p) {
58
        J2SEProject project = (J2SEProject)p.getLookup().lookup(J2SEProject.class);
59
        assert project != null;
60
        return new WsNodeList(project);
61
    }
62
    
63
    public Node findPath(Project p, Node root, Object target) {
64
        return null;
65
    }
66
    
67
    private static class WsNodeList implements NodeList {
68
        
69
        private static final String WSDL_FOLDER=J2SEProjectWebServicesClientSupport.WSDL_FOLDER;
70
        // Web service client
71
        private static final Object KEY_SERVICE_REFS = "serviceRefs"; // NOI18N
72
        
73
        private J2SEProject project;
74
        
75
        private List listeners = new ArrayList();
76
        private final WsdlCreationListener wsdlListener;
77
        private final MetaInfListener metaInfListener;
78
        private FileObject wsdlFolder;
79
80
        private PropertyEvaluator evaluator;
81
        private UpdateHelper helper;
82
        private ReferenceHelper resolver;
83
        
84
        
85
        public WsNodeList(J2SEProject proj) {
86
            project = proj;
87
            this.metaInfListener = new MetaInfListener();
88
            this.wsdlListener = new WsdlCreationListener();
89
            J2SELogicalViewProvider logView = (J2SELogicalViewProvider)project.getLookup().lookup(J2SELogicalViewProvider.class);
90
            assert logView != null;
91
            evaluator = logView.getEvaluator();
92
            helper = logView.getUpdateHelper();
93
            resolver = logView.getRefHelper();
94
        }
95
        
96
        public List keys() {
97
            return Collections.singletonList(KEY_SERVICE_REFS);
98
        }
99
        
100
        public synchronized void addChangeListener(ChangeListener l) {
101
            listeners.add(l);
102
        }
103
        
104
        public synchronized void removeChangeListener(ChangeListener l) {
105
            listeners.remove(l);
106
        }
107
        
108
        private void fireChange() {
109
            ArrayList list = new ArrayList();
110
            synchronized (this) {
111
                list.addAll(listeners);
112
            }
113
            Iterator it = list.iterator();
114
            while (it.hasNext()) {
115
                ChangeListener elem = (ChangeListener) it.next();
116
                elem.stateChanged(new ChangeEvent( this ));
117
            }
118
        }
119
        
120
        public Node node(Object key) {
121
            FileObject clientRoot = project.getProjectDirectory();
122
            WebServicesClientView clientView = WebServicesClientView.getWebServicesClientView(clientRoot);
123
            if (clientView != null) {
124
                WebServicesClientSupport wss = WebServicesClientSupport.getWebServicesClientSupport(clientRoot);
125
                if (wss!=null) {
126
                    FileObject wsdlFolder = wss.getWsdlFolder();
127
                    if (wsdlFolder!=null) {
128
                        FileObject[] children = wsdlFolder.getChildren();
129
                        boolean foundWsdl = false;
130
                        for (int i=0;i<children.length;i++) {
131
                            if (children[i].getExt().equalsIgnoreCase(WSDL_FOLDER)) { //NOI18N
132
                                foundWsdl=true;
133
                                break;
134
                            }
135
                        }
136
                        if (foundWsdl) {
137
                            return  clientView.createWebServiceClientView(wsdlFolder);
138
                        }
139
                    }
140
                }
141
            }
142
            return null;
143
        }
144
        
145
        public void addNotify() {
146
            AntProjectHelper projectHelper = helper.getAntProjectHelper();
147
            String prop = evaluator.getProperty("meta.inf.dir"); //NOI18N
148
            if (prop!=null) {
149
                FileObject metaInf = projectHelper.resolveFileObject(prop);
150
                if (metaInf!=null) metaInf.addFileChangeListener(metaInfListener);
151
            }
152
            prop = evaluator.getProperty("src.dir"); //NOI18N
153
            if (prop!=null) {
154
                FileObject srcDir = projectHelper.resolveFileObject(prop);
155
                if (srcDir!=null) srcDir.addFileChangeListener(metaInfListener);
156
            }
157
            
158
            //XXX: Not very nice, the wsdlFolder should be hold by this class because it listens on it
159
            WebServicesClientSupport wsClientSupportImpl = WebServicesClientSupport.getWebServicesClientSupport(project.getProjectDirectory());
160
            try {
161
                if (wsClientSupportImpl != null) {
162
                    wsdlFolder = wsClientSupportImpl.getWsdlFolder(false);
163
                }
164
            } catch (IOException ex) {
165
                ErrorManager.getDefault().notify(ex);
166
            }
167
            if (wsdlFolder != null) {
168
                wsdlFolder.addFileChangeListener(wsdlListener);
169
            }
170
        }
171
        
172
        public void removeNotify() {
173
            AntProjectHelper projectHelper = helper.getAntProjectHelper();
174
            String prop = evaluator.getProperty("meta.inf.dir"); //NOI18N
175
            if (prop!=null) {
176
                FileObject metaInf = projectHelper.resolveFileObject(prop);
177
                if (metaInf!=null) metaInf.addFileChangeListener(metaInfListener);
178
            }
179
            prop = evaluator.getProperty("src.dir"); //NOI18N
180
            if (prop!=null) {
181
                FileObject srcDir = projectHelper.resolveFileObject(prop);
182
                if (srcDir!=null) srcDir.removeFileChangeListener(metaInfListener);
183
            }
184
            if (wsdlFolder != null) {
185
                wsdlFolder.removeFileChangeListener(wsdlListener);
186
            }
187
        }
188
        private final class WsdlCreationListener extends FileChangeAdapter {
189
            
190
            public void fileDataCreated(FileEvent fe) {
191
                if (WSDL_FOLDER.equalsIgnoreCase(fe.getFile().getExt())) {
192
                    SwingUtilities.invokeLater(new Runnable() {
193
                        public void run() {
194
                            fireChange();
195
                        }
196
                    });
197
                }
198
            }
199
            
200
            public void fileDeleted(FileEvent fe) {
201
                if (WSDL_FOLDER.equalsIgnoreCase(fe.getFile().getExt())) {
202
                    SwingUtilities.invokeLater(new Runnable() {
203
                        public void run() {
204
                            fireChange();
205
                        }
206
                    });
207
                } else if (fe.getFile().isFolder() && WSDL_FOLDER.equals(fe.getFile().getName())) {
208
                    SwingUtilities.invokeLater(new Runnable() {
209
                        public void run() {
210
                            fireChange();
211
                        }
212
                    });
213
                }
214
            }
215
        }
216
        
217
        private final class MetaInfListener extends FileChangeAdapter {
218
            
219
            public void fileFolderCreated(FileEvent fe) {
220
                if (fe.getFile().isFolder() && WSDL_FOLDER.equals(fe.getFile().getName())) {
221
                    fe.getFile().addFileChangeListener(wsdlListener);
222
                } else if (fe.getFile().isFolder() && "META-INF".equals(fe.getFile().getName())) { //NOI18N
223
                    fe.getFile().addFileChangeListener(metaInfListener);
224
                }
225
            }
226
            
227
            public void fileDeleted(FileEvent fe) {
228
                if (fe.getFile().isFolder() && WSDL_FOLDER.equals(fe.getFile().getName())) {
229
                    fe.getFile().removeFileChangeListener(wsdlListener);
230
                    SwingUtilities.invokeLater(new Runnable() {
231
                        public void run() {
232
                            fireChange();
233
                        }
234
                    });
235
                } else if (fe.getFile().isFolder() && "META-INF".equals(fe.getFile().getName())) { //NOI18N
236
                    fe.getFile().removeFileChangeListener(metaInfListener);
237
                }
238
            }
239
        }
240
        
241
        
242
    }
243
    
244
    
245
    
246
}

Return to bug 72441