[prev in list] [next in list] [prev in thread] [next in thread]
List: jedit-cvs
Subject: [ jEdit-commits ] SF.net SVN: jedit: [9355]
From: ezust () users ! sourceforge ! net
Date: 2007-03-29 23:18:27
Message-ID: E1HX3sx-0004vl-P8 () sc8-pr-svn4 ! sourceforge ! net
[Download RAW message or body]
Revision: 9355
http://svn.sourceforge.net/jedit/?rev=9355&view=rev
Author: ezust
Date: 2007-03-29 16:18:27 -0700 (Thu, 29 Mar 2007)
Log Message:
-----------
cleanup of ViewHandlers when the plugin is stopped.
Modified Paths:
--------------
plugins/Docker/trunk/docker/DockFocusManager.java
plugins/Docker/trunk/docker/DockerPlugin.java
plugins/Docker/trunk/docker/ViewHandler.java
Modified: plugins/Docker/trunk/docker/DockFocusManager.java
===================================================================
--- plugins/Docker/trunk/docker/DockFocusManager.java 2007-03-29 23:01:18 UTC (rev \
9354)
+++ plugins/Docker/trunk/docker/DockFocusManager.java 2007-03-29 23:18:27 UTC (rev \
9355) @@ -28,6 +28,7 @@
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.util.ArrayList;
+import java.util.Stack;
import javax.swing.SwingUtilities;
@@ -47,7 +48,7 @@
{
ArrayList <Triple> tlist = new ArrayList<Triple>();
- ArrayList <Container> clist = new ArrayList<Container>();
+ Stack <Container> clist = new Stack<Container>();
public DockFocusManager()
{
@@ -67,12 +68,14 @@
}
}
- public void destroy() {
+ public void destroy()
+ {
for (Triple t: tlist) {
t.view.setFocusTraversalPolicy(t.oftp);
}
tlist.clear();
- for (Container c: clist) {
+ while (!clist.empty()) {
+ Container c = clist.pop();
c.removeContainerListener(this);
}
clist.clear();
@@ -163,7 +166,7 @@
{
Container c = (Container)view.getDockableWindowManager().getComponent(compIdx);
c.addContainerListener(this);
- clist.add(c);
+ clist.push(c);
}
/** Temporary storage to remember what we need to clean up at plugin unload time */
Modified: plugins/Docker/trunk/docker/DockerPlugin.java
===================================================================
--- plugins/Docker/trunk/docker/DockerPlugin.java 2007-03-29 23:01:18 UTC (rev 9354)
+++ plugins/Docker/trunk/docker/DockerPlugin.java 2007-03-29 23:18:27 UTC (rev 9355)
@@ -56,11 +56,8 @@
{
static private Icon dockIcon;
-
private Map<View, ViewHandler> handlers;
-
private DockerConfig config;
-
private DockFocusManager dfm;
/**
@@ -118,13 +115,11 @@
{
if (editPaneUpdate.getWhat().equals(EditPaneUpdate.CREATED))
{
- viewHandler.editPaneCreated(editPaneUpdate
- .getEditPane());
+ viewHandler.editPaneCreated(editPaneUpdate.getEditPane());
}
else
{
- viewHandler.editPaneDestroyed(editPaneUpdate
- .getEditPane());
+ viewHandler.editPaneDestroyed(editPaneUpdate.getEditPane());
}
}
}
@@ -136,8 +131,7 @@
*/
public void showTopDockPopup(View view)
{
- showDockPopup(view, view.getDockableWindowManager().getTopDockingArea(),
- "docker.popup.top-dock");
+ showDockPopup(view, view.getDockableWindowManager().getTopDockingArea(), \
"docker.popup.top-dock"); }
/**
@@ -177,6 +171,12 @@
{
EditBus.removeFromBus(dfm);
dfm.destroy();
+ Iterator<ViewHandler> itr = handlers.values().iterator();
+ while (itr.hasNext()) {
+ ViewHandler vh = itr.next();
+ vh.detach();
+ }
+ handlers.clear();
}
/**
@@ -200,7 +200,7 @@
*/
private void detach(View view)
{
- ((ViewHandler) handlers.remove(view)).detach();
+ handlers.remove(view).detach();
}
/**
@@ -210,13 +210,13 @@
String actionName)
{
String[] names = dock.getDockables();
- List items = new ArrayList(names.length + 1);
+ List<DockListItem> items = new ArrayList<DockListItem>(names.length + 1);
items.add(new DockListItem(view.getDockableWindowManager(), null));
for (int i = 0; i < names.length; i++)
{
items.add(new DockListItem(view.getDockableWindowManager(), names[i]));
}
- PopupList popup = PopupList.show(view, items, getCurrentDockable(view, dock),
+ PopupList popup = PopupList.show(view, items, getCurrentDockable(view, dock),
new ActionListener()
{
public void actionPerformed(ActionEvent evt)
@@ -226,51 +226,34 @@
if (name == null)
{
dock.show(null);
- view
- .addWindowFocusListener(new java.awt.event.WindowAdapter()
+ view.addWindowFocusListener(new java.awt.event.WindowAdapter()
{
- public void windowGainedFocus(
- WindowEvent evt)
+ public void windowGainedFocus(WindowEvent evt)
{
- view.getEditPane()
- .getTextArea()
- .requestFocus();
- view
- .removeWindowFocusListener(this);
- super
- .windowGainedFocus(evt);
+ view.getEditPane().getTextArea().requestFocus();
+ view.removeWindowFocusListener(this);
+ super.windowGainedFocus(evt);
}
});
popup.cancel();
/*
- * Log.log(Log.DEBUG, this,
- * "Sending focus to text
- * area");
+ * Log.log(Log.DEBUG, this, "Sending focus to text area");
* view.getEditPane().getTextArea().requestFocus();
*/
}
else
{
- Log.log(Log.DEBUG, this,
- "Sending focus to dockable: " + name);
- view
- .addWindowFocusListener(new java.awt.event.WindowAdapter()
+ Log.log(Log.DEBUG, this, "Sending focus to dockable: " + name);
+ view.addWindowFocusListener(new java.awt.event.WindowAdapter()
{
- public void windowGainedFocus(
- WindowEvent evt)
+ public void windowGainedFocus(WindowEvent evt)
{
- view
- .getDockableWindowManager()
- .getDockable(name)
- .requestDefaultFocus();
- view
- .removeWindowFocusListener(this);
- super
- .windowGainedFocus(evt);
+ view.getDockableWindowManager().getDockable(name).requestFocus();
+ view.removeWindowFocusListener(this);
+ super.windowGainedFocus(evt);
}
});
- view.getDockableWindowManager().showDockableWindow(
- name);
+ view.getDockableWindowManager().showDockableWindow(name);
}
}
});
Modified: plugins/Docker/trunk/docker/ViewHandler.java
===================================================================
--- plugins/Docker/trunk/docker/ViewHandler.java 2007-03-29 23:01:18 UTC (rev 9354)
+++ plugins/Docker/trunk/docker/ViewHandler.java 2007-03-29 23:18:27 UTC (rev 9355)
@@ -32,149 +32,175 @@
import org.gjt.sp.jedit.gui.PanelWindowContainer;
/**
- * Handles auto-hiding when the EditPane gets focus.
+ * Handles auto-hiding when the EditPane gets focus. One of these is created for \
each View.
*
*/
public class ViewHandler implements FocusListener
{
- private View view;
- private Map<String, DockHandler> docks;
- private Set<EditPane> editPanes;
- private DockerConfig config;
+ private View view;
- /**
- * Create a new <code>ViewHandler</code>
- */
- public ViewHandler(View aView) {
- view = aView;
- docks = new HashMap<String, DockHandler>(4);
- editPanes = new HashSet<EditPane>(2);
- config = DockerPlugin.getPlugin().getConfig();
- init();
- }
+ private Map<String, DockHandler> docks;
- /**
- * Initialize this handler.
- */
- public void init() {
- docks.clear();
- attachDock(DockableWindowManager.TOP);
- attachDock(DockableWindowManager.LEFT);
- attachDock(DockableWindowManager.BOTTOM);
- attachDock(DockableWindowManager.RIGHT);
- EditPane[] editPanes = view.getEditPanes();
- for (int i=0; i<editPanes.length; i++) {
- editPaneCreated(editPanes[i]);
- }
- }
+ private Set<EditPane> editPanes;
- /**
- * Detach this handler from the view.
- */
- public void detach()
- {
- for (Iterator i = docks.values().iterator(); i.hasNext();) {
- ((DockHandler) i.next()).detach();
- }
- EditPane[] editPanes = view.getEditPanes();
- for (int i=0; i<editPanes.length; i++) {
- editPaneDestroyed(editPanes[i]);
- }
- }
+ private DockerConfig config;
- /**
- * Handle an edit pane creation message.
- */
- public void editPaneCreated(EditPane editPane)
- {
- editPane.getTextArea().removeFocusListener(this);
- editPane.getTextArea().addFocusListener(this);
- editPanes.add(editPane);
- }
+ /**
+ * Create a new <code>ViewHandler</code>
+ */
+ public ViewHandler(View aView)
+ {
+ view = aView;
+ docks = new HashMap<String, DockHandler>(4);
+ editPanes = new HashSet<EditPane>(2);
+ config = DockerPlugin.getPlugin().getConfig();
+ init();
+ }
- /**
- * Returns <code>true</code> if any dock is visible.
- */
- public boolean isAnyDockVisible() {
- for (Iterator i = docks.values().iterator(); i.hasNext();) {
- if (((DockHandler) i.next()).isDockVisible()) {
- return true;
- }
- }
- return false;
- }
+ /**
+ * Initialize this handler.
+ */
+ public void init()
+ {
+ docks.clear();
+ attachDock(DockableWindowManager.TOP);
+ attachDock(DockableWindowManager.LEFT);
+ attachDock(DockableWindowManager.BOTTOM);
+ attachDock(DockableWindowManager.RIGHT);
+ EditPane[] editPanes = view.getEditPanes();
+ for (int i = 0; i < editPanes.length; i++)
+ {
+ editPaneCreated(editPanes[i]);
+ }
+ }
- public void collapseAllDocks() {
- for (Iterator<DockHandler> i = docks.values().iterator(); i.hasNext();) {
- i.next().collapse();
- }
- }
+ /**
+ * Detach this handler from the view.
+ */
+ public void detach()
+ {
+ for (Iterator i = docks.values().iterator(); i.hasNext();)
+ {
+ ((DockHandler) i.next()).detach();
+ }
+ EditPane[] editPanes = view.getEditPanes();
+ for (int i = 0; i < editPanes.length; i++)
+ {
+ editPaneDestroyed(editPanes[i]);
+ }
+ }
- public void saveDockState() {
- for (Iterator<DockHandler> i = docks.values().iterator(); i.hasNext();) {
- i.next().saveDockState();
- }
- }
+ /**
+ * Handle an edit pane creation message.
+ */
+ public void editPaneCreated(EditPane editPane)
+ {
+ editPane.getTextArea().removeFocusListener(this);
+ editPane.getTextArea().addFocusListener(this);
+ editPanes.add(editPane);
+ }
- public void restoreDockState() {
- for (Iterator<DockHandler> i = docks.values().iterator(); i.hasNext();) {
- i.next().restoreDockState();
- }
- }
+ /**
+ * Returns <code>true</code> if any dock is visible.
+ */
+ public boolean isAnyDockVisible()
+ {
+ for (Iterator i = docks.values().iterator(); i.hasNext();)
+ {
+ if (((DockHandler) i.next()).isDockVisible())
+ {
+ return true;
+ }
+ }
+ return false;
+ }
- /**
- * Handle an edit pane destruction message.
- */
- public void editPaneDestroyed(EditPane editPane)
- {
- editPane.getTextArea().removeFocusListener(this);
- editPanes.remove(editPane);
- }
+ public void collapseAllDocks()
+ {
+ for (Iterator<DockHandler> i = docks.values().iterator(); i.hasNext();)
+ {
+ i.next().collapse();
+ }
+ }
- // {{{ FocusListener Methods
- /**
- * Handle a focus gained event.
- */
- public final void focusGained(FocusEvent evt)
- {
- //Log.log(Log.DEBUG, this, "Focus gained");
- for (Iterator<DockHandler> i = docks.values().iterator(); i.hasNext();) {
- i.next().autoHide();
- }
- }
+ public void saveDockState()
+ {
+ for (Iterator<DockHandler> i = docks.values().iterator(); i.hasNext();)
+ {
+ i.next().saveDockState();
+ }
+ }
- /**
- * Handle a focus lost event.
- */
- public final void focusLost(FocusEvent evt) {
- //Log.log(Log.DEBUG, this, "Focus gained");
- }
- // }}}
+ public void restoreDockState()
+ {
+ for (Iterator<DockHandler> i = docks.values().iterator(); i.hasNext();)
+ {
+ i.next().restoreDockState();
+ }
+ }
- /**
- * Attach a handler to a dock.
- */
- private void attachDock(String dockName)
- {
- int compIdx = 0;
- DockableWindowManager wm = view.getDockableWindowManager();
- PanelWindowContainer container = null;
- if (DockableWindowManager.TOP.equals(dockName)) {
- container = wm.getTopDockingArea();
- compIdx = 4;
- } else if (DockableWindowManager.LEFT.equals(dockName)) {
- container = wm.getLeftDockingArea();
- compIdx = 5;
- } else if (DockableWindowManager.BOTTOM.equals(dockName)) {
- container = wm.getBottomDockingArea();
- compIdx = 6;
- } else if (DockableWindowManager.RIGHT.equals(dockName)) {
- container = wm.getRightDockingArea();
- compIdx = 7;
- }
- docks.put(dockName, new DockHandler(dockName, wm, container, config));
- }
+ /**
+ * Handle an edit pane destruction message.
+ */
+ public void editPaneDestroyed(EditPane editPane)
+ {
+ editPane.getTextArea().removeFocusListener(this);
+ editPanes.remove(editPane);
+ }
+ // {{{ FocusListener Methods
+ /**
+ * Handle a focus gained event.
+ */
+ public final void focusGained(FocusEvent evt)
+ {
+ // Log.log(Log.DEBUG, this, "Focus gained");
+ for (Iterator<DockHandler> i = docks.values().iterator(); i.hasNext();)
+ {
+ i.next().autoHide();
+ }
+ }
+
+ /**
+ * Handle a focus lost event.
+ */
+ public final void focusLost(FocusEvent evt)
+ {
+ // Log.log(Log.DEBUG, this, "Focus gained");
+ }
+
+ // }}}
+
+ /**
+ * Attach a handler to a dock.
+ */
+ private void attachDock(String dockName)
+ {
+ int compIdx = 0;
+ DockableWindowManager wm = view.getDockableWindowManager();
+ PanelWindowContainer container = null;
+ if (DockableWindowManager.TOP.equals(dockName))
+ {
+ container = wm.getTopDockingArea();
+ compIdx = 4;
+ }
+ else if (DockableWindowManager.LEFT.equals(dockName))
+ {
+ container = wm.getLeftDockingArea();
+ compIdx = 5;
+ }
+ else if (DockableWindowManager.BOTTOM.equals(dockName))
+ {
+ container = wm.getBottomDockingArea();
+ compIdx = 6;
+ }
+ else if (DockableWindowManager.RIGHT.equals(dockName))
+ {
+ container = wm.getRightDockingArea();
+ compIdx = 7;
+ }
+ docks.put(dockName, new DockHandler(dockName, wm, container, config));
+ }
+
}
-
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
jEdit-CVS mailing list
jEdit-CVS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jedit-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic