Fixed build (was crashing after splash screen)

This commit is contained in:
pesckal
2011-08-03 04:49:28 +00:00
parent 5eebe98314
commit f1c7aabf14
2 changed files with 24 additions and 22 deletions
@@ -46,7 +46,7 @@ public class ContributionManager {
static public final String DELETION_FLAG = "flagged_for_deletion";
static private final String DOUBLE_CLICK_SECONDARY =
"Click “Yes” to install this library to your sketchbook...";
"Click “Yes” to install this library to your sketchbook...";
static private final String DISCOVERY_ERROR_TITLE = "Trouble discovering libraries";
@@ -609,8 +609,11 @@ public class ContributionManager {
// Move newTool to the sketchbook library folder
if (newTool.getFolder().renameTo(newToolDest)) {
ToolContribution movedTool = ToolContribution.getTool(newToolDest);
if (movedTool.instantiateToolClass()) {
try {
movedTool.initializeToolClass();
return movedTool;
} catch (Exception e) {
e.printStackTrace();
}
} else {
Base.showWarning("Trouble moving new tool to the sketchbook",
@@ -689,7 +692,7 @@ public class ContributionManager {
result = Base.showYesNoQuestion(editor, "Replace",
"Replace existing \"" + oldLib.getName() + "\" library?",
"An existing copy of the \"" + oldLib.getName() + "\" library<br>"+
"has been found in your sketchbook. Clicking “Yes”<br>"+
"has been found in your sketchbook. Clicking “Yes”<br>"+
"will move the existing library to a backup folder<br>" +
" in <i>libraries/old</i> before replacing it.");
}
@@ -1029,4 +1032,4 @@ abstract class JProgressMonitor extends AbstractProgressMonitor {
public abstract void finishedAction();
}
}
+17 -18
View File
@@ -110,19 +110,12 @@ public class ToolContribution extends InstalledContribution implements Tool {
}
/**
* Creates and instance of the Tool object. Warning: this makes it impossible
* (on Windows) to move the files in the tool's classpath without restarting
* the PDE.
* Loads the tool, making it impossible (on Windows) to move the files in the
* classpath without restarting the PDE.
*/
public boolean instantiateToolClass() {
try {
Class<?> toolClass = Class.forName(className, true, loader);
tool = (Tool) toolClass.newInstance();
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
public void initializeToolClass() throws Exception {
Class<?> toolClass = Class.forName(className, true, loader);
tool = (Tool) toolClass.newInstance();
}
static protected String findClassInZipFile(String base, File file) {
@@ -171,7 +164,7 @@ public class ToolContribution extends InstalledContribution implements Tool {
}
static protected void list(File folder, ArrayList<ToolContribution> tools,
boolean instantiateToolClass) {
boolean doInitializeToolClass) {
File[] folders = folder.listFiles(new FileFilter() {
public boolean accept(File folder) {
@@ -199,10 +192,16 @@ public class ToolContribution extends InstalledContribution implements Tool {
}
for (int i = 0; i < folders.length; i++) {
ToolContribution contrib = getTool(folders[i]);
if (!instantiateToolClass
|| (instantiateToolClass && contrib.instantiateToolClass())) {
tools.add(contrib);
try {
final ToolContribution tool = getTool(folders[i]);
try {
if (doInitializeToolClass)
tool.initializeToolClass();
tools.add(tool);
} catch (Exception e) {
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@@ -223,4 +222,4 @@ public class ToolContribution extends InstalledContribution implements Tool {
return Type.TOOL;
}
}
}