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

(-)a/core.ui/src/org/netbeans/core/ui/options/filetypes/Bundle.properties (+2 lines)
Lines 101-103 Link Here
101
101
102
ERR_CantConvert=Cannot convert {0} object to {1} type
102
ERR_CantConvert=Cannot convert {0} object to {1} type
103
ERR_CantOpen=Cannot open {0}
103
ERR_CantOpen=Cannot open {0}
104
FileAssociationsPanel.lblScanning.text=Scannig
105
FileAssociationsPanel.ignoreHiddenInHome.text=Ignore all .dotted files in home folder
(-)a/core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsPanel.form (-20 / +47 lines)
Lines 22-28 Link Here
22
    <DimensionLayout dim="0">
22
    <DimensionLayout dim="0">
23
      <Group type="103" groupAlignment="0" attributes="0">
23
      <Group type="103" groupAlignment="0" attributes="0">
24
          <Group type="102" attributes="0">
24
          <Group type="102" attributes="0">
25
              <EmptySpace min="-2" max="-2" attributes="0"/>
25
              <EmptySpace max="-2" attributes="0"/>
26
              <Group type="103" groupAlignment="0" attributes="0">
26
              <Group type="103" groupAlignment="0" attributes="0">
27
                  <Group type="102" alignment="0" attributes="0">
27
                  <Group type="102" alignment="0" attributes="0">
28
                      <Component id="lblFileAssociations" min="-2" max="-2" attributes="0"/>
28
                      <Component id="lblFileAssociations" min="-2" max="-2" attributes="0"/>
Lines 30-46 Link Here
30
                      <Component id="sepFileAssociations" max="32767" attributes="0"/>
30
                      <Component id="sepFileAssociations" max="32767" attributes="0"/>
31
                  </Group>
31
                  </Group>
32
                  <Group type="102" alignment="0" attributes="0">
32
                  <Group type="102" alignment="0" attributes="0">
33
                      <Component id="autoScan" min="-2" max="-2" attributes="0"/>
34
                      <EmptySpace max="32767" attributes="0"/>
35
                      <Component id="txtPatternError" pref="0" max="32767" attributes="0"/>
36
                  </Group>
37
                  <Group type="102" alignment="0" attributes="0">
38
                      <Component id="lblFilesIgnored" min="-2" max="-2" attributes="0"/>
33
                      <Component id="lblFilesIgnored" min="-2" max="-2" attributes="0"/>
39
                      <EmptySpace max="-2" attributes="0"/>
34
                      <EmptySpace max="-2" attributes="0"/>
40
                      <Component id="setFilesIgnored" max="32767" attributes="0"/>
35
                      <Component id="setFilesIgnored" max="32767" attributes="0"/>
41
                  </Group>
36
                  </Group>
37
                  <Component id="txtPatternError" alignment="0" pref="0" max="32767" attributes="0"/>
38
                  <Group type="102" alignment="0" attributes="0">
39
                      <Component id="lblScanning" min="-2" max="-2" attributes="0"/>
40
                      <EmptySpace max="-2" attributes="0"/>
41
                      <Component id="setScanning" max="32767" attributes="0"/>
42
                  </Group>
42
                  <Group type="102" attributes="0">
43
                  <Group type="102" attributes="0">
43
                      <EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
44
                      <EmptySpace min="10" pref="10" max="-2" attributes="0"/>
44
                      <Group type="103" groupAlignment="0" attributes="0">
45
                      <Group type="103" groupAlignment="0" attributes="0">
45
                          <Group type="102" attributes="0">
46
                          <Group type="102" attributes="0">
46
                              <Group type="103" groupAlignment="0" attributes="0">
47
                              <Group type="103" groupAlignment="0" attributes="0">
Lines 77-83 Link Here
77
                              <Component id="jScrollPane1" max="32767" attributes="0"/>
78
                              <Component id="jScrollPane1" max="32767" attributes="0"/>
78
                              <EmptySpace max="-2" attributes="0"/>
79
                              <EmptySpace max="-2" attributes="0"/>
79
                              <Component id="btnDefaultIgnored" min="-2" max="-2" attributes="1"/>
80
                              <Component id="btnDefaultIgnored" min="-2" max="-2" attributes="1"/>
80
                              <EmptySpace min="0" pref="0" max="-2" attributes="0"/>
81
                          </Group>
82
                          <Group type="102" attributes="0">
83
                              <Group type="103" groupAlignment="0" attributes="0">
84
                                  <Component id="ignoreHiddenInHome" min="-2" max="-2" attributes="0"/>
85
                                  <Component id="autoScan" alignment="0" min="-2" max="-2" attributes="0"/>
86
                              </Group>
87
                              <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
81
                          </Group>
88
                          </Group>
82
                      </Group>
89
                      </Group>
83
                  </Group>
90
                  </Group>
Lines 116-138 Link Here
116
                  <Component id="setFilesIgnored" alignment="2" min="-2" max="-2" attributes="0"/>
123
                  <Component id="setFilesIgnored" alignment="2" min="-2" max="-2" attributes="0"/>
117
                  <Component id="lblFilesIgnored" alignment="2" min="-2" max="-2" attributes="0"/>
124
                  <Component id="lblFilesIgnored" alignment="2" min="-2" max="-2" attributes="0"/>
118
              </Group>
125
              </Group>
119
              <EmptySpace max="-2" attributes="0"/>
126
              <EmptySpace type="unrelated" max="-2" attributes="0"/>
120
              <Group type="103" groupAlignment="0" attributes="0">
127
              <Group type="103" groupAlignment="0" attributes="0">
121
                  <Component id="lblPattern" alignment="0" min="-2" max="-2" attributes="0"/>
122
                  <Component id="btnDefaultIgnored" alignment="0" min="-2" max="-2" attributes="0"/>
128
                  <Component id="btnDefaultIgnored" alignment="0" min="-2" max="-2" attributes="0"/>
123
                  <Component id="jScrollPane1" min="-2" pref="45" max="-2" attributes="0"/>
129
                  <Component id="jScrollPane1" min="-2" pref="45" max="-2" attributes="0"/>
130
                  <Component id="lblPattern" alignment="0" min="-2" max="-2" attributes="0"/>
124
              </Group>
131
              </Group>
132
              <EmptySpace type="unrelated" max="-2" attributes="0"/>
133
              <Component id="ignoreHiddenInHome" min="-2" max="-2" attributes="0"/>
134
              <EmptySpace type="separate" max="-2" attributes="0"/>
135
              <Group type="103" groupAlignment="2" attributes="0">
136
                  <Component id="setScanning" alignment="2" min="-2" max="-2" attributes="0"/>
137
                  <Component id="lblScanning" alignment="2" min="-2" max="-2" attributes="0"/>
138
              </Group>
139
              <EmptySpace type="unrelated" max="-2" attributes="0"/>
140
              <Component id="autoScan" min="-2" max="-2" attributes="0"/>
125
              <EmptySpace max="-2" attributes="0"/>
141
              <EmptySpace max="-2" attributes="0"/>
126
              <Group type="103" groupAlignment="0" attributes="0">
142
              <Component id="txtPatternError" pref="49" max="32767" attributes="0"/>
127
                  <Group type="102" attributes="0">
143
              <EmptySpace max="-2" attributes="0"/>
128
                      <Component id="txtPatternError" pref="129" max="32767" attributes="0"/>
129
                      <EmptySpace min="-2" max="-2" attributes="0"/>
130
                  </Group>
131
                  <Group type="102" alignment="0" attributes="0">
132
                      <EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
133
                      <Component id="autoScan" min="-2" max="-2" attributes="0"/>
134
                  </Group>
135
              </Group>
136
          </Group>
144
          </Group>
137
      </Group>
145
      </Group>
138
    </DimensionLayout>
146
    </DimensionLayout>
Lines 385-389 Link Here
385
        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="autoScanActionPerformed"/>
393
        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="autoScanActionPerformed"/>
386
      </Events>
394
      </Events>
387
    </Component>
395
    </Component>
396
    <Component class="javax.swing.JLabel" name="lblScanning">
397
      <Properties>
398
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
399
          <ResourceString bundle="org/netbeans/core/ui/options/filetypes/Bundle.properties" key="FileAssociationsPanel.lblScanning.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
400
        </Property>
401
      </Properties>
402
    </Component>
403
    <Component class="javax.swing.JSeparator" name="setScanning">
404
    </Component>
405
    <Component class="javax.swing.JCheckBox" name="ignoreHiddenInHome">
406
      <Properties>
407
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
408
          <ResourceString bundle="org/netbeans/core/ui/options/filetypes/Bundle.properties" key="FileAssociationsPanel.ignoreHiddenInHome.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
