mirror of
https://github.com/processing/processing4.git
synced 2026-02-13 18:35:37 +01:00
Display dialog to prevent user from changing an active mode
And a few clean ups
This commit is contained in:
@@ -436,30 +436,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
|
||||
public void rebuildModeMenu() {
|
||||
modeMenu = new JMenu();
|
||||
ButtonGroup modeGroup = new ButtonGroup();
|
||||
for (final Mode m : base.getModeList()) {
|
||||
JRadioButtonMenuItem item = new JRadioButtonMenuItem(m.getTitle());
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
base.changeMode(m);
|
||||
}
|
||||
});
|
||||
modeMenu.add(item);
|
||||
modeGroup.add(item);
|
||||
if (mode == m) {
|
||||
item.setSelected(true);
|
||||
}
|
||||
}
|
||||
|
||||
modeMenu.addSeparator();
|
||||
JMenuItem addLib = new JMenuItem("Add Mode...");
|
||||
addLib.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
base.handleOpenModeManager();
|
||||
}
|
||||
});
|
||||
modeMenu.add(addLib);
|
||||
initModeMenu();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -139,13 +139,10 @@ class AvailableContribution extends Contribution {
|
||||
// backup old if needed, then move things into place and reload.
|
||||
installedContrib =
|
||||
newContrib.copyAndLoad(editor, confirmReplace, status);
|
||||
if (newContrib != null && type.requiresRestart()) {
|
||||
if (newContrib != null && type.requiresRestart() && type != ContributionType.MODE) {
|
||||
installedContrib.setRestartFlag();
|
||||
//status.setMessage("Restart Processing to finish the installation.");
|
||||
}
|
||||
// else if (type == ContributionType.MODE) {
|
||||
//
|
||||
// }
|
||||
|
||||
// 3. Delete the newContrib, do a garbage collection, hope and pray
|
||||
// that Java will unlock the temp folder on Windows now
|
||||
@@ -154,10 +151,10 @@ class AvailableContribution extends Contribution {
|
||||
|
||||
|
||||
if (Base.isWindows()) {
|
||||
// we'll even give it a second to finish up ... because file ops are
|
||||
// we'll even give it 2 seconds to finish up ... because file ops are
|
||||
// just that flaky on Windows.
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -137,6 +137,13 @@ class ContributionPanel extends JPanel {
|
||||
resetInstallProgressBarState();
|
||||
installRemoveButton.setEnabled(true);
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
super.cancel();
|
||||
resetInstallProgressBarState();
|
||||
updateButton.setEnabled(true);
|
||||
installRemoveButton.setEnabled(true);
|
||||
}
|
||||
},
|
||||
listPanel.contribManager.status);
|
||||
}
|
||||
@@ -236,11 +243,18 @@ class ContributionPanel extends JPanel {
|
||||
String url = ad.link;
|
||||
installContribution(ad, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
super.cancel();
|
||||
resetInstallProgressBarState();
|
||||
installRemoveButton.setEnabled(true);
|
||||
}
|
||||
|
||||
}, listPanel.contribManager.status);
|
||||
} else {
|
||||
updateButton.setEnabled(false);
|
||||
AvailableContribution ad = contribListing
|
||||
.getAvailableContribution(contrib);
|
||||
AvailableContribution ad = contribListing.getAvailableContribution(contrib);
|
||||
String url = ad.link;
|
||||
installContribution(ad, url);
|
||||
}
|
||||
|
||||
@@ -329,8 +329,10 @@ public abstract class LocalContribution extends Contribution {
|
||||
}
|
||||
|
||||
|
||||
void remove(final Editor editor, final ProgressMonitor pm,
|
||||
final StatusPanel status, final ContributionListing contribListing) {
|
||||
void remove(final Editor editor,
|
||||
final ProgressMonitor pm,
|
||||
final StatusPanel status,
|
||||
final ContributionListing contribListing) {
|
||||
pm.startTask("Removing", ProgressMonitor.UNKNOWN);
|
||||
|
||||
boolean doBackup = Preferences.getBoolean("contribution.backup.on_remove");
|
||||
@@ -353,13 +355,15 @@ public abstract class LocalContribution extends Contribution {
|
||||
if (!isModeActive)
|
||||
m.clearClassLoader(editor.getBase());
|
||||
else {
|
||||
if (!doBackup || (doBackup && backup(editor, false, status))) {
|
||||
if (setDeletionFlag(true)) {
|
||||
contribListing.replaceContribution(this, this);
|
||||
}
|
||||
}
|
||||
ContributionManager.refreshInstalled(editor);
|
||||
pm.finished();
|
||||
// if (!doBackup || (doBackup && backup(editor, false, status))) {
|
||||
// if (setDeletionFlag(true)) {
|
||||
// contribListing.replaceContribution(this, this);
|
||||
// }
|
||||
// }
|
||||
pm.cancel();
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -371,8 +375,8 @@ public abstract class LocalContribution extends Contribution {
|
||||
}
|
||||
|
||||
if (success) {
|
||||
Contribution advertisedVersion = contribListing
|
||||
.getAvailableContribution(this);
|
||||
Contribution advertisedVersion =
|
||||
contribListing.getAvailableContribution(this);
|
||||
|
||||
if (advertisedVersion == null) {
|
||||
contribListing.removeContribution(this);
|
||||
|
||||
@@ -26,9 +26,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.JRadioButtonMenuItem;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user