import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackInserter;
import org.tizen.dynamicanalyzer.ui.info.screenshot.ScreenshotTimer;
import org.tizen.dynamicanalyzer.ui.page.UpdateViewTimer;
-import org.tizen.dynamicanalyzer.ui.summary.SummaryPage;
import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
import org.tizen.dynamicanalyzer.util.Logger;
-import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
-import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
-import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
-import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
import org.tizen.dynamicanalyzer.widgets.da.base.ProgressDialog;
-import org.tizen.dynamicanalyzer.workbench.LayoutManager;
public class StopTraceManager implements Runnable {
- private STAGE lastStage = STAGE.NONE;
private ProgressDialog progressDlg = null;
private DAResult error;
private boolean stopFromTarget = false;
private Boolean stopThreadCompleted = false;
public StopTraceManager(DAResult err, boolean stopFromTarget) {
this.error = err;
- this.stopFromTarget = stopFromTarget;
-
- // create progress dialog and open it
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
- progressDlg = new ProgressDialog(shell, LayoutManager.getBaseComposite());
- if (null != progressDlg) {
- progressDlg.setProgressMessage(AnalyzerLabels.DLG_SUMMARIZING_DATA);
- progressDlg.setProgressInfo(AnalyzerLabels.DLG_PLEASE_WAIT);
- if (!error.isSuccess()) {
- progressDlg.setProgressStyle(ProgressDialog.PROGRESS_STYLE_WARNING);
- String errorMessage = error.getMessage();
- if (errorMessage.length() > 240) {
- progressDlg.setWarnigDialogType(ProgressDialog.DIALOG_TYPE_LARGE);
- } else if (errorMessage.length() > 120) {
- progressDlg.setWarnigDialogType(ProgressDialog.DIALOG_TYPE_MIDDLE);
- } else {
- progressDlg.setWarnigDialogType(ProgressDialog.DIALOG_TYPE_SMALL);
- }
- progressDlg.setProgressWarningMessage(errorMessage);
- progressDlg.setOkListener(new DACustomButtonClickEventListener() {
- @Override
- public void handleClickEvent(DACustomButton button) {
- progressDlg.close();
- }
- });
- }
- progressDlg.open();
- }
- }
- });
+ this.stopFromTarget = stopFromTarget;
}
@Override
try {
// stop resource monitor
ResourceMonitor.stop();
- setStageComplete(STAGE.STOP_RESOURCE_MONITOR);
// send stop message if necessary
if (!stopFromTarget) {
DACommunicator.stopTrace();
}
- setStageComplete(STAGE.SEND_STOPMSG);
Thread stopTimers = new Thread(new Runnable() {
public void run() {
- // stop clock
- try{
- Toolbar.INSTANCE.stopTimer();
- setStageComplete(STAGE.STOP_CLOCK);
+ Toolbar.INSTANCE.stopTimer();
// stop replay timer
ReplayManager.resetStopAlarm();
- setStageComplete(STAGE.STOP_REPLAY_TIMER);
// stop screenshot timer
ScreenshotTimer.stop();
- setStageComplete(STAGE.STOP_SCREENSHOT_TIMER);
// stop update timer
UpdateViewTimer.stop();
- setStageComplete(STAGE.STOP_UPDATE_TIMER);
- }
- catch(InterruptedException e){
- Logger.debug(); // for new line
- Logger.debug("Interrupt occurred while stopTimers");
- }
}
});
});
stopForcedThread.start();
- setStageComplete(STAGE.STOP_DATATHREADS);
} else {
stopNormalThread.start();
- setStageComplete(STAGE.STOP_DATATHREADS);
-
Project project = Global.getProject();
if (project != null && project.isValid()) {
project.setTotalStopTime(Toolbar.INSTANCE.getTime());
// change to summary page
UIAction.applyStopTraceUI();
- // confirm that all stage run
- setStageComplete(STAGE.FINAL);
} catch (InterruptedException e) {
// canceled stop tracing
// never happened
}
}
- private void setStageComplete(STAGE st) throws InterruptedException {
- lastStage = st;
-
- int percent = ProgressTable.getPercent(PHASE.TRACE_END, lastStage);
- if (percent != 100) {
- testCancel();
- }
-
- setProgressPercent(percent);
- }
-
private void testCancel() throws InterruptedException {
// do nothing
}