You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by lk...@apache.org on 2020/10/23 01:10:51 UTC

[netbeans] 04/18: Reload external changes automatically in headless mode.

This is an automated email from the ASF dual-hosted git repository.

lkishalmi pushed a commit to branch release122
in repository https://gitbox.apache.org/repos/asf/netbeans.git

commit f6ef4eaa13ee415c10c600700af25e7d3f0bbd84
Author: Martin Entlicher <ma...@oracle.com>
AuthorDate: Mon Oct 19 17:54:05 2020 +0200

    Reload external changes automatically in headless mode.
---
 .../src/org/openide/text/DataEditorSupport.java        | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/platform/openide.loaders/src/org/openide/text/DataEditorSupport.java b/platform/openide.loaders/src/org/openide/text/DataEditorSupport.java
index 2edd115..fe9254c 100644
--- a/platform/openide.loaders/src/org/openide/text/DataEditorSupport.java
+++ b/platform/openide.loaders/src/org/openide/text/DataEditorSupport.java
@@ -21,6 +21,7 @@ package org.openide.text;
 
 
 import java.awt.EventQueue;
+import java.awt.GraphicsEnvironment;
 import org.netbeans.modules.openide.loaders.SimpleES;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
@@ -1352,12 +1353,19 @@ public class DataEditorSupport extends CloneableEditorSupport {
                 try {
                     des.superSaveDoc();
                 } catch (UserQuestionException ex) {
-                    NotifyDescriptor nd = new NotifyDescriptor.Confirmation(ex.getLocalizedMessage(),
-                            NotifyDescriptor.YES_NO_OPTION);
-                    Object res = DialogDisplayer.getDefault().notify(nd);
-
-                    if (NotifyDescriptor.OK_OPTION.equals(res)) {
+                    if (GraphicsEnvironment.isHeadless()) {
+                        // We cn not ask for anything in headless mode.
+                        // When there are e.g. external changes, we want to reload them,
+                        // otherwise we'd keep an inconsistent state.
                         ex.confirmed();
+                    } else {
+                        NotifyDescriptor nd = new NotifyDescriptor.Confirmation(ex.getLocalizedMessage(),
+                                NotifyDescriptor.YES_NO_OPTION);
+                        Object res = DialogDisplayer.getDefault().notify(nd);
+
+                        if (NotifyDescriptor.OK_OPTION.equals(res) || true) {
+                            ex.confirmed();
+                        }
                     }
                 }
             } catch (IOException e) {


---------------------------------------------------------------------
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