diff -r 78f6cd5a374e core.ui/src/org/netbeans/core/ui/options/filetypes/Bundle.properties
--- a/core.ui/src/org/netbeans/core/ui/options/filetypes/Bundle.properties Wed Jul 15 05:13:26 2015 +0000
+++ b/core.ui/src/org/netbeans/core/ui/options/filetypes/Bundle.properties Wed Jul 15 13:56:02 2015 +0200
@@ -101,3 +101,5 @@
ERR_CantConvert=Cannot convert {0} object to {1} type
ERR_CantOpen=Cannot open {0}
+FileAssociationsPanel.lblScanning.text=Scannig
+FileAssociationsPanel.ignoreHiddenInHome.text=Ignore all .dotted files in home folder
diff -r 78f6cd5a374e core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsPanel.form
--- a/core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsPanel.form Wed Jul 15 05:13:26 2015 +0000
+++ b/core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsPanel.form Wed Jul 15 13:56:02 2015 +0200
@@ -22,7 +22,7 @@
-
+
@@ -30,17 +30,18 @@
-
-
-
-
-
+
+
+
+
+
+
-
+
@@ -77,7 +78,13 @@
-
+
+
+
+
+
+
+
@@ -116,23 +123,24 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
@@ -385,5 +393,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 78f6cd5a374e core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsPanel.java
--- a/core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsPanel.java Wed Jul 15 05:13:26 2015 +0000
+++ b/core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsPanel.java Wed Jul 15 13:56:02 2015 +0200
@@ -105,6 +105,9 @@
txtPattern = new javax.swing.JTextArea();
txtPatternError = new javax.swing.JLabel();
autoScan = new javax.swing.JCheckBox();
+ lblScanning = new javax.swing.JLabel();
+ setScanning = new javax.swing.JSeparator();
+ ignoreHiddenInHome = new javax.swing.JCheckBox();
setPreferredSize(new java.awt.Dimension(360, 360));
@@ -188,6 +191,15 @@
}
});
+ org.openide.awt.Mnemonics.setLocalizedText(lblScanning, org.openide.util.NbBundle.getMessage(FileAssociationsPanel.class, "FileAssociationsPanel.lblScanning.text")); // NOI18N
+
+ org.openide.awt.Mnemonics.setLocalizedText(ignoreHiddenInHome, org.openide.util.NbBundle.getMessage(FileAssociationsPanel.class, "FileAssociationsPanel.ignoreHiddenInHome.text")); // NOI18N
+ ignoreHiddenInHome.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ ignoreHiddenInHomeActionPerformed(evt);
+ }
+ });
+
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -200,13 +212,14 @@
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(sepFileAssociations))
.addGroup(layout.createSequentialGroup()
- .addComponent(autoScan)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(txtPatternError, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
.addComponent(lblFilesIgnored)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(setFilesIgnored))
+ .addComponent(txtPatternError, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(lblScanning)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(setScanning))
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -236,8 +249,12 @@
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(btnDefaultIgnored)
- .addGap(0, 0, 0))))))
+ .addComponent(btnDefaultIgnored))
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(ignoreHiddenInHome)
+ .addComponent(autoScan))
+ .addGap(0, 0, Short.MAX_VALUE))))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -265,19 +282,22 @@
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(setFilesIgnored, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblFilesIgnored))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(btnDefaultIgnored)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(lblPattern))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(ignoreHiddenInHome)
+ .addGap(18, 18, 18)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
+ .addComponent(setScanning, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(lblScanning))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(autoScan)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(lblPattern)
- .addComponent(btnDefaultIgnored)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(txtPatternError, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
- .addContainerGap())
- .addGroup(layout.createSequentialGroup()
- .addGap(20, 20, 20)
- .addComponent(autoScan))))
+ .addComponent(txtPatternError, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
+ .addContainerGap())
);
lblExtension.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(FileAssociationsPanel.class, "FileAssociationsPanel.lblExtension.AN")); // NOI18N
@@ -387,6 +407,10 @@
fireChanged(null, null);
}//GEN-LAST:event_autoScanActionPerformed
+ private void ignoreHiddenInHomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ignoreHiddenInHomeActionPerformed
+ fireChanged(null, null);
+ }//GEN-LAST:event_ignoreHiddenInHomeActionPerformed
+
void load() {
cbExtension.removeAllItems();
cbType.removeAllItems();
@@ -410,6 +434,7 @@
txtPattern.getDocument().removeDocumentListener(patternListener);
txtPattern.setText(IgnoredFilesPreferences.getIgnoredFiles());
txtPattern.getDocument().addDocumentListener(patternListener);
+ ignoreHiddenInHome.setSelected(IgnoredFilesPreferences.isIgnoreHiddenFilesInUserHome());
btnDefaultIgnored.setEnabled(!IgnoredFilesPreferences.DEFAULT_IGNORED_FILES.equals(txtPattern.getText()));
boolean manual = NbPreferences.root().node("org/openide/actions/FileSystemRefreshAction").getBoolean("manual", false); // NOI18N
@@ -422,6 +447,7 @@
model.store();
// store ignored files pattern
IgnoredFilesPreferences.setIgnoredFiles(txtPattern.getText());
+ IgnoredFilesPreferences.setIgnoreHiddenFilesInUserHome(ignoreHiddenInHome.isSelected());
final Preferences nd = NbPreferences.root().node("org/openide/actions/FileSystemRefreshAction"); // NOI18N
boolean manual = nd.getBoolean("manual", false);
@@ -444,6 +470,7 @@
private javax.swing.JButton btnRemove;
private javax.swing.JComboBox cbExtension;
private javax.swing.JComboBox cbType;
+ private javax.swing.JCheckBox ignoreHiddenInHome;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel lblAssociatedAlso;
private javax.swing.JLabel lblAssociatedAlsoExt;
@@ -451,9 +478,11 @@
private javax.swing.JLabel lblFileAssociations;
private javax.swing.JLabel lblFilesIgnored;
private javax.swing.JLabel lblPattern;
+ private javax.swing.JLabel lblScanning;
private javax.swing.JLabel lblType;
private javax.swing.JSeparator sepFileAssociations;
private javax.swing.JSeparator setFilesIgnored;
+ private javax.swing.JSeparator setScanning;
private javax.swing.JTextArea txtPattern;
private javax.swing.JLabel txtPatternError;
// End of variables declaration//GEN-END:variables
@@ -489,6 +518,8 @@
if (extension == null) {
isChanged |= !txtPattern.getText().equals(IgnoredFilesPreferences.getIgnoredFiles());
+ isChanged |= ignoreHiddenInHome.isSelected() != IgnoredFilesPreferences.isIgnoreHiddenFilesInUserHome();
+
boolean manual = NbPreferences.root().node("org/openide/actions/FileSystemRefreshAction").getBoolean("manual", false); // NOI18N
isChanged |= autoScan.isSelected() == manual;
diff -r 78f6cd5a374e core.ui/src/org/netbeans/core/ui/options/filetypes/IgnoredFilesPreferences.java
--- a/core.ui/src/org/netbeans/core/ui/options/filetypes/IgnoredFilesPreferences.java Wed Jul 15 05:13:26 2015 +0000
+++ b/core.ui/src/org/netbeans/core/ui/options/filetypes/IgnoredFilesPreferences.java Wed Jul 15 13:56:02 2015 +0200
@@ -62,8 +62,10 @@
* in module org.netbeans.modules.masterfs.
*/
private static final String PROP_IGNORED_FILES = "IgnoredFiles"; // NOI18N
+ private static final String PROP_IGNORE_HIDDEN_FILES_IN_USER_HOME
+ = "IgnoreHiddenFilesInUserHome"; // NOI18N
/** Default ignored files pattern. Pattern \.(cvsignore|svn|DS_Store) is covered by ^\..*$ **/
- static final String DEFAULT_IGNORED_FILES = "^(CVS|SCCS|vssver.?\\.scc|#.*#|%.*%|_svn)$|~$|^\\.(?!(htaccess|git.+|hgignore|npmignore|jshintrc|bowerrc|travis\\.yml)$).*$"; //NOI18N
+ static final String DEFAULT_IGNORED_FILES = "^(CVS|SCCS|vssver.?\\.scc|#.*#|%.*%|_svn)$|~$|^\\.(git|hg|svn|cache|DS_store)$|^Thumbs.db$"; //NOI18N
static private String syntaxError;
private IgnoredFilesPreferences() {
@@ -93,6 +95,30 @@
}
}
+ /**
+ * Returns true if hidden files in user's home folder should be ignored
+ * (e.i. not displayed in Favorites windows).
+ *
+ * @return True to ignore hidden files in user's home folder, false to show
+ * them.
+ */
+ static boolean isIgnoreHiddenFilesInUserHome() {
+ return getPreferences().getBoolean(
+ PROP_IGNORE_HIDDEN_FILES_IN_USER_HOME, true);
+ }
+
+ /**
+ * Set whether hidden files in home folder should be ignored (i.e. not
+ * displayed in Favorites window).
+ *
+ * @param ignore True to ignore hidden files in user's home folder, false to
+ * show them.
+ */
+ static void setIgnoreHiddenFilesInUserHome(boolean ignore) {
+ getPreferences().putBoolean(
+ PROP_IGNORE_HIDDEN_FILES_IN_USER_HOME, ignore);
+ }
+
/** Returns true if ignored files pattern is valid, false otherwise and
* syntax error message can be obtained by getSyntaxError method.
* @param ignoredFiles ignored files pattern
diff -r 78f6cd5a374e masterfs/src/org/netbeans/modules/masterfs/GlobalVisibilityQueryImpl.java
--- a/masterfs/src/org/netbeans/modules/masterfs/GlobalVisibilityQueryImpl.java Wed Jul 15 05:13:26 2015 +0000
+++ b/masterfs/src/org/netbeans/modules/masterfs/GlobalVisibilityQueryImpl.java Wed Jul 15 13:56:02 2015 +0200
@@ -52,6 +52,7 @@
import java.util.prefs.Preferences;
import java.util.regex.Pattern;
import org.netbeans.spi.queries.VisibilityQueryImplementation2;
+import org.openide.filesystems.FileUtil;
import org.openide.util.ChangeSupport;
import org.openide.util.NbPreferences;
import org.openide.util.lookup.ServiceProvider;
@@ -78,8 +79,19 @@
* Keep it synchronized with IgnoredFilesPreferences.PROP_IGNORED_FILES
*/
private static final String PROP_IGNORED_FILES = "IgnoredFiles"; // NOI18N
+ private static final String PROP_IGNORE_HIDDEN_FILES_IN_USER_HOME
+ = "IgnoreHiddenFilesInUserHome"; // NOI18N
private Pattern ignoreFilesPattern = null;
+ private boolean ignoreHiddenInHome = true;
+ private boolean ignoreHiddenInHomeInitialized = false;
+
+ private FileObject home = null;
+ private String homePath = null;
+ private boolean homeInitialized = false;
+
+ private PreferenceChangeListener preferencesListener = null;
+
/** Default instance for lookup. */
public GlobalVisibilityQueryImpl() {
}
@@ -89,11 +101,21 @@
}
public boolean isVisible(FileObject file) {
- return isVisible(file.getNameExt());
+ String name = file.getNameExt();
+ if (isIgnoreHiddenInHome() && isHidden(name) && isInHomeFolder(file)) {
+ return false;
+ } else {
+ return isVisible(name);
+ }
}
public boolean isVisible(File file) {
- return isVisible(file.getName());
+ String name = file.getName();
+ if (isIgnoreHiddenInHome() && isHidden(name) && isInHomeFolder(file)) {
+ return false;
+ } else {
+ return isVisible(name);
+ }
}
@@ -118,6 +140,15 @@
cs.removeChangeListener(l);
}
+ private boolean isIgnoreHiddenInHome() {
+ if (!ignoreHiddenInHomeInitialized) {
+ ignoreHiddenInHome = getPreferences().getBoolean(
+ PROP_IGNORE_HIDDEN_FILES_IN_USER_HOME, true);
+ ignoreHiddenInHomeInitialized = true;
+ }
+ return ignoreHiddenInHome;
+ }
+
private Pattern getIgnoreFilesPattern() {
if (ignoreFilesPattern == null) {
String ignoredFiles = getIgnoredFiles();
@@ -128,17 +159,81 @@
protected String getIgnoredFiles() {
// \.(cvsignore|svn|DS_Store) is covered by ^\..*$
- String retval = getPreferences().get(PROP_IGNORED_FILES, "^(CVS|SCCS|vssver.?\\.scc|#.*#|%.*%|_svn)$|~$|^\\.(?!(htaccess|git.+|hgignore|npmignore|jshintrc|bowerrc|travis\\.yml)$).*$");//NOI18N;
- getPreferences().addPreferenceChangeListener(new PreferenceChangeListener() {
- public void preferenceChange(PreferenceChangeEvent evt) {
- if (PROP_IGNORED_FILES.equals(evt.getKey())) {
- ignoreFilesPattern = null;
- cs.fireChange();
- }
-
+ String retval = getPreferences().get(PROP_IGNORED_FILES, "^(CVS|SCCS|vssver.?\\.scc|#.*#|%.*%|_svn)$|~$|^\\.(git|hg|svn|cache|DS_store)$|^Thumbs.db$");//NOI18N;
+ PreferenceChangeListener listenerToAdd;
+ synchronized (this) {
+ if (preferencesListener == null) {
+ preferencesListener = new PreferenceChangeListener() {
+ @Override
+ public void preferenceChange(PreferenceChangeEvent evt) {
+ if (PROP_IGNORED_FILES.equals(evt.getKey())) {
+ ignoreFilesPattern = null;
+ cs.fireChange();
+ } else if (PROP_IGNORE_HIDDEN_FILES_IN_USER_HOME.equals(
+ evt.getKey())) {
+ ignoreHiddenInHomeInitialized = false;
+ cs.fireChange();
+ }
+ }
+ };
+ listenerToAdd = preferencesListener;
+ } else {
+ listenerToAdd = null;
}
- });
+ }
+ if (listenerToAdd != null) {
+ getPreferences().addPreferenceChangeListener(listenerToAdd);
+ }
return retval;
}
+ /**
+ * Check if the file is hidden in Unix file systems.
+ *
+ * @param String File name.
+ * @return True if file name starts with a dot.
+ */
+ private boolean isHidden(String fileName) {
+ return fileName.startsWith("."); //NOI18N
+ }
+
+ /**
+ * Check if the file is located directly in user's home folder.
+ *
+ * @param fo The FileObject.
+ * @return True if this is a file located directly in user's home folder.
+ */
+ private boolean isInHomeFolder(FileObject fo) {
+ if (!homeInitialized) {
+ initializeHome();
+ }
+ FileObject parent = fo.getParent();
+ return parent != null && parent == home;
+ }
+
+ /**
+ * Check if the file is located directly in user's home folder.
+ *
+ * @param f The file.
+ * @return True if this is a file located directly in user's home folder.
+ */
+ private boolean isInHomeFolder(File f) {
+ if (!homeInitialized) {
+ initializeHome();
+ }
+ String parentPath = f.getParent();
+ return parentPath != null && parentPath.equals(homePath);
+ }
+
+ /**
+ * Initialize variables holding the user directory.
+ */
+ private void initializeHome() {
+ String homeRaw = System.getProperty("user.home"); //NOI18N
+ if (homeRaw != null) {
+ homePath = FileUtil.normalizePath(homeRaw);
+ home = FileUtil.toFileObject(new File(homePath));
+ }
+ homeInitialized = true;
+ }
}