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

(-)a/html.custom/src/org/netbeans/modules/html/custom/conf/Configuration.java (-41 / +32 lines)
Lines 127-164 Link Here
127
127
128
    public Configuration(Project project) {
128
    public Configuration(Project project) {
129
        //TODO fix the conf location in maven and other project types
129
        //TODO fix the conf location in maven and other project types
130
        FileObject nbproject = project.getProjectDirectory().getFileObject("config"); //NOI18N
130
        FileObject nbproject = project.getProjectDirectory().getFileObject("nbproject"); //NOI18N
131
        nbproject = nbproject == null ? project.getProjectDirectory() : nbproject;
131
        if (nbproject != null) {
132
        if (nbproject != null) {
132
            try {
133
            try {
133
                configFile = nbproject.getFileObject(CONF_FILE_NAME);
134
                configFile = nbproject.getFileObject(CONF_FILE_NAME);
135
                if (configFile == null) {
136
                    configFile = nbproject.createData(CONF_FILE_NAME); //create one if doesn't exist
137
                    LOGGER.log(Level.INFO, "Created configuration file {0} ", configFile.getPath()); //NOI18N
138
                }
139
                configFile.addFileChangeListener(new FileChangeAdapter() {
134
140
135
//            if (configFile == null) {
141
                    @Override
136
//                configFile = nbproject.createData(CONF_FILE_NAME); //create one if doesn't exist
142
                    public void fileChanged(FileEvent fe) {
137
//                LOGGER.log(Level.INFO, "Created configuration file {0} ", configFile.getPath()); //NOI18N
143
                        LOGGER.log(Level.INFO, "Config file {0} changed - reloading configuration.", configFile.getPath()); //NOI18N
138
//            }
144
                        try {
139
                if (configFile != null) {
145
                            reload();
140
                    configFile.addFileChangeListener(new FileChangeAdapter() {
146
                        } catch (IOException ex) {
147
                            handleIOEFromReload(ex);
148
                        }
149
                    }
141
150
142
                        @Override
151
                });
143
                        public void fileChanged(FileEvent fe) {
152
                reload();
144
                            LOGGER.log(Level.INFO, "Config file {0} changed - reloading configuration.", configFile.getPath()); //NOI18N
145
                            try {
146
                                reload();
147
                            } catch (IOException ex) {
148
                                handleIOEFromReload(ex);
149
                            }
150
                        }
151
152
                    });
153
154
                    reload();
155
                }
156
157
            } catch (IOException ex) {
153
            } catch (IOException ex) {
158
                handleIOEFromReload(ex);
154
                handleIOEFromReload(ex);
159
            }
155
            }
160
        }
156
        }
161
162
    }
157
    }
163
158
164
    public FileObject getProjectsConfigurationFile() {
159
    public FileObject getProjectsConfigurationFile() {
Lines 250-275 Link Here
250
245
251
        String content = docContentRef.get();
246
        String content = docContentRef.get();
252
        root = (JSONObject) JSONValue.parse(content);
247
        root = (JSONObject) JSONValue.parse(content);
253
        if (root == null) {
248
        if (root != null) {
254
            //parsing error
249
            JSONObject elements = (JSONObject) root.get(ELEMENTS);
255
            throw new IOException("Can't parse the JSON source"); //NOI18N
250
            if (elements != null) {
256
        }
251
                Collection<Tag> rootTags = loadTags(elements, null);
257
252
                for (Tag rootTag : rootTags) {
258
        JSONObject elements = (JSONObject) root.get(ELEMENTS);
253
                    tags.put(rootTag.getName(), rootTag);
259
        if (elements != null) {
254
                }
260
            Collection<Tag> rootTags = loadTags(elements, null);
255
            }
261
            for (Tag rootTag : rootTags) {
256
            JSONObject attributes = (JSONObject) root.get(ATTRIBUTES);
262
                tags.put(rootTag.getName(), rootTag);
257
            if (attributes != null) {
258
                Collection<Attribute> rootAttrs = loadAttributes(attributes, null);
259
                for (Attribute a : rootAttrs) {
260
                    attrs.put(a.getName(), a);
261
                }
263
            }
262
            }
264
        }
263
        }
265
        JSONObject attributes = (JSONObject) root.get(ATTRIBUTES);
266
        if (attributes != null) {
267
            Collection<Attribute> rootAttrs = loadAttributes(attributes, null);
268
            for (Attribute a : rootAttrs) {
269
                attrs.put(a.getName(), a);
270
            }
271
        }
272
273
    }
264
    }
274
265
275
    private Document getDocument(FileObject file) throws IOException {
266
    private Document getDocument(FileObject file) throws IOException {

Return to bug 237992