| |
---|
| | import java.util.HashSet; |
---|
| | 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; |
---|
| | |
---|
| | /** |
---|
| | * The activator class controls the plug-in life cycle |
---|
| |
---|
| | public class TraceDebuggerPlugin extends AbstractUIPlugin { |
---|
| | |
---|
| | // 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; |
---|
| | |
---|
| | private static int uniqueIdForViews = 0; |
---|
| |
---|
| | public static TraceDebuggerPlugin getDefault() { |
---|
| | return plugin; |
---|
| | } |
---|
| | |
---|
| | public boolean fileOpenAction(Shell shell) { |
---|
| | if (debuggingController.isLoadingTraceFile()) { |
---|
| | if (isJapanese()) { |
---|
| | MessageDialog.openInformation(null, "読み込み中", "トレースファイルを読み込み中です"); |
---|
| | } else { |
---|
| | MessageDialog.openInformation(null, "Loading", "This debugger is loading the trace."); |
---|
| | } |
---|
| | return false; |
---|
| | } |
---|
| | if (debuggingController.isRunning()) { |
---|
| | if (isJapanese()) { |
---|
| | MessageDialog.openInformation(null, "実行中", "トレース上で実行中です"); |
---|
| | } else { |
---|
| | MessageDialog.openInformation(null, "Running", "This debugger is running on the trace."); |
---|
| | } |
---|
| | return false; |
---|
| | } |
---|
| | FileDialog fileDialog = new FileDialog(shell, SWT.OPEN); |
---|
| | fileDialog.setText(isJapanese() ? "トレースファイルを開く" : "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() ? "トレースファイルを読み込み中" : "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のイベントディスパッチを行っているスレッドからしか操作できないのでそうする |
---|
| | 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; |
---|
| | } |
---|
| | |
---|
| |
---|
| | |