|
Lines 441-446
public final class Workbench extends EventManager implements IWorkbench {
Link Here
|
| 441 |
|
441 |
|
| 442 |
private Job autoSaveJob; |
442 |
private Job autoSaveJob; |
| 443 |
|
443 |
|
|
|
444 |
private boolean autoSaveRunning = true; |
| 445 |
|
| 444 |
/** |
446 |
/** |
| 445 |
* Creates a new workbench. |
447 |
* Creates a new workbench. |
| 446 |
* |
448 |
* |
|
Lines 1034-1039
public final class Workbench extends EventManager implements IWorkbench {
Link Here
|
| 1034 |
if(autoSaveJob != null) { |
1036 |
if(autoSaveJob != null) { |
| 1035 |
autoSaveJob.cancel(); |
1037 |
autoSaveJob.cancel(); |
| 1036 |
autoSaveJob = null; |
1038 |
autoSaveJob = null; |
|
|
1039 |
autoSaveRunning = false; |
| 1037 |
} |
1040 |
} |
| 1038 |
|
1041 |
|
| 1039 |
boolean closeEditors = !force |
1042 |
boolean closeEditors = !force |
|
Lines 2677-2700
UIEvents.Context.TOPIC_CONTEXT,
Link Here
|
| 2677 |
}; |
2680 |
}; |
| 2678 |
e4Context.set(PartRenderingEngine.EARLY_STARTUP_HOOK, earlyStartup); |
2681 |
e4Context.set(PartRenderingEngine.EARLY_STARTUP_HOOK, earlyStartup); |
| 2679 |
// start workspace auto-save |
2682 |
// start workspace auto-save |
| 2680 |
final int millisecondInterval = getAutoSaveJobTime(); |
2683 |
Thread autoSaveThread = new Thread(new Runnable() { |
| 2681 |
if (millisecondInterval > 0) { |
2684 |
|
| 2682 |
autoSaveJob = new WorkbenchJob("Workbench Auto-Save Job") { //$NON-NLS-1$ |
2685 |
public void run() { |
| 2683 |
@Override |
2686 |
while (autoSaveRunning) { |
| 2684 |
public IStatus runInUIThread(IProgressMonitor monitor) { |
2687 |
if (autoSaveJob != null) { |
| 2685 |
final int nextDelay = getAutoSaveJobTime(); |
2688 |
autoSaveJob.cancel(); |
| 2686 |
persist(false); |
2689 |
} |
| 2687 |
monitor.done(); |
2690 |
final int millisecondInterval = getAutoSaveJobTime(); |
| 2688 |
// repeat |
2691 |
if (millisecondInterval > 0) { |
| 2689 |
if (nextDelay > 0) { |
2692 |
autoSaveJob = new WorkbenchJob("Workbench Auto-Save Job") { //$NON-NLS-1$ |
| 2690 |
this.schedule(nextDelay); |
2693 |
@Override |
|
|
2694 |
public IStatus runInUIThread(IProgressMonitor monitor) { |
| 2695 |
persist(false); |
| 2696 |
monitor.done(); |
| 2697 |
return Status.OK_STATUS; |
| 2698 |
} |
| 2699 |
}; |
| 2700 |
autoSaveJob.setSystem(true); |
| 2701 |
try { |
| 2702 |
Thread.sleep(millisecondInterval); |
| 2703 |
} catch (InterruptedException e) { |
| 2704 |
String msg = "Exception in Workbench.runUI"; //$NON-NLS-1$ |
| 2705 |
WorkbenchPlugin.log(msg, new Status(IStatus.INFO, |
| 2706 |
WorkbenchPlugin.PI_WORKBENCH, 1, msg, e)); |
| 2707 |
} |
| 2708 |
autoSaveJob.schedule(); |
| 2709 |
|
| 2710 |
} else { |
| 2711 |
try { |
| 2712 |
Thread.sleep(IPreferenceConstants.DEFAULT_WORBENCH_SAVE_INTERVAL); |
| 2713 |
} catch (InterruptedException e) { |
| 2714 |
String msg = "Exception in Workbench.runUI"; //$NON-NLS-1$ |
| 2715 |
WorkbenchPlugin.log(msg, new Status(IStatus.INFO, |
| 2716 |
WorkbenchPlugin.PI_WORKBENCH, 1, msg, e)); |
| 2717 |
} |
| 2691 |
} |
2718 |
} |
| 2692 |
return Status.OK_STATUS; |
2719 |
|
| 2693 |
} |
2720 |
} |
| 2694 |
}; |
2721 |
} |
| 2695 |
autoSaveJob.setSystem(true); |
2722 |
}, "Workbench Auto-Save Thread"); //$NON-NLS-1$ |
| 2696 |
autoSaveJob.schedule(millisecondInterval); |
2723 |
|
| 2697 |
} |
2724 |
autoSaveThread.start(); |
| 2698 |
|
2725 |
|
| 2699 |
// WWinPluginAction.refreshActionList(); |
2726 |
// WWinPluginAction.refreshActionList(); |
| 2700 |
|
2727 |
|