You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ne...@apache.org on 2022/10/18 15:49:59 UTC
[netbeans] branch master updated: Add PROP_RELOADED event to signal reload after external change.
This is an automated email from the ASF dual-hosted git repository.
neilcsmith pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 962d237ef5 Add PROP_RELOADED event to signal reload after external change.
new 8898e37912 Merge pull request #4249 from errael/AfterFileExternalChangeFireReloadedEvent
962d237ef5 is described below
commit 962d237ef573577aea18b3d48bac0af74fa7d845
Author: Ernie Rael <er...@raelity.com>
AuthorDate: Sun Jun 19 13:35:01 2022 -0700
Add PROP_RELOADED event to signal reload after external change.
---
platform/openide.text/apichanges.xml | 51 +++++++++++++++-------
platform/openide.text/manifest.mf | 2 +-
.../src/org/openide/cookies/EditorCookie.java | 6 +++
.../src/org/openide/text/DocumentOpenClose.java | 8 ++++
4 files changed, 51 insertions(+), 16 deletions(-)
diff --git a/platform/openide.text/apichanges.xml b/platform/openide.text/apichanges.xml
index d647739eb2..281f564878 100644
--- a/platform/openide.text/apichanges.xml
+++ b/platform/openide.text/apichanges.xml
@@ -25,21 +25,42 @@
<apidef name="text">Text API</apidef>
</apidefs>
<changes>
- <change id="ask.on.document.reload">
- <api name="text"/>
- <summary>Rebrand defaults for Reload Editor Dialog</summary>
- <version major="6" minor="80"/>
- <date day="22" month="1" year="2021"/>
- <author login="dbalek"/>
- <compatibility addition="yes" binary="compatible" source="compatible"
- semantic="incompatible" deletion="no"
- modification="no"/>
- <description>
- A branding API to disable showing reload externally modified document dialog
- - <a href="architecture-summary.html#group-branding">ASK_OnReload</a>.
- </description>
- <class package="org.openide.text" name="CloneableEditorSupport"/>
- </change>
+ <change id="EditorCookie.Observable.PROP_RELOADING">
+ <api name="text"/>
+ <summary>Added EditorCookie.Observable.PROP_RELOADING and associated begin/end events</summary>
+ <version major="6" minor="86"/>
+ <date day="22" month="6" year="2022"/>
+ <author login="errael"/>
+ <compatibility addition="yes" binary="compatible" source="compatible"
+ semantic="compatible" deletion="no"
+ modification="no"/>
+ <description>
+ Added EditorCookie.Observable.PROP_RELOADING and associated
+ begin/end events so that editor modules can handle external file change.
+ These events are fired on the EDT by the document's CloneableEditorSupport;
+ evt.getNewValue() is a Boolean, true signals the start of reload
+ and false the end.
+ An editor kit might adjust multiple carets to keep the same
+ line/column before and after reload of an externally modified file.
+ </description>
+ <class package="org.openide.text" name="CloneableEditorSupport"/>
+ <class package="org.openide.cookies" name="EditorCookie"/>
+ </change>
+ <change id="ask.on.document.reload">
+ <api name="text"/>
+ <summary>Rebrand defaults for Reload Editor Dialog</summary>
+ <version major="6" minor="80"/>
+ <date day="22" month="1" year="2021"/>
+ <author login="dbalek"/>
+ <compatibility addition="yes" binary="compatible" source="compatible"
+ semantic="incompatible" deletion="no"
+ modification="no"/>
+ <description>
+ A branding API to disable showing reload externally modified document dialog
+ - <a href="architecture-summary.html#group-branding">ASK_OnReload</a>.
+ </description>
+ <class package="org.openide.text" name="CloneableEditorSupport"/>
+ </change>
<change id="PositionRef.Position">
<api name="text"/>
<summary>Implement Position interface for compatibility</summary>
diff --git a/platform/openide.text/manifest.mf b/platform/openide.text/manifest.mf
index 4547fd1c37..c6c6dddb53 100644
--- a/platform/openide.text/manifest.mf
+++ b/platform/openide.text/manifest.mf
@@ -2,5 +2,5 @@ Manifest-Version: 1.0
OpenIDE-Module: org.openide.text
OpenIDE-Module-Localizing-Bundle: org/openide/text/Bundle.properties
AutoUpdate-Essential-Module: true
-OpenIDE-Module-Specification-Version: 6.85
+OpenIDE-Module-Specification-Version: 6.86
diff --git a/platform/openide.text/src/org/openide/cookies/EditorCookie.java b/platform/openide.text/src/org/openide/cookies/EditorCookie.java
index 1be3452c08..6e467fb923 100644
--- a/platform/openide.text/src/org/openide/cookies/EditorCookie.java
+++ b/platform/openide.text/src/org/openide/cookies/EditorCookie.java
@@ -144,6 +144,12 @@ public interface EditorCookie extends LineCookie {
*/
public static final String PROP_OPENED_PANES = "openedPanes";
+ /** This property is fired on the EDT when the reloading state of the
+ * document has changed; reloading is due to an external file change.
+ * @since 6.86
+ */
+ public static final String PROP_RELOADING = "reloading";
+
/** Add a PropertyChangeListener to the listener list.
* @param l the PropertyChangeListener to be added
*/
diff --git a/platform/openide.text/src/org/openide/text/DocumentOpenClose.java b/platform/openide.text/src/org/openide/text/DocumentOpenClose.java
index 25d29cbc64..c7b0a6c8c0 100644
--- a/platform/openide.text/src/org/openide/text/DocumentOpenClose.java
+++ b/platform/openide.text/src/org/openide/text/DocumentOpenClose.java
@@ -25,12 +25,15 @@ import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.logging.Level;
import java.util.logging.Logger;
+
import javax.swing.JEditorPane;
import javax.swing.text.BadLocationException;
import javax.swing.text.EditorKit;
import javax.swing.text.Position;
import javax.swing.text.StyledDocument;
+
import org.openide.awt.UndoRedo;
+import org.openide.cookies.EditorCookie;
import org.openide.util.Mutex;
import org.openide.util.RequestProcessor;
import org.openide.util.Task;
@@ -692,6 +695,10 @@ final class DocumentOpenClose {
", loadSuccess=" + loadSuccess + "\n"); // NOI18N
}
}
+ if(reload) {
+ Mutex.EVENT.postReadRequest(() ->
+ ces.firePropertyChange(EditorCookie.Observable.PROP_RELOADING, true, false));
+ }
}
}
}
@@ -816,6 +823,7 @@ final class DocumentOpenClose {
}
});
+ ces.firePropertyChange(EditorCookie.Observable.PROP_RELOADING, false, true);
// Next portion will run as Task in RP
activeReloadTask = RP.create(this);
activeReloadTask.schedule(0);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists