diff --git a/src/org/ntlab/traceDebugger/BreakPointView.java b/src/org/ntlab/traceDebugger/BreakPointView.java index ab1ffc4..e2059cb 100644 --- a/src/org/ntlab/traceDebugger/BreakPointView.java +++ b/src/org/ntlab/traceDebugger/BreakPointView.java @@ -123,7 +123,7 @@ createToolBar(); createMenuBar(); createPopupMenu(); - updateImagesForBreakPoint(DebuggingController.getInstance().hasLoadedTraceFileStatus()); + updateImagesForBreakPoint(DebuggingController.getInstance().hasLoadedTraceFile()); TraceDebuggerPlugin.setActiveView(ID, this); } @@ -160,7 +160,7 @@ @Override public void run() { // �g���[�X�o�͐�Q�ƃE�B�U�[�h - debuggingController.fileOpenAction(shell); + TraceDebuggerPlugin.getDefault().fileOpenAction(shell); } }; diff --git a/src/org/ntlab/traceDebugger/DebuggingController.java b/src/org/ntlab/traceDebugger/DebuggingController.java index 23dcdc0..e3628b1 100644 --- a/src/org/ntlab/traceDebugger/DebuggingController.java +++ b/src/org/ntlab/traceDebugger/DebuggingController.java @@ -65,86 +65,31 @@ public TracePoint getCurrentTp() { return debuggingTp.duplicate(); } + + public boolean isLoadingTraceFile() { + return (loadingTraceFileStatus == LoadingTraceFileStatus.PROGRESS); + } - public boolean hasLoadedTraceFileStatus() { + public boolean hasLoadedTraceFile() { return (loadingTraceFileStatus == LoadingTraceFileStatus.DONE); } + public void setLodingTraceFile() { + loadingTraceFileStatus = LoadingTraceFileStatus.PROGRESS; + } + + public void setHasLoadedTraceFile() { + loadingTraceFileStatus = LoadingTraceFileStatus.DONE; + } + + public void setHasNotLoadedTraceFile() { + loadingTraceFileStatus = LoadingTraceFileStatus.NOT_YET; + } + public boolean isRunning() { return isRunning; } - - public boolean fileOpenAction(Shell shell) { - if (loadingTraceFileStatus == LoadingTraceFileStatus.PROGRESS) { - if (TraceDebuggerPlugin.isJapanese()) { - MessageDialog.openInformation(null, "�ǂݍ��ݒ�", "�g���[�X�t�@�C����ǂݍ��ݒ��ł�"); - } else { - MessageDialog.openInformation(null, "Loading", "This debugger is loading the trace."); - } - return false; - } - if (isRunning) { - if (TraceDebuggerPlugin.isJapanese()) { - MessageDialog.openInformation(null, "���s��", "�g���[�X��Ŏ��s���ł�"); - } else { - MessageDialog.openInformation(null, "Running", "This debugger is running on the trace."); - } - return false; - } - FileDialog fileDialog = new FileDialog(shell, SWT.OPEN); - fileDialog.setText(TraceDebuggerPlugin.isJapanese() ? "�g���[�X�t�@�C�����J��" : "Open Trace File"); - fileDialog.setFilterExtensions(new String[]{"*.*"}); - String path = fileDialog.open(); - if (path == null) return false; - ((CallStackView)TraceDebuggerPlugin.getActiveView(CallStackView.ID)).reset(); - ((VariableView)TraceDebuggerPlugin.getActiveView(VariableView.ID)).reset(); - ((BreakPointView)TraceDebuggerPlugin.getActiveView(BreakPointView.ID)).reset(); - TracePointsRegisterView tracePointsView = (TracePointsRegisterView)TraceDebuggerPlugin.getActiveView(TracePointsRegisterView.ID); - if (tracePointsView != null) tracePointsView.reset(); - CallTreeView callTreeView = (CallTreeView)TraceDebuggerPlugin.getActiveView(CallTreeView.ID); - if (callTreeView != null) callTreeView.reset(); - loadTraceFileOnOtherThread(path); - return true; - } - - private void loadTraceFileOnOtherThread(final String filePath) { - final String msg = TraceDebuggerPlugin.isJapanese() ? "�g���[�X�t�@�C����ǂݍ��ݒ�" : "Loading Trace File"; - Job job = new Job(msg) { - @Override - protected IStatus run(IProgressMonitor monitor) { - monitor.beginTask(msg + " (" + filePath + ")", IProgressMonitor.UNKNOWN); - loadingTraceFileStatus = LoadingTraceFileStatus.PROGRESS; - TraceDebuggerPlugin.setAnalyzer(null); - TraceJSON trace = new TraceJSON(filePath); - TraceDebuggerPlugin.setAnalyzer(new DeltaExtractionAnalyzer(trace)); - VariableUpdatePointFinder.getInstance().setTrace(trace); - traceBreakPoints = new TraceBreakPoints(trace); - - // GUI�̑����GUI�̃C�x���g�f�B�X�p�b�`���s���Ă���X���b�h���炵������ł��Ȃ��̂ł������� - final BreakPointView breakpointView = (BreakPointView)TraceDebuggerPlugin.getActiveView(BreakPointView.ID); - Control control = breakpointView.getViewer().getControl(); - control.getDisplay().syncExec(new Runnable() { - @Override - public void run() { - breakpointView.updateTraceBreakPoints(traceBreakPoints); - breakpointView.updateImagesForBreakPoint(true); - } - }); - monitor.done(); - if (!(monitor.isCanceled())) { - loadingTraceFileStatus = LoadingTraceFileStatus.DONE; - return Status.OK_STATUS; - } else { - loadingTraceFileStatus = LoadingTraceFileStatus.NOT_YET; - return Status.CANCEL_STATUS; - } - } - }; - job.setUser(true); - job.schedule(); - } - public boolean addTraceBreakPointAction() { if (loadingTraceFileStatus != LoadingTraceFileStatus.DONE) { if (TraceDebuggerPlugin.isJapanese()) { diff --git a/src/org/ntlab/traceDebugger/TraceDebuggerPlugin.java b/src/org/ntlab/traceDebugger/TraceDebuggerPlugin.java index 866d7c0..90d6277 100644 --- a/src/org/ntlab/traceDebugger/TraceDebuggerPlugin.java +++ b/src/org/ntlab/traceDebugger/TraceDebuggerPlugin.java @@ -5,14 +5,26 @@ import java.util.Map; import java.util.Set; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.ntlab.traceAnalysisPlatform.tracer.trace.TraceJSON; import org.ntlab.traceDebugger.analyzerProvider.AbstractAnalyzer; +import org.ntlab.traceDebugger.analyzerProvider.DeltaExtractionAnalyzer; +import org.ntlab.traceDebugger.analyzerProvider.VariableUpdatePointFinder; import org.osgi.framework.BundleContext; /** @@ -22,6 +34,8 @@ // The plug-in ID public static final String PLUGIN_ID = "org.ntlab.traceDebugger"; //$NON-NLS-1$ + + private static DebuggingController debuggingController = DebuggingController.getInstance();; private static AbstractAnalyzer analyzer; @@ -69,6 +83,77 @@ return plugin; } + public boolean fileOpenAction(Shell shell) { + if (debuggingController.isLoadingTraceFile()) { + if (isJapanese()) { + MessageDialog.openInformation(null, "�ǂݍ��ݒ�", "�g���[�X�t�@�C����ǂݍ��ݒ��ł�"); + } else { + MessageDialog.openInformation(null, "Loading", "This debugger is loading the trace."); + } + return false; + } + if (debuggingController.isRunning()) { + if (isJapanese()) { + MessageDialog.openInformation(null, "���s��", "�g���[�X��Ŏ��s���ł�"); + } else { + MessageDialog.openInformation(null, "Running", "This debugger is running on the trace."); + } + return false; + } + FileDialog fileDialog = new FileDialog(shell, SWT.OPEN); + fileDialog.setText(isJapanese() ? "�g���[�X�t�@�C�����J��" : "Open Trace File"); + fileDialog.setFilterExtensions(new String[]{"*.*"}); + String path = fileDialog.open(); + if (path == null) return false; + + ((CallStackView)getActiveView(CallStackView.ID)).reset(); + ((VariableView)getActiveView(VariableView.ID)).reset(); + ((BreakPointView)getActiveView(BreakPointView.ID)).reset(); + TracePointsRegisterView tracePointsView = (TracePointsRegisterView)getActiveView(TracePointsRegisterView.ID); + if (tracePointsView != null) tracePointsView.reset(); + CallTreeView callTreeView = (CallTreeView)getActiveView(CallTreeView.ID); + if (callTreeView != null) callTreeView.reset(); + loadTraceFileOnNewThread(path); + return true; + } + + private void loadTraceFileOnNewThread(final String filePath) { + final String msg = isJapanese() ? "�g���[�X�t�@�C����ǂݍ��ݒ�" : "Loading Trace File"; + Job job = new Job(msg) { + @Override + protected IStatus run(IProgressMonitor monitor) { + monitor.beginTask(msg + " (" + filePath + ")", IProgressMonitor.UNKNOWN); + debuggingController.setLodingTraceFile(); + analyzer = null; + TraceJSON trace = new TraceJSON(filePath); + analyzer = new DeltaExtractionAnalyzer(trace); + VariableUpdatePointFinder.getInstance().setTrace(trace); + final TraceBreakPoints traceBreakPoints = new TraceBreakPoints(trace); + + // GUI�̑����GUI�̃C�x���g�f�B�X�p�b�`���s���Ă���X���b�h���炵������ł��Ȃ��̂ł������� + final BreakPointView breakpointView = (BreakPointView)getActiveView(BreakPointView.ID); + Control control = breakpointView.getViewer().getControl(); + control.getDisplay().syncExec(new Runnable() { + @Override + public void run() { + breakpointView.updateTraceBreakPoints(traceBreakPoints); + breakpointView.updateImagesForBreakPoint(true); + } + }); + monitor.done(); + if (!(monitor.isCanceled())) { + debuggingController.setHasLoadedTraceFile(); + return Status.OK_STATUS; + } else { + debuggingController.setHasNotLoadedTraceFile(); + return Status.CANCEL_STATUS; + } + } + }; + job.setUser(true); + job.schedule(); + } + public static AbstractAnalyzer getAnalyzer() { return analyzer; }