This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 238679
Collapse All | Expand All

(-)a/php.nette2/src/org/netbeans/modules/php/nette2/Nette2FrameworkProvider.java (-2 / +34 lines)
Lines 42-52 Link Here
42
package org.netbeans.modules.php.nette2;
42
package org.netbeans.modules.php.nette2;
43
43
44
import java.io.File;
44
import java.io.File;
45
import java.io.IOException;
46
import java.nio.file.Files;
47
import java.nio.file.LinkOption;
48
import java.nio.file.Path;
45
import java.util.ArrayList;
49
import java.util.ArrayList;
46
import java.util.Arrays;
50
import java.util.Arrays;
47
import java.util.Collections;
51
import java.util.Collections;
48
import java.util.List;
52
import java.util.List;
49
import java.util.Set;
53
import java.util.Set;
54
import java.util.logging.Level;
55
import java.util.logging.Logger;
50
import org.netbeans.modules.php.api.framework.BadgeIcon;
56
import org.netbeans.modules.php.api.framework.BadgeIcon;
51
import org.netbeans.modules.php.api.phpmodule.PhpModule;
57
import org.netbeans.modules.php.api.phpmodule.PhpModule;
52
import org.netbeans.modules.php.api.phpmodule.PhpModuleProperties;
58
import org.netbeans.modules.php.api.phpmodule.PhpModuleProperties;
Lines 97-105 Link Here
97
        if (!result) {
103
        if (!result) {
98
            FileObject sourceDirectory = phpModule.getSourceDirectory();
104
            FileObject sourceDirectory = phpModule.getSourceDirectory();
99
            if (sourceDirectory != null) {
105
            if (sourceDirectory != null) {
100
                FileObject bootstrap = sourceDirectory.getFileObject(Constants.COMMON_BOOTSTRAP_PATH);
106
                FileObject bootstrap = getFileObject(sourceDirectory, Constants.COMMON_BOOTSTRAP_PATH);
101
                result = bootstrap != null && !bootstrap.isFolder() && bootstrap.isValid();
107
                result = bootstrap != null && !bootstrap.isFolder() && bootstrap.isValid();
102
                FileObject config = sourceDirectory.getFileObject(Constants.COMMON_CONFIG_PATH);
108
                FileObject config = getFileObject(sourceDirectory, Constants.COMMON_CONFIG_PATH);
103
                result = result && config != null && config.isFolder() && config.isValid();
109
                result = result && config != null && config.isFolder() && config.isValid();
104
            }
110
            }
105
        }
111
        }
Lines 181-184 Link Here
181
        return new Nette2CustomizerExtender(phpModule);
187
        return new Nette2CustomizerExtender(phpModule);
182
    }
188
    }
183
189
190
    /**
191
     * Try to get a FileObject with correct filename case. See bug 238679.
192
     *
193
     * @param parent Parent FileObject.
194
     * @param relPath Relative path, separated by slashes.
195
     */
196
    private FileObject getFileObject(FileObject parent, String relPath) {
197
        File parentFile = FileUtil.toFile(parent);
198
        if (parentFile != null) {
199
            String nativePath = relPath.replace('/', File.separatorChar);
200
            try {
201
                Path filePath = parentFile.toPath().resolve(nativePath);
202
                if (!Files.exists(filePath)) {
203
                    return null;
204
                }
205
                Path realPath = filePath.toRealPath(LinkOption.NOFOLLOW_LINKS);
206
                return FileUtil.toFileObject(realPath.toFile());
207
            } catch (IOException ex) {
208
                Logger.getLogger(Nette2FrameworkProvider.class.getName()).log(
209
                        Level.FINE, null, ex);
210
                return null;
211
            }
212
        } else {
213
            return null;
214
        }
215
    }
184
}
216
}
(-)a/php.symfony2/src/org/netbeans/modules/php/symfony2/commands/Symfony2Script.java (-1 / +19 lines)
Lines 47-52 Link Here
47
import java.io.IOException;
47
import java.io.IOException;
48
import java.io.InputStreamReader;
48
import java.io.InputStreamReader;
49
import java.io.Reader;
49
import java.io.Reader;
50
import java.nio.file.Files;
51
import java.nio.file.LinkOption;
52
import java.nio.file.Path;
50
import java.util.ArrayList;
53
import java.util.ArrayList;
51
import java.util.Arrays;
54
import java.util.Arrays;
52
import java.util.Collections;
55
import java.util.Collections;
Lines 117-123 Link Here
117
            // perhaps deleted app dir? fallback to default and let it fail later...
120
            // perhaps deleted app dir? fallback to default and let it fail later...
118
            return null;
121
            return null;
119
        }
122
        }
120
        return appDir.getFileObject(SCRIPT_NAME);
123
        File appDirFile = FileUtil.toFile(appDir); // #238679
124
        if (appDirFile != null) {
125
            try {
126
                Path filePath = appDirFile.toPath().resolve(SCRIPT_NAME);
127
                if (!Files.exists(filePath)) {
128
                    return null;
129
                }
130
                Path realPath = filePath.toRealPath(LinkOption.NOFOLLOW_LINKS);
131
                return FileUtil.toFileObject(realPath.toFile());
132
            } catch (IOException ex) {
133
                LOGGER.log(Level.FINE, null, ex);
134
                return null;
135
            }
136
        } else {
137
            return null;
138
        }
121
    }
139
    }
122
140
123
    /**
141
    /**
(-)a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/views/debugging/DebuggingViewComponent.java (-7 / +152 lines)
Lines 146-151 Link Here
146
    private Preferences preferences = NbPreferences.forModule(getClass()).node("debugging"); // NOI18N
146
    private Preferences preferences = NbPreferences.forModule(getClass()).node("debugging"); // NOI18N
147
    private PreferenceChangeListener prefListener;
147
    private PreferenceChangeListener prefListener;
148
    private SessionsComboBoxListener sessionsComboListener;
148
    private SessionsComboBoxListener sessionsComboListener;
149
    private VisibleTreePosition visibleTreePosition = null;
149
150
150
    private transient ImageIcon resumeIcon;
151
    private transient ImageIcon resumeIcon;
151
    private transient ImageIcon focusedResumeIcon;
152
    private transient ImageIcon focusedResumeIcon;
Lines 265-270 Link Here
265
        treeScrollBar.addAdjustmentListener(this);
266
        treeScrollBar.addAdjustmentListener(this);
266
267
267
        setSuspendTableVisible(preferences.getBoolean(FiltersDescriptor.SHOW_SUSPEND_TABLE, true));
268
        setSuspendTableVisible(preferences.getBoolean(FiltersDescriptor.SHOW_SUSPEND_TABLE, true));
269
270
        mainScrollPane.getVerticalScrollBar().addAdjustmentListener(
271
                new AdjustmentListener() {
272
273
                    @Override
274
                    public void adjustmentValueChanged(AdjustmentEvent e) {
275
                        if (e.getValueIsAdjusting()) {
276
                            storeScrollPosition();
277
                        }
278
                    }
279
                });
268
    }
280
    }
269
281
270
    /** This method is called from within the constructor to
282
    /** This method is called from within the constructor to
Lines 577-584 Link Here
577
            }
589
            }
578
            if (currentThread != null) {
590
            if (currentThread != null) {
579
                DVThread thread = threadMadeCurrentRef != null ? threadMadeCurrentRef.get() : null;
591
                DVThread thread = threadMadeCurrentRef != null ? threadMadeCurrentRef.get() : null;
580
                if (thread == currentThread) {
592
                if (thread != currentThread) {
581
                    threadToScrollRef = new WeakReference(thread);
593
                    threadToScrollRef = new WeakReference(currentThread);
582
                }
594
                }
583
            }
595
            }
584
            refreshView();
596
            refreshView();
Lines 682-690 Link Here
682
    
694
    
683
    @Override
695
    @Override
684
    public void treeExpanded(TreeExpansionEvent event) {
696
    public void treeExpanded(TreeExpansionEvent event) {
697
        TreePath path = event.getPath();
698
        checkIfWeShouldScrollToCurrentThread(path);
685
        refreshView();
699
        refreshView();
686
    }
700
    }
687
701
702
    /**
703
     * Check whether we should scroll to the current thread.
704
     *
705
     * @param path Path of node that has been just expanded, or that has new
706
     * children.
707
     */