409
        </Property>
410
      </Properties>
411
      <Events>
412
        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ignoreHiddenInHomeActionPerformed"/>
413
      </Events>
414
    </Component>
388
  </SubComponents>
415
  </SubComponents>
389
</Form>
416
</Form>
(-)a/core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsPanel.java (-18 / +49 lines)
Lines 105-110 Link Here
105
        txtPattern = new javax.swing.JTextArea();
105
        txtPattern = new javax.swing.JTextArea();
106
        txtPatternError = new javax.swing.JLabel();
106
        txtPatternError = new javax.swing.JLabel();
107
        autoScan = new javax.swing.JCheckBox();
107
        autoScan = new javax.swing.JCheckBox();
108
        lblScanning = new javax.swing.JLabel();
109
        setScanning = new javax.swing.JSeparator();
110
        ignoreHiddenInHome = new javax.swing.JCheckBox();
108
111
109
        setPreferredSize(new java.awt.Dimension(360, 360));
112
        setPreferredSize(new java.awt.Dimension(360, 360));
110
113
Lines 188-193 Link Here
188
            }
191
            }
189
        });
192
        });
190
193
194
        org.openide.awt.Mnemonics.setLocalizedText(lblScanning, org.openide.util.NbBundle.getMessage(FileAssociationsPanel.class, "FileAssociationsPanel.lblScanning.text")); // NOI18N
195
196
        org.openide.awt.Mnemonics.setLocalizedText(ignoreHiddenInHome, org.openide.util.NbBundle.getMessage(FileAssociationsPanel.class, "FileAssociationsPanel.ignoreHiddenInHome.text")); // NOI18N
197
        ignoreHiddenInHome.addActionListener(new java.awt.event.ActionListener() {
198
            public void actionPerformed(java.awt.event.ActionEvent evt) {
199
                ignoreHiddenInHomeActionPerformed(evt);
200
            }
201
        });
202
191
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
203
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
192
        this.setLayout(layout);
204
        this.setLayout(layout);
193
        layout.setHorizontalGroup(
205
        layout.setHorizontalGroup(
Lines 200-212 Link Here
200
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
212
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
201
                        .addComponent(sepFileAssociations))
213
                        .addComponent(sepFileAssociations))
202
                    .addGroup(layout.createSequentialGroup()
214
                    .addGroup(layout.createSequentialGroup()
203
                        .addComponent(autoScan)
204
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
205
                        .addComponent(txtPatternError, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE))
206
                    .addGroup(layout.createSequentialGroup()
207
                        .addComponent(lblFilesIgnored)
215
                        .addComponent(lblFilesIgnored)
208
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
216
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
209
                        .addComponent(setFilesIgnored))
217
                        .addComponent(setFilesIgnored))
218
                    .addComponent(txtPatternError, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE)
219
                    .addGroup(layout.createSequentialGroup()
220
                        .addComponent(lblScanning)
221
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
222
                        .addComponent(setScanning))
210
                    .addGroup(layout.createSequentialGroup()
223
                    .addGroup(layout.createSequentialGroup()
211
                        .addGap(10, 10, 10)
224
                        .addGap(10, 10, 10)
212
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
225
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
Lines 236-243 Link Here
236
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
249
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
237
                                .addComponent(jScrollPane1)
250
                                .addComponent(jScrollPane1)
238
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
251
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
239
                                .addComponent(btnDefaultIgnored)
252
                                .addComponent(btnDefaultIgnored))
240
                                .addGap(0, 0, 0))))))
253
                            .addGroup(layout.createSequentialGroup()
254
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
255
                                    .addComponent(ignoreHiddenInHome)
256
                                    .addComponent(autoScan))
257
                                .addGap(0, 0, Short.MAX_VALUE))))))
241
        );
258
        );
242
        layout.setVerticalGroup(
259
        layout.setVerticalGroup(
243
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
260
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
Lines 265-283 Link Here
265
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
282
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
266
                    .addComponent(setFilesIgnored, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
283
                    .addComponent(setFilesIgnored, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
267
                    .addComponent(lblFilesIgnored))
284
                    .addComponent(lblFilesIgnored))
285
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
286
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
287
                    .addComponent(btnDefaultIgnored)
288
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
289
                    .addComponent(lblPattern))
290
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
291
                .addComponent(ignoreHiddenInHome)
292
                .addGap(18, 18, 18)
293
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
294
                    .addComponent(setScanning, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
295
                    .addComponent(lblScanning))
296
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
297
                .addComponent(autoScan)
268
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
298
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
269
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
299
                .addComponent(txtPatternError, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
270
                    .addComponent(lblPattern)
300
                .addContainerGap())
271
                    .addComponent(btnDefaultIgnored)
272
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
273
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
274
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
275
                    .addGroup(layout.createSequentialGroup()
276
                        .addComponent(txtPatternError, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
277
                        .addContainerGap())
278
                    .addGroup(layout.createSequentialGroup()
279
                        .addGap(20, 20, 20)
280
                        .addComponent(autoScan))))
281
        );
301
        );
282
302
283
        lblExtension.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(FileAssociationsPanel.class, "FileAssociationsPanel.lblExtension.AN")); // NOI18N
303
        lblExtension.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(FileAssociationsPanel.class, "FileAssociationsPanel.lblExtension.AN")); // NOI18N
Lines 387-392 Link Here
387
    fireChanged(null, null);
407
    fireChanged(null, null);
388
}//GEN-LAST:event_autoScanActionPerformed
408
}//GEN-LAST:event_autoScanActionPerformed
389
409
410
    private void ignoreHiddenInHomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ignoreHiddenInHomeActionPerformed
411
        fireChanged(null, null);
412
    }//GEN-LAST:event_ignoreHiddenInHomeActionPerformed
