mirror of
https://github.com/processing/processing4.git
synced 2026-02-13 18:35:37 +01:00
Done revamping Contribution Manager
Lots of Bug Squashin' * Fixed the bug that appeared when trying to remove the present mode * Minor bug fix in working of Lib Manager * Minor GUI Changes * Solves ConcurModifExcept that randomly pops up * Fix bug that appears when multiple modes are to be updated on restart * Fixed bug affecting failedupdate for modes * Solved bug that involved auto-update on startup * Removed pointless commented out code
This commit is contained in:
@@ -166,7 +166,9 @@ public class ContributionListing {
|
||||
|
||||
|
||||
protected AvailableContribution getAvailableContribution(Contribution info) {
|
||||
for (AvailableContribution advertised : advertisedContributions) {
|
||||
Iterator<AvailableContribution> iter = advertisedContributions.iterator();
|
||||
while(iter.hasNext()) {
|
||||
AvailableContribution advertised = iter.next();
|
||||
if (advertised.getType() == info.getType() &&
|
||||
advertised.getName().equals(info.getName())) {
|
||||
return advertised;
|
||||
|
||||
@@ -25,6 +25,8 @@ import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.SwingWorker;
|
||||
|
||||
import processing.app.Base;
|
||||
import processing.app.Editor;
|
||||
import processing.app.Language;
|
||||
@@ -189,7 +191,7 @@ public class ContributionManager {
|
||||
|
||||
try {
|
||||
download(url, contribZip, null);
|
||||
|
||||
|
||||
LocalContribution contribution = ad.install(base, contribZip,
|
||||
false, null);
|
||||
|
||||
@@ -211,7 +213,8 @@ public class ContributionManager {
|
||||
handleUpdateFailedMarkers(ad, filename.substring(0, filename.lastIndexOf('.')));
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// Chuck the stack trace. The user might have no idea why it is appearing, or what (s)he did wrong...
|
||||
// e.printStackTrace();
|
||||
System.out.println("Error during download and install of "
|
||||
+ ad.getName());
|
||||
}
|
||||
@@ -235,16 +238,32 @@ public class ContributionManager {
|
||||
* The name of the folder in which the contribution is supposed to be stored.
|
||||
*/
|
||||
static private void handleUpdateFailedMarkers(final AvailableContribution ac, String filename) {
|
||||
|
||||
|
||||
File contribLocn = ac.getType().getSketchbookFolder();
|
||||
|
||||
try {
|
||||
new File(contribLocn, ac.getName()).createNewFile();
|
||||
} catch (IOException e) {
|
||||
// File already exists...
|
||||
//e.printStackTrace();
|
||||
for (File contribDir : contribLocn.listFiles())
|
||||
if (contribDir.isDirectory()) {
|
||||
File[] contents = contribDir.listFiles(new FilenameFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File dir, String file) {
|
||||
return file.equals(ac.getType() + ".properties");
|
||||
}
|
||||
});
|
||||
if (contents.length > 0 && Base.readSettings(contents[0]).get("name").equals(ac.getName())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
new File(contribLocn, ac.getName()).createNewFile();
|
||||
} catch (IOException e) {
|
||||
// Again, forget about the stack trace. The user ain't done wrong
|
||||
// e.printStackTrace();
|
||||
System.err.println("The unupdated contribution marker seems to not like "
|
||||
+ ac.getName() + ". You may have to install it manually to update...");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -317,7 +336,7 @@ public class ContributionManager {
|
||||
* and remove any "requires restart" flags.
|
||||
* Also updates all entries previously marked for update.
|
||||
*/
|
||||
static public void cleanup(Base base) throws Exception {
|
||||
static public void cleanup(final Base base) throws Exception {
|
||||
|
||||
deleteTemp(Base.getSketchbookModesFolder());
|
||||
deleteTemp(Base.getSketchbookToolsFolder());
|
||||
@@ -327,11 +346,27 @@ public class ContributionManager {
|
||||
deleteFlagged(Base.getSketchbookToolsFolder());
|
||||
|
||||
installPreviouslyFailed(base, Base.getSketchbookModesFolder());
|
||||
installPreviouslyFailed(base, Base.getSketchbookToolsFolder());
|
||||
|
||||
updateFlagged(base, Base.getSketchbookModesFolder());
|
||||
|
||||
updateFlagged(base, Base.getSketchbookToolsFolder());
|
||||
|
||||
SwingWorker s = new SwingWorker<Void, Void>() {
|
||||
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
try {
|
||||
Thread.sleep(1 * 1000);
|
||||
installPreviouslyFailed(base, Base.getSketchbookToolsFolder());
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
s.execute();
|
||||
|
||||
|
||||
|
||||
clearRestartFlags(Base.getSketchbookModesFolder());
|
||||
clearRestartFlags(Base.getSketchbookToolsFolder());
|
||||
}
|
||||
@@ -399,6 +434,7 @@ public class ContributionManager {
|
||||
while (iter.hasNext()) {
|
||||
AvailableContribution availableContrib = iter.next();
|
||||
if (file.getName().equals(availableContrib.getName())) {
|
||||
file.delete();
|
||||
installOnStartUp(base, availableContrib);
|
||||
contribListing
|
||||
.replaceContribution(availableContrib, availableContrib);
|
||||
|
||||
@@ -98,7 +98,7 @@ public class ContributionManagerDialog {
|
||||
Iterator<Editor> iter = editor.getBase().getEditors().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Editor ed = iter.next();
|
||||
if (ed.getSketch().isModified() || ed.getSketch().isUntitled()) {
|
||||
if (ed.getSketch().isModified()) {
|
||||
int option = Base
|
||||
.showYesNoQuestion(editor, title,
|
||||
"Unsaved changes have been found",
|
||||
|
||||
@@ -41,6 +41,7 @@ import javax.swing.text.html.HTMLDocument;
|
||||
import javax.swing.text.html.StyleSheet;
|
||||
|
||||
import processing.app.Base;
|
||||
import processing.app.Editor;
|
||||
import processing.app.Language;
|
||||
|
||||
|
||||
@@ -168,7 +169,7 @@ class ContributionPanel extends JPanel {
|
||||
resetInstallProgressBarState();
|
||||
isRemoveInProgress = false;
|
||||
installRemoveButton.setEnabled(true);
|
||||
// ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, BUTTON_CONSTRAINT);
|
||||
|
||||
reorganizePaneComponents();
|
||||
setSelected(true); // Needed for smooth working. Dunno why, though...
|
||||
}
|
||||
@@ -176,12 +177,29 @@ class ContributionPanel extends JPanel {
|
||||
public void cancel() {
|
||||
super.cancel();
|
||||
resetInstallProgressBarState();
|
||||
listPanel.contribManager.restartButton.setVisible(true);
|
||||
isRemoveInProgress = false;
|
||||
installRemoveButton.setEnabled(true);
|
||||
// ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, BUTTON_CONSTRAINT);
|
||||
|
||||
reorganizePaneComponents();
|
||||
setSelected(true);
|
||||
|
||||
boolean isModeActive = false;
|
||||
if (contrib.getType() == ContributionType.MODE) {
|
||||
ModeContribution m = (ModeContribution) contrib;
|
||||
Iterator<Editor> iter = listPanel.contribManager.editor.getBase().getEditors().iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
Editor e = iter.next();
|
||||
if (e.getMode().equals(m.getMode())) {
|
||||
isModeActive = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!isModeActive)
|
||||
listPanel.contribManager.restartButton.setVisible(true);
|
||||
else
|
||||
updateButton.setEnabled(true);
|
||||
}
|
||||
},
|
||||
listPanel.contribManager.status);
|
||||
@@ -296,14 +314,31 @@ class ContributionPanel extends JPanel {
|
||||
((LocalContribution)contrib).setUpdateFlag(true);
|
||||
((LocalContribution)contrib).setDeletionFlag(false);
|
||||
contribListing.replaceContribution(contrib,contrib);
|
||||
// updateButton.setVisible(false);
|
||||
}
|
||||
listPanel.contribManager.restartButton.setVisible(true);
|
||||
|
||||
boolean isModeActive = false;
|
||||
if (contrib.getType() == ContributionType.MODE) {
|
||||
ModeContribution m = (ModeContribution) contrib;
|
||||
Iterator<Editor> iter = listPanel.contribManager.editor.getBase().getEditors().iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
Editor e = iter.next();
|
||||
if (e.getMode().equals(m.getMode())) {
|
||||
isModeActive = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!isModeActive)
|
||||
listPanel.contribManager.restartButton.setVisible(true);
|
||||
else
|
||||
updateButton.setEnabled(true);
|
||||
}
|
||||
|
||||
}, listPanel.contribManager.status);
|
||||
} else {
|
||||
updateButton.setEnabled(false);
|
||||
installRemoveButton.setEnabled(false);
|
||||
AvailableContribution ad = contribListing.getAvailableContribution(contrib);
|
||||
String url = ad.link;
|
||||
installContribution(ad, url);
|
||||
|
||||
@@ -360,7 +360,7 @@ public abstract class LocalContribution extends Contribution {
|
||||
pm.startTask("Removing", ProgressMonitor.UNKNOWN);
|
||||
|
||||
boolean doBackup = Preferences.getBoolean("contribution.backup.on_remove");
|
||||
// if (getType().requiresRestart() && getType() != ContributionType.MODE) {
|
||||
// if (getType().requiresRestart()) {
|
||||
// if (!doBackup || (doBackup && backup(editor, false, status))) {
|
||||
// if (setDeletionFlag(true)) {
|
||||
// contribListing.replaceContribution(this, this);
|
||||
@@ -386,10 +386,10 @@ public abstract class LocalContribution extends Contribution {
|
||||
Base.showMessage("Mode Manager",
|
||||
"Please save your Sketch and change the Mode of all Editor\nwindows that have "
|
||||
+ this.name + " as the active Mode.");
|
||||
// ContributionManager.refreshInstalled(editor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (getType() == ContributionType.TOOL) {
|
||||
ToolContribution t = (ToolContribution) this;
|
||||
Iterator<Editor> iter = editor.getBase().getEditors().iterator();
|
||||
@@ -399,6 +399,7 @@ public abstract class LocalContribution extends Contribution {
|
||||
}
|
||||
t.clearClassLoader(editor.getBase());
|
||||
}
|
||||
|
||||
if (doBackup) {
|
||||
success = backup(editor, true, status);
|
||||
} else {
|
||||
@@ -422,7 +423,6 @@ public abstract class LocalContribution extends Contribution {
|
||||
}
|
||||
else {
|
||||
// There was a failure backing up the folder
|
||||
if (getType().requiresRestart()) {
|
||||
if (!doBackup || (doBackup && backup(editor, false, status))) {
|
||||
if (setDeletionFlag(true)) {
|
||||
contribListing.replaceContribution(this, this);
|
||||
@@ -430,7 +430,6 @@ public abstract class LocalContribution extends Contribution {
|
||||
}
|
||||
else
|
||||
status.setErrorMessage("Could not delete the contribution's files");
|
||||
}
|
||||
}
|
||||
// }
|
||||
ContributionManager.refreshInstalled(editor);
|
||||
|
||||
@@ -67,10 +67,6 @@ public class ToolContribution extends LocalContribution implements Tool {
|
||||
* a tool can be removed without restart.
|
||||
*/
|
||||
public void clearClassLoader(Base base) {
|
||||
// ArrayList<ToolContribution> contribTools = base.getActiveEditor().contribTools;
|
||||
// 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);
|
||||
try {
|
||||
((URLClassLoader) this.loader).close();
|
||||
} catch (IOException e1) {
|
||||
@@ -92,7 +88,6 @@ public class ToolContribution extends LocalContribution implements Tool {
|
||||
// base.getActiveEditor().rebuildToolMenu();
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user