diff -r 6c7bff0022c6 core.ui/arch.xml
--- a/core.ui/arch.xml Tue Apr 27 13:44:48 2010 +0200
+++ b/core.ui/arch.xml Tue Apr 27 15:05:43 2010 +0200
@@ -580,7 +580,15 @@
-->
- XXX no answer for exec-property
+
+ When set, no check for external file changes is performed on focus gain. Works in
+ concert with Parsing API.
+
+
+
+ External changes refresh is only performed when manual refresh is off.
+ Various UI elements can also change the value of this preference setting.
+
diff -r 6c7bff0022c6 core.ui/src/org/netbeans/core/ui/options/filetypes/Bundle.properties
--- a/core.ui/src/org/netbeans/core/ui/options/filetypes/Bundle.properties Tue Apr 27 13:44:48 2010 +0200
+++ b/core.ui/src/org/netbeans/core/ui/options/filetypes/Bundle.properties Tue Apr 27 15:05:43 2010 +0200
@@ -92,3 +92,5 @@
# display name for options export
Files.Options.Export.displayName=Files
OpenAsPanel.lblDescription.text=NetBeans does not know this type of file. Please specify how should these files be treated.
+FileAssociationsPanel.autoScan.text=Auto-scan for external changes when IDE gains focus
+FileAssociationsPanel.autoScanLabel.text=You may want to turn this off if you have a large project or if you don't use external tools
diff -r 6c7bff0022c6 core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsPanel.form
--- a/core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsPanel.form Tue Apr 27 13:44:48 2010 +0200
+++ b/core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsPanel.form Tue Apr 27 15:05:43 2010 +0200
@@ -1,4 +1,4 @@
-
+
diff -r 6c7bff0022c6 core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsPanel.java
--- a/core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsPanel.java Tue Apr 27 13:44:48 2010 +0200
+++ b/core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsPanel.java Tue Apr 27 15:05:43 2010 +0200
@@ -42,13 +42,14 @@
import java.util.ArrayList;
import java.util.Collections;
-import javax.swing.UIManager;
+import java.util.prefs.Preferences;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import org.netbeans.core.ui.options.filetypes.FileAssociationsModel.MimeItem;
import org.openide.DialogDescriptor;
import org.openide.DialogDisplayer;
import org.openide.util.NbBundle;
+import org.openide.util.NbPreferences;
/** Options panel with extensions and associated MIME types.
*
@@ -95,6 +96,8 @@
jScrollPane1 = new javax.swing.JScrollPane();
txtPattern = new javax.swing.JTextArea();
txtPatternError = new javax.swing.JLabel();
+ autoScan = new javax.swing.JCheckBox();
+ autoScanLabel = new javax.swing.JLabel();
lblExtension.setLabelFor(cbExtension);
org.openide.awt.Mnemonics.setLocalizedText(lblExtension, org.openide.util.NbBundle.getMessage(FileAssociationsPanel.class, "FileAssociationsPanel.lblExtension.text")); // NOI18N
@@ -169,6 +172,15 @@
txtPatternError.setVerticalAlignment(javax.swing.SwingConstants.TOP);
txtPatternError.setFocusable(false);
+ org.openide.awt.Mnemonics.setLocalizedText(autoScan, org.openide.util.NbBundle.getMessage(FileAssociationsPanel.class, "FileAssociationsPanel.autoScan.text", new Object[] {})); // NOI18N
+ autoScan.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ autoScanActionPerformed(evt);
+ }
+ });
+
+ org.openide.awt.Mnemonics.setLocalizedText(autoScanLabel, org.openide.util.NbBundle.getMessage(FileAssociationsPanel.class, "FileAssociationsPanel.autoScanLabel.text", new Object[] {})); // NOI18N
+
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -179,7 +191,7 @@
.addGroup(layout.createSequentialGroup()
.addComponent(lblFileAssociations)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(sepFileAssociations, javax.swing.GroupLayout.DEFAULT_SIZE, 530, Short.MAX_VALUE))
+ .addComponent(sepFileAssociations, javax.swing.GroupLayout.DEFAULT_SIZE, 542, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -190,11 +202,11 @@
.addGroup(layout.createSequentialGroup()
.addComponent(lblAssociatedAlso)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(lblAssociatedAlsoExt, javax.swing.GroupLayout.DEFAULT_SIZE, 281, Short.MAX_VALUE))
+ .addComponent(lblAssociatedAlsoExt, javax.swing.GroupLayout.DEFAULT_SIZE, 323, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(cbExtension, 0, 254, Short.MAX_VALUE)
- .addComponent(cbType, 0, 254, Short.MAX_VALUE))
+ .addComponent(cbExtension, 0, 293, Short.MAX_VALUE)
+ .addComponent(cbType, 0, 293, Short.MAX_VALUE))
.addGap(10, 10, 10)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
@@ -203,19 +215,30 @@
.addComponent(btnRemove))
.addComponent(btnDefault)))))
.addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGap(10, 10, 10)
+ .addComponent(lblPattern))
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(autoScan, javax.swing.GroupLayout.DEFAULT_SIZE, 503, Short.MAX_VALUE)
+ .addGap(44, 44, 44)))
+ .addGap(41, 41, 41))
+ .addGroup(layout.createSequentialGroup()
+ .addGap(21, 21, 21)
+ .addComponent(autoScanLabel)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
+ .addComponent(txtPatternError, javax.swing.GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE))
+ .addGroup(layout.createSequentialGroup()
.addComponent(lblFilesIgnored)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(setFilesIgnored, javax.swing.GroupLayout.DEFAULT_SIZE, 482, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addGap(10, 10, 10)
- .addComponent(lblPattern)
- .addGap(41, 41, 41)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(txtPatternError, javax.swing.GroupLayout.DEFAULT_SIZE, 455, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
- .addComponent(jScrollPane1)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 407, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(btnDefaultIgnored)))))
+ .addComponent(btnDefaultIgnored))
+ .addComponent(setFilesIgnored, javax.swing.GroupLayout.DEFAULT_SIZE, 499, Short.MAX_VALUE))))
.addContainerGap())
);
layout.setVerticalGroup(
@@ -250,8 +273,17 @@
.addComponent(btnDefaultIgnored)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(txtPatternError, javax.swing.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE)
- .addGap(16, 16, 16))
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(txtPatternError, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
+ .addGap(16, 16, 16))
+ .addGroup(layout.createSequentialGroup()
+ .addGap(20, 20, 20)
+ .addComponent(autoScan)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(autoScanLabel)
+ .addGap(79, 79, 79))))
);
lblExtension.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(FileAssociationsPanel.class, "FileAssociationsPanel.lblExtension.AN")); // NOI18N
@@ -354,6 +386,10 @@
txtPattern.setText(IgnoredFilesPreferences.DEFAULT_IGNORED_FILES);
}//GEN-LAST:event_btnDefaultIgnoredActionPerformed
+private void autoScanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_autoScanActionPerformed
+ controller.changed();
+}//GEN-LAST:event_autoScanActionPerformed
+
void load() {
cbExtension.removeAllItems();
cbType.removeAllItems();
@@ -378,6 +414,9 @@
txtPattern.setText(IgnoredFilesPreferences.getIgnoredFiles());
txtPattern.getDocument().addDocumentListener(patternListener);
btnDefaultIgnored.setEnabled(!IgnoredFilesPreferences.DEFAULT_IGNORED_FILES.equals(txtPattern.getText()));
+
+ boolean manual = NbPreferences.root().node("org/openide/actions/FileSystemRefreshAction").getBoolean("manual", false); // NOI18N
+ autoScan.setSelected(!manual);
}
void store() {
@@ -385,6 +424,12 @@
model.store();
// store ignored files pattern
IgnoredFilesPreferences.setIgnoredFiles(txtPattern.getText());
+
+ final Preferences nd = NbPreferences.root().node("org/openide/actions/FileSystemRefreshAction"); // NOI18N
+ boolean manual = nd.getBoolean("manual", false);
+ if (manual == autoScan.isSelected()) {
+ nd.putBoolean("manual", !manual); // NOI18N
+ }
}
boolean valid() {
@@ -394,6 +439,8 @@
}
// Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JCheckBox autoScan;
+ private javax.swing.JLabel autoScanLabel;
private javax.swing.JButton btnDefault;
private javax.swing.JButton btnDefaultIgnored;
private javax.swing.JButton btnNew;
diff -r 6c7bff0022c6 core.ui/src/org/netbeans/core/ui/warmup/Bundle.properties
--- a/core.ui/src/org/netbeans/core/ui/warmup/Bundle.properties Tue Apr 27 13:44:48 2010 +0200
+++ b/core.ui/src/org/netbeans/core/ui/warmup/Bundle.properties Tue Apr 27 15:05:43 2010 +0200
@@ -44,12 +44,15 @@
LOG_WINDOW_ACTIVATED=Main Window Activated, refresh took {0} ms
LOG_WINDOW_DEACTIVATED=Main Window Deactivated
LOG_WINDOW_REFRESH_CANCEL=Refresh canceled for {0} time
+LOG_WINDOW_REFRESH_OFF=Turning off refresh on focus gained
MSG_Refresh=Checking for external changes
MSG_Refresh_Suspend=Suspended
-MSG_SoDInfo=You seem to have troubles with long refreshes.\n \
-There exist an experimental module Scan On Demand which\n \
-disables automatic refreshes all together and replaces them\n \
-with manual File/Refresh All action.\n \
-Do you want to download the module now?
+MSG_SoDInfo=When you switch from another program to the IDE, the IDE scans for \
+changes to your code.\n\
+You can disable this feature and \
+manually scan your project when you make changes\n\
+using the Refresh Folder action or Source/Scan for External Changes action.\
+\n\n\
+Disable scanning for external changes?
diff -r 6c7bff0022c6 core.ui/src/org/netbeans/core/ui/warmup/MenuWarmUpTask.java
--- a/core.ui/src/org/netbeans/core/ui/warmup/MenuWarmUpTask.java Tue Apr 27 13:44:48 2010 +0200
+++ b/core.ui/src/org/netbeans/core/ui/warmup/MenuWarmUpTask.java Tue Apr 27 15:05:43 2010 +0200
@@ -54,7 +54,6 @@
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
-import javax.swing.Action;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JLabel;
@@ -73,6 +72,7 @@
import org.openide.util.Cancellable;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
+import org.openide.util.NbPreferences;
import org.openide.util.Utilities;
/**
@@ -141,6 +141,7 @@
private AtomicBoolean goOn;
private static final Logger UILOG = Logger.getLogger("org.netbeans.ui.focus"); // NOI18N
private static final Logger LOG = Logger.getLogger("org.netbeans.core.ui.focus"); // NOI18N
+ private boolean warnedNoRefresh;
@Override
public void windowActivated(WindowEvent e) {
@@ -178,9 +179,20 @@
}
}
+ private static boolean isNoRefresh() {
+ if (Boolean.getBoolean("netbeans.indexing.noFileRefresh")) {
+ return true;
+ }
+ return NbPreferences.root().node("org/openide/actions/FileSystemRefreshAction").getBoolean("manual", false); // NOI18N
+ }
+
@Override
public void run() {
- if (Boolean.getBoolean("netbeans.indexing.noFileRefresh") == true) { // NOI18N
+ if (isNoRefresh()) {
+ if (!warnedNoRefresh) {
+ LOG.info("External Changes Refresh on focus gain disabled"); // NOI18N
+ warnedNoRefresh = true;
+ }
LOG.fine("Refresh disabled, aborting");
return; // no file refresh
}
@@ -307,29 +319,27 @@
++counter;
- LogRecord r = new LogRecord(Level.FINE, "LOG_WINDOW_REFRESH_CANCEL"); // NOI18N
- r.setParameters(new Object[]{counter});
- r.setResourceBundleName("org.netbeans.core.ui.warmup.Bundle"); // NOI18N
- r.setResourceBundle(NbBundle.getBundle(MenuWarmUpTask.class)); // NOI18N
- r.setLoggerName(UILOG.getName());
- UILOG.log(r);
+ {
+ LogRecord r = new LogRecord(Level.FINE, "LOG_WINDOW_REFRESH_CANCEL"); // NOI18N
+ r.setParameters(new Object[]{counter});
+ r.setResourceBundleName("org.netbeans.core.ui.warmup.Bundle"); // NOI18N
+ r.setResourceBundle(NbBundle.getBundle(MenuWarmUpTask.class)); // NOI18N
+ r.setLoggerName(UILOG.getName());
+ UILOG.log(r);
+ }
- if (counter >= 3) {
- FileObject action = FileUtil.getConfigFile("Actions/System/org-netbeans-modules-autoupdate-ui-actions-PluginManagerAction.instance"); // NOI18N
- Object obj = action == null ? null : action.getAttribute("instanceCreate"); // NOI18N
- if (obj instanceof Action) {
- JEditorPane browser = new JEditorPane();
- browser.setBorder(javax.swing.BorderFactory.createEmptyBorder(8, 8, 0, 8));
- browser.setPreferredSize(new Dimension(300, 150));
- browser.setEditable(false);
- browser.setEditorKit(new HTMLEditorKit()); // needed up to nb5.5
- browser.setBackground(new JLabel().getBackground());
- browser.setText(NbBundle.getMessage(MenuWarmUpTask.class, "MSG_SoDInfo"));
- Message nd = new Message(browser);
- nd.setOptions(new Object[] { Message.YES_OPTION, Message.NO_OPTION });
- if (DialogDisplayer.getDefault().notify(nd) == Message.YES_OPTION) {
- ((Action)obj).actionPerformed(new ActionEvent(this, 0, ""));
- }
+ if (counter >= 1) {
+ Message nd = new Message(NbBundle.getMessage(MenuWarmUpTask.class, "MSG_SoDInfo"));
+ nd.setOptions(new Object[] { Message.YES_OPTION, Message.NO_OPTION });
+ if (DialogDisplayer.getDefault().notify(nd) == Message.YES_OPTION) {
+ NbPreferences.root().node("org/openide/actions/FileSystemRefreshAction").putBoolean("manual", true); // NOI18N
+
+ LogRecord r = new LogRecord(Level.FINE, "LOG_WINDOW_REFRESH_OFF"); // NOI18N
+ r.setParameters(new Object[]{counter});
+ r.setResourceBundleName("org.netbeans.core.ui.warmup.Bundle"); // NOI18N
+ r.setResourceBundle(NbBundle.getBundle(MenuWarmUpTask.class)); // NOI18N
+ r.setLoggerName(UILOG.getName());
+ UILOG.log(r);
}
}
return true;
diff -r 6c7bff0022c6 openide.loaders/arch.xml
--- a/openide.loaders/arch.xml Tue Apr 27 13:44:48 2010 +0200
+++ b/openide.loaders/arch.xml Tue Apr 27 15:05:43 2010 +0200
@@ -1210,7 +1210,11 @@
-->
- XXX no answer for resources-preferences
+
+ If NbPreferences.root().node("org.openide.actions.FileSystemRefreshAction").getBoolean("manual", false)
+ returns true, then FileSystemRefreshAction
+ is displayed in popup menu of folders.
+
diff -r 6c7bff0022c6 openide.loaders/src/org/openide/actions/FileSystemAction.java
--- a/openide.loaders/src/org/openide/actions/FileSystemAction.java Tue Apr 27 13:44:48 2010 +0200
+++ b/openide.loaders/src/org/openide/actions/FileSystemAction.java Tue Apr 27 15:05:43 2010 +0200
@@ -139,12 +139,18 @@
backSet.addAll(backupList);
result.addAll(Arrays.asList(fs.getActions (backSet)));
}
-
+
+ if (isManualRefresh()) {
+ result.add(FileSystemRefreshAction.get(FileSystemRefreshAction.class));
+ }
return createMenu (Collections.enumeration (result), popUp, createProxyLookup(lookup, backSet)/*lookup*/);
}
return NONE;
}
+ private static boolean isManualRefresh() {
+ return NbPreferences.root().node("org/openide/actions/FileSystemRefreshAction").getBoolean("manual", false); // NOI18N
+ }
private static ProxyLookup createProxyLookup(final Lookup lookup, final Set backSet) {
return new ProxyLookup(lookup, Lookups.fixed((Object[])backSet.toArray(new FileObject [backSet.size()])));
diff -r 6c7bff0022c6 openide.loaders/test/unit/src/org/openide/actions/FileSystemActionTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/openide.loaders/test/unit/src/org/openide/actions/FileSystemActionTest.java Tue Apr 27 15:05:43 2010 +0200
@@ -0,0 +1,87 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2010 Sun Microsystems, Inc.
+ */
+
+package org.openide.actions;
+
+import java.io.IOException;
+import java.util.prefs.Preferences;
+import javax.swing.Action;
+import javax.swing.JComponent;
+import org.netbeans.junit.NbTestCase;
+import org.openide.awt.DynamicMenuContent;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.loaders.DataFolder;
+import org.openide.util.Lookup;
+import org.openide.util.NbPreferences;
+import org.openide.util.actions.Presenter;
+import org.openide.util.lookup.Lookups;
+
+/**
+ *
+ * @author Jaroslav Tulach
+ */
+public class FileSystemActionTest extends NbTestCase {
+
+ public FileSystemActionTest(String s) {
+ super(s);
+ }
+
+ public void testManualRefreshPreference() throws IOException {
+ Preferences pref = NbPreferences.root().node("org/openide/actions/FileSystemRefreshAction");
+ assertFalse("Not set", pref.getBoolean("manual", false));
+
+ FileObject fo = FileUtil.toFileObject(getWorkDir());
+ Lookup lkp = Lookups.singleton(DataFolder.findFolder(fo).getNodeDelegate());
+
+ FileSystemAction fsa = FileSystemAction.get(FileSystemAction.class);
+ Action a = fsa.createContextAwareInstance(lkp);
+
+ assertEquals("Menu presenter ", true, a instanceof Presenter.Menu);
+
+ Presenter.Menu pm = (Presenter.Menu)a;
+ DynamicMenuContent submenu = (DynamicMenuContent)pm.getMenuPresenter();
+ assertEquals("No submenu", 0, submenu.getMenuPresenters().length);
+
+ pref.putBoolean("manual", true);
+
+ DynamicMenuContent submenu2 = (DynamicMenuContent)pm.getMenuPresenter();
+ assertEquals("One action", 1, submenu2.getMenuPresenters().length);
+ }
+}
\ No newline at end of file