From 40652baeef76e8eaad9d5dbf5026d5f3a8323332 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Sun, 29 Jun 2014 13:10:46 +0530 Subject: [PATCH] Remove works across multiple open editors --- .../app/contrib/LocalContribution.java | 3 +- .../app/contrib/ToolContribution.java | 36 +++++++++++-------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java index d892a5869..7c17c4d04 100644 --- a/app/src/processing/app/contrib/LocalContribution.java +++ b/app/src/processing/app/contrib/LocalContribution.java @@ -369,7 +369,8 @@ public abstract class LocalContribution extends Contribution { } if (getType() == ContributionType.TOOL) { ToolContribution t = (ToolContribution) this; - editor.clearToolMenu(); + for (Editor ed : editor.getBase().getEditors()) + ed.clearToolMenu(); t.clearClassLoader(editor.getBase()); } if (doBackup) { diff --git a/app/src/processing/app/contrib/ToolContribution.java b/app/src/processing/app/contrib/ToolContribution.java index cb8c017b5..cf7ecab6e 100644 --- a/app/src/processing/app/contrib/ToolContribution.java +++ b/app/src/processing/app/contrib/ToolContribution.java @@ -71,21 +71,29 @@ public class ToolContribution extends LocalContribution implements Tool { // int botherToRemove = contribTools.indexOf(this); // if (botherToRemove != -1) { // The poor thing doesn't even exist, and we're trying to remove it... // contribTools.remove(botherToRemove); - ArrayList contribTools = base.getActiveEditor().contribTools; - for (ToolContribution toolContrib : contribTools) - if (toolContrib.getName().equals(this.name)) { - try { - System.out.println("Here " + name); - ((URLClassLoader) this.loader).close(); - ((URLClassLoader) toolContrib.loader).close(); - // The typecast should be safe, since the only case when loader is not of - // type URLClassLoader is when no archives were found in the first - // place... - } catch (IOException e) { - e.printStackTrace(); - } + try { + ((URLClassLoader) this.loader).close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + List editors = base.getEditors(); + for (Editor editor : editors) { + ArrayList contribTools = editor.contribTools; + for (ToolContribution toolContrib : contribTools) + if (toolContrib.getName().equals(this.name)) { + try { + System.out.println("Here " + name); + ((URLClassLoader) toolContrib.loader).close(); + System.out.println(contribTools.size()); + editor.contribTools.remove(toolContrib); + System.out.println(contribTools.size()); + break; + } catch (IOException e) { + e.printStackTrace(); + } // base.getActiveEditor().rebuildToolMenu(); - } + } + } // } }