・トレースファイルの読み込み部分を DebuggingController から TraceDebuggerPlugin に移動した。
1 parent b45b95a commit b6d6d345e55989b5bfa9cac9f44e483e31d41229
n-nitta authored on 25 Mar 2021
Showing 3 changed files
View
4
src/org/ntlab/traceDebugger/BreakPointView.java
createActions();
createToolBar();
createMenuBar();
createPopupMenu();
updateImagesForBreakPoint(DebuggingController.getInstance().hasLoadedTraceFileStatus());
updateImagesForBreakPoint(DebuggingController.getInstance().hasLoadedTraceFile());
TraceDebuggerPlugin.setActiveView(ID, this);
}
 
@Override
fileOpenAction = new Action(msg, fileOpenIcon) {
@Override
public void run() {
// トレース出力先参照ウィザード
debuggingController.fileOpenAction(shell);
TraceDebuggerPlugin.getDefault().fileOpenAction(shell);
}
};
 
addTraceBreakPointAction = new Action() {
View
95
src/org/ntlab/traceDebugger/DebuggingController.java
public TracePoint getCurrentTp() {
return debuggingTp.duplicate();
}
public boolean hasLoadedTraceFileStatus() {
public boolean isLoadingTraceFile() {
return (loadingTraceFileStatus == LoadingTraceFileStatus.PROGRESS);
}
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, "読み込み中", "トレースファイルを読み込み中です");
} else {
MessageDialog.openInformation(null, "Loading", "This debugger is loading the trace.");
}
return false;
}
if (isRunning) {
if (TraceDebuggerPlugin.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(TraceDebuggerPlugin.isJapanese() ? "トレースファイルを開く" : "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() ? "トレースファイルを読み込み中" : "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のイベントディスパッチを行っているスレッドからしか操作できないのでそうする
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()) {
MessageDialog.openInformation(null, "エラー", "トレースが見つかりませんでした");
View
85
src/org/ntlab/traceDebugger/TraceDebuggerPlugin.java
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;
}