413
390
    void load() {
414
    void load() {
391
        cbExtension.removeAllItems();
415
        cbExtension.removeAllItems();
392
        cbType.removeAllItems();
416
        cbType.removeAllItems();
Lines 410-415 Link Here
410
        txtPattern.getDocument().removeDocumentListener(patternListener);
434
        txtPattern.getDocument().removeDocumentListener(patternListener);
411
        txtPattern.setText(IgnoredFilesPreferences.getIgnoredFiles());
435
        txtPattern.setText(IgnoredFilesPreferences.getIgnoredFiles());
412
        txtPattern.getDocument().addDocumentListener(patternListener);
436
        txtPattern.getDocument().addDocumentListener(patternListener);
437
        ignoreHiddenInHome.setSelected(IgnoredFilesPreferences.isIgnoreHiddenFilesInUserHome());
413
        btnDefaultIgnored.setEnabled(!IgnoredFilesPreferences.DEFAULT_IGNORED_FILES.equals(txtPattern.getText()));
438
        btnDefaultIgnored.setEnabled(!IgnoredFilesPreferences.DEFAULT_IGNORED_FILES.equals(txtPattern.getText()));
414
439
415
        boolean manual = NbPreferences.root().node("org/openide/actions/FileSystemRefreshAction").getBoolean("manual", false); // NOI18N
440
        boolean manual = NbPreferences.root().node("org/openide/actions/FileSystemRefreshAction").getBoolean("manual", false); // NOI18N
Lines 422-427 Link Here
422
        model.store();
447
        model.store();
423
        // store ignored files pattern
448
        // store ignored files pattern
424
        IgnoredFilesPreferences.setIgnoredFiles(txtPattern.getText());
449
        IgnoredFilesPreferences.setIgnoredFiles(txtPattern.getText());
450
        IgnoredFilesPreferences.setIgnoreHiddenFilesInUserHome(ignoreHiddenInHome.isSelected());
425
451
426
        final Preferences nd = NbPreferences.root().node("org/openide/actions/FileSystemRefreshAction"); // NOI18N
452
        final Preferences nd = NbPreferences.root().node("org/openide/actions/FileSystemRefreshAction"); // NOI18N
427
        boolean manual = nd.getBoolean("manual", false);
453
        boolean manual = nd.getBoolean("manual", false);
Lines 444-449 Link Here
444
    private javax.swing.JButton btnRemove;
470
    private javax.swing.JButton btnRemove;
445
    private javax.swing.JComboBox cbExtension;
471
    private javax.swing.JComboBox cbExtension;
446
    private javax.swing.JComboBox cbType;
472
    private javax.swing.JComboBox cbType;
473
    private javax.swing.JCheckBox ignoreHiddenInHome;
447
    private javax.swing.JScrollPane jScrollPane1;
474
    private javax.swing.JScrollPane jScrollPane1;
448
    private javax.swing.JLabel lblAssociatedAlso;
475
    private javax.swing.JLabel lblAssociatedAlso;
449
    private javax.swing.JLabel lblAssociatedAlsoExt;
476
    private javax.swing.JLabel lblAssociatedAlsoExt;
Lines 451-459 Link Here
451
    private javax.swing.JLabel lblFileAssociations;
478
    private javax.swing.JLabel lblFileAssociations;
452
    private javax.swing.JLabel lblFilesIgnored;
479
    private javax.swing.JLabel lblFilesIgnored;
453
    private javax.swing.JLabel lblPattern;
480
    private javax.swing.JLabel lblPattern;
481
    private javax.swing.JLabel lblScanning;
454
    private javax.swing.JLabel lblType;
482
    private javax.swing.JLabel lblType;
455
    private javax.swing.JSeparator sepFileAssociations;
483
    private javax.swing.JSeparator sepFileAssociations;
456
    private javax.swing.JSeparator setFilesIgnored;
484
    private javax.swing.JSeparator setFilesIgnored;
485
    private javax.swing.JSeparator setScanning;
457
    private javax.swing.JTextArea txtPattern;
486
    private javax.swing.JTextArea txtPattern;
458
    private javax.swing.JLabel txtPatternError;
487
    private javax.swing.JLabel txtPatternError;
459
    // End of variables declaration//GEN-END:variables
488
    // End of variables declaration//GEN-END:variables
Lines 489-494 Link Here
489
        if (extension == null) {
518
        if (extension == null) {
490
            isChanged |= !txtPattern.getText().equals(IgnoredFilesPreferences.getIgnoredFiles());
519
            isChanged |= !txtPattern.getText().equals(IgnoredFilesPreferences.getIgnoredFiles());
491
520
521
            isChanged |= ignoreHiddenInHome.isSelected() != IgnoredFilesPreferences.isIgnoreHiddenFilesInUserHome();
522
492
            boolean manual = NbPreferences.root().node("org/openide/actions/FileSystemRefreshAction").getBoolean("manual", false); // NOI18N
523
            boolean manual = NbPreferences.root().node("org/openide/actions/FileSystemRefreshAction").getBoolean("manual", false); // NOI18N
493
            isChanged |= autoScan.isSelected() == manual;
524
            isChanged |= autoScan.isSelected() == manual;
494
525
(-)a/core.ui/src/org/netbeans/core/ui/options/filetypes/IgnoredFilesPreferences.java (-1 / +27 lines)
Lines 62-69 Link Here
62
     * in module org.netbeans.modules.masterfs.
62
     * in module org.netbeans.modules.masterfs.
63
     */
63
     */
64
    private static final String PROP_IGNORED_FILES = "IgnoredFiles"; // NOI18N
64
    private static final String PROP_IGNORED_FILES = "IgnoredFiles"; // NOI18N
65
    private static final String PROP_IGNORE_HIDDEN_FILES_IN_USER_HOME
66
            = "IgnoreHiddenFilesInUserHome";                           // NOI18N
65
    /** Default ignored files pattern. Pattern \.(cvsignore|svn|DS_Store) is covered by ^\..*$ **/
67
    /** Default ignored files pattern. Pattern \.(cvsignore|svn|DS_Store) is covered by ^\..*$ **/
66
    static final String DEFAULT_IGNORED_FILES = "^(CVS|SCCS|vssver.?\\.scc|#.*#|%.*%|_svn)$|~$|^\\.(?!(htaccess|git.+|hgignore|npmignore|jshintrc|bowerrc|travis\\.yml)$).*$"; //NOI18N
68
    static final String DEFAULT_IGNORED_FILES = "^(CVS|SCCS|vssver.?\\.scc|#.*#|%.*%|_svn)$|~$|^\\.(git|hg|svn|cache|DS_store)$|^Thumbs.db$"; //NOI18N
67
    static private String syntaxError;
69
    static private String syntaxError;
68
70
69
    private IgnoredFilesPreferences() {
71
    private IgnoredFilesPreferences() {
Lines 93-98 Link Here
93
        }
95
        }
94
    }
96
    }
95
97
98
    /**
99
     * Returns true if hidden files in user's home folder should be ignored
100
     * (e.i. not displayed in Favorites windows).
101
     *
102
     * @return True to ignore hidden files in user's home folder, false to show
103
     * them.
104
     */
105
    static boolean isIgnoreHiddenFilesInUserHome() {
106
        return getPreferences().getBoolean(
107
                PROP_IGNORE_HIDDEN_FILES_IN_USER_HOME, true);
108
    }
109
110
    /**
111
     * Set whether hidden files in home folder should be ignored (i.e. not
112
     * displayed in Favorites window).
113
     *
114
     * @param ignore True to ignore hidden files in user's home folder, false to
115
     * show them.
116
     */
117
    static void setIgnoreHiddenFilesInUserHome(boolean ignore) {
118
        getPreferences().putBoolean(
119
                PROP_IGNORE_HIDDEN_FILES_IN_USER_HOME, ignore);
120
    }
121
96
    /** Returns true if ignored files pattern is valid, false otherwise and
122
    /** Returns true if ignored files pattern is valid, false otherwise and
97
     * syntax error message can be obtained by getSyntaxError method.
123
     * syntax error message can be obtained by getSyntaxError method.
98
     * @param ignoredFiles ignored files pattern
124
     * @param ignoredFiles ignored files pattern
(-)a/masterfs/src/org/netbeans/modules/masterfs/GlobalVisibilityQueryImpl.java (-11 / +106 lines)
Lines 52-57 Link Here
52
import java.util.prefs.Preferences;
52
import java.util.prefs.Preferences;
53
import java.util.regex.Pattern;
53
import java.util.regex.Pattern;
54
import org.netbeans.spi.queries.VisibilityQueryImplementation2;
54
import org.netbeans.spi.queries.VisibilityQueryImplementation2;
55
import org.openide.filesystems.FileUtil;
55
import org.openide.util.ChangeSupport;
56
import org.openide.util.ChangeSupport;
56
import org.openide.util.NbPreferences;
57
import org.openide.util.NbPreferences;
57
import org.openide.util.lookup.ServiceProvider;
58
import org.openide.util.lookup.ServiceProvider;
Lines 78-85 Link Here
78
     * Keep it synchronized with IgnoredFilesPreferences.PROP_IGNORED_FILES
79
     * Keep it synchronized with IgnoredFilesPreferences.PROP_IGNORED_FILES
79
     */ 
80
     */ 
80
    private static final String PROP_IGNORED_FILES = "IgnoredFiles"; // NOI18N
81
    private static final String PROP_IGNORED_FILES = "IgnoredFiles"; // NOI18N
82
    private static final String PROP_IGNORE_HIDDEN_FILES_IN_USER_HOME
83
            = "IgnoreHiddenFilesInUserHome";                           // NOI18N
81
    private Pattern ignoreFilesPattern = null;
84
    private Pattern ignoreFilesPattern = null;
82
85
86
    private boolean ignoreHiddenInHome = true;
87
    private boolean ignoreHiddenInHomeInitialized = false;
88
89
    private FileObject home = null;
90
    private String homePath = null;
91
    private boolean homeInitialized = false;
92
93
    private PreferenceChangeListener preferencesListener = null;
94
83
    /** Default instance for lookup. */
95
    /** Default instance for lookup. */
84
    public GlobalVisibilityQueryImpl() {
96
    public GlobalVisibilityQueryImpl() {
85
    }
97
    }
Lines 89-99 Link Here
89
    }
101
    }
