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

(-)i18n/src/org/netbeans/modules/i18n/I18nOptions.java (-1 / +60 lines)
Lines 23-33 Link Here
23
23
24
import java.io.File;
24
import java.io.File;
25
import java.io.File;
25
import java.io.File;
26
import java.net.URL;
26
import java.util.ArrayList;
27
import java.util.ArrayList;
27
import java.util.List;
28
import java.util.List;
28
import java.util.logging.Level;
29
import java.util.logging.Level;
29
import java.util.logging.Logger;
30
import java.util.logging.Logger;
30
import java.util.prefs.Preferences;
31
import java.util.prefs.Preferences;
32
import org.netbeans.api.java.classpath.ClassPath;
33
import org.netbeans.api.java.queries.SourceForBinaryQuery;
34
import org.netbeans.api.project.Project;
31
35
32
import org.openide.filesystems.FileObject;
36
import org.openide.filesystems.FileObject;
33
import org.openide.filesystems.FileStateInvalidException;
37
import org.openide.filesystems.FileStateInvalidException;
Lines 35-40 Link Here
35
import org.openide.filesystems.FileSystem;
39
import org.openide.filesystems.FileSystem;
36
import org.openide.filesystems.FileUtil;
40
import org.openide.filesystems.FileUtil;
37
import org.openide.loaders.DataObject;
41
import org.openide.loaders.DataObject;
42
import org.openide.util.Exceptions;
38
import org.openide.util.HelpCtx;
43
import org.openide.util.HelpCtx;
39
import org.openide.loaders.DataObjectNotFoundException;
44
import org.openide.loaders.DataObjectNotFoundException;
40
import org.openide.nodes.BeanNode;
45
import org.openide.nodes.BeanNode;
Lines 155-163 Link Here
155
    }
160
    }
156
    
161
    
157
    /** Getter for last resource property. */
162
    /** Getter for last resource property. */
163
    @Deprecated
158
    public DataObject getLastResource2() {
164
    public DataObject getLastResource2() {
165
        return getLastResource2(null);
166
    }
167
168
    /** Getter for last resource property. */
169
    public DataObject getLastResource2(DataObject srcDataObject) {
159
        String path = getPreferences().get(PROP_LAST_RESOURCE2,null);
170
        String path = getPreferences().get(PROP_LAST_RESOURCE2,null);
160
        FileObject f = (path != null) ? findFileObject(path) : null;
171
        if(path == null) {
172
            return null;
173
        }
174
        FileObject f = (srcDataObject != null) ? findFileObject(srcDataObject, path) : findFileObject(path);
161
        if ((f != null) && !f.isFolder() && f.isValid()) {
175
        if ((f != null) && !f.isFolder() && f.isValid()) {
162
            try {
176
            try {
163
                return DataObject.find(f);
177
                return DataObject.find(f);
Lines 202-207 Link Here
202
        return retval.toArray(new FileSystem[retval.size()]);
216
        return retval.toArray(new FileSystem[retval.size()]);
203
    }
217
    }
204
    
218
    
219
    @Deprecated
205
    private static FileObject findFileObject(String path) {
220
    private static FileObject findFileObject(String path) {
206
        for (FileSystem fileSystem : getFileSystems()) {
221
        for (FileSystem fileSystem : getFileSystems()) {
207
            FileObject retval = fileSystem.findResource(path);
222
            FileObject retval = fileSystem.findResource(path);
Lines 212-217 Link Here
212
        return null;
227
        return null;
213
    }
228
    }
214
229
230
    private static FileObject findFileObject(DataObject srcDataObject, String path) {
231
        FileObject pfo = srcDataObject.getPrimaryFile();
232
        ClassPath cp = ClassPath.getClassPath(pfo, ClassPath.EXECUTE);
233
234
        for(FileObject fo : getRoots(cp)) {
235
            try {
236
                FileSystem fs = fo.getFileSystem();
237
                if (fs != null) {
238
                    FileObject retval = fs.findResource(path);
239
                    if (retval != null) {
240
                        return retval;
241
                    }
242
                }
243
            } catch (FileStateInvalidException ex) {
244
                Logger.getLogger(I18nOptions.class.getName()).log(Level.INFO, null, ex);
245
            }
246
        }
247
        
248
        return null;
249
    }
250
251
252
    private static List<FileObject> getRoots(ClassPath cp) {
253
        ArrayList<FileObject> l = new ArrayList<FileObject>(cp.entries().size());
254
        for (ClassPath.Entry e : cp.entries()) {
255
256
            // try to map it to sources
257
            URL url = e.getURL();
258
            SourceForBinaryQuery.Result r= SourceForBinaryQuery.findSourceRoots(url);
259
            FileObject [] fos = r.getRoots();
260
            if (fos.length > 0) {
261
                for (FileObject fo : fos) {
262
                    l.add(fo);
263
                }
264
            } else {
265
                if (e.getRoot()!=null) 
266
                    l.add(e.getRoot()); // add the class-path location
267
                                        // directly
268
            }
269
        }
270
271
        return l;
272
    }    
273
    
215
    private static BeanNode createViewNode() throws java.beans.IntrospectionException {
274
    private static BeanNode createViewNode() throws java.beans.IntrospectionException {
216
        return new BeanNode(I18nOptions.getDefault());
275
        return new BeanNode(I18nOptions.getDefault());
217
    }             
276
    }             
(-)i18n/src/org/netbeans/modules/i18n/I18nPanel.form (-1 / +1 lines)
Lines 1-6 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
1
<?xml version="1.0" encoding="UTF-8" ?>
2
2
3
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
3
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <AuxValues>
4
  <AuxValues>
5
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
5
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
6
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
6
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
(-)i18n/src/org/netbeans/modules/i18n/java/JavaI18nSupport.java (-1 / +1 lines)
Lines 107-113 Link Here
107
        final ResourceHolder resourceHolder
107
        final ResourceHolder resourceHolder
108
                = i18nString.getSupport().getResourceHolder();
108
                = i18nString.getSupport().getResourceHolder();
109
        if (resourceHolder.getResource() == null) {
109
        if (resourceHolder.getResource() == null) {
110
            DataObject lastResource = I18nUtil.getOptions().getLastResource2();
110
            DataObject lastResource = I18nUtil.getOptions().getLastResource2(sourceDataObject);
111
            if (lastResource != null) {
111
            if (lastResource != null) {
112
                FileObject sourceFile = sourceDataObject.getPrimaryFile();
112
                FileObject sourceFile = sourceDataObject.getPrimaryFile();
113
                FileObject bundleFile = lastResource.getPrimaryFile();
113
                FileObject bundleFile = lastResource.getPrimaryFile();

Return to bug 102612