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

(-)ReferenceHelper.java (-27 / +47 lines)
Lines 293-334 Link Here
293
     * @return was there any change or not
293
     * @return was there any change or not
294
     */
294
     */
295
    private boolean setPathProperty(File base, File path, String propertyName) {
295
    private boolean setPathProperty(File base, File path, String propertyName) {
296
        String value;
296
        String[] values;
297
        String propertiesFile;
297
        String[] propertiesFiles;
298
        if (CollocationQuery.areCollocated(base, path)) {
298
        
299
        String relativePath = relativizeFileToExtraBaseFolders(path);
300
        // try relativize against external base dirs
301
        if (relativePath != null) {
302
            propertiesFiles = new String[] {
303
                AntProjectHelper.PROJECT_PROPERTIES_PATH
304
            };
305
            values = new String[] {
306
                relativePath
307
            };
308
        }        
309
        else if (CollocationQuery.areCollocated(base, path)) {
299
            // Fine, using a relative path to subproject.
310
            // Fine, using a relative path to subproject.
300
            value = PropertyUtils.relativizeFile(base, path);
311
            relativePath = PropertyUtils.relativizeFile(base, path);
301
            assert value != null : "These dirs are not really collocated: " + base + " & " + path;
312
            assert relativePath != null : "These dirs are not really collocated: " + base + " & " + path;
302
            propertiesFile = AntProjectHelper.PROJECT_PROPERTIES_PATH;
313
            values = new String[] {
303
        } else {
314
                relativePath,
304
            // try relativize against external base dirs
315
                path.getAbsolutePath()
305
            value = relativizeFileToExtraBaseFolders(path);
316
            };            
306
            if (value != null) {
317
            propertiesFiles = new String[] {
307
                propertiesFile = AntProjectHelper.PROJECT_PROPERTIES_PATH;
318
                AntProjectHelper.PROJECT_PROPERTIES_PATH,
308
            } else {
319
                AntProjectHelper.PRIVATE_PROPERTIES_PATH,
309
                // use an absolute path.
320
            };
310
                propertiesFile = AntProjectHelper.PRIVATE_PROPERTIES_PATH;
321
        } else {                        
311
                value = path.getAbsolutePath();
322
            // use an absolute path.
323
            propertiesFiles = new String[] {
324
                AntProjectHelper.PRIVATE_PROPERTIES_PATH
325
            };
326
            values = new String[] {
327
                path.getAbsolutePath()
328
            };            
329
        }
330
        
331
        boolean metadataChanged = false;
332
        for (int i=0; i<propertiesFiles.length; i++) {
333
            EditableProperties props = h.getProperties(propertiesFiles[i]);
334
            if (!values[i].equals(props.getProperty(propertyName))) {
335
                props.put(propertyName, values[i]);
336
                h.putProperties(propertiesFiles[i], props);
337
                metadataChanged = true;
312
            }
338
            }
313
            
314
        }
339
        }
315
        EditableProperties props = h.getProperties(propertiesFile);
340
        
316
        if (!value.equals(props.getProperty(propertyName))) {
341
        if (propertiesFiles.length == 1) {                    
317
            props.put(propertyName, value);
318
            h.putProperties(propertiesFile, props);
319
            // check presence of this property in opposite property file and
342
            // check presence of this property in opposite property file and
320
            // remove it if necessary
343
            // remove it if necessary
321
            propertiesFile = (propertiesFile == AntProjectHelper.PROJECT_PROPERTIES_PATH ? 
344
            String propertiesFile = (propertiesFiles[0] == AntProjectHelper.PROJECT_PROPERTIES_PATH ? 
322
                AntProjectHelper.PRIVATE_PROPERTIES_PATH : AntProjectHelper.PROJECT_PROPERTIES_PATH);
345
                AntProjectHelper.PRIVATE_PROPERTIES_PATH : AntProjectHelper.PROJECT_PROPERTIES_PATH);
323
            props = h.getProperties(propertiesFile);
346
            EditableProperties props = h.getProperties(propertiesFile);
324
            if (props.remove(propertyName) != null) {
347
            if (props.remove(propertyName) != null) {
325
                h.putProperties(propertiesFile, props);
348
                h.putProperties(propertiesFile, props);
326
            }
349
            }
327
            return true;
328
        } else {
329
            return false;
330
        }
350
        }
331
        
351
        return metadataChanged;
332
    }
352
    }
333
    
353
    
334
    /**
354
    /**
Lines 1298-1304 Link Here
1298
            
1318
            
1299
            //TODO: extra base dir relativization:
1319
            //TODO: extra base dir relativization:
1300
            if (CollocationQuery.areCollocated(absolutePath, projectDir)) {
1320
            if (CollocationQuery.areCollocated(absolutePath, projectDir)) {
1301
                privRemove.add(key);
1321
// Don't remove it from private properties and add the relative path to project properties   privRemove.add(key);
1302
                pubAdd.put(key, PropertyUtils.relativizeFile(projectDir, absolutePath));
1322
                pubAdd.put(key, PropertyUtils.relativizeFile(projectDir, absolutePath));
1303
            }
1323
            }
1304
        }
1324
        }

Return to bug 63267