-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#31 Support for NB 8.2 - show outline again (widget hierarchy has bee…
…n changed in 8.2)
- Loading branch information
Showing
3 changed files
with
73 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 64 additions & 70 deletions
134
src/main/java/de/markiewb/netbeans/plugins/outline/OutlineSideBarFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,64 @@ | ||
/* | ||
* Copyright (C) 2015 markiewb | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
*/ | ||
package de.markiewb.netbeans.plugins.outline; | ||
|
||
import bluej.editor.moe.NaviView; | ||
import java.awt.Container; | ||
import java.awt.Dimension; | ||
import javax.swing.BorderFactory; | ||
import javax.swing.JComponent; | ||
import javax.swing.JScrollPane; | ||
import javax.swing.border.BevelBorder; | ||
import javax.swing.text.JTextComponent; | ||
|
||
/** | ||
* | ||
* @author markiewb | ||
*/ | ||
public class OutlineSideBarFactory implements org.netbeans.spi.editor.SideBarFactory { | ||
|
||
private final static int NAVIVIEW_WIDTH = 90; // width of the "naviview" (min-source) box | ||
private boolean enabled = true; | ||
|
||
@Override | ||
public JComponent createSideBar(JTextComponent jtc) { | ||
|
||
if (!enabled) { | ||
return null; | ||
} | ||
|
||
Container parent = jtc.getParent(); | ||
if (null == parent) { | ||
return null; | ||
} | ||
parent = parent.getParent(); | ||
if (null == parent) { | ||
return null; | ||
} | ||
if (parent instanceof JScrollPane && null != jtc.getDocument()) { | ||
|
||
JScrollPane scrollPane = (JScrollPane) parent; | ||
|
||
return new NaviViewExt(jtc.getDocument(), scrollPane.getVerticalScrollBar()); | ||
// scrollPane.getVerticalScrollBar().setUnitIncrement(16); | ||
// | ||
// NaviView naviView = new NaviView(jtc.getDocument(), scrollPane.getVerticalScrollBar()); | ||
// naviView.setPreferredSize(new Dimension(NAVIVIEW_WIDTH, 0)); | ||
// naviView.setMaximumSize(new Dimension(NAVIVIEW_WIDTH, Integer.MAX_VALUE)); | ||
//// naviView.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); | ||
// return naviView; | ||
} | ||
return null; | ||
|
||
} | ||
|
||
} | ||
/* | ||
* Copyright (C) 2015 markiewb | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
*/ | ||
package de.markiewb.netbeans.plugins.outline; | ||
|
||
import java.awt.Container; | ||
import javax.swing.JComponent; | ||
import javax.swing.JScrollPane; | ||
import javax.swing.text.JTextComponent; | ||
|
||
/** | ||
* | ||
* @author markiewb | ||
*/ | ||
public class OutlineSideBarFactory implements org.netbeans.spi.editor.SideBarFactory { | ||
|
||
@Override | ||
public JComponent createSideBar(JTextComponent jtc) { | ||
|
||
/** | ||
* <pre> | ||
* jtc.getParent() #8227 NbEditorUI$LayeredEditorPane | ||
* jtc.getParent().getParent() #8233 JViewport | ||
* jtc.getParent().getParent().getParent() #8234 JScrollPane | ||
* </pre> | ||
*/ | ||
Container parent = jtc.getParent(); | ||
if (null == parent) { | ||
return null; | ||
} | ||
parent = parent.getParent(); | ||
if (null == parent) { | ||
return null; | ||
} | ||
// a new container JViewport has been introduced in 8.2 | ||
parent = parent.getParent(); | ||
if (null == parent) { | ||
return null; | ||
} | ||
if (parent instanceof JScrollPane && null != jtc.getDocument()) { | ||
|
||
JScrollPane scrollPane = (JScrollPane) parent; | ||
|
||
return new NaviViewExt(jtc.getDocument(), scrollPane.getVerticalScrollBar()); | ||
} | ||
return null; | ||
|
||
} | ||
|
||
} |