| 199 |
199 |
|
| 200 |
200 |
private boolean locked = false;
|
| 201 |
201 |
|
|
202 |
|
| 202 |
203 |
/**
|
|
204 |
* Computing Job. Stored to restrict the computing to one at time.
|
|
205 |
*/
|
|
206 |
protected JobHandler computingJob = null;
|
|
207 |
|
|
208 |
|
|
209 |
|
|
210 |
/**
|
| 203 |
211 |
* Default constructor.
|
| 204 |
212 |
*/
|
| 205 |
213 |
public TXMEditor() {
|
| ... | ... | |
| 847 |
855 |
// }
|
| 848 |
856 |
|
| 849 |
857 |
|
| 850 |
|
JobHandler computeJob = null;
|
| 851 |
858 |
/**
|
| 852 |
859 |
* Computes the TXMResult if all required parameters are set then refreshes the editor UI.
|
| 853 |
860 |
* Also loads and saves some parameters from result to Widgets fields and from Widgets fields to result.
|
| ... | ... | |
| 857 |
864 |
*/
|
| 858 |
865 |
@Override
|
| 859 |
866 |
public JobHandler compute(final boolean update) {
|
| 860 |
|
if (computeJob != null && computeJob.getResult() == null) {
|
| 861 |
|
Log.info(NLS.bind("Editor is already computing {0}. Please wait or abort the computing job ({1}).", result.getSimpleName(), computeJob.getName()));
|
| 862 |
|
return computeJob;
|
|
867 |
|
|
868 |
// restrict the computing Job to one at time
|
|
869 |
if (this.computingJob != null && this.computingJob.getResult() == null) {
|
|
870 |
Log.info(NLS.bind("Editor is already computing {0}. Please wait or abort the computing job ({1}).", this.result.getSimpleName(), this.computingJob.getName()));
|
|
871 |
return this.computingJob;
|
| 863 |
872 |
}
|
|
873 |
|
| 864 |
874 |
StatusLine.setMessage(this.getResult().getComputingStartMessage());
|
| 865 |
875 |
|
| 866 |
|
// FIXME: SJ: long process simulation to test the Job cancelation or UI progress dialog visibility
|
| 867 |
|
// try {
|
| 868 |
|
// IWorkbench wb = PlatformUI.getWorkbench();
|
| 869 |
|
// IProgressService ps = wb.getProgressService();
|
| 870 |
|
// ps.busyCursorWhile(new IRunnableWithProgress() {
|
| 871 |
|
// public void run(IProgressMonitor pm) {
|
| 872 |
|
// pm.beginTask("long process simulation test", 10);
|
| 873 |
|
// for (int i = 0; i < 12; i++) {
|
| 874 |
|
// try {
|
| 875 |
|
// Thread.sleep(25);
|
| 876 |
|
// }
|
| 877 |
|
// catch (InterruptedException e) {
|
| 878 |
|
// // TODO Auto-generated catch block
|
| 879 |
|
// e.printStackTrace();
|
| 880 |
|
// }
|
| 881 |
|
// pm.worked(1);
|
| 882 |
|
// }
|
| 883 |
|
//
|
| 884 |
|
// }
|
| 885 |
|
// });
|
| 886 |
|
// }
|
| 887 |
|
// catch (InvocationTargetException e1) {
|
| 888 |
|
// // TODO Auto-generated catch block
|
| 889 |
|
// e1.printStackTrace();
|
| 890 |
|
// }
|
| 891 |
|
// catch (InterruptedException e1) {
|
| 892 |
|
// // TODO Auto-generated catch block
|
| 893 |
|
// e1.printStackTrace();
|
| 894 |
|
// }
|
| 895 |
876 |
|
| 896 |
|
|
| 897 |
|
|
| 898 |
|
// UIJob j = new UIJob("test") {
|
| 899 |
|
//
|
| 900 |
|
// @Override
|
| 901 |
|
// public IStatus runInUIThread(IProgressMonitor monitor) {
|
| 902 |
|
// monitor.beginTask("long process simulation test", 10);
|
| 903 |
|
// for (int i = 0; i < 10; i++) {
|
| 904 |
|
// try {
|
| 905 |
|
// Thread.sleep(1000);
|
| 906 |
|
// }
|
| 907 |
|
// catch (InterruptedException e) {
|
| 908 |
|
// // TODO Auto-generated catch block
|
| 909 |
|
// e.printStackTrace();
|
| 910 |
|
// }
|
| 911 |
|
// monitor.worked(1);
|
| 912 |
|
// }
|
| 913 |
|
//
|
| 914 |
|
//
|
| 915 |
|
//
|
| 916 |
|
// return null;
|
| 917 |
|
// }
|
| 918 |
|
// };
|
| 919 |
|
// j.setUser(true);
|
| 920 |
|
// j.schedule();
|
| 921 |
|
|
| 922 |
|
computeJob = new JobHandler(TXMCoreMessages.bind(TXMUIMessages.computing, this.getResult().getName())) {
|
|
877 |
this.computingJob = new JobHandler(TXMCoreMessages.bind(TXMUIMessages.computing, this.getResult().getName())) {
|
| 923 |
878 |
|
| 924 |
879 |
@Override
|
| 925 |
880 |
protected IStatus run(IProgressMonitor monitor) {
|
| ... | ... | |
| 1011 |
966 |
|
| 1012 |
967 |
notifyExtensions("notifyStartOfCompute"); //$NON-NLS-1$
|
| 1013 |
968 |
|
| 1014 |
|
// user log info
|
| 1015 |
|
// if (
|
| 1016 |
|
// // update &&
|
| 1017 |
|
// TXMEditor.this.getResult().canCompute() && !TXMEditor.this.getResult().getComputingStartMessage().isEmpty()) {
|
| 1018 |
|
// Log.info(TXMEditor.this.getResult().getComputingStartMessage());
|
| 1019 |
|
// }
|
| 1020 |
|
|
| 1021 |
969 |
if (!TXMEditor.this.getResult().compute(monitor)) {
|
| 1022 |
970 |
Log.fine("TXMEditor.compute(): " + TXMEditor.this.getClass().getSimpleName() + ": computing failed.");
|
| 1023 |
971 |
}
|
| 1024 |
|
// user log info
|
| 1025 |
|
// else if (
|
| 1026 |
|
// // update &&
|
| 1027 |
|
// !TXMEditor.this.getResult().getComputingDoneMessage().isEmpty()) {
|
| 1028 |
|
// Log.info(TXMEditor.this.getResult().getComputingDoneMessage());
|
| 1029 |
|
// }
|
| 1030 |
972 |
|
| 1031 |
|
|
| 1032 |
973 |
notifyExtensions("notifyEndOfCompute"); //$NON-NLS-1$
|
| 1033 |
974 |
|
| 1034 |
975 |
monitor.worked(50);
|
| ... | ... | |
| 1081 |
1022 |
// ps.showInDialog(null, job);
|
| 1082 |
1023 |
// ps.busyCursorWhile(job);
|
| 1083 |
1024 |
|
| 1084 |
|
computeJob.setPriority(Job.DECORATE);
|
|
1025 |
computingJob.setPriority(Job.DECORATE);
|
| 1085 |
1026 |
// FIXME: SJ tests
|
| 1086 |
1027 |
// job.setPriority(Job.INTERACTIVE);
|
| 1087 |
|
computeJob.setUser(true);
|
| 1088 |
|
computeJob.schedule();
|
|
1028 |
computingJob.setUser(true);
|
|
1029 |
computingJob.schedule();
|
| 1089 |
1030 |
|
| 1090 |
|
return computeJob;
|
|
1031 |
return computingJob;
|
| 1091 |
1032 |
}
|
| 1092 |
1033 |
|
| 1093 |
1034 |
/**
|