708
    private void checkIfWeShouldScrollToCurrentThread(TreePath path) {
709
        Node node = Visualizer.findNode(path.getLastPathComponent());
710
        if (node == null) {
711
            return;
712
        }
713
        DVThread dvThread = node.getLookup().lookup(DVThread.class);
714
        DVThread currentThread;
715
        synchronized (lock) {
716
            currentThread = (debugger != null) ? debugger.getCurrentThread() : null;
717
        }
718
        if (currentThread != null && currentThread == dvThread) {
719
            threadToScrollRef = new WeakReference<DVThread>(dvThread);
720
        }
721
    }
722
688
    @Override
723
    @Override
689
    public void treeCollapsed(TreeExpansionEvent event) {
724
    public void treeCollapsed(TreeExpansionEvent event) {
690
        refreshView();
725
        refreshView();
Lines 697-702 Link Here
697
732
698
    @Override
733
    @Override
699
    public void treeNodesInserted(TreeModelEvent e) {
734
    public void treeNodesInserted(TreeModelEvent e) {
735
        TreePath path = e.getTreePath();
736
        checkIfWeShouldScrollToCurrentThread(path);
700
        refreshView();
737
        refreshView();
701
    }
738
    }
702
739
Lines 856-861 Link Here
856
        setRootContext(compoundModel, de);
893
        setRootContext(compoundModel, de);
857
    }
894
    }
858
    
895
    
896
    /**
897
     * Store first visible node and its offset. Called when the view is scrolled
898
     * by the user.
899
     */
900
    private void storeScrollPosition() {
901
902
        JTree tree = getJTree();
903
        if (tree != null) {
904
            int scrollTop = mainScrollPane.getViewport().getViewPosition().y;
905
            int row = tree.getRowForLocation(tree.getRowBounds(0).x + 1,
906
                    scrollTop);
907
            if (row >= 0) {
908
                TreePath path = tree.getPathForRow(row);
909
                if (path != null) {
910
                    int offset = tree.getRowBounds(row).y - scrollTop;
911
                    visibleTreePosition = new VisibleTreePosition(
912
                            path, offset);
913
                    return;
914
                }
915
            }
916
        }
917
        visibleTreePosition = null;
918
    }
919
920
    /**
921
     * Store visible offset of an important node. Called when the view is
922
     * scrolled by ViewRefresher
923
     *
924
     * @param path Path to a node that should stay visible at the same position.
925
     */
926
    private void storeScrollPosition(TreePath path) {
927
        JTree tree = getJTree();
928
        if (tree != null && path != null) {
929
            int row = tree.getRowForPath(path);
930
            if (row > 0) {
931
                int scrollTop = mainScrollPane.getViewport().getViewPosition().y;
932
                int offset = tree.getRowBounds(row).y - scrollTop;
933
                visibleTreePosition = new VisibleTreePosition(
934
                        path, offset);
935
                return;
936
            }
937
        }
938
        visibleTreePosition = null;
939
    }
940
941
    private JTree getJTree() {
942
        DebugTreeView treeView1 = getTreeView();
943
        if (treeView1 != null) {
944
            JTree tree = treeView1.getTree();
945
            if (tree != null && tree.getRowCount() > 0) {
946
                return tree;
947
            }
948
        }
949
        return null;
950
    }
951
952
    /**
953
     * Restore stored scroll position.
954
     */
955
    private void restoreScrollPosition() {
956
        if (visibleTreePosition != null) {
957
            JTree tree = getJTree();
958
            if (tree != null) {
959
                int row = tree.getRowForPath(visibleTreePosition.getPath());
960
                if (row != -1) {
961
                    Rectangle bounds = tree.getRowBounds(row);
962
                    if (bounds != null) {
963
                        int scrollY = bounds.y - visibleTreePosition.getOffset();
964
                        JViewport viewport = mainScrollPane.getViewport();
965
                        Rectangle rect = viewport.getViewRect();
966
                        rect.y = scrollY;
967
                        if (!rect.isEmpty()) {
968
                            ((JComponent) viewport.getView()).scrollRectToVisible(
969
                                    rect);
970
                        }
971
                    }
972
                }
973
            }
974
        }
975
    }
976
859
    // **************************************************************************
977
    // **************************************************************************
