Revision 2441

tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 2441)
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
	/**
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 2441)
1943 1943
	
1944 1944
	
1945 1945
	/**
1946
	 * Gets the user name if exists otherwise, the lazy name if exists, otherwise the simple name.
1946
	 * Gets the user name if exists otherwise, the simple name if not null, otherwise the lazy name.
1947 1947
	 * 
1948 1948
	 * @return the current name
1949 1949
	 */
......
1951 1951
		if (!this.userName.isEmpty()) {
1952 1952
			return this.userName;
1953 1953
		}
1954
		else if (this.lazyName != null && !this.lazyName.isEmpty()) {
1955
			return this.lazyName;
1954
		// FIXME: SJ: original version
1955
		// else if (this.lazyName != null && !this.lazyName.isEmpty()) {
1956
		// return this.lazyName;
1957
		// }
1958
		// else {
1959
		// return this.getSimpleName();
1960
		// }
1961
		// FIXME: SJ: new version to manage the lazy loading of child of an edited parent (eg. LT => Specificities where the user modify the LT property)
1962
		// Need to check that all works well then remove the above original version
1963
		else if (this.getSimpleName() != null && !this.getSimpleName().isEmpty()) {
1964
			return this.getSimpleName();
1956 1965
		}
1957 1966
		else {
1958
			return this.getSimpleName();
1967
			return this.lazyName;
1959 1968
		}
1969
		
1960 1970
	}
1961 1971
	
1962 1972
	
......
2368 2378
				
2369 2379
				// FIXME: SJ: tests for long processing, eg. to see progress bar subtask or to test the user canceling
2370 2380
				// monitor.beginTask("long process simulation test", 10);
2371
				// for (int i = 0; i < 12; i++) {
2381
				// for (int i = 0; i < 1200; i++) {
2372 2382
				// try {
2373
				// Thread.sleep(25);
2383
				// Thread.sleep(10);
2374 2384
				// }
2375 2385
				// catch (InterruptedException e) {
2376 2386
				// // TODO Auto-generated catch block
......
2442 2452
				
2443 2453
				if (monitor != null && children.size() > 1) {
2444 2454
					monitor.beginTask("Computing children of " + this, children.size());
2455
					// monitor.subTask("Computing children of " + this);
2445 2456
				}
2446 2457
				
2447 2458
				// set the children as dirty since the result has changed

Also available in: Unified diff