⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dockablewindowmanager.java

📁 开源的java 编辑器源代码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
		//{{{ 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 _topToolbars = (topToolbars == null				? new Dimension(0,0)				: topToolbars.getPreferredSize());			Dimension _bottomToolbars = (bottomToolbars == null				? new Dimension(0,0)				: bottomToolbars.getPreferredSize());			int topButtonHeight = -1;			int bottomButtonHeight = -1;			int leftButtonWidth = -1;			int rightButtonWidth = -1;			Dimension _top = top.getPreferredSize();			Dimension _left = left.getPreferredSize();			Dimension _bottom = bottom.getPreferredSize();			Dimension _right = right.getPreferredSize();			int topHeight = _top.height;			int bottomHeight = _bottom.height;			int leftWidth = _left.width;			int rightWidth = _right.width;			boolean topEmpty = ((Container)topButtons)				.getComponentCount() <= 2;			boolean leftEmpty = ((Container)leftButtons)				.getComponentCount() <= 2;			boolean bottomEmpty = ((Container)bottomButtons)				.getComponentCount() <= 2;			boolean rightEmpty = ((Container)rightButtons)				.getComponentCount() <= 2;			Dimension closeBoxSize;			if(((Container)topButtons).getComponentCount() == 0)				closeBoxSize = new Dimension(0,0);			else			{				closeBoxSize = ((Container)topButtons)					.getComponent(0).getPreferredSize();			}			int closeBoxWidth = Math.max(closeBoxSize.width,				closeBoxSize.height) + 1;			if(alternateLayout)			{				//{{{ Lay out independent buttons				int _width = size.width;				int padding = (leftEmpty&&rightEmpty)					? 0 : closeBoxWidth;				topButtonHeight = DockableWindowManager.this.					top.getWrappedDimension(_width					- closeBoxWidth * 2);				topButtons.setBounds(					padding,					0,					size.width - padding * 2,					topButtonHeight);				bottomButtonHeight = DockableWindowManager.this.					bottom.getWrappedDimension(_width);				bottomButtons.setBounds(					padding,					size.height - bottomButtonHeight,					size.width - padding * 2,					bottomButtonHeight);				int _height = size.height					- topButtonHeight					- bottomButtonHeight;				//}}}				//{{{ Lay out dependent buttons				leftButtonWidth = DockableWindowManager.this.					left.getWrappedDimension(_height);				leftButtons.setBounds(					0,					topHeight + topButtonHeight,					leftButtonWidth,					_height - topHeight - bottomHeight);				rightButtonWidth = DockableWindowManager.this.					right.getWrappedDimension(_height);				rightButtons.setBounds(					size.width - rightButtonWidth,					topHeight + topButtonHeight,					rightButtonWidth,					_height - topHeight - bottomHeight);				//}}}				int[] dimensions = adjustDockingAreasToFit(					size,					topHeight,					leftWidth,					bottomHeight,					rightWidth,					topButtonHeight,					leftButtonWidth,					bottomButtonHeight,					rightButtonWidth,					_topToolbars,					_bottomToolbars);				topHeight = dimensions[0];				leftWidth = dimensions[1];				bottomHeight = dimensions[2];				rightWidth = dimensions[3];				//{{{ Lay out docking areas				top.setBounds(					0,					topButtonHeight,					size.width,					topHeight);				bottom.setBounds(					0,					size.height					- bottomHeight					- bottomButtonHeight,					size.width,					bottomHeight);				left.setBounds(					leftButtonWidth,					topButtonHeight + topHeight,					leftWidth,					_height - topHeight - bottomHeight);				right.setBounds(					_width - rightButtonWidth - rightWidth,					topButtonHeight + topHeight,					rightWidth,					_height - topHeight - bottomHeight); //}}}			}			else			{				//{{{ Lay out independent buttons				int _height = size.height;				int padding = (topEmpty && bottomEmpty					? 0 : closeBoxWidth);				leftButtonWidth = DockableWindowManager.this.					left.getWrappedDimension(_height					- closeBoxWidth * 2);				leftButtons.setBounds(					0,					padding,					leftButtonWidth,					_height - padding * 2);				rightButtonWidth = DockableWindowManager.this.					right.getWrappedDimension(_height);				rightButtons.setBounds(					size.width - rightButtonWidth,					padding,					rightButtonWidth,					_height - padding * 2);				int _width = size.width					- leftButtonWidth					- rightButtonWidth;				//}}}				//{{{ Lay out dependent buttons				topButtonHeight = DockableWindowManager.this.					top.getWrappedDimension(_width);				topButtons.setBounds(					leftButtonWidth + leftWidth,					0,					_width - leftWidth - rightWidth,					topButtonHeight);				bottomButtonHeight = DockableWindowManager.this.					bottom.getWrappedDimension(_width);				bottomButtons.setBounds(					leftButtonWidth + leftWidth,					_height - bottomButtonHeight,					_width - leftWidth - rightWidth,					bottomButtonHeight); //}}}				int[] dimensions = adjustDockingAreasToFit(					size,					topHeight,					leftWidth,					bottomHeight,					rightWidth,					topButtonHeight,					leftButtonWidth,					bottomButtonHeight,					rightButtonWidth,					_topToolbars,					_bottomToolbars);				topHeight = dimensions[0];				leftWidth = dimensions[1];				bottomHeight = dimensions[2];				rightWidth = dimensions[3];				//{{{ Lay out docking areas				top.setBounds(					leftButtonWidth + leftWidth,					topButtonHeight,					_width - leftWidth - rightWidth,					topHeight);				bottom.setBounds(					leftButtonWidth + leftWidth,					size.height - bottomHeight - bottomButtonHeight,					_width - leftWidth - rightWidth,					bottomHeight);				left.setBounds(					leftButtonWidth,					0,					leftWidth,					_height);				right.setBounds(					size.width - rightWidth - rightButtonWidth,					0,					rightWidth,					_height); //}}}			}			//{{{ Position tool bars if they are managed by us			if(topToolbars != null)			{				topToolbars.setBounds(					leftButtonWidth + leftWidth,					topButtonHeight + topHeight,					size.width - leftWidth - rightWidth					- leftButtonWidth - rightButtonWidth,					_topToolbars.height);			}			if(bottomToolbars != null)			{				bottomToolbars.setBounds(					leftButtonWidth + leftWidth,					size.height - bottomHeight					- bottomButtonHeight					- _bottomToolbars.height					+ topButtonHeight					+ topHeight,					size.width - leftWidth - rightWidth					- leftButtonWidth - rightButtonWidth,					_bottomToolbars.height);			} //}}}			//{{{ Position center (edit pane, or split pane)			if(center != null)			{				center.setBounds(					leftButtonWidth + leftWidth,					topButtonHeight + topHeight					+ _topToolbars.height,					size.width					- leftWidth					- rightWidth					- leftButtonWidth					- rightButtonWidth,					size.height					- topHeight					- topButtonHeight					- bottomHeight					- bottomButtonHeight					- _topToolbars.height					- _bottomToolbars.height);			} //}}}		} //}}}		//{{{ adjustDockingAreasToFit() method		private int[] adjustDockingAreasToFit(			Dimension size,			int topHeight,			int leftWidth,			int bottomHeight,			int rightWidth,			int topButtonHeight,			int leftButtonWidth,			int bottomButtonHeight,			int rightButtonWidth,			Dimension _topToolbars,			Dimension _bottomToolbars)		{			int maxTopHeight = size.height - bottomHeight				- topButtonHeight - bottomButtonHeight				- _topToolbars.height - _bottomToolbars.height;			topHeight = Math.min(Math.max(0,maxTopHeight),				topHeight);			leftWidth = Math.min(Math.max(0,				size.width - leftButtonWidth				- rightButtonWidth - rightWidth),leftWidth);			int maxBottomHeight = size.height - topHeight				- topButtonHeight - bottomButtonHeight				- _topToolbars.height - _bottomToolbars.height;			bottomHeight = Math.min(Math.max(0,maxBottomHeight),				bottomHeight);			rightWidth = Math.min(Math.max(0,				size.width - leftButtonWidth				- rightButtonWidth - leftWidth),rightWidth);			DockableWindowManager.this.top.setDimension(topHeight);			DockableWindowManager.this.left.setDimension(leftWidth);			DockableWindowManager.this.bottom.setDimension(bottomHeight);			DockableWindowManager.this.right.setDimension(rightWidth);			return new int[] {				topHeight,				leftWidth,				bottomHeight,				rightWidth			};		} //}}}		//{{{ 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;		// only for docked		AbstractButton btn;		//{{{ 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 = getDockableTitle(factory.name);		} //}}}	} //}}}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -