[hg] main-silver: #232675: added temporary boundaries for Home/E...

  • From: Svata Dedic < >
  • To: , ,
  • Subject: [hg] main-silver: #232675: added temporary boundaries for Home/E...
  • Date: Thu, 18 Jul 2013 15:52:21 -0700

changeset 8a29a36bcfd0 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/8a29a36bcfd0
description:
        #232675: added temporary boundaries for Home/End during instant rename

diffstat:

 csl.api/nbproject/project.xml                                                
       |   2 +-
 csl.api/src/org/netbeans/modules/csl/editor/InstantRenamePerformer.java      
       |   2 +
 editor.lib/nbproject/project.properties                                      
       |   2 +-
 editor.lib/src/org/netbeans/editor/BaseKit.java                              
       |  44 +++++++++-
 java.editor/nbproject/project.xml                                            
       |   2 +-
 
java.editor/src/org/netbeans/modules/java/editor/rename/InstantRenamePerformer.java
 |   3 +-
 6 files changed, 50 insertions(+), 5 deletions(-)

diffs (157 lines):

diff --git a/csl.api/nbproject/project.xml b/csl.api/nbproject/project.xml
--- a/csl.api/nbproject/project.xml
+++ b/csl.api/nbproject/project.xml
@@ -144,7 +144,7 @@
                     <compile-dependency/>
                     <run-dependency>
                         <release-version>3</release-version>
-                        <specification-version>3.24</specification-version>
+                        <specification-version>3.45</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
diff --git 
a/csl.api/src/org/netbeans/modules/csl/editor/InstantRenamePerformer.java 
b/csl.api/src/org/netbeans/modules/csl/editor/InstantRenamePerformer.java
--- a/csl.api/src/org/netbeans/modules/csl/editor/InstantRenamePerformer.java
+++ b/csl.api/src/org/netbeans/modules/csl/editor/InstantRenamePerformer.java
@@ -149,6 +149,7 @@
         
        target.addKeyListener(this);
        
+        target.putClientProperty("NetBeansEditor.navigateBoundaries", 
mainRegion); // NOI18N
        target.putClientProperty(InstantRenamePerformer.class, this);
        
        requestRepaint();
@@ -228,6 +229,7 @@
     }
 
     void release() {
+        target.putClientProperty("NetBeansEditor.navigateBoundaries", null); 
// NOI18N
        target.putClientProperty(InstantRenamePerformer.class, null);
         if (doc instanceof BaseDocument) {
             ((BaseDocument) 
doc).removePostModificationDocumentListener(this);
diff --git a/editor.lib/nbproject/project.properties 
b/editor.lib/nbproject/project.properties
--- a/editor.lib/nbproject/project.properties
+++ b/editor.lib/nbproject/project.properties
@@ -42,7 +42,7 @@
 
 javac.compilerargs=-Xlint:unchecked
 javac.source=1.7
-spec.version.base=3.44.0
+spec.version.base=3.45.0
 is.autoload=true
 
 javadoc.arch=${basedir}/arch.xml
diff --git a/editor.lib/src/org/netbeans/editor/BaseKit.java 
b/editor.lib/src/org/netbeans/editor/BaseKit.java
--- a/editor.lib/src/org/netbeans/editor/BaseKit.java
+++ b/editor.lib/src/org/netbeans/editor/BaseKit.java
@@ -103,6 +103,7 @@
 import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
 import org.netbeans.modules.editor.lib.KitsTracker;
 import org.netbeans.api.editor.NavigationHistory;
+import org.netbeans.lib.editor.util.swing.PositionRegion;
 import org.netbeans.modules.editor.lib.SettingsConversions;
 import org.netbeans.modules.editor.lib2.RectangularSelectionUtils;
 import org.netbeans.modules.editor.lib2.actions.KeyBindingsUpdater;
@@ -378,6 +379,12 @@
     
     private boolean keyBindingsUpdaterInited;
 
+    /**
+     * Navigational boundaries for "home" and "end" actions. If defined on 
the target component,
+     * home/end will move the caret first to the boundary, and only after 
that proceeds as usual (to the start/end of line).
+     * The property must contain {@link PositionRegion} instance
+     */
+    private static final String PROP_NAVIGATE_BOUNDARIES = 
"NetBeansEditor.navigateBoundaries"; // NOI18N
 
     /**
      * Gets an editor kit from its implemetation class.
@@ -2628,6 +2635,22 @@
                 BaseDocument doc = (BaseDocument)target.getDocument();
                 try {
                     int dot = caret.getDot();
+                    // #232675: if bounds are defined, use them rather than 
line start/end
+                    Object o = 
target.getClientProperty(PROP_NAVIGATE_BOUNDARIES);
+                    PositionRegion bounds = null;
+                    if (o instanceof PositionRegion) {
+                        bounds = (PositionRegion)o;
+                        int start = bounds.getStartOffset();
+                        int end = bounds.getEndOffset();
+                        if (dot > start && dot <= end) {
+                            // move to the region start
+                            dot = start;
+                        } else {
+                            bounds = null;
+                        }
+                    }
+                    
+                    if (bounds == null) {
                     int lineStartPos = Utilities.getRowStart(target, dot);
                     if (homeKeyColumnOne) { // to first column
                         dot = lineStartPos;
@@ -2644,6 +2667,7 @@
                             dot = textStartPos;
                         }
                     }
+                    }
                     // For partial view hierarchy check bounds
                     dot = Math.max(dot, 
target.getUI().getRootView(target).getStartOffset());
                     String actionName = (String) getValue(Action.NAME);
@@ -2678,7 +2702,25 @@
             if (target != null) {
                 Caret caret = target.getCaret();
                 try {
-                    int dot = Utilities.getRowEnd(target, caret.getDot());
+                    // #232675: if bounds are defined, use them rather than 
line start/end
+                    Object o = 
target.getClientProperty(PROP_NAVIGATE_BOUNDARIES);
+                    int dot = -1;
+                    
+                    if (o instanceof PositionRegion) {
+                        PositionRegion bounds = (PositionRegion)o;
+                        int start = bounds.getStartOffset();
+                        int end = bounds.getEndOffset();
+                        int d = caret.getDot();
+                        if (d >= start && d < end) {
+                            // move to the region start
+                            dot = end;
+                        }
+                    }
+
+                    if (dot == -1) {
+                        dot = Utilities.getRowEnd(target, caret.getDot());
+                    }
+                    
                     // For partial view hierarchy check bounds
                     dot = Math.min(dot, 
target.getUI().getRootView(target).getEndOffset());
                     boolean select = 
selectionEndLineAction.equals(getValue(Action.NAME));
diff --git a/java.editor/nbproject/project.xml 
b/java.editor/nbproject/project.xml
--- a/java.editor/nbproject/project.xml
+++ b/java.editor/nbproject/project.xml
@@ -161,7 +161,7 @@
                     <compile-dependency/>
                     <run-dependency>
                         <release-version>3</release-version>
-                        <specification-version>3.24</specification-version>
+                        <specification-version>3.45</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
diff --git 
a/java.editor/src/org/netbeans/modules/java/editor/rename/InstantRenamePerformer.java
 
b/java.editor/src/org/netbeans/modules/java/editor/rename/InstantRenamePerformer.java
--- 
a/java.editor/src/org/netbeans/modules/java/editor/rename/InstantRenamePerformer.java
+++ 
b/java.editor/src/org/netbeans/modules/java/editor/rename/InstantRenamePerformer.java
@@ -214,6 +214,7 @@
         target.addKeyListener(this);
 
         target.putClientProperty(InstantRenamePerformer.class, this);
+        target.putClientProperty("NetBeansEditor.navigateBoundaries", 
mainRegion); // NOI18N
        
         requestRepaint();
         
@@ -717,7 +718,7 @@
             //already released
             return ;
         }
-        
+        target.putClientProperty("NetBeansEditor.navigateBoundaries", null); 
// NOI18N
         target.putClientProperty(InstantRenamePerformer.class, null);
         if (doc instanceof BaseDocument) {
             ((BaseDocument) doc).setPostModificationDocumentListener(null);

[hg] main-silver: #232675: added temporary boundaries for Home/E...

Svata Dedic 07/18/2013

Project Features

About this Project

Editor was started in November 2009, is owned by Martin Ryzl, and has 147 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close