@@ -246,7 +246,7 @@ public class TextEditor extends JFrame implements ActionListener,
246246 private FindAndReplaceDialog findDialog ;
247247 private JCheckBoxMenuItem autoSave , wrapLines , tabsEmulated , autoImport ,
248248 autocompletion , fallbackAutocompletion , keylessAutocompletion ,
249- markOccurences , paintTabs , whiteSpace , marginLine ;
249+ markOccurences , paintTabs , whiteSpace , marginLine , lockPane ;
250250 private ButtonGroup themeRadioGroup ;
251251 private JTextArea errorScreen = new JTextArea ();
252252
@@ -299,11 +299,13 @@ public class TextEditor extends JFrame implements ActionListener,
299299 private boolean incremental = false ;
300300 private DragSource dragSource ;
301301 private boolean layoutLoading = true ;
302+ private OutlineTreePanel sourceTreePanel ;
302303
303304 public static final ArrayList <TextEditor > instances = new ArrayList <>();
304305 public static final ArrayList <Context > contexts = new ArrayList <>();
305306
306307 public TextEditor (final Context context ) {
308+
307309 super ("Script Editor" );
308310 instances .add (this );
309311 contexts .add (context );
@@ -313,15 +315,10 @@ public TextEditor(final Context context) {
313315 // NB: All panes must be initialized before menus are assembled!
314316 tabbed = new JTabbedPane ();
315317 tree = new FileSystemTree (log );
316- body = new JSplitPane (JSplitPane .HORIZONTAL_SPLIT , new FileSystemTreePanel (tree , context ), tabbed );
317- try {// on Aqua L&F, 'one touch arrows' collide with borderless options button, which in turn are
318- // needed for proper resize of the search panel. Grrrrr....
319- if ("com.apple.laf.AquaLookAndFeel" .equals (UIManager .getLookAndFeel ().getClass ().getName ())) {
320- body .setOneTouchExpandable (false );
321- }
322- } catch (final Exception ignored ) {
323- // do nothing
324- }
318+ final JTabbedPane sideTabs = new JTabbedPane ();
319+ sideTabs .addTab ("File Explorer" , new FileSystemTreePanel (tree , context ));
320+ sideTabs .addTab ("Outline" , sourceTreePanel = new OutlineTreePanel (this ));
321+ body = new JSplitPane (JSplitPane .HORIZONTAL_SPLIT , sideTabs , tabbed );
325322
326323 // These items are dynamic and need to be initialized before EditorPane creation
327324 initializeDynamicMenuComponents ();
@@ -356,7 +353,7 @@ public TextEditor(final Context context) {
356353 makeJarWithSource = addToMenu (file , "Export as JAR (With Source)..." , 0 , 0 );
357354 makeJarWithSource .setMnemonic (KeyEvent .VK_X );
358355 file .addSeparator ();
359- final JCheckBoxMenuItem lockPane = new JCheckBoxMenuItem ("Lock (Make Read Only)" );
356+ lockPane = new JCheckBoxMenuItem ("Lock (Make Read Only)" );
360357 lockPane .setToolTipText ("Protects file from accidental editing" );
361358 file .add (lockPane );
362359 lockPane .addActionListener (e -> {
@@ -366,7 +363,6 @@ public TextEditor(final Context context) {
366363 new SetWritableAction ().actionPerformedImpl (e , getEditorPane ());
367364 }
368365 });
369- tabbed .addChangeListener (e -> lockPane .setSelected (getTab (tabbed .getSelectedIndex ()).editorPane .isLocked ()));
370366 JMenuItem jmi = new JMenuItem ("Revert..." );
371367 jmi .addActionListener (e -> {
372368 if (getEditorPane ().isLocked ()) {
@@ -552,7 +548,7 @@ public TextEditor(final Context context) {
552548 tabsMenu .setMnemonic (KeyEvent .VK_W );
553549 addMenubarSeparator (tabsMenu , "Panes:" );
554550 // Assume initial status from prefs or panel visibility
555- final JCheckBoxMenuItem jcmi1 = new JCheckBoxMenuItem ("File Explorer " ,
551+ final JCheckBoxMenuItem jcmi1 = new JCheckBoxMenuItem ("Side Pane " ,
556552 prefService .getInt (getClass (), MAIN_DIV_LOCATION , body .getDividerLocation ()) > 0
557553 || isLeftPaneExpanded (body ));
558554 jcmi1 .addItemListener (e -> collapseSplitPane (0 , !jcmi1 .isSelected ()));
@@ -677,8 +673,14 @@ public TextEditor(final Context context) {
677673
678674 // -- END MENUS --
679675
680- // Add the editor and output area
676+ // add tab-related listeners
681677 tabbed .addChangeListener (this );
678+ sideTabs .addChangeListener (e -> {
679+ if (sideTabs .getSelectedIndex () == 1 )
680+ sourceTreePanel .refreshSourceTree (getTab (tabbed .getSelectedIndex ()).editorPane );
681+ });
682+
683+ // Add the editor and output area
682684 new FileDrop (tabbed , files -> {
683685 final ArrayList <File > filteredFiles = new ArrayList <>();
684686 assembleFlatFileCollection (filteredFiles , files );
@@ -895,9 +897,7 @@ private void assembleEditMenu() {
895897 addMappedActionToMenu (editMenu , "Goto Matching Bracket" , EditorPaneActions .rstaGoToMatchingBracketAction , false );
896898
897899 final JMenuItem gotoType = new JMenuItem ("Goto Type..." );
898- gotoType .setAccelerator (KeyStroke .getKeyStroke (KeyEvent .VK_G , ctrl + shift )); // default is Ctrl+Shift+O
899- gotoType .setToolTipText (
900- "Alternative shortcut: " + getEditorPane ().getPaneActions ().getAcceleratorLabel ("GoToType" ));
900+ gotoType .setAccelerator (getEditorPane ().getPaneActions ().getAccelerator ("GoToType" ));
901901 gotoType .addActionListener (e -> {
902902 try {
903903 getTextArea ().getActionMap ().get ("GoToType" ).actionPerformed (e );
@@ -1976,6 +1976,7 @@ public void stateChanged(final ChangeEvent e) {
19761976 return ;
19771977 }
19781978 final EditorPane editorPane = getEditorPane (index );
1979+ lockPane .setSelected (editorPane .isLocked ());
19791980 editorPane .requestFocus ();
19801981 checkForOutsideChanges ();
19811982
@@ -2209,6 +2210,7 @@ public TextEditorTab open(final File file) {
22092210
22102211 updateLanguageMenu (tab .editorPane .getCurrentLanguage ());
22112212 tab .editorPane .getDocument ().addDocumentListener (this );
2213+ tab .editorPane .requestFocusInWindow ();
22122214 return tab ;
22132215 }
22142216 catch (final FileNotFoundException e ) {
@@ -2460,9 +2462,9 @@ public void updateTabAndFontSize(final boolean setByLanguage) {
24602462
24612463 public void updateUI (final boolean setByLanguage ) {
24622464 final EditorPane pane = getEditorPane ();
2463- if (pane .getCurrentLanguage () == null ) return ;
2465+ // if (pane.getCurrentLanguage() == null) return;
24642466
2465- if (setByLanguage ) {
2467+ if (setByLanguage && pane . getCurrentLanguage () != null ) {
24662468 if (pane .getCurrentLanguage ().getLanguageName ().equals ("Python" )) {
24672469 pane .setTabSize (4 );
24682470 }
@@ -2513,6 +2515,7 @@ else if (tabSize == Integer.parseInt(item.getText())) {
25132515 autocompletion .setState (pane .isAutoCompletionEnabled ());
25142516 fallbackAutocompletion .setState (pane .isAutoCompletionFallbackEnabled ());
25152517 keylessAutocompletion .setState (pane .isAutoCompletionKeyless ());
2518+ sourceTreePanel .refreshSourceTree (pane );
25162519 }
25172520
25182521 public void setEditorPaneFileName (final String baseName ) {
@@ -3928,7 +3931,7 @@ else if (file.isDirectory())
39283931 return collection ;
39293932 }
39303933
3931- private static Color getDisabledComponentColor () {
3934+ protected static Color getDisabledComponentColor () {
39323935 try {
39333936 return UIManager .getColor ("MenuItem.disabledForeground" );
39343937 } catch (final Exception ignored ) {
0 commit comments