📄 dockablewindowmanager.java
字号:
} if(newPosition.equals(FLOATING)) /* do nothing */; else { if(newPosition.equals(TOP)) entry.container = top; else if(newPosition.equals(LEFT)) entry.container = left; else if(newPosition.equals(BOTTOM)) entry.container = bottom; else if(newPosition.equals(RIGHT)) entry.container = right; else throw new InternalError("Unknown position: " + newPosition); entry.container.register(entry); } } } if(entry.container instanceof FloatingWindowContainer) { SwingUtilities.updateComponentTreeUI(((JFrame)entry.container) .getRootPane()); } } } //}}} //{{{ Private members private View view; private Hashtable windows; private boolean alternateLayout; private PanelWindowContainer left; private PanelWindowContainer right; private PanelWindowContainer top; private PanelWindowContainer bottom; //}}} //}}} //{{{ DockableLayout class public class DockableLayout implements LayoutManager2 { // for backwards compatibility with plugins that fiddle with // jEdit's UI layout static final String CENTER = BorderLayout.CENTER; public static final String TOP_TOOLBARS = "top-toolbars"; public static final String BOTTOM_TOOLBARS = "bottom-toolbars"; static final String TOP_BUTTONS = "top-buttons"; static final String LEFT_BUTTONS = "left-buttons"; static final String BOTTOM_BUTTONS = "bottom-buttons"; static final String RIGHT_BUTTONS = "right-buttons"; Component topToolbars, bottomToolbars; Component center; Component top, left, bottom, right; Component topButtons, leftButtons, bottomButtons, rightButtons; //{{{ addLayoutComponent() method public void addLayoutComponent(String name, Component comp) { addLayoutComponent(comp,name); } //}}} //{{{ addLayoutComponent() method public void addLayoutComponent(Component comp, Object cons) { if(cons == null || CENTER.equals(cons)) center = comp; else if(TOP_TOOLBARS.equals(cons)) topToolbars = comp; else if(BOTTOM_TOOLBARS.equals(cons)) bottomToolbars = comp; else if(TOP.equals(cons)) top = comp; else if(LEFT.equals(cons)) left = comp; else if(BOTTOM.equals(cons)) bottom = comp; else if(RIGHT.equals(cons)) right = comp; else if(TOP_BUTTONS.equals(cons)) topButtons = comp; else if(LEFT_BUTTONS.equals(cons)) leftButtons = comp; else if(BOTTOM_BUTTONS.equals(cons)) bottomButtons = comp; else if(RIGHT_BUTTONS.equals(cons)) rightButtons = comp; } //}}} //{{{ removeLayoutComponent() method public void removeLayoutComponent(Component comp) { if(center == comp) center = null; if(comp == topToolbars) topToolbars = null; if(comp == bottomToolbars) bottomToolbars = null; { // none of the others are ever meant to be // removed. retarded, eh? this needs to be // fixed eventually, for plugins might // want to do weird stuff to jEdit's UI } } //}}} //{{{ preferredLayoutSize() method public Dimension preferredLayoutSize(Container parent) { Dimension prefSize = new Dimension(0,0); Dimension _top = top.getPreferredSize(); Dimension _left = left.getPreferredSize(); Dimension _bottom = bottom.getPreferredSize(); Dimension _right = right.getPreferredSize(); Dimension _topButtons = topButtons.getPreferredSize(); Dimension _leftButtons = leftButtons.getPreferredSize(); Dimension _bottomButtons = bottomButtons.getPreferredSize(); Dimension _rightButtons = rightButtons.getPreferredSize(); Dimension _center = (center == null ? new Dimension(0,0) : center.getPreferredSize()); Dimension _topToolbars = (topToolbars == null ? new Dimension(0,0) : topToolbars.getPreferredSize()); Dimension _bottomToolbars = (bottomToolbars == null ? new Dimension(0,0) : bottomToolbars.getPreferredSize()); prefSize.height = _top.height + _bottom.height + _center.height + _topButtons.height + _bottomButtons.height + _topToolbars.height + _bottomToolbars.height; prefSize.width = _left.width + _right.width + Math.max(_center.width, Math.max(_topToolbars.width,_bottomToolbars.width)) + _leftButtons.width + _rightButtons.width; return prefSize; } //}}} //{{{ minimumLayoutSize() method public Dimension minimumLayoutSize(Container parent) { // I'm lazy return preferredLayoutSize(parent); } //}}} //{{{ maximumLayoutSize() method public Dimension maximumLayoutSize(Container parent) { return new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE); } //}}} //{{{ layoutContainer() method public void layoutContainer(Container parent) { Dimension size = parent.getSize(); Dimension _topButtons = topButtons.getPreferredSize(); Dimension _leftButtons = leftButtons.getPreferredSize(); Dimension _bottomButtons = bottomButtons.getPreferredSize(); Dimension _rightButtons = rightButtons.getPreferredSize(); Dimension _topToolbars = (topToolbars == null ? new Dimension(0,0) : topToolbars.getPreferredSize()); Dimension _bottomToolbars = (bottomToolbars == null ? new Dimension(0,0) : bottomToolbars.getPreferredSize()); int _width = size.width - _leftButtons.width - _rightButtons.width; int _height = size.height - _topButtons.height - _bottomButtons.height; Dimension _top = top.getPreferredSize(); Dimension _left = left.getPreferredSize(); Dimension _bottom = bottom.getPreferredSize(); Dimension _right = right.getPreferredSize(); int topHeight = Math.min(Math.max(0,_height - _bottom.height),_top.height); int leftWidth = Math.min(Math.max(0,_width - _right.width),_left.width); int bottomHeight = Math.min(Math.max(0,_height - topHeight),_bottom.height); int rightWidth = Math.min(Math.max(0,_width - leftWidth),_right.width); DockableWindowManager.this.top.setDimension(topHeight); DockableWindowManager.this.left.setDimension(leftWidth); DockableWindowManager.this.bottom.setDimension(bottomHeight); DockableWindowManager.this.right.setDimension(rightWidth); if(alternateLayout) { topButtons.setBounds( _leftButtons.width, 0, _width, _topButtons.height); leftButtons.setBounds( 0, _topButtons.height + _top.height, _leftButtons.width, _height - _top.height - _bottom.height); bottomButtons.setBounds( _leftButtons.width, size.height - _bottomButtons.height, _width, _bottomButtons.height); rightButtons.setBounds( size.width - _rightButtons.width, _topButtons.height + _top.height, _rightButtons.width, _height - _top.height - _bottom.height); top.setBounds( _leftButtons.width, _topButtons.height, _width, topHeight); bottom.setBounds( _leftButtons.width, size.height - bottomHeight - _bottomButtons.height, _width, bottomHeight); left.setBounds( _leftButtons.width, _topButtons.height + topHeight, leftWidth, _height - topHeight - bottomHeight); right.setBounds( size.width - rightWidth - _rightButtons.width, _topButtons.height + topHeight, rightWidth, _height - topHeight - bottomHeight); } else { topButtons.setBounds( _leftButtons.width + leftWidth, 0, _width - leftWidth - rightWidth, _topButtons.height); leftButtons.setBounds( 0, _topButtons.height, _leftButtons.width, _height); bottomButtons.setBounds( _leftButtons.width + leftWidth, size.height - _bottomButtons.height, _width - leftWidth - rightWidth, _bottomButtons.height); rightButtons.setBounds( size.width - _rightButtons.width, _topButtons.height, _rightButtons.width, _height); top.setBounds( _leftButtons.width + leftWidth, _topButtons.height, _width - leftWidth - rightWidth, topHeight); bottom.setBounds( _leftButtons.width + leftWidth, size.height - bottomHeight - _bottomButtons.height, _width - leftWidth - rightWidth, bottomHeight); left.setBounds( _leftButtons.width, _topButtons.height, leftWidth, _height); right.setBounds( size.width - rightWidth - _rightButtons.width, _topButtons.height, rightWidth, _height); } if(topToolbars != null) { topToolbars.setBounds( _leftButtons.width + _left.width, _topButtons.height + _top.height, _width - _left.width - _right.width, _topToolbars.height); } if(bottomToolbars != null) { bottomToolbars.setBounds( _leftButtons.width + _left.width, _height - _bottom.height - _bottomToolbars.height + _topButtons.height, _width - _left.width - _right.width, _bottomToolbars.height); } if(center != null) { center.setBounds( _leftButtons.width + _left.width, _topButtons.height + _top.height + _topToolbars.height, _width - _left.width - _right.width, _height - _top.height - _bottom.height - _topToolbars.height - _bottomToolbars.height); } } //}}} //{{{ getLayoutAlignmentX() method public float getLayoutAlignmentX(Container target) { return 0.5f; } //}}} //{{{ getLayoutAlignmentY() method public float getLayoutAlignmentY(Container target) { return 0.5f; } //}}} //{{{ invalidateLayout() method public void invalidateLayout(Container target) {} //}}} } //}}} //{{{ Entry class class Entry { Factory factory; String title; String position; DockableWindowContainer container; // only set if open JComponent win; //{{{ Entry constructor Entry(Factory factory) { this(factory,jEdit.getProperty(factory.name + ".dock-position",FLOATING)); } //}}} //{{{ Entry constructor Entry(Factory factory, String position) { this.factory = factory; this.position = position; // get the title here, not in the factory constructor, // since the factory might be created before a plugin's // props are loaded title = jEdit.getProperty(factory.name + ".title"); if(title == null) title = "NO TITLE PROPERTY: " + factory.name; if(position == null) position = FLOATING; else if(position.equals(FLOATING)) /* do nothing */; else { if(position.equals(TOP)) container = top; else if(position.equals(LEFT)) container = left; else if(position.equals(BOTTOM)) container = bottom; else if(position.equals(RIGHT)) container = right; else throw new InternalError("Unknown position: " + position); container.register(this); } } //}}} //{{{ open() method void open() { win = factory.createDockableWindow(view,position); if(win == null) { // error occurred return; } Log.log(Log.DEBUG,this,"Adding " + factory.name + " with position " + position); if(position.equals(FLOATING)) { container = new FloatingWindowContainer( DockableWindowManager.this); container.register(this); } container.add(this); } //}}} //{{{ remove() method void remove() { Log.log(Log.DEBUG,this,"Removing " + factory.name + " from " + container); container.save(this); container.remove(this); if(container instanceof FloatingWindowContainer) container = null; win = null; } //}}} } //}}}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -