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 244126
Collapse All | Expand All

(-)projectapi/apichanges.xml (+16 lines)
Lines 108-113 Link Here
108
108
109
    <changes>
109
    <changes>
110
        
110
        
111
         <change id="ProjectManager.Result">
112
            <api name="general"/>
113
            <summary>More information in <code>ProjectManager.Result</code></summary>
114
            <version major="1" minor="59"/>
115
            <date day="28" month="4" year="2014"/>
116
            <author login="tstupka"/>
117
            <compatibility addition="yes"/>
118
            <description>
119
                <p>
120
                  Introduced <code>ProjectManager.Result.getDisplayName()</code> and <code>ProjectManager.Result.getProjectType()</code>
121
                  to provide more information about a potential project via <code>ProjectManager.isProject2(FileObject)</code>.
122
                </p>
123
            </description>
124
            <class package="org.netbeans.api.project" name="ProjectManager"/>
125
            <issue number="244126"/>
126
        </change>
111
        <change id="DependencyProjectProvider">
127
        <change id="DependencyProjectProvider">
112
            <api name="general"/>
128
            <api name="general"/>
113
            <summary></summary>
129
            <summary></summary>
(-)projectapi/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.projectapi/1
2
OpenIDE-Module: org.netbeans.modules.projectapi/1
3
OpenIDE-Module-Specification-Version: 1.58
3
OpenIDE-Module-Specification-Version: 1.59
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/projectapi/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/projectapi/Bundle.properties
5
OpenIDE-Module-Layer: org/netbeans/modules/projectapi/layer.xml
5
OpenIDE-Module-Layer: org/netbeans/modules/projectapi/layer.xml
6
6
(-)projectapi/src/org/netbeans/api/project/ProjectManager.java (-1 / +34 lines)
Lines 788-800 Link Here
788
     */
788
     */
789
    public static final class Result {
789
    public static final class Result {
790
        private Icon icon;
790
        private Icon icon;
791
        private final String displayName;
792
        private final String projectType;
791
793
792
793
        public Result(Icon icon) {
794
        public Result(Icon icon) {
795
            this(null, null, icon);
796
        }
797
798
        /**
799
         * C'tor.  
800
         * @param displayName a display name or null if not available
801
         * @param projectType a project type or null if not available
802
         * @param icon an icon or null if not available
803
         * @since org.netbeans.modules.projectapi 1.59
804
         */
805
        public Result(String displayName, String projectType, Icon icon) {
794
            this.icon = icon;
806
            this.icon = icon;
807
            this.displayName = displayName;
808
            this.projectType = projectType;
795
        }
809
        }
796
810
797
        /**
811
        /**
812
          * Get a human-readable display name for the project.
813
          * May contain spaces, international characters, etc.
814
          * @return a display name for the project or null if the display name cannot be found this way.
815
          * @since org.netbeans.modules.projectapi 1.59
816
          */
817
        public String getDisplayName() {
818
            return displayName;
819
        }
820
         
821
        /**
822
         * Get the project type e.g. {@code "org-netbeans-modules-java-j2seproject"}
823
         * @return the project type or null if the project type cannot be found this way.
824
         * @since org.netbeans.modules.projectapi 1.59
825
         */
826
        public String getProjectType() {
827
            return projectType;
828
        }
829
         
830
        /**
798
         * Get the project icon.
831
         * Get the project icon.
799
         * @return project type icon for the result or null if the icon cannot be found this way.
832
         * @return project type icon for the result or null if the icon cannot be found this way.
800
         */
833
         */
(-)projectapi/test/unit/src/org/netbeans/api/project/ProjectManagerTest.java (+25 lines)
Lines 222-227 Link Here
222
        }
222
        }
223
    }
223
    }
224
    
224
    
225
    public void testIsProject() throws Exception {
226
        assertTrue("Should have recognized goodproject", pm.isProject(goodproject));
227
        
228
        assertTrue("Should have recognized badproject", pm.isProject(badproject));
229
        
230
        assertFalse("Should not have been able to load mysteryproject", pm.isProject(mysteryproject));
231
    }
232
    
233
    public void testIsProject2() throws Exception {
234
        ProjectManager.Result r = pm.isProject2(goodproject);
235
        assertNotNull("Should have recognized goodproject", r);
236
        assertEquals(goodproject.getName(), r.getDisplayName());
237
        assertEquals(TestUtil.TEST_PROJECT_ICON, r.getIcon());
238
        assertEquals(TestUtil.TEST_PROJECT_TYPE, r.getProjectType());
239
        
240
        ProjectManager.Result r2 = pm.isProject2(badproject);
241
        assertNotNull("Should have recognized badproject", r2);
242
        assertNull("Should not have a project name for badproject", r2.getDisplayName());
243
        assertEquals(TestUtil.TEST_PROJECT_ICON, r2.getIcon());
244
        assertNull("Should not have a project type for badproject", r2.getProjectType());
245
        
246
        ProjectManager.Result r3 = pm.isProject2(mysteryproject);
247
        assertNull("Should not have been able to load mysteryproject", r3);
248
    }
249
    
225
    public void testModify() throws Exception {
250
    public void testModify() throws Exception {
226
        Project p1 = pm.findProject(goodproject);
251
        Project p1 = pm.findProject(goodproject);
227
        Project p2 = pm.findProject(goodproject2);
252
        Project p2 = pm.findProject(goodproject2);
(-)projectapi/test/unit/src/org/netbeans/api/project/TestUtil.java (-1 / +35 lines)
Lines 44-49 Link Here
44
44
45
package org.netbeans.api.project;
45
package org.netbeans.api.project;
46
46
47
import java.awt.Component;
48
import java.awt.Graphics;
47
import java.io.File;
49
import java.io.File;
48
import java.io.IOException;
50
import java.io.IOException;
49
import java.io.InputStream;
51
import java.io.InputStream;
Lines 54-62 Link Here
54
import java.util.StringTokenizer;
56
import java.util.StringTokenizer;
55
import java.util.WeakHashMap;
57
import java.util.WeakHashMap;
56
import java.util.logging.Logger;
58
import java.util.logging.Logger;
59
import javax.swing.Icon;
57
import junit.framework.Assert;
60
import junit.framework.Assert;
58
import org.netbeans.junit.NbTestCase;
61
import org.netbeans.junit.NbTestCase;
59
import org.netbeans.spi.project.ProjectFactory;
62
import org.netbeans.spi.project.ProjectFactory;
63
import org.netbeans.spi.project.ProjectFactory2;
60
import org.netbeans.spi.project.ProjectState;
64
import org.netbeans.spi.project.ProjectState;
61
import org.openide.filesystems.FileObject;
65
import org.openide.filesystems.FileObject;
62
import org.openide.filesystems.FileUtil;
66
import org.openide.filesystems.FileUtil;
Lines 187-193 Link Here
187
     */
191
     */
188
    public static Lookup LOOKUP = null;
192
    public static Lookup LOOKUP = null;
189
193
190
    private static final class TestProjectFactory implements ProjectFactory {
194
    public static final String TEST_PROJECT_TYPE = "test.project.type";
195
    public static final Icon TEST_PROJECT_ICON = new Icon() {
196
        @Override
197
        public void paintIcon(Component c, Graphics g, int x, int y) {
198
            throw new UnsupportedOperationException("Not supported yet.");
199
        }
200
        @Override
201
        public int getIconWidth() {
202
            throw new UnsupportedOperationException("Not supported yet.");
203
        }
204
        @Override
205
        public int getIconHeight() {
206
            throw new UnsupportedOperationException("Not supported yet.");
207
        }
208
    };
209
    private static final class TestProjectFactory implements ProjectFactory, ProjectFactory2 {
191
        
210
        
192
        TestProjectFactory() {}
211
        TestProjectFactory() {}
193
        
212
        
Lines 232-239 Link Here
232
            return testproject != null && testproject.isFolder();
251
            return testproject != null && testproject.isFolder();
233
        }
252
        }
234
        
253
        
254
        @Override
255
        public ProjectManager.Result isProject2(FileObject dir) {
256
            FileObject testproject = dir.getFileObject("testproject");
257
            if(testproject != null && testproject.isFolder() && testproject.getFileObject("broken") != null) {
258
                return new ProjectManager.Result(TEST_PROJECT_ICON);
235
    }
259
    }
260
            if(testproject != null && testproject.isFolder()) {
261
                return new ProjectManager.Result(
262
                            dir.getName(), 
263
                            TEST_PROJECT_TYPE, 
264
                            TEST_PROJECT_ICON);
265
            }
266
            return null;
267
        }
236
    
268
    
269
    }
270
    
237
    private static final class TestProject implements Project {
271
    private static final class TestProject implements Project {
238
        
272
        
239
        private final FileObject dir;
273
        private final FileObject dir;

Return to bug 244126