mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Added a restart button in case restarless update/removal fails
This commit is contained in:
@@ -27,6 +27,9 @@ import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.util.*;
|
||||
|
||||
@@ -79,13 +82,55 @@ public class ContributionManagerDialog {
|
||||
return contribListing.hasUpdates(base);
|
||||
}
|
||||
|
||||
public void showFrame(Editor editor) {
|
||||
public void showFrame(final Editor editor) {
|
||||
this.editor = editor;
|
||||
|
||||
if (dialog == null) {
|
||||
dialog = new JFrame(title);
|
||||
|
||||
restartButton = new JButton("Restart Processing");
|
||||
restartButton.setVisible(false);
|
||||
restartButton.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
|
||||
for (Editor ed : editor.getBase().getEditors())
|
||||
if (ed.getSketch().isModified() || ed.getSketch().isUntitled()) {
|
||||
int option = Base
|
||||
.showYesNoQuestion(editor, title,
|
||||
"Unsaved changes have been found",
|
||||
"Are you sure you want to restart Processing without saving first?");
|
||||
|
||||
if (option == JOptionPane.NO_OPTION)
|
||||
return;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
// Thanks to http://stackoverflow.com/a/4160543
|
||||
StringBuilder cmd = new StringBuilder();
|
||||
cmd.append(System.getProperty("java.home") + File.separator + "bin"
|
||||
+ File.separator + "java ");
|
||||
for (String jvmArg : ManagementFactory.getRuntimeMXBean()
|
||||
.getInputArguments()) {
|
||||
cmd.append(jvmArg + " ");
|
||||
}
|
||||
cmd.append("-cp ")
|
||||
.append(ManagementFactory.getRuntimeMXBean().getClassPath())
|
||||
.append(" ");
|
||||
cmd.append(Base.class.getName());
|
||||
|
||||
try {
|
||||
Runtime.getRuntime().exec(cmd.toString());
|
||||
System.exit(0);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Toolkit.setIcon(dialog);
|
||||
createComponents();
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.awt.event.*;
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.Date;
|
||||
@@ -132,6 +133,17 @@ class ContributionPanel extends JPanel {
|
||||
LocalContribution installed = (LocalContribution) contrib;
|
||||
installed.setDeletionFlag(false);
|
||||
contribListing.replaceContribution(contrib, contrib); // ??
|
||||
ArrayList<Contribution> contribsList = contribListing.allContributions;
|
||||
boolean toBeRestarted = false;
|
||||
for(Contribution contribElement : contribsList)
|
||||
if (contrib.getType().equals(contribElement.getType())) {
|
||||
if (contribElement.isDeletionFlagged() || contribElement.isUpdateFlagged())
|
||||
{
|
||||
toBeRestarted = !toBeRestarted;
|
||||
break;
|
||||
}
|
||||
}
|
||||
listPanel.contribManager.restartButton.setVisible(toBeRestarted);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -162,6 +174,7 @@ 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);
|
||||
@@ -274,6 +287,7 @@ class ContributionPanel extends JPanel {
|
||||
public void cancel() {
|
||||
super.cancel();
|
||||
resetInstallProgressBarState();
|
||||
listPanel.contribManager.status.setMessage("");
|
||||
isUpdateInProgress = false;
|
||||
installRemoveButton.setEnabled(true);
|
||||
if (contrib.isDeletionFlagged()) {
|
||||
@@ -282,7 +296,7 @@ class ContributionPanel extends JPanel {
|
||||
contribListing.replaceContribution(contrib,contrib);
|
||||
// updateButton.setVisible(false);
|
||||
}
|
||||
listPanel.contribManager.status.setMessage("");
|
||||
listPanel.contribManager.restartButton.setVisible(true);
|
||||
}
|
||||
|
||||
}, listPanel.contribManager.status);
|
||||
|
||||
Reference in New Issue
Block a user