📄 dockablewindowmanager.java
字号:
return true; } //}}} //{{{ isSelected() method public boolean isSelected(View view) { return view.getDockableWindowManager() .isDockableWindowVisible(name); } //}}} //{{{ getCode() method public String getCode() { return "view.getDockableWindowManager()" + ".toggleDockableWindow(\"" + name + "\");"; } //}}} //{{{ getLabel() method public String getLabel() { String[] args = { jEdit.getProperty(name + ".label") }; return jEdit.getProperty("view.docking.toggle.label",args); } //}}} } //}}} //{{{ FloatAction class class FloatAction extends EditAction { //{{{ FloatAction constructor FloatAction() { super(name + "-float"); } //}}} //{{{ invoke() method public void invoke(View view) { view.getDockableWindowManager() .floatDockableWindow(name); } //}}} //{{{ getCode() method public String getCode() { return "view.getDockableWindowManager()" + ".floatDockableWindow(\"" + name + "\");"; } //}}} //{{{ getLabel() method public String getLabel() { String[] args = { jEdit.getProperty(name + ".label") }; return jEdit.getProperty("view.docking.float.label",args); } //}}} } //}}} } //}}} private static Vector dockableWindowFactories; //{{{ Static initializer static { dockableWindowFactories = new Vector(); } //}}} //}}} //{{{ Instance part of class //{{{ DockableWindowManager constructor /** * Creates a new dockable window manager. * @param view The view * @since jEdit 2.6pre3 */ public DockableWindowManager(View view) { setLayout(new DockableLayout()); this.view = view; windows = new Hashtable(); top = new PanelWindowContainer(this,TOP); left = new PanelWindowContainer(this,LEFT); bottom = new PanelWindowContainer(this,BOTTOM); right = new PanelWindowContainer(this,RIGHT); add(DockableLayout.TOP_BUTTONS,top.getButtonBox()); add(DockableLayout.LEFT_BUTTONS,left.getButtonBox()); add(DockableLayout.BOTTOM_BUTTONS,bottom.getButtonBox()); add(DockableLayout.RIGHT_BUTTONS,right.getButtonBox()); add(TOP,top.getDockablePanel()); add(LEFT,left.getDockablePanel()); add(BOTTOM,bottom.getDockablePanel()); add(RIGHT,right.getDockablePanel()); } //}}} //{{{ init() method /** * Initialises dockable window manager. * @since jEdit 2.6pre3 */ public void init() { for(int i = 0; i < dockableWindowFactories.size(); i++) { Factory factory = (Factory) dockableWindowFactories.elementAt(i); Entry e; if(view.isPlainView()) e = new Entry(factory,FLOATING); else e = new Entry(factory); windows.put(factory.name,e); } if(!view.isPlainView()) { String lastTop = jEdit.getProperty("view.dock.top.last"); if(lastTop != null && lastTop.length() != 0) showDockableWindow(lastTop); String lastLeft = jEdit.getProperty("view.dock.left.last"); if(lastLeft != null && lastLeft.length() != 0) showDockableWindow(lastLeft); String lastBottom = jEdit.getProperty("view.dock.bottom.last"); if(lastBottom != null && lastBottom.length() != 0) showDockableWindow(lastBottom); String lastRight = jEdit.getProperty("view.dock.right.last"); if(lastRight != null && lastRight.length() != 0) showDockableWindow(lastRight); } } //}}} //{{{ getView() method /** * Returns this dockable window manager's view. * @since jEdit 4.0pre2 */ public View getView() { return view; } //}}} //{{{ floatDockableWindow() method /** * Opens a new instance of the specified dockable window in a floating * container. * @param name The dockable window name * @return The new dockable window instance * @since jEdit 4.1pre2 */ public JComponent floatDockableWindow(String name) { Entry entry = (Entry)windows.get(name); if(entry == null) { Log.log(Log.ERROR,this,"Unknown dockable window: " + name); return null; } // create a copy of this dockable window and float it Entry newEntry = new Entry(entry.factory,FLOATING); newEntry.open(); if(newEntry.win != null) newEntry.container.show(newEntry); return newEntry.win; } //}}} //{{{ showDockableWindow() method /** * Opens the specified dockable window. * @param name The dockable window name * @since jEdit 2.6pre3 */ public void showDockableWindow(String name) { Entry entry = (Entry)windows.get(name); if(entry == null) { Log.log(Log.ERROR,this,"Unknown dockable window: " + name); return; } if(entry.win == null) entry.open(); if(entry.win != null) entry.container.show(entry); else /* an error occurred */; } //}}} //{{{ addDockableWindow() method /** * Opens the specified dockable window. As of version 4.0pre1, has the same * effect as calling showDockableWindow(). * @param name The dockable window name * @since jEdit 2.6pre3 */ public void addDockableWindow(String name) { showDockableWindow(name); } //}}} //{{{ removeDockableWindow() method /** * Removes the specified dockable window. * @param name The dockable window name * @since jEdit 2.6pre3 */ public void removeDockableWindow(String name) { Entry entry = (Entry)windows.get(name); if(entry == null) { Log.log(Log.ERROR,this,"This DockableWindowManager" + " does not have a window named " + name); return; } if(entry.win == null) return; if(entry.container instanceof FloatingWindowContainer) { entry.container.save(entry); entry.container.remove(entry); entry.container = null; entry.win = null; } else entry.container.show(null); } //}}} //{{{ toggleDockableWindow() method /** * Toggles the visibility of the specified dockable window. * @param name The dockable window name */ public void toggleDockableWindow(String name) { if(isDockableWindowVisible(name)) removeDockableWindow(name); else addDockableWindow(name); } //}}} //{{{ getDockableWindow() method /** * Returns the specified dockable window. * @param name The name of the dockable window * @since jEdit 4.1pre2 */ public JComponent getDockableWindow(String name) { return getDockable(name); } //}}} //{{{ getDockable() method /** * Returns the specified dockable window. For historical reasons, this * does the same thing as {@link #getDockableWindow(String)}. * @param name The name of the dockable window * @since jEdit 4.0pre1 */ public JComponent getDockable(String name) { Entry entry = (Entry)windows.get(name); if(entry == null || entry.win == null) return null; else return entry.win; } //}}} //{{{ getDockableTitle() method /** * Returns the title of the specified dockable window. * @param name The name of the dockable window. * @since jEdit 4.1pre5 */ public String getDockableTitle(String name) { Entry entry = (Entry)windows.get(name); if(entry == null) return null; else return entry.title; } //}}} //{{{ isDockableWindowVisible() method /** * Returns if the specified dockable window is visible. * @param name The dockable window name */ public boolean isDockableWindowVisible(String name) { Entry entry = (Entry)windows.get(name); if(entry == null || entry.win == null) return false; else return entry.container.isVisible(entry); } //}}} //{{{ isDockableWindowDocked() method /** * Returns if the specified dockable window is docked into the * view. * @param name The dockable's name * @since jEdit 4.0pre2 */ public boolean isDockableWindowDocked(String name) { Entry entry = (Entry)windows.get(name); if(entry == null) return false; else return (entry.position != FLOATING); } //}}} //{{{ closeCurrentArea() method /** * Closes the currently focused docking area. * @since jEdit 4.1pre3 */ public void closeCurrentArea() { // I don't know of any other way to fix this, since invoking this // command from a menu results in the focus owner being the menu // until the menu goes away. SwingUtilities.invokeLater(new Runnable() { public void run() { Component comp = view.getFocusOwner(); while(comp != null) { //System.err.println(comp.getClass()); if(comp instanceof PanelWindowContainer .DockablePanel) { PanelWindowContainer container = ((PanelWindowContainer.DockablePanel) comp).getWindowContainer(); container.show(null); return; } comp = comp.getParent(); } getToolkit().beep(); } }); } //}}} //{{{ close() method /** * Called when the view is being closed. * @since jEdit 2.6pre3 */ public void close() { if(!view.isPlainView()) { top.save(); left.save(); bottom.save(); right.save(); } Enumeration enum = windows.elements(); while(enum.hasMoreElements()) { Entry entry = (Entry)enum.nextElement(); if(entry.win != null) entry.remove(); } } //}}} //{{{ getTopDockingArea() method public PanelWindowContainer getTopDockingArea() { return top; } //}}} //{{{ getLeftDockingArea() method public PanelWindowContainer getLeftDockingArea() { return left; } //}}} //{{{ getBottomDockingArea() method public PanelWindowContainer getBottomDockingArea() { return bottom; } //}}} //{{{ getRightDockingArea() method public PanelWindowContainer getRightDockingArea() { return right; } //}}} //{{{ propertiesChanged() method /** * Called by the view when properties change. * @since jEdit 2.6pre3 */ public void propertiesChanged() { alternateLayout = jEdit.getBooleanProperty("view.docking.alternateLayout"); Enumeration enum = windows.elements(); while(enum.hasMoreElements()) { Entry entry = (Entry)enum.nextElement(); if(!view.isPlainView()) { String position = entry.position; String newPosition = jEdit.getProperty(entry.factory.name + ".dock-position"); if(newPosition != null /* ??? */ && !newPosition.equals(position)) { entry.position = newPosition; if(entry.container != null) { entry.container.remove(entry); entry.container = null; entry.win = null;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -