mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-10 05:15:51 -04:00
refactoring of ATMISP start
This commit is contained in:
parent
13fddf9eb4
commit
c8fec43820
@ -24,7 +24,7 @@ import java.util.ArrayList;
|
|||||||
import static de.neemann.gui.Screen.isLinux;
|
import static de.neemann.gui.Screen.isLinux;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DIalog used to show the result of the external fitter.
|
* Dialog used to show the result of the external fitter.
|
||||||
*/
|
*/
|
||||||
public class ATFDialog extends JDialog {
|
public class ATFDialog extends JDialog {
|
||||||
private final JDialog parent;
|
private final JDialog parent;
|
||||||
@ -47,8 +47,6 @@ public class ATFDialog extends JDialog {
|
|||||||
startATMISPAction = new ToolTipAction(Lang.get("btn_startATMISP")) {
|
startATMISPAction = new ToolTipAction(Lang.get("btn_startATMISP")) {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent actionEvent) {
|
public void actionPerformed(ActionEvent actionEvent) {
|
||||||
startATMISPAction.setEnabled(false);
|
|
||||||
try {
|
|
||||||
File atmispFile = Settings.getInstance().get(Keys.SETTINGS_ATMISP);
|
File atmispFile = Settings.getInstance().get(Keys.SETTINGS_ATMISP);
|
||||||
|
|
||||||
ArrayList<String> args = new ArrayList<>();
|
ArrayList<String> args = new ArrayList<>();
|
||||||
@ -57,21 +55,13 @@ public class ATFDialog extends JDialog {
|
|||||||
args.add(atmispFile.getPath());
|
args.add(atmispFile.getPath());
|
||||||
args.add(chnFile.getName());
|
args.add(chnFile.getName());
|
||||||
|
|
||||||
|
startATMISPAction.setEnabled(false);
|
||||||
|
|
||||||
OSExecute atmisp = new OSExecute(args)
|
OSExecute atmisp = new OSExecute(args)
|
||||||
.setWorkingDir(chnFile.getParentFile())
|
.setWorkingDir(chnFile.getParentFile())
|
||||||
.setTimeOutSec(6000)
|
.setTimeOutSec(6000);
|
||||||
.startInThread(new OSExecute.ProcessCallback() {
|
|
||||||
@Override
|
|
||||||
public void processTerminated(String consoleOut) {
|
|
||||||
// ignore console out
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
final WindowAdapter windowListener = new WindowAdapter() {
|
||||||
public void exception(Exception e) {
|
|
||||||
SwingUtilities.invokeLater(new ErrorMessage(Lang.get("msg_errorStartingATMISP")).addCause(e));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
addWindowListener(new WindowAdapter() {
|
|
||||||
@Override
|
@Override
|
||||||
public void windowClosed(WindowEvent e) {
|
public void windowClosed(WindowEvent e) {
|
||||||
if (atmisp.isAlive()) {
|
if (atmisp.isAlive()) {
|
||||||
@ -82,13 +72,32 @@ public class ATFDialog extends JDialog {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
} finally {
|
addWindowListener(windowListener);
|
||||||
|
|
||||||
|
atmisp.startInThread(new OSExecute.ProcessCallback() {
|
||||||
|
@Override
|
||||||
|
public void processTerminated(String consoleOut) {
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
startATMISPAction.setEnabled(true);
|
startATMISPAction.setEnabled(true);
|
||||||
|
removeWindowListener(windowListener);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exception(Exception e) {
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
startATMISPAction.setEnabled(true);
|
||||||
|
removeWindowListener(windowListener);
|
||||||
|
new ErrorMessage(Lang.get("msg_errorStartingATMISP")).addCause(e).show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}.setToolTip(Lang.get("btn_startATMISP_tt")).setEnabledChain(false);
|
}.setToolTip(Lang.get("btn_startATMISP_tt")).setEnabledChain(false);
|
||||||
|
|
||||||
buttons.add(startATMISPAction.createJButton());
|
buttons.add(startATMISPAction.createJButton());
|
||||||
|
|
||||||
okButton = new ToolTipAction(Lang.get("ok")) {
|
okButton = new ToolTipAction(Lang.get("ok")) {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent actionEvent) {
|
public void actionPerformed(ActionEvent actionEvent) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user