90
    
102
    
91
    public boolean isVisible(FileObject file) {
103
    public boolean isVisible(FileObject file) {
92
        return isVisible(file.getNameExt());
104
        String name = file.getNameExt();
105
        if (isIgnoreHiddenInHome() && isHidden(name) && isInHomeFolder(file)) {
106
            return false;
107
        } else {
108
            return isVisible(name);
109
        }
93
    }
110
    }
94
    
111
    
95
    public boolean isVisible(File file) {
112
    public boolean isVisible(File file) {
96
        return isVisible(file.getName());
113
        String name = file.getName();
114
        if (isIgnoreHiddenInHome() && isHidden(name) && isInHomeFolder(file)) {
115
            return false;
116
        } else {
117
            return isVisible(name);
118
        }
97
    }
119
    }
98
    
120
    
99
121
Lines 118-123 Link Here
118
        cs.removeChangeListener(l);
140
        cs.removeChangeListener(l);
119
    }
141
    }
120
142
143
    private boolean isIgnoreHiddenInHome() {
144
        if (!ignoreHiddenInHomeInitialized) {
145
            ignoreHiddenInHome = getPreferences().getBoolean(
146
                    PROP_IGNORE_HIDDEN_FILES_IN_USER_HOME, true);
147
            ignoreHiddenInHomeInitialized = true;
148
        }
149
        return ignoreHiddenInHome;
150
    }
