fix error when installing Mode with no windows open (fixes #445, fixes #446)

This commit is contained in:
Ben Fry
2022-03-11 19:01:04 -05:00
parent 4d33354e8a
commit ba88401396
4 changed files with 28 additions and 108 deletions
@@ -193,6 +193,7 @@ public class ContributionManager {
status.setErrorMessage(Language
.interpolate("contrib.errors.download_and_install",
ad.getName()));
downloadProgress.exception.printStackTrace();
}
}
contribZip.delete();
@@ -63,41 +63,6 @@ public enum ContributionType {
}
/*
public String getPluralTitle() {
switch (this) {
case LIBRARY:
return "Libraries";
case MODE:
return "Modes";
case TOOL:
return "Tools";
case EXAMPLES:
return "Examples";
}
return null; // should be unreachable
}
*/
// public String getFolderName() {
// return toString();
// /*
// switch (this) {
// case LIBRARY:
// return "libraries";
// case TOOL:
// return "tools";
// case MODE:
// return "modes";
// case EXAMPLES:
// return "examples";
// }
// return null; // should be unreachable
// */
// }
/** Get the name of the properties file for this type of contribution. */
public String getPropertiesName() {
return this + ".properties";
@@ -109,42 +74,11 @@ public enum ContributionType {
}
/*
// removed for 4.0a6, doesn't appear to be in use
public File[] listTempFolders() throws IOException {
File base = getSketchbookFolder();
return base.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
String name = file.getName();
return (file.isDirectory() &&
name.startsWith(toString()) && name.endsWith("tmp"));
}
});
}
*/
public boolean isTempFolderName(String name) {
return name.startsWith(toString()) && name.endsWith("tmp");
}
// public String getTempPrefix() {
// return toString();
// }
//
//
// public String getTempSuffix() {
// return "tmp";
// }
// public String getPropertiesName() {
// return toString() + ".properties";
// }
static public ContributionType fromName(String s) {
if (s != null) {
if ("library".equalsIgnoreCase(s)) {
@@ -239,20 +173,22 @@ public enum ContributionType {
}
List<LocalContribution> listContributions(Editor editor) {
List<LocalContribution> listContributions(Base base, Editor editor) {
List<LocalContribution> contribs = new ArrayList<>();
switch (this) {
case LIBRARY:
contribs.addAll(editor.getMode().contribLibraries);
if (editor != null) {
contribs.addAll(editor.getMode().contribLibraries);
}
break;
case TOOL:
contribs.addAll(editor.getBase().getToolContribs());
contribs.addAll(base.getToolContribs());
break;
case MODE:
contribs.addAll(editor.getBase().getModeContribs());
contribs.addAll(base.getModeContribs());
break;
case EXAMPLES:
contribs.addAll(editor.getBase().getExampleContribs());
contribs.addAll(base.getExampleContribs());
break;
}
return contribs;
@@ -266,11 +202,6 @@ public enum ContributionType {
File createBackupFolder(StatusPanel status) {
File backupFolder = getBackupFolder();
// if (backupFolder.isDirectory()) {
// status.setErrorMessage("First remove the folder named \"old\" from the " +
// getFolderName() + " folder in the sketchbook.");
// return null;
// }
if (!backupFolder.exists() && !backupFolder.mkdirs()) {
status.setErrorMessage("Could not create a backup folder in the " +
"sketchbook " + this + " folder.");
@@ -278,29 +209,4 @@ public enum ContributionType {
}
return backupFolder;
}
// /**
// * Create a filter for a specific contribution type.
// * @param type The type, or null for a generic update checker.
// */
// Contribution.Filter createFilter2() {
// return new Contribution.Filter() {
// public boolean matches(Contribution contrib) {
// return contrib.getType() == ContributionType.this;
// }
// };
// }
// static Contribution.Filter createUpdateFilter() {
// return new Contribution.Filter() {
// public boolean matches(Contribution contrib) {
// if (contrib instanceof LocalContribution) {
// return ContributionListing.getInstance().hasUpdates(contrib);
// }
// return false;
// }
// };
// }
}
@@ -247,7 +247,7 @@ public abstract class LocalContribution extends Contribution {
Editor editor = base.getActiveEditor();
List<LocalContribution> oldContribs =
getType().listContributions(editor);
getType().listContributions(base, editor);
// In case an update marker exists, and the user wants to install, delete the update marker
if (contribFolder.exists() && !contribFolder.isDirectory()) {
+19 -6
View File
@@ -5,6 +5,25 @@ X through sketch.properties is not rewritten
X dropping folder into sketch window throws weird exception
X https://github.com/processing/processing4/issues/441
manager
X "Error during download and install of Python Mode for Processing"
X https://github.com/processing/processing/issues/5918
X https://github.com/processing/processing4/issues/445
X Manager fails to complete install of PythonMode when no windows open
X https://github.com/processing/processing/issues/5309
X https://github.com/processing/processing4/issues/446
_ allow update of the current Mode
_ an incompatible Mode prevents the PDE from quitting after last window is closed
_ https://github.com/processing/processing/issues/5112
_ remove checkbox for detaching sketch name
_ just do this manually, and Save As will reset the name
_ update wiki with recent changes (i.e. separating sketch folder)
_ https://github.com/processing/processing4/wiki/Processing-4
_ clicking "Update All" on the Updates tab throws NPE
_ https://github.com/processing/processing4/issues/440
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot invoke "javax.swing.JProgressBar.setVisible(boolean)" because "this.progressBar" is null
@@ -813,12 +832,6 @@ _ e.g. ocd is broken in 0125 because of method signature changes
PDE / Manager
_ Manager fails to complete install of PythonMode when no windows open
_ https://github.com/processing/processing/issues/5309
_ Python Mode not downloading?
_ https://github.com/processing/processing/issues/5918
_ an incompatible Mode prevents the PDE from quitting after last window is closed
_ https://github.com/processing/processing/issues/5112
_ “could not move the contribution to the backup folder” message while updating
_ problem is that any sketch that uses a library, the lib is stuck as "in use"
_ https://github.com/processing/processing/issues/4973