860
    // inner classes
978
    // inner classes
861
    // **************************************************************************
979
    // **************************************************************************
Lines 893-899 Link Here
893
            DVThread threadToScroll = threadToScrollRef != null ? threadToScrollRef.get() : null;
1011
            DVThread threadToScroll = threadToScrollRef != null ? threadToScrollRef.get() : null;
894
            threadToScrollRef = null;
1012
            threadToScrollRef = null;
895
            int scrollStart = -1, scrollEnd = -1;
1013
            int scrollStart = -1, scrollEnd = -1;
896
            boolean pathToScrollSearching = false;
897
1014
898
            int mainPanelHeight = 0;
1015
            int mainPanelHeight = 0;
899
            int treeViewWidth = 0;
1016
            int treeViewWidth = 0;
Lines 904-909 Link Here
904
            Object currentObject = null;
1021
            Object currentObject = null;
905
            int currentSY = 0;
1022
            int currentSY = 0;
906
            int height = 0;
1023
            int height = 0;
1024
            TreePath scrollPath = null;
907
1025
908
            if (tView != null) {
1026
            if (tView != null) {
909
                for (TreePath path : tView.getVisiblePaths()) {
1027
                for (TreePath path : tView.getVisiblePaths()) {
Lines 916-924 Link Here
916
                    height = rect != null ? (int) Math.round(rect.getHeight()) : 0;
1034
                    height = rect != null ? (int) Math.round(rect.getHeight()) : 0;
917
1035
918
                    if (dvThread != null || dvThreadGroup != null) {
1036
                    if (dvThread != null || dvThreadGroup != null) {
919
                        pathToScrollSearching = dvThread == threadToScroll;
1037
                        if (dvThread == threadToScroll) {
920
                        if (pathToScrollSearching) {
921
                            scrollStart = mainPanelHeight;
1038
                            scrollStart = mainPanelHeight;
1039
                            scrollEnd = scrollStart + height;
1040
                            scrollPath = path;
922
                        }
1041
                        }
923
                        if (currentObject != null) {
1042
                        if (currentObject != null) {
924
                            addPanels(currentObject, isCurrent, isAtBreakpoint, isInDeadlock,
1043
                            addPanels(currentObject, isCurrent, isAtBreakpoint, isInDeadlock,
Lines 946-953 Link Here
946
                    leftBarHeight += height;
1065
                    leftBarHeight += height;
947
                    sy += height;
1066
                    sy += height;
948
1067
949
                    if (pathToScrollSearching) {
1068
                    if (scrollPath != null && scrollPath.equals(path.getParentPath())) {
950
                        scrollEnd = mainPanelHeight;
1069
                        scrollEnd += height;
951
                    }
1070
                    }
952
                } // for
1071
                } // for
953
            } // if
1072
            } // if
Lines 977-983 Link Here
977
                Rectangle aRect = new Rectangle(0, scrollStart, 1, aRectHeight);
1096
                Rectangle aRect = new Rectangle(0, scrollStart, 1, aRectHeight);
978
                if (!aRect.isEmpty()) {
1097
                if (!aRect.isEmpty()) {
979
                    ((JComponent)viewport.getView()).scrollRectToVisible(aRect);
1098
                    ((JComponent)viewport.getView()).scrollRectToVisible(aRect);
1099
                    storeScrollPosition(scrollPath);
980
                }
1100
                }
1101
            } else {
1102
                restoreScrollPosition();
981
            }
1103
            }
982
        }
1104
        }
983
1105
Lines 1279-1282 Link Here
1279
1401
1280
    }
1402
    }
1281
1403
1404
    private class VisibleTreePosition {
1405
1406
        final TreePath path;
1407
        final int offset;
1408
1409
        public VisibleTreePosition(TreePath path, int offset) {
1410
            this.path = path;
1411
            this.offset = offset;
1412
        }
1413
1414
        public TreePath getPath() {
1415
            return path;
1416
        }
1417
1418
        public int getOffset() {
1419
            return offset;
1420
        }
1421
1422
        @Override
1423
        public String toString() {
1424
            return "VisibleTreePosition[" + path + ", " + offset + "]"; //NOI18N
1425
        }
1426
    }
1282
}
1427
}

Return to bug 238679