151
121
    private Pattern getIgnoreFilesPattern() {
152
    private Pattern getIgnoreFilesPattern() {
122
        if (ignoreFilesPattern == null) {
153
        if (ignoreFilesPattern == null) {
123
            String ignoredFiles = getIgnoredFiles();
154
            String ignoredFiles = getIgnoredFiles();
Lines 128-144 Link Here
128
159
129
    protected String getIgnoredFiles() {
160
    protected String getIgnoredFiles() {
130
        // \.(cvsignore|svn|DS_Store) is covered by ^\..*$
161
        // \.(cvsignore|svn|DS_Store) is covered by ^\..*$
131
        String retval = getPreferences().get(PROP_IGNORED_FILES, "^(CVS|SCCS|vssver.?\\.scc|#.*#|%.*%|_svn)$|~$|^\\.(?!(htaccess|git.+|hgignore|npmignore|jshintrc|bowerrc|travis\\.yml)$).*$");//NOI18N;
162
        String retval = getPreferences().get(PROP_IGNORED_FILES, "^(CVS|SCCS|vssver.?\\.scc|#.*#|%.*%|_svn)$|~$|^\\.(git|hg|svn|cache|DS_store)$|^Thumbs.db$");//NOI18N;
132
        getPreferences().addPreferenceChangeListener(new PreferenceChangeListener() {
163
        PreferenceChangeListener listenerToAdd;
133
            public void preferenceChange(PreferenceChangeEvent evt) {
164
        synchronized (this) {
134
                if (PROP_IGNORED_FILES.equals(evt.getKey())) {
165
            if (preferencesListener == null) {
135
                    ignoreFilesPattern = null;
166
                preferencesListener = new PreferenceChangeListener() {
136
                    cs.fireChange();
167
                    @Override
137
                }
168
                    public void preferenceChange(PreferenceChangeEvent evt) {
138
                
169
                        if (PROP_IGNORED_FILES.equals(evt.getKey())) {
170
                            ignoreFilesPattern = null;
171
                            cs.fireChange();
172
                        } else if (PROP_IGNORE_HIDDEN_FILES_IN_USER_HOME.equals(
173
                                evt.getKey())) {
174
                            ignoreHiddenInHomeInitialized = false;
175
                            cs.fireChange();
176
                        }
177
                    }
178
                };
179
                listenerToAdd = preferencesListener;
180
            } else {
181
                listenerToAdd = null;
139
            }
182
            }
140
        });                
183
        }
184
        if (listenerToAdd != null) {
185
            getPreferences().addPreferenceChangeListener(listenerToAdd);
186
        }
141
        return retval;
187
        return retval;
142
    }
188
    }
143
189
190
    /**
191
     * Check if the file is hidden in Unix file systems.
192
     *
193
     * @param String File name.
194
     * @return True if file name starts with a dot.
195
     */
196
    private boolean isHidden(String fileName) {
197
        return fileName.startsWith(".");                                //NOI18N
198
    }
199
200
    /**
201
     * Check if the file is located directly in user's home folder.
202
     *
203
     * @param fo The FileObject.
204
     * @return True if this is a file located directly in user's home folder.
205
     */
206
    private boolean isInHomeFolder(FileObject fo) {
207
        if (!homeInitialized) {
208
            initializeHome();
209
        }
210
        FileObject parent = fo.getParent();
211
        return parent != null && parent == home;
212
    }
213
214
    /**
215
     * Check if the file is located directly in user's home folder.
216
     *
217
     * @param f The file.
218
     * @return True if this is a file located directly in user's home folder.
219
     */
220
    private boolean isInHomeFolder(File f) {
221
        if (!homeInitialized) {
222
            initializeHome();
223
        }
224
        String parentPath = f.getParent();
225
        return parentPath != null && parentPath.equals(homePath);
226
    }
227
228
    /**
229
     * Initialize variables holding the user directory.
230
     */
231
    private void initializeHome() {
232
        String homeRaw = System.getProperty("user.home");               //NOI18N
233
        if (homeRaw != null) {
234
            homePath = FileUtil.normalizePath(homeRaw);
235
            home = FileUtil.toFileObject(new File(homePath));
236
        }
237
        homeInitialized = true;
238
    }
144
}
239
}

Return to